Bug 1351535 - Part 9: Call StyleSubtreeForReconstruct when doing frame reconstruction. r=bholley
☠☠ backed out by 928f3c613164 ☠ ☠
authorCameron McCormack <cam@mcc.id.au>
Tue, 04 Apr 2017 19:36:09 +0800
changeset 351946 0410ff8981572bed9c09b1e8b26f690b9f7595cf
parent 351945 bff89114412cf482997864451b08b744e0647be6
child 351947 928f3c61316437162d5f4483997e4b73f0ce70b7
push id40349
push usercmccormack@mozilla.com
push dateSat, 08 Apr 2017 14:47:16 +0000
treeherderautoland@0410ff898157 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1351535
milestone55.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 1351535 - Part 9: Call StyleSubtreeForReconstruct when doing frame reconstruction. r=bholley MozReview-Commit-ID: HxoGLPKJpnt
layout/base/nsCSSFrameConstructor.cpp
layout/base/nsCSSFrameConstructor.h
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -7423,16 +7423,32 @@ nsCSSFrameConstructor::StyleNewChildRang
       if (parent->HasServoData()) {
         styleSet->StyleNewChildren(parent);
       }
     }
   }
 }
 
 void
+nsCSSFrameConstructor::StyleChildRangeForReconstruct(nsIContent* aStartChild,
+                                                     nsIContent* aEndChild)
+{
+  ServoStyleSet* styleSet = mPresShell->StyleSet()->AsServo();
+
+  // We take a parallelism hit here, since we don't have a great API to pass
+  // a range of elements to style to Servo.
+  for (nsIContent* child = aStartChild; child != aEndChild;
+       child = child->GetNextSibling()) {
+    if (child->IsElement()) {
+      styleSet->StyleSubtreeForReconstruct(child->AsElement());
+    }
+  }
+}
+
+void
 nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
                                        nsIContent* aFirstNewContent,
                                        bool aAllowLazyConstruction,
                                        bool aForReconstruction,
                                        TreeMatchContext* aProvidedTreeMatchContext)
 {
   MOZ_ASSERT_IF(aProvidedTreeMatchContext, !aAllowLazyConstruction);
   MOZ_ASSERT_IF(aAllowLazyConstruction, !RestyleManager()->IsInStyleRefresh());
@@ -7510,18 +7526,22 @@ nsCSSFrameConstructor::ContentAppended(n
       if (isNewlyAddedContentForServo) {
         aContainer->AsElement()->NoteDirtyDescendantsForServo();
       }
       return;
     }
   }
 
   // We couldn't construct lazily. Make Servo eagerly traverse the new content.
-  if (isNewlyAddedContentForServo) {
-    StyleNewChildRange(aFirstNewContent, nullptr);
+  if (aContainer->IsStyledByServo()) {
+    if (aForReconstruction) {
+      StyleChildRangeForReconstruct(aFirstNewContent, nullptr);
+    } else {
+      StyleNewChildRange(aFirstNewContent, nullptr);
+    }
   }
 
   if (isNewShadowTreeContent) {
     // Recreate frames if content is appended into a ShadowRoot
     // because children of ShadowRoot are rendered in place of children
     // of the host.
     //XXXsmaug This is super unefficient!
     nsIContent* bindingParent = aContainer->GetBindingParent();
@@ -7991,18 +8011,22 @@ nsCSSFrameConstructor::ContentRangeInser
       if (isNewlyAddedContentForServo) {
         aContainer->AsElement()->NoteDirtyDescendantsForServo();
       }
       return;
     }
   }
 
   // We couldn't construct lazily. Make Servo eagerly traverse the new content.
-  if (isNewlyAddedContentForServo) {
-    StyleNewChildRange(aStartChild, aEndChild);
+  if (aContainer->IsStyledByServo()) {
+    if (aForReconstruction) {
+      StyleChildRangeForReconstruct(aStartChild, aEndChild);
+    } else {
+      StyleNewChildRange(aStartChild, aEndChild);
+    }
   }
 
   if (isNewShadowTreeContent) {
     // Recreate frames if content is inserted into a ShadowRoot
     // because children of ShadowRoot are rendered in place of
     // the children of the host.
     //XXXsmaug This is super unefficient!
     nsIContent* bindingParent = aContainer->GetBindingParent();
--- a/layout/base/nsCSSFrameConstructor.h
+++ b/layout/base/nsCSSFrameConstructor.h
@@ -162,16 +162,23 @@ private:
    * For each child in the aStartChild/aEndChild range, calls StyleNewChildren
    * on their flattened tree parents.  This is used when content is inserted
    * into the document.  It handles children being rebound to different
    * insertion points by calling StyleNewChildren on each child's flattened
    * tree parent.  Only used when we are styled by Servo.
    */
   void StyleNewChildRange(nsIContent* aStartChild, nsIContent* aEndChild);
 
+  /**
+   * Calls StyleSubtreeForReconstruct on each child in the aStartChild/aEndChild
+   * range. Only used when we are styled by Servo.
+   */
+  void StyleChildRangeForReconstruct(nsIContent* aStartChild,
+                                     nsIContent* aEndChild);
+
 public:
   /**
    * Lazy frame construction is controlled by the aAllowLazyConstruction bool
    * parameter of nsCSSFrameConstructor::ContentAppended/Inserted. It is true
    * for all inserts/appends as passed from the presshell, except for the
    * insert of the root element, which is always non-lazy. Even if the
    * aAllowLazyConstruction passed to ContentAppended/Inserted is true we still
    * may not be able to construct lazily, so we call MaybeConstructLazily.