From e8a9de31ab03153390fe0c3ae2d0cdb48dbaf52d Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 5 Aug 2010 14:39:39 -0400 Subject: [PATCH] Bug 575336 part 1. Make sure to update the size of the current prescontext on style flush, so that media queries do the right thing. r=roc --- layout/base/nsPresShell.cpp | 3 ++- view/public/nsIViewManager.h | 6 +++--- view/src/nsViewManager.cpp | 18 ++++++++++++++---- view/src/nsViewManager.h | 2 +- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index ffac31607fb..492c15d30b4 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -4789,6 +4789,7 @@ PresShell::FlushPendingNotifications(mozFlushType aType) // Process pending restyles, since any flush of the presshell wants // up-to-date style data. if (!mIsDestroying) { + mViewManager->FlushDelayedResize(PR_FALSE); mPresContext->FlushPendingMediaFeatureValuesChanged(); // Flush any pending update of the user font set, since that could @@ -4835,7 +4836,7 @@ PresShell::FlushPendingNotifications(mozFlushType aType) if (aType >= (mSuppressInterruptibleReflows ? Flush_Layout : Flush_InterruptibleLayout) && !mIsDestroying) { mFrameConstructor->RecalcQuotesAndCounters(); - mViewManager->FlushDelayedResize(); + mViewManager->FlushDelayedResize(PR_TRUE); if (ProcessReflowCommands(aType < Flush_Layout) && mContentToScrollTo) { // We didn't get interrupted. Go ahead and scroll to our content DoScrollContentIntoView(mContentToScrollTo, mContentScrollVPosition, diff --git a/view/public/nsIViewManager.h b/view/public/nsIViewManager.h index 39c5e1975b8..22fa5495d8b 100644 --- a/view/public/nsIViewManager.h +++ b/view/public/nsIViewManager.h @@ -50,8 +50,8 @@ class nsIDeviceContext; class nsIViewObserver; #define NS_IVIEWMANAGER_IID \ - { 0x9e924719, 0x3c4b, 0x435b, \ - { 0xaf, 0x1e, 0x71, 0x52, 0x04, 0x6d, 0xaa, 0x44 } } + { 0x35c07b12, 0x5d96, 0x49f9, \ + { 0x91, 0xa3, 0x2f, 0xad, 0x3e, 0x84, 0x0c, 0x91 } } class nsIViewManager : public nsISupports { @@ -116,7 +116,7 @@ public: /** * Do any resizes that are pending. */ - NS_IMETHOD FlushDelayedResize() = 0; + NS_IMETHOD FlushDelayedResize(PRBool aDoReflow) = 0; /** * Called to force a redrawing of any dirty areas. diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index 73a6247d873..fa477fb6af9 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -60,6 +60,8 @@ #include "nsContentUtils.h" #include "nsIPluginWidget.h" #include "nsXULPopupManager.h" +#include "nsIPresShell.h" +#include "nsPresContext.h" static NS_DEFINE_IID(kRegionCID, NS_REGION_CID); @@ -333,11 +335,19 @@ NS_IMETHODIMP nsViewManager::SetWindowDimensions(nscoord aWidth, nscoord aHeight return NS_OK; } -NS_IMETHODIMP nsViewManager::FlushDelayedResize() +NS_IMETHODIMP nsViewManager::FlushDelayedResize(PRBool aDoReflow) { if (mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE)) { - DoSetWindowDimensions(mDelayedResize.width, mDelayedResize.height); - mDelayedResize.SizeTo(NSCOORD_NONE, NSCOORD_NONE); + if (aDoReflow) { + DoSetWindowDimensions(mDelayedResize.width, mDelayedResize.height); + mDelayedResize.SizeTo(NSCOORD_NONE, NSCOORD_NONE); + } else if (mObserver) { + nsCOMPtr shell = do_QueryInterface(mObserver); + nsPresContext* presContext = shell->GetPresContext(); + if (presContext) { + presContext->SetVisibleArea(nsRect(nsPoint(0, 0), mDelayedResize)); + } + } } return NS_OK; } @@ -842,7 +852,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, : nsnull) { if (vm->mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) && IsViewVisible(vm->mRootView)) { - vm->FlushDelayedResize(); + vm->FlushDelayedResize(PR_TRUE); // Paint later. vm->UpdateView(vm->mRootView, NS_VMREFRESH_NO_SYNC); diff --git a/view/src/nsViewManager.h b/view/src/nsViewManager.h index 72302bc1b2d..79e4ece68ce 100644 --- a/view/src/nsViewManager.h +++ b/view/src/nsViewManager.h @@ -111,7 +111,7 @@ public: NS_IMETHOD GetWindowDimensions(nscoord *width, nscoord *height); NS_IMETHOD SetWindowDimensions(nscoord width, nscoord height); - NS_IMETHOD FlushDelayedResize(); + NS_IMETHOD FlushDelayedResize(PRBool aDoReflow); NS_IMETHOD Composite(void);