From fd2d4e8b6fb0bea11cd87908f8e6f9512d2f0b9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 31 Aug 2017 21:21:49 +0200 Subject: [PATCH] Bug 1374235: style: Remove the for reconstruction traversals. r=bholley One less hack, a few more to go. MozReview-Commit-ID: 6katL1EGn2U --- layout/base/nsCSSFrameConstructor.cpp | 32 +++------------------ layout/base/nsCSSFrameConstructor.h | 7 ----- layout/style/ServoStyleSet.cpp | 41 --------------------------- layout/style/ServoStyleSet.h | 10 ------- layout/style/ServoTypes.h | 3 -- 5 files changed, 4 insertions(+), 89 deletions(-) diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 54a809f76254..b04295f13f9e 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -7597,22 +7597,6 @@ nsCSSFrameConstructor::StyleNewChildRange(nsIContent* aStartChild, } } -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, @@ -7702,12 +7686,8 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer, } // We couldn't construct lazily. Make Servo eagerly traverse the new content. - if (aContainer->IsStyledByServo()) { - if (aForReconstruction) { - StyleChildRangeForReconstruct(aFirstNewContent, nullptr); - } else { - StyleNewChildRange(aFirstNewContent, nullptr); - } + if (isNewlyAddedContentForServo) { + StyleNewChildRange(aFirstNewContent, nullptr); } if (isNewShadowTreeContent) { @@ -8191,12 +8171,8 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer, } // We couldn't construct lazily. Make Servo eagerly traverse the new content. - if (aContainer->IsStyledByServo()) { - if (aForReconstruction) { - StyleChildRangeForReconstruct(aStartChild, aEndChild); - } else { - StyleNewChildRange(aStartChild, aEndChild); - } + if (isNewlyAddedContentForServo) { + StyleNewChildRange(aStartChild, aEndChild); } if (isNewShadowTreeContent) { diff --git a/layout/base/nsCSSFrameConstructor.h b/layout/base/nsCSSFrameConstructor.h index 8c5f73cf78c6..ac05b3e3b72b 100644 --- a/layout/base/nsCSSFrameConstructor.h +++ b/layout/base/nsCSSFrameConstructor.h @@ -185,13 +185,6 @@ private: */ 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 diff --git a/layout/style/ServoStyleSet.cpp b/layout/style/ServoStyleSet.cpp index 0eeadbbc4b0a..56f5f1f389d7 100644 --- a/layout/style/ServoStyleSet.cpp +++ b/layout/style/ServoStyleSet.cpp @@ -1051,47 +1051,6 @@ ServoStyleSet::StyleNewlyBoundElement(Element* aElement) } } -void -ServoStyleSet::StyleSubtreeForReconstruct(Element* aRoot) -{ - MOZ_ASSERT(MayTraverseFrom(aRoot)); - MOZ_ASSERT(aRoot->HasServoData()); - - // If the restyle root is beneath |aRoot|, there won't be any descendants bit - // leading us to aRoot. In this case, we need to traverse from the restyle - // root instead. - nsIDocument* doc = mPresContext->Document(); - nsINode* restyleRoot = doc->GetServoRestyleRoot(); - if (!restyleRoot) { - return; - } - Element* el = restyleRoot->IsElement() ? restyleRoot->AsElement() : nullptr; - if (el && nsContentUtils::ContentIsFlattenedTreeDescendantOf(el, aRoot)) { - MOZ_ASSERT(MayTraverseFrom(el)); - aRoot = el; - doc->ClearServoRestyleRoot(); - } - - auto flags = ServoTraversalFlags::Forgetful | - ServoTraversalFlags::AggressivelyForgetful | - ServoTraversalFlags::ClearDirtyBits; - PreTraverse(flags); - - AutoPrepareTraversal guard(this); - - const SnapshotTable& snapshots = Snapshots(); - - DebugOnly postTraversalRequired = - Servo_TraverseSubtree(aRoot, mRawSet.get(), &snapshots, flags); - MOZ_ASSERT(!postTraversalRequired); - - if (mPresContext->EffectCompositor()->PreTraverseInSubtree(flags, aRoot)) { - postTraversalRequired = - Servo_TraverseSubtree(aRoot, mRawSet.get(), &snapshots, flags); - MOZ_ASSERT(!postTraversalRequired); - } -} - void ServoStyleSet::MarkOriginsDirty(OriginFlags aChangedOrigins) { diff --git a/layout/style/ServoStyleSet.h b/layout/style/ServoStyleSet.h index 0c7642fa9bed..a049fea9cac1 100644 --- a/layout/style/ServoStyleSet.h +++ b/layout/style/ServoStyleSet.h @@ -302,16 +302,6 @@ public: */ void StyleNewlyBoundElement(dom::Element* aElement); - /** - * Like StyleNewSubtree, but in response to a request to reconstruct frames - * for the given subtree, and so works on elements that already have - * styles. This will leave the subtree in a state just like after an initial - * styling, i.e. with new styles, no change hints, and with the dirty - * descendants bits cleared. No comparison of old and new styles is done, - * so no change hints will be processed. - */ - void StyleSubtreeForReconstruct(dom::Element* aRoot); - /** * Helper for correctly calling UpdateStylist without paying the cost of an * extra function call in the common no-rebuild-needed case. diff --git a/layout/style/ServoTypes.h b/layout/style/ServoTypes.h index 108df7edcd53..04713718bafd 100644 --- a/layout/style/ServoTypes.h +++ b/layout/style/ServoTypes.h @@ -67,9 +67,6 @@ enum class ServoTraversalFlags : uint32_t { // pre-traversal. A forgetful traversal is usually the right thing if you // aren't going to do a post-traversal. Forgetful = 1 << 3, - // Actively seeks out and clears change hints that may have been posted into - // the tree. Nonsensical without also passing Forgetful. - AggressivelyForgetful = 1 << 4, // Clears all the dirty bits (dirty descendants, animation-only dirty-descendants, // needs frame, descendants need frames) on the elements traversed. // in the subtree.