diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index d3ad08474e1..63a74b63c10 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -126,7 +126,6 @@ #include "nsIObserverService.h" #include "nsIObserver.h" #include "nsIDocShell.h" // for reflow observation -#include "nsIBaseWindow.h" #include "nsLayoutErrors.h" #include "nsLayoutUtils.h" #include "nsCSSRendering.h" @@ -1222,7 +1221,6 @@ public: nsEvent* aEvent, nsEventStatus* aStatus); NS_IMETHOD ResizeReflow(nsIView *aView, nscoord aWidth, nscoord aHeight); - NS_IMETHOD_(PRBool) IsVisible(); // caret handling NS_IMETHOD GetCaret(nsICaret **aOutCaret); @@ -6036,18 +6034,6 @@ PresShell::ResizeReflow(nsIView *aView, nscoord aWidth, nscoord aHeight) return ResizeReflow(aWidth, aHeight); } -NS_IMETHODIMP_(PRBool) -PresShell::IsVisible() -{ - nsCOMPtr container = mPresContext->GetContainer(); - nsCOMPtr bw = do_QueryInterface(container); - if (!bw) - return PR_FALSE; - PRBool res = PR_TRUE; - bw->GetVisibility(&res); - return res; -} - nsresult PresShell::GetAgentStyleSheets(nsCOMArray& aSheets) { diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index d3ad08474e1..63a74b63c10 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -126,7 +126,6 @@ #include "nsIObserverService.h" #include "nsIObserver.h" #include "nsIDocShell.h" // for reflow observation -#include "nsIBaseWindow.h" #include "nsLayoutErrors.h" #include "nsLayoutUtils.h" #include "nsCSSRendering.h" @@ -1222,7 +1221,6 @@ public: nsEvent* aEvent, nsEventStatus* aStatus); NS_IMETHOD ResizeReflow(nsIView *aView, nscoord aWidth, nscoord aHeight); - NS_IMETHOD_(PRBool) IsVisible(); // caret handling NS_IMETHOD GetCaret(nsICaret **aOutCaret); @@ -6036,18 +6034,6 @@ PresShell::ResizeReflow(nsIView *aView, nscoord aWidth, nscoord aHeight) return ResizeReflow(aWidth, aHeight); } -NS_IMETHODIMP_(PRBool) -PresShell::IsVisible() -{ - nsCOMPtr container = mPresContext->GetContainer(); - nsCOMPtr bw = do_QueryInterface(container); - if (!bw) - return PR_FALSE; - PRBool res = PR_TRUE; - bw->GetVisibility(&res); - return res; -} - nsresult PresShell::GetAgentStyleSheets(nsCOMArray& aSheets) { diff --git a/mozilla/view/public/nsIViewObserver.h b/mozilla/view/public/nsIViewObserver.h index 0c1c8a42c37..1691869264b 100644 --- a/mozilla/view/public/nsIViewObserver.h +++ b/mozilla/view/public/nsIViewObserver.h @@ -46,8 +46,8 @@ struct nsRect; struct nsGUIEvent; #define NS_IVIEWOBSERVER_IID \ -{ 0x0f4bc34a, 0xc93b, 0x4699, \ -{ 0xb6, 0xc2, 0xb3, 0xca, 0x9e, 0xe4, 0x6c, 0x95 } } +{ 0x6a1529e0, 0x3d2c, 0x11d2, \ +{ 0xa8, 0x32, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } } class nsIViewObserver : public nsISupports { @@ -85,12 +85,6 @@ public: * @return error status */ NS_IMETHOD ResizeReflow(nsIView * aView, nscoord aWidth, nscoord aHeight) = 0; - - /** - * Hack to find out if the view observer is itself visible, in lieu - * of having the view trees linked. - */ - NS_IMETHOD_(PRBool) IsVisible() = 0; }; #endif diff --git a/mozilla/view/src/nsViewManager.cpp b/mozilla/view/src/nsViewManager.cpp index 37d96ed6ba6..cda56c162b9 100644 --- a/mozilla/view/src/nsViewManager.cpp +++ b/mozilla/view/src/nsViewManager.cpp @@ -412,24 +412,6 @@ static PRInt32 CompareZIndex(PRInt32 aZIndex1, PRBool aTopMost1, PRBool aIsAuto1 } } -static PRBool IsViewVisible(nsView *aView) -{ - for (nsIView *view = aView; view; view = view->GetParent()) { - // We don't check widget visibility here because in the future (with - // the better approach to this that's in attachment 160801 on bug - // 227361), callers of the equivalent to this function should be able - // to rely on being notified when the result of this function changes. - if (view->GetVisibility() == nsViewVisibility_kHide) - return PR_FALSE; - } - // Find out if the root view is visible by asking the view observer - // (this won't be needed anymore if we link view trees across chrome / - // content boundaries in DocumentViewerImpl::MakeWindow). - nsCOMPtr vo; - aView->GetViewManager()->GetViewObserver(*getter_AddRefs(vo)); - return vo->IsVisible(); -} - void nsViewManager::PostInvalidateEvent() { @@ -456,7 +438,6 @@ PRUint32 nsViewManager::gLastUserEventTime = 0; nsViewManager::nsViewManager() : mMouseLocation(NSCOORD_NONE, NSCOORD_NONE) - , mDelayedResize(NSCOORD_NONE, NSCOORD_NONE) { if (gViewManagers == nsnull) { NS_ASSERTION(mVMCount == 0, "View Manager count is incorrect"); @@ -626,15 +607,10 @@ NS_IMETHODIMP nsViewManager::SetRootView(nsIView *aView) NS_IMETHODIMP nsViewManager::GetWindowDimensions(nscoord *aWidth, nscoord *aHeight) { if (nsnull != mRootView) { - if (mDelayedResize == nsSize(NSCOORD_NONE, NSCOORD_NONE)) { - nsRect dim; - mRootView->GetDimensions(dim); - *aWidth = dim.width; - *aHeight = dim.height; - } else { - *aWidth = mDelayedResize.width; - *aHeight = mDelayedResize.height; - } + nsRect dim; + mRootView->GetDimensions(dim); + *aWidth = dim.width; + *aHeight = dim.height; } else { @@ -646,15 +622,19 @@ NS_IMETHODIMP nsViewManager::GetWindowDimensions(nscoord *aWidth, nscoord *aHeig NS_IMETHODIMP nsViewManager::SetWindowDimensions(nscoord aWidth, nscoord aHeight) { - if (mRootView) { - if (IsViewVisible(mRootView)) { - mDelayedResize.SizeTo(NSCOORD_NONE, NSCOORD_NONE); - DoSetWindowDimensions(aWidth, aHeight); - } else { - mDelayedResize.SizeTo(aWidth, aHeight); - } + // Resize the root view + if (nsnull != mRootView) { + nsRect dim(0, 0, aWidth, aHeight); + // Don't resize the widget. It is already being set elsewhere. + mRootView->SetDimensions(dim, PR_TRUE, PR_FALSE); } + //printf("new dims: %d %d\n", aWidth, aHeight); + // Inform the presentation shell that we've been resized + if (nsnull != mObserver) + mObserver->ResizeReflow(mRootView, aWidth, aHeight); + //printf("reflow done\n"); + return NS_OK; } @@ -1831,7 +1811,6 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS case NS_PAINT: { - nsPaintEvent *event = NS_STATIC_CAST(nsPaintEvent*, aEvent); nsView *view = nsView::GetViewFor(aEvent->widget); if (!view || !mContext) @@ -1841,12 +1820,12 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS // The rect is in device units, and it's in the coordinate space of its // associated window. - nsCOMPtr region = event->region; + nsCOMPtr region = ((nsPaintEvent*)aEvent)->region; if (!region) { if (NS_FAILED(CreateRegion(getter_AddRefs(region)))) break; - const nsRect& damrect = *event->rect; + const nsRect& damrect = *((nsPaintEvent*)aEvent)->rect; region->SetTo(damrect.x, damrect.y, damrect.width, damrect.height); } @@ -1855,21 +1834,8 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS // Refresh the view if (mRefreshEnabled) { - // If an ancestor widget was hidden and then shown, we could - // have a delayed resize to handle. - if (view == mRootView && - mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) && - IsViewVisible(view)) { - DoSetWindowDimensions(mDelayedResize.width, mDelayedResize.height); - mDelayedResize.SizeTo(NSCOORD_NONE, NSCOORD_NONE); - - // Paint later. - UpdateView(view, NS_VMREFRESH_NO_SYNC); - } else { - NS_ASSERTION(IsViewVisible(view), "painting an invisible view"); - Refresh(view, event->renderingContext, region, - NS_VMREFRESH_DOUBLE_BUFFER); - } + Refresh(view, ((nsPaintEvent*)aEvent)->renderingContext, region, + NS_VMREFRESH_DOUBLE_BUFFER); } else { // since we got an NS_PAINT event, we need to // draw something so we don't get blank areas. diff --git a/mozilla/view/src/nsViewManager.h b/mozilla/view/src/nsViewManager.h index bc6bbba285e..2fd687b549c 100644 --- a/mozilla/view/src/nsViewManager.h +++ b/mozilla/view/src/nsViewManager.h @@ -351,19 +351,6 @@ private: */ void GetMaxWidgetBounds(nsRect& aMaxWidgetBounds) const; - void DoSetWindowDimensions(nscoord aWidth, nscoord aHeight) - { - nsRect oldDim; - nsRect newDim(0, 0, aWidth, aHeight); - mRootView->GetDimensions(oldDim); - if (oldDim != newDim) { - // Don't resize the widget. It is already being set elsewhere. - mRootView->SetDimensions(newDim, PR_TRUE, PR_FALSE); - if (mObserver) - mObserver->ResizeReflow(mRootView, aWidth, aHeight); - } - } - public: // NOT in nsIViewManager, so private to the view module nsView* GetRootView() const { return mRootView; } nsView* GetMouseEventGrabber() const; @@ -404,11 +391,6 @@ private: nsIScrollableView *mRootScrollable; nscolor mDefaultBackgroundColor; nsPoint mMouseLocation; // device units, relative to mRootView - - // The size for a resize that we delayed until the root view becomes - // visible again. - nsSize mDelayedResize; - nsCOMPtr mBlender; nsISupportsArray *mCompositeListeners; nsCOMPtr mRegionFactory;