Bug 1449807: Don't flush in nsXBLResourceLoader::NotifyBoundElements. r?bz draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 29 Mar 2018 02:56:57 +0200
changeset 774515 becfba30ea4f264acf5bc17d56d4f638f8d5ad62
parent 774403 825cdcd3130f2f3620b73a8d12daf08662754f8f
push id104426
push userbmo:emilio@crisal.io
push dateThu, 29 Mar 2018 02:13:45 +0000
reviewersbz
bugs1449807, 1357142, 1303605
milestone61.0a1
Bug 1449807: Don't flush in nsXBLResourceLoader::NotifyBoundElements. r?bz Before bug 1357142, we used to legitimately need to check for redundant frame tree insertions and such, since we went into frame construction synchronously. But after that, all this dance of flushing, querying the primary frame and the uncomputed maps is just needless. We can just post as many reframes as we want, they'll be processed properly on the next flush. This removes one of the queries to the undisplayed map which I'm trying to remove in bug 1303605. I could have just poked at the style stored in the element, but this one is easy to just get rid of. MozReview-Commit-ID: 4ng4bU6C4Bs
dom/xbl/nsXBLResourceLoader.cpp
--- a/dom/xbl/nsXBLResourceLoader.cpp
+++ b/dom/xbl/nsXBLResourceLoader.cpp
@@ -230,57 +230,33 @@ nsXBLResourceLoader::NotifyBoundElements
   for (uint32_t j = 0; j < eltCount; j++) {
     nsCOMPtr<nsIContent> content = mBoundElements.ObjectAt(j);
     MOZ_ASSERT(content->IsElement());
     content->OwnerDoc()->UnblockOnload(/* aFireSync = */ false);
 
     bool ready = false;
     xblService->BindingReady(content, bindingURI, &ready);
 
-    if (ready) {
-      // We need the document to flush out frame construction and
-      // such, so we want to use the current document.
-      nsIDocument* doc = content->GetUncomposedDoc();
-
-      if (doc) {
-        // Flush first to make sure we can get the frame for content
-        doc->FlushPendingNotifications(FlushType::Frames);
+    if (!ready) {
+      continue;
+    }
 
-        // If |content| is (in addition to having binding |mBinding|)
-        // also a descendant of another element with binding |mBinding|,
-        // then we might have just constructed it due to the
-        // notification of its parent.  (We can know about both if the
-        // binding loads were triggered from the DOM rather than frame
-        // construction.)  So we have to check both whether the element
-        // has a primary frame and whether it's in the undisplayed map
-        // before sending a ContentInserted notification, or bad things
-        // will happen.
-        nsIPresShell *shell = doc->GetShell();
-        if (shell) {
-          nsIFrame* childFrame = content->GetPrimaryFrame();
-          if (!childFrame) {
-            // Check if it's in the display:none or display:contents maps.
-            ComputedStyle* sc =
-              shell->FrameConstructor()->GetDisplayNoneStyleFor(content);
+    // We need the document to flush out frame construction and
+    // such, so we want to use the current document.
+    nsIDocument* doc = content->GetUncomposedDoc();
+    if (!doc) {
+      continue;
+    }
 
-            if (!sc) {
-              sc = shell->FrameConstructor()->GetDisplayContentsStyleFor(content);
-            }
+    nsIPresShell* shell = doc->GetShell();
+    if (!shell) {
+      continue;
+    }
 
-            if (!sc) {
-              shell->PostRecreateFramesFor(content->AsElement());
-            }
-          }
-        }
-
-        // Flush again
-        // XXXbz why is this needed?
-        doc->FlushPendingNotifications(FlushType::ContentAndNotify);
-      }
-    }
+    shell->PostRecreateFramesFor(content->AsElement());
   }
 
   // Clear out the whole array.
   mBoundElements.Clear();
 
   // Delete ourselves.
   mResources->ClearLoader();
 }