Bug 1384769 - Clean up ForThrottledAnimationFlush stuff. r=hiro

MozReview-Commit-ID: I6xeHv65nH2
This commit is contained in:
Bobby Holley 2017-07-26 10:00:28 -07:00
Родитель 12955e0dde
Коммит 07295b450f
5 изменённых файлов: 27 добавлений и 51 удалений

Просмотреть файл

@ -498,7 +498,7 @@ NeedsToTraverseElementChildren(const Element& aParent,
return true;
}
if (!(aFlags & ServoTraversalFlags::ForThrottledAnimationFlush)) {
if (!(aFlags & ServoTraversalFlags::AnimationOnly)) {
return aParent.HasDirtyDescendantsForServo() ||
aParent.HasFlag(NODE_DESCENDANTS_NEED_FRAMES);
}
@ -662,7 +662,7 @@ ServoRestyleManager::ProcessPostTraversal(
const bool descendantsNeedFrames =
aElement->HasFlag(NODE_DESCENDANTS_NEED_FRAMES);
const bool forThrottledAnimationFlush =
!!(aFlags & ServoTraversalFlags::ForThrottledAnimationFlush);
!!(aFlags & ServoTraversalFlags::AnimationOnly);
const bool traverseTextChildren =
wasRestyled || (!forThrottledAnimationFlush && descendantsNeedFrames);
bool recreatedAnyContext = wasRestyled;
@ -832,8 +832,7 @@ ServoRestyleManager::DoProcessPendingRestyles(ServoTraversalFlags aFlags)
ServoStyleSet* styleSet = StyleSet();
nsIDocument* doc = PresContext()->Document();
bool forThrottledAnimationFlush =
!!(aFlags & ServoTraversalFlags::ForThrottledAnimationFlush);
bool forThrottledAnimationFlush = !!(aFlags & ServoTraversalFlags::AnimationOnly);
// Ensure the refresh driver is active during traversal to avoid mutating
// mActiveTimer and mMostRecentRefresh time.
@ -852,9 +851,7 @@ ServoRestyleManager::DoProcessPendingRestyles(ServoTraversalFlags aFlags)
aFlags |= ServoTraversalFlags::ForCSSRuleChanges;
}
while (forThrottledAnimationFlush
? styleSet->StyleDocumentForThrottledAnimationFlush()
: styleSet->StyleDocument(aFlags)) {
while (styleSet->StyleDocument(aFlags)) {
if (!forThrottledAnimationFlush) {
ClearSnapshots();
}
@ -865,8 +862,7 @@ ServoRestyleManager::DoProcessPendingRestyles(ServoTraversalFlags aFlags)
// Recreate style contexts, and queue up change hints (which also handle
// lazy frame construction).
{
AutoRestyleTimelineMarker marker(
mPresContext->GetDocShell(), forThrottledAnimationFlush);
AutoRestyleTimelineMarker marker(mPresContext->GetDocShell(), forThrottledAnimationFlush);
DocumentStyleRootIterator iter(doc);
while (Element* root = iter.GetNextStyleRoot()) {
ServoRestyleState state(*styleSet, currentChanges);
@ -953,7 +949,7 @@ ServoRestyleManager::UpdateOnlyAnimationStyles()
return;
}
DoProcessPendingRestyles(ServoTraversalFlags::ForThrottledAnimationFlush);
DoProcessPendingRestyles(ServoTraversalFlags::AnimationOnly);
}
void

Просмотреть файл

@ -123,6 +123,19 @@ public:
nsRestyleHint aRestyleHint);
void ProcessPendingRestyles();
/**
* Performs a Servo animation-only traversal to compute style for all nodes
* with the animation-only dirty bit in the document.
*
* This processes just the traversal for animation-only restyles and skips the
* normal traversal for other restyles unrelated to animations.
* This is used to bring throttled animations up-to-date such as when we need
* to get correct position for transform animations that are throttled because
* they are running on the compositor.
*
* This will traverse all of the document's style roots (that is, its document
* element, and the roots of the document-level native anonymous content).
*/
void UpdateOnlyAnimationStyles();
void ContentStateChanged(nsIContent* aContent, EventStates aStateMask);

Просмотреть файл

@ -272,11 +272,9 @@ ServoStyleSet::PrepareAndTraverseSubtree(
RawGeckoElementBorrowed aRoot,
ServoTraversalFlags aFlags)
{
bool forThrottledAnimationFlush =
!!(aFlags & ServoTraversalFlags::ForThrottledAnimationFlush);
bool forThrottledAnimationFlush = !!(aFlags & ServoTraversalFlags::AnimationOnly);
AutoRestyleTimelineMarker marker(
mPresContext->GetDocShell(), forThrottledAnimationFlush);
AutoRestyleTimelineMarker marker(mPresContext->GetDocShell(), forThrottledAnimationFlush);
// 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
@ -780,11 +778,11 @@ ServoStyleSet::HasStateDependentStyle(dom::Element* aElement,
bool
ServoStyleSet::StyleDocument(ServoTraversalFlags aFlags)
{
MOZ_ASSERT(aFlags == ServoTraversalFlags::Empty ||
aFlags == ServoTraversalFlags::ForCSSRuleChanges,
"Should only be called for normal traversal or CSS rule changes");
PreTraverse();
if (!!(aFlags & ServoTraversalFlags::AnimationOnly)) {
PreTraverse(nullptr, EffectCompositor::AnimationRestyleType::Full);
} else {
PreTraverse();
}
// Restyle the document from the root element and each of the document level
// NAC subtree roots.
@ -798,21 +796,6 @@ ServoStyleSet::StyleDocument(ServoTraversalFlags aFlags)
return postTraversalRequired;
}
bool
ServoStyleSet::StyleDocumentForThrottledAnimationFlush()
{
PreTraverse(nullptr, EffectCompositor::AnimationRestyleType::Full);
bool postTraversalRequired = false;
DocumentStyleRootIterator iter(mPresContext->Document());
while (Element* root = iter.GetNextStyleRoot()) {
if (PrepareAndTraverseSubtree(root, ServoTraversalFlags::ForThrottledAnimationFlush)) {
postTraversalRequired = true;
}
}
return postTraversalRequired;
}
void
ServoStyleSet::StyleNewSubtree(Element* aRoot)
{

Просмотреть файл

@ -264,8 +264,7 @@ public:
* This will traverse all of the document's style roots (that is, its document
* element, and the roots of the document-level native anonymous content).
*
* The only allowed flag (for now ) is `ForCSSRuleChanges`.
* We need to specify |ForCSSRuleChanges| to try to update all CSS animations
* We specify |ForCSSRuleChanges| to try to update all CSS animations
* when we call this function due to CSS rule changes since @keyframes rules
* may have changed.
*
@ -273,15 +272,6 @@ public:
*/
bool StyleDocument(ServoTraversalFlags aFlags);
/**
* Performs a Servo animation-only traversal to compute style for all nodes
* with the animation-only dirty bit in the document.
*
* This will traverse all of the document's style roots (that is, its document
* element, and the roots of the document-level native anonymous content).
*/
bool StyleDocumentForThrottledAnimationFlush();
/**
* Eagerly styles a subtree of unstyled nodes that was just appended to the
* tree. This is used in situations where we need the style immediately and

Просмотреть файл

@ -66,12 +66,6 @@ enum class ServoTraversalFlags : uint32_t {
// or display:none subtrees (which can occur when styling elements with
// newly applied XBL bindings).
ForNewlyBoundElement = 1 << 4,
// Processes just the traversal for animation-only restyles and skips the
// normal traversal for other restyles unrelated to animations.
// This is used to bring throttled animations up-to-date such as when we need
// to get correct position for transform animations that are throttled because
// they are running on the compositor.
ForThrottledAnimationFlush = 1 << 5,
};
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(ServoTraversalFlags)