From 0a3df9a0d91d706f0cb7d0ec13bfaf1e50530d75 Mon Sep 17 00:00:00 2001 From: Timothy Nikkel Date: Sat, 10 Apr 2010 13:03:40 -0500 Subject: [PATCH] Bug 553366. When flushing, make sure to flush external documents too. r=bzbarsky --- content/base/public/nsIDocument.h | 8 ++++++++ content/base/src/nsDocument.cpp | 20 ++++++++++++++++++++ content/base/src/nsDocument.h | 1 + layout/base/nsPresShell.cpp | 8 ++++++++ 4 files changed, 37 insertions(+) diff --git a/content/base/public/nsIDocument.h b/content/base/public/nsIDocument.h index c6dbe5e334e4..175085afbd11 100644 --- a/content/base/public/nsIDocument.h +++ b/content/base/public/nsIDocument.h @@ -705,6 +705,14 @@ public: */ 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(); diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 8da2c8ea9e9c..a562f879e809 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -6445,6 +6445,26 @@ nsDocument::FlushPendingNotifications(mozFlushType aType) } } +static PRBool +Flush(nsIDocument* aDocument, void* aData) +{ + const mozFlushType* type = static_cast(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() { diff --git a/content/base/src/nsDocument.h b/content/base/src/nsDocument.h index 834794e859cf..687cad6ffffd 100644 --- a/content/base/src/nsDocument.h +++ b/content/base/src/nsDocument.h @@ -704,6 +704,7 @@ public: nsIStyleRule* aStyleRule); virtual void FlushPendingNotifications(mozFlushType aType); + virtual void FlushExternalResources(mozFlushType aType); virtual nsIScriptEventManager* GetScriptEventManager(); virtual void SetXMLDeclaration(const PRUnichar *aVersion, const PRUnichar *aEncoding, diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 2453b73cb1bb..9dde8f0e4fe7 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -4589,6 +4589,14 @@ PresShell::FlushPendingNotifications(mozFlushType aType) // 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