Prevent rebuilding all style data when paginated. (Bug 468645) r+sr=bzbarsky
authorL. David Baron <dbaron@dbaron.org>
Mon, 29 Dec 2008 10:07:37 -0500
changeset 23167 6849ce51dfef0df9838e72af1acdd8a9f407a373
parent 23166 e09da908f8b4b045f7704173b903f22427bbc482
child 23168 dee577166dd8fabe74957cc913ced117555c64c9
child 23979 6f2d2ef53d758d199d16ddb88ca982ecd6e67845
push idunknown
push userunknown
push dateunknown
bugs468645
milestone1.9.2a1pre
Prevent rebuilding all style data when paginated. (Bug 468645) r+sr=bzbarsky
layout/base/nsCSSFrameConstructor.cpp
layout/base/nsPresContext.cpp
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -13393,16 +13393,23 @@ nsCSSFrameConstructor::RebuildAllStyleDa
 
   mRebuildAllStyleData = PR_FALSE;
   NS_UpdateHint(aExtraHint, mRebuildAllExtraHint);
   mRebuildAllExtraHint = nsChangeHint(0);
 
   if (!mPresShell || !mPresShell->GetRootFrame())
     return;
 
+  if (mPresShell->GetPresContext()->IsPaginated()) {
+    // We don't support doing this because of bug 470929 and probably
+    // other issues.
+    NS_NOTREACHED("not allowed to rebuild all style data when paginated");
+    return;
+  }
+
   // Processing the style changes could cause a flush that propagates to
   // the parent frame and thus destroys the pres shell.
   nsCOMPtr<nsIPresShell> kungFuDeathGrip(mPresShell);
 
   // Tell the style set to get the old rule tree out of the way
   // so we can recalculate while maintaining rule tree immutability
   nsresult rv = mPresShell->StyleSet()->BeginReconstruct();
   if (NS_FAILED(rv))
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -728,16 +728,23 @@ nsPresContext::GetUserPreferences()
   // prescontext or we are being called from UpdateAfterPreferencesChanged()
   // which triggers a reflow anyway.
   SetBidi(bidiOptions, PR_FALSE);
 }
 
 void
 nsPresContext::PreferenceChanged(const char* aPrefName)
 {
+  if (IsPaginated()) {
+    // Until we fix things so that we can do multiple reflows and style
+    // rebuilds (see, e.g., bug 470929) in paginated mode, we should
+    // ignore preference changes when paginated.
+    return;
+  }
+
   nsDependentCString prefName(aPrefName);
   if (prefName.EqualsLiteral("layout.css.dpi")) {
     PRInt32 oldAppUnitsPerDevPixel = AppUnitsPerDevPixel();
     if (mDeviceContext->CheckDPIChange() && mShell) {
       mDeviceContext->FlushFontCache();
 
       // Re-fetch the view manager's window dimensions in case there's a deferred
       // resize which hasn't affected our mVisibleArea yet