Bug 1368852: Avoid flushing frames from nsHideViewer if we know we're not going to get a frame. r=tnikkel
authorEmilio Cobos Álvarez <emilio@crisal.io>
Wed, 13 Sep 2017 00:08:46 +0200
changeset 430010 9b4a1e0081bc0a834f380d7e621a9af36db49105
parent 430009 f92907da4b686181d2451664fa5e94d975d675dc
child 430011 760b27ede9924a024c4fb9a8ca5f2ca93704c1ae
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel
bugs1368852
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1368852: Avoid flushing frames from nsHideViewer if we know we're not going to get a frame. r=tnikkel MozReview-Commit-ID: ATVMfQ8myC1
layout/generic/nsSubDocumentFrame.cpp
--- a/layout/generic/nsSubDocumentFrame.cpp
+++ b/layout/generic/nsSubDocumentFrame.cpp
@@ -925,17 +925,26 @@ public:
     NS_ASSERTION(mPresShell, "Must have a presshell");
   }
 
   NS_IMETHOD Run() override
   {
     // Flush frames, to ensure any pending display:none changes are made.
     // Note it can be unsafe to flush if we've destroyed the presentation
     // for some other reason, like if we're shutting down.
-    if (!mPresShell->IsDestroying()) {
+    //
+    // But avoid the flush if we know for sure we're away, like when we're out
+    // of the document already.
+    //
+    // FIXME(emilio): This could still be a perf footgun when removing lots of
+    // siblings where each of them cause the reframe of an ancestor which happen
+    // to contain a subdocument.
+    //
+    // We should find some way to avoid that!
+    if (!mPresShell->IsDestroying() && mFrameElement->IsInComposedDoc()) {
       mPresShell->FlushPendingNotifications(FlushType::Frames);
     }
 
     // Either the frame has been constructed by now, or it never will be,
     // either way we want to clear the stashed views.
     mFrameLoader->SetDetachedSubdocFrame(nullptr, nullptr);
 
     nsSubDocumentFrame* frame = do_QueryFrame(mFrameElement->GetPrimaryFrame());