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