No bug - Tweak and expand the comments for subdocument flush propagation to ancestor documents. r=dbaron
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 06 Dec 2019 02:51:33 +0000
changeset 567943 482892b2dd97385d2ab07520b5d4884d8441aa26
parent 567942 7c75c3077b22479e61a6e414b54fef6bb932f092
child 567944 464a15bfedb87e6dda633d65bea9ea5d4761b804
push id12493
push userffxbld-merge
push dateMon, 06 Jan 2020 15:38:57 +0000
treeherdermozilla-beta@63ae456b848d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1440537, 687441
milestone73.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
No bug - Tweak and expand the comments for subdocument flush propagation to ancestor documents. r=dbaron After bug 1440537 and bug 687441, the condition here is a bit more subtle. Differential Revision: https://phabricator.services.mozilla.com/D56128
dom/base/Document.cpp
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -9778,28 +9778,37 @@ void Document::FlushPendingNotifications
   // Should we be flushing pending binding constructors in here?
 
   if (flushType <= FlushType::ContentAndNotify) {
     // Nothing to do here
     return;
   }
 
   // If we have a parent we must flush the parent too to ensure that our
-  // container is reflowed if its size was changed.  But if it's not safe to
-  // flush ourselves, then don't flush the parent, since that can cause things
-  // like resizes of our frame's widget, which we can't handle while flushing
-  // is unsafe.
-  // Since media queries mean that a size change of our container can
-  // affect style, we need to promote a style flush on ourself to a
-  // layout flush on our parent, since we need our container to be the
-  // correct size to determine the correct style.
+  // container is reflowed if its size was changed.
+  //
+  // We do it only if the subdocument and the parent can observe each other
+  // synchronously (that is, if we're not cross-origin), to avoid work that is
+  // not observable, and if the parent document has finished loading all its
+  // render-blocking stylesheets and may start laying out the document, to avoid
+  // unnecessary flashes of unstyled content on the parent document. Note that
+  // this last bit means that size-dependent media queries in this document may
+  // produce incorrect results temporarily.
+  //
+  // But if it's not safe to flush ourselves, then don't flush the parent, since
+  // that can cause things like resizes of our frame's widget, which we can't
+  // handle while flushing is unsafe.
   if (StyleOrLayoutObservablyDependsOnParentDocumentLayout() &&
       mParentDocument->MayStartLayout() && IsSafeToFlush()) {
-    mozilla::ChangesToFlush parentFlush = aFlush;
+    ChangesToFlush parentFlush = aFlush;
     if (flushType >= FlushType::Style) {
+      // Since media queries mean that a size change of our container can affect
+      // style, we need to promote a style flush on ourself to a layout flush on
+      // our parent, since we need our container to be the correct size to
+      // determine the correct style.
       parentFlush.mFlushType = std::max(FlushType::Layout, flushType);
     }
     mParentDocument->FlushPendingNotifications(parentFlush);
   }
 
   if (RefPtr<PresShell> presShell = GetPresShell()) {
     presShell->FlushPendingNotifications(aFlush);
   }