Bug 1344619 - Part 3: Kick EffectCompositor::PreTraverse(). r?heycam draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Thu, 09 Mar 2017 05:20:17 +0900
changeset 495415 fdb5bd9fe402ab843df1c7364cf67a2f1f8e48cc
parent 495414 48003fcedcf38000574d9ab155b98949540bf4ef
child 495416 0a2b694d91144d831307ff200c93831837cff3d2
push id48329
push userhikezoe@mozilla.com
push dateWed, 08 Mar 2017 20:20:57 +0000
reviewersheycam
bugs1344619
milestone55.0a1
Bug 1344619 - Part 3: Kick EffectCompositor::PreTraverse(). r?heycam MozReview-Commit-ID: HbBrQ7HZ8gf
layout/style/ServoStyleSet.cpp
layout/style/ServoStyleSet.h
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -196,21 +196,30 @@ ServoStyleSet::GetContext(already_AddRef
 void
 ServoStyleSet::ResolveMappedAttrDeclarationBlocks()
 {
   if (nsHTMLStyleSheet* sheet = mPresContext->Document()->GetAttributeStyleSheet()) {
     sheet->CalculateMappedServoDeclarations();
   }
 }
 
+void
+ServoStyleSet::PreTraverse()
+{
+  ResolveMappedAttrDeclarationBlocks();
+
+  // Process animation stuff that we should avoid doing during the parallel
+  // traversal.
+  mPresContext->EffectCompositor()->PreTraverse();
+}
+
 bool
 ServoStyleSet::PrepareAndTraverseSubtree(RawGeckoElementBorrowed aRoot,
-                                         mozilla::TraversalRootBehavior aRootBehavior) {
-  ResolveMappedAttrDeclarationBlocks();
-
+                                         mozilla::TraversalRootBehavior aRootBehavior)
+{
   // Get the Document's root element to ensure that the cache is valid before
   // calling into the (potentially-parallel) Servo traversal, where a cache hit
   // is necessary to avoid a data race when updating the cache.
   mozilla::Unused << aRoot->OwnerDoc()->GetRootElement();
 
   MOZ_ASSERT(!sInServoTraversal);
   sInServoTraversal = true;
   bool postTraversalRequired =
@@ -603,40 +612,47 @@ ServoStyleSet::HasStateDependentStyle(do
 {
   NS_WARNING("stylo: HasStateDependentStyle always returns zero!");
   return nsRestyleHint(0);
 }
 
 bool
 ServoStyleSet::StyleDocument()
 {
+  PreTraverse();
+
   // Restyle the document from the root element and each of the document level
   // NAC subtree roots.
   bool postTraversalRequired = false;
   DocumentStyleRootIterator iter(mPresContext->Document());
   while (Element* root = iter.GetNextStyleRoot()) {
     if (PrepareAndTraverseSubtree(root, TraversalRootBehavior::Normal)) {
       postTraversalRequired = true;
     }
   }
   return postTraversalRequired;
 }
 
 void
 ServoStyleSet::StyleNewSubtree(Element* aRoot)
 {
   MOZ_ASSERT(!aRoot->HasServoData());
+
+  PreTraverse();
+
   DebugOnly<bool> postTraversalRequired =
     PrepareAndTraverseSubtree(aRoot, TraversalRootBehavior::Normal);
   MOZ_ASSERT(!postTraversalRequired);
 }
 
 void
 ServoStyleSet::StyleNewChildren(Element* aParent)
 {
+  PreTraverse();
+
   PrepareAndTraverseSubtree(aParent, TraversalRootBehavior::UnstyledChildrenOnly);
   // We can't assert that Servo_TraverseSubtree returns false, since aParent
   // or some of its other children might have pending restyles.
 }
 
 void
 ServoStyleSet::NoteStyleSheetsChanged()
 {
--- a/layout/style/ServoStyleSet.h
+++ b/layout/style/ServoStyleSet.h
@@ -260,16 +260,21 @@ private:
 
   /**
    * Clear our cached mNonInheritingStyleContexts.  We do this when we want to
    * make sure those style contexts won't live too long (e.g. when rebuilding
    * all style data or when shutting down the style set).
    */
   void ClearNonInheritingStyleContexts();
 
+  /**
+   * Perform processes that we should do before traversing.
+   */
+  void PreTraverse();
+
   nsPresContext* mPresContext;
   UniquePtr<RawServoStyleSet> mRawSet;
   EnumeratedArray<SheetType, SheetType::Count,
                   nsTArray<RefPtr<ServoStyleSheet>>> mSheets;
   int32_t mBatching;
 
   // Stores pointers to our cached style contexts for non-inheriting anonymous
   // boxes.