Bug 553366. When flushing, make sure to flush external documents too. r=bzbarsky
☠☠ backed out by 47ef6d724773 ☠ ☠
authorTimothy Nikkel <tnikkel@gmail.com>
Sat, 10 Apr 2010 13:03:40 -0500
changeset 40650 761790684f3be4ebb9c30895d1864dbd12516a9a
parent 40649 02e8391669c3975821e20d9a5485eaa27cf0a39d
child 40651 633cc14c86b81a341d461982504b5366843add39
child 40667 47ef6d724773f2eb7157f93c1da8d53a8589f26a
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs553366
milestone1.9.3a5pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
Bug 553366. When flushing, make sure to flush external documents too. r=bzbarsky
content/base/public/nsIDocument.h
content/base/src/nsDocument.cpp
content/base/src/nsDocument.h
layout/base/nsPresShell.cpp
--- a/content/base/public/nsIDocument.h
+++ b/content/base/public/nsIDocument.h
@@ -700,16 +700,24 @@ public:
                                 nsIStyleRule* aStyleRule) = 0;
 
   /**
    * Flush notifications for this document and its parent documents
    * (since those may affect the layout of this one).
    */
   virtual void FlushPendingNotifications(mozFlushType aType) = 0;
 
+  /**
+   * Calls FlushPendingNotifications on any external resources this document
+   * has. If this document has no external resources or is an external resource
+   * itself this does nothing. This should only be called with
+   * aType >= Flush_Style.
+   */
+  virtual void FlushExternalResources(mozFlushType aType) = 0;
+
   nsBindingManager* BindingManager() const
   {
     return mNodeInfoManager->GetBindingManager();
   }
 
   /**
    * Only to be used inside Gecko, you can't really do anything with the
    * pointer outside Gecko anyway.
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -6440,16 +6440,36 @@ nsDocument::FlushPendingNotifications(mo
   }
 
   nsCOMPtr<nsIPresShell> shell = GetPrimaryShell();
   if (shell) {
     shell->FlushPendingNotifications(aType);
   }
 }
 
+static PRBool
+Flush(nsIDocument* aDocument, void* aData)
+{
+  const mozFlushType* type = static_cast<const mozFlushType*>(aData);
+  aDocument->FlushPendingNotifications(*type);
+  return PR_TRUE;
+}
+
+void
+nsDocument::FlushExternalResources(mozFlushType aType)
+{
+  NS_ASSERTION(aType >= Flush_Style,
+    "should only need to flush for style or higher in external resources");
+
+  if (GetDisplayDocument()) {
+    return;
+  }
+  EnumerateExternalResources(Flush, &aType);
+}
+
 nsIScriptEventManager*
 nsDocument::GetScriptEventManager()
 {
   if (!mScriptEventManager) {
     mScriptEventManager = new nsScriptEventManager(this);
     // automatically AddRefs
   }
 
--- a/content/base/src/nsDocument.h
+++ b/content/base/src/nsDocument.h
@@ -699,16 +699,17 @@ public:
                                 nsIStyleRule* aOldStyleRule,
                                 nsIStyleRule* aNewStyleRule);
   virtual void StyleRuleAdded(nsIStyleSheet* aStyleSheet,
                               nsIStyleRule* aStyleRule);
   virtual void StyleRuleRemoved(nsIStyleSheet* aStyleSheet,
                                 nsIStyleRule* aStyleRule);
 
   virtual void FlushPendingNotifications(mozFlushType aType);
+  virtual void FlushExternalResources(mozFlushType aType);
   virtual nsIScriptEventManager* GetScriptEventManager();
   virtual void SetXMLDeclaration(const PRUnichar *aVersion,
                                  const PRUnichar *aEncoding,
                                  const PRInt32 aStandalone);
   virtual void GetXMLDeclaration(nsAString& aVersion,
                                  nsAString& aEncoding,
                                  nsAString& Standalone);
   virtual PRBool IsScriptEnabled();
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -4584,16 +4584,24 @@ PresShell::FlushPendingNotifications(moz
       }
     }
 
     // Style reresolves not in conjunction with reflows can't cause
     // painting or geometry changes, so don't bother with view update
     // batching if we only have style reresolve
     nsIViewManager::UpdateViewBatch batch(mViewManager);
 
+    // We need to make sure external resource documents are flushed too (for
+    // example, svg filters that reference a filter in an external document
+    // need the frames in the external document to be constructed for the
+    // filter to work). We only need external resources to be flushed when the
+    // main document is flushing >= Flush_Frames, so we flush external
+    // resources here instead of nsDocument::FlushPendingNotifications.
+    mDocument->FlushExternalResources(aType);
+
     // Force flushing of any pending content notifications that might have
     // queued up while our event was pending.  That will ensure that we don't
     // construct frames for content right now that's still waiting to be
     // notified on,
     mDocument->FlushPendingNotifications(Flush_ContentAndNotify);
 
     // Process pending restyles, since any flush of the presshell wants
     // up-to-date style data.