Bug 1344619 - Part 3: Kick EffectCompositor::PreTraverse(). r?heycam
MozReview-Commit-ID: HbBrQ7HZ8gf
--- 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.