зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1356103 - Part 3: Make it easy to access the ServoStyleSet currently in traversal. r=bholley
In a later patch, we'll want to queue up some tasks to run when the Servo traversal is one, and the ServoStyleSet seems like the natural place to store those tasks. We could probably find the ServoStyleSet by chasing a bunch of pointers from the task-adding call sites, but it seems simpler just to make it available directly. MozReview-Commit-ID: AJoFZEoNaGm --HG-- extra : rebase_source : 78389d72ba6dfb4301ba75bd39bbdc51d13cb4d5
This commit is contained in:
Родитель
115e900d63
Коммит
b23bdd20ae
|
@ -295,8 +295,7 @@ ServoStyleSet::PrepareAndTraverseSubtree(RawGeckoElementBorrowed aRoot,
|
|||
// is necessary to avoid a data race when updating the cache.
|
||||
mozilla::Unused << aRoot->OwnerDoc()->GetRootElement();
|
||||
|
||||
MOZ_ASSERT(!sInServoTraversal);
|
||||
sInServoTraversal = true;
|
||||
AutoSetInServoTraversal guard(this);
|
||||
|
||||
bool isInitial = !aRoot->HasServoData();
|
||||
bool forReconstruct =
|
||||
|
@ -338,7 +337,6 @@ ServoStyleSet::PrepareAndTraverseSubtree(RawGeckoElementBorrowed aRoot,
|
|||
}
|
||||
}
|
||||
|
||||
sInServoTraversal = false;
|
||||
return postTraversalRequired;
|
||||
}
|
||||
|
||||
|
@ -983,8 +981,8 @@ already_AddRefed<ServoComputedValues>
|
|||
ServoStyleSet::ResolveStyleLazily(Element* aElement, nsIAtom* aPseudoTag)
|
||||
{
|
||||
mPresContext->EffectCompositor()->PreTraverse(aElement, aPseudoTag);
|
||||
MOZ_ASSERT(!sInServoTraversal);
|
||||
sInServoTraversal = true;
|
||||
|
||||
AutoSetInServoTraversal guard(this);
|
||||
|
||||
/**
|
||||
* NB: This is needed because we process animations and transitions on the
|
||||
|
@ -1023,8 +1021,6 @@ ServoStyleSet::ResolveStyleLazily(Element* aElement, nsIAtom* aPseudoTag)
|
|||
mRawSet.get()).Consume();
|
||||
}
|
||||
|
||||
sInServoTraversal = false;
|
||||
|
||||
return computedValues.forget();
|
||||
}
|
||||
|
||||
|
@ -1110,4 +1106,4 @@ ServoStyleSet::RemoveSheetOfType(SheetType aType,
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool ServoStyleSet::sInServoTraversal = false;
|
||||
ServoStyleSet* ServoStyleSet::sInServoTraversal = nullptr;
|
||||
|
|
|
@ -85,6 +85,11 @@ public:
|
|||
return sInServoTraversal;
|
||||
}
|
||||
|
||||
static ServoStyleSet* Current()
|
||||
{
|
||||
return sInServoTraversal;
|
||||
}
|
||||
|
||||
ServoStyleSet();
|
||||
~ServoStyleSet();
|
||||
|
||||
|
@ -309,6 +314,23 @@ public:
|
|||
const ServoComputedValuesWithParent& aComputedValues);
|
||||
|
||||
private:
|
||||
class MOZ_STACK_CLASS AutoSetInServoTraversal
|
||||
{
|
||||
public:
|
||||
explicit AutoSetInServoTraversal(ServoStyleSet* aSet)
|
||||
{
|
||||
MOZ_ASSERT(!sInServoTraversal);
|
||||
MOZ_ASSERT(aSet);
|
||||
sInServoTraversal = aSet;
|
||||
}
|
||||
|
||||
~AutoSetInServoTraversal()
|
||||
{
|
||||
MOZ_ASSERT(sInServoTraversal);
|
||||
sInServoTraversal = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
already_AddRefed<nsStyleContext> GetContext(already_AddRefed<ServoComputedValues>,
|
||||
nsStyleContext* aParentContext,
|
||||
nsIAtom* aPseudoTag,
|
||||
|
@ -399,7 +421,7 @@ private:
|
|||
nsCSSAnonBoxes::NonInheriting::_Count,
|
||||
RefPtr<nsStyleContext>> mNonInheritingStyleContexts;
|
||||
|
||||
static bool sInServoTraversal;
|
||||
static ServoStyleSet* sInServoTraversal;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
Загрузка…
Ссылка в новой задаче