Bug 1368236: Implement the "hints handled for descendants" optimization. r=heycam

MozReview-Commit-ID: D6CCmWbEXTs
This commit is contained in:
Emilio Cobos Álvarez 2017-06-13 16:17:23 +02:00
parent 7d7c7502a9
commit 152083b709
3 changed files with 20 additions and 8 deletions

View File

@ -182,16 +182,19 @@ struct ServoRestyleManager::TextPostTraversalState
bool mShouldPostHints;
bool mShouldComputeHints;
nsChangeHint mComputedHint;
nsChangeHint mHintsHandled;
TextPostTraversalState(nsStyleContext& aParentContext,
ServoStyleSet& aStyleSet,
bool aDisplayContentsParentStyleChanged)
bool aDisplayContentsParentStyleChanged,
nsChangeHint aHintsHandled)
: mParentContext(aParentContext)
, mStyleSet(aStyleSet)
, mStyle(nullptr)
, mShouldPostHints(aDisplayContentsParentStyleChanged)
, mShouldComputeHints(aDisplayContentsParentStyleChanged)
, mComputedHint(nsChangeHint_Empty)
, mHintsHandled(aHintsHandled)
{}
nsStyleContext& ComputeStyle(nsIContent* aTextNode)
@ -230,6 +233,7 @@ struct ServoRestyleManager::TextPostTraversalState
oldContext->CalcStyleDifference(&aNewContext,
&equalStructs,
&samePointerStructs);
mComputedHint = NS_RemoveSubsumedHints(mComputedHint, mHintsHandled);
}
if (mComputedHint) {
@ -312,12 +316,15 @@ bool
ServoRestyleManager::ProcessPostTraversal(Element* aElement,
nsStyleContext* aParentContext,
ServoStyleSet* aStyleSet,
nsStyleChangeList& aChangeList)
nsStyleChangeList& aChangeList,
nsChangeHint aChangesHandled)
{
nsIFrame* styleFrame = nsLayoutUtils::GetStyleFrame(aElement);
// Grab the change hint from Servo.
nsChangeHint changeHint = Servo_TakeChangeHint(aElement);
changeHint = NS_RemoveSubsumedHints(changeHint, aChangesHandled);
aChangesHandled |= changeHint;
// Handle lazy frame construction by posting a reconstruct for any lazily-
// constructed roots.
@ -446,12 +453,15 @@ ServoRestyleManager::ProcessPostTraversal(Element* aElement,
StyleChildrenIterator it(aElement);
TextPostTraversalState textState(
*upToDateContext, *aStyleSet, displayContentsNode && recreateContext);
*upToDateContext,
*aStyleSet,
displayContentsNode && recreateContext,
aChangesHandled);
for (nsIContent* n = it.GetNextChild(); n; n = it.GetNextChild()) {
if (traverseElementChildren && n->IsElement()) {
recreatedAnyContext |=
ProcessPostTraversal(n->AsElement(), upToDateContext,
aStyleSet, aChangeList);
aStyleSet, aChangeList, aChangesHandled);
} else if (traverseTextChildren && n->IsNodeOfType(nsINode::eTEXT)) {
recreatedAnyContext |=
ProcessPostTraversalForText(n, aChangeList, textState);
@ -616,7 +626,8 @@ ServoRestyleManager::DoProcessPendingRestyles(TraversalRestyleBehavior
bool anyStyleChanged = false;
while (Element* root = iter.GetNextStyleRoot()) {
anyStyleChanged |=
ProcessPostTraversal(root, nullptr, styleSet, currentChanges);
ProcessPostTraversal(
root, nullptr, styleSet, currentChanges, nsChangeHint(0));
}
// Process the change hints.

View File

@ -128,7 +128,8 @@ private:
bool ProcessPostTraversal(Element* aElement,
nsStyleContext* aParentContext,
ServoStyleSet* aStyleSet,
nsStyleChangeList& aChangeList);
nsStyleChangeList& aChangeList,
nsChangeHint aChangesHandledForDescendants);
struct TextPostTraversalState;
bool ProcessPostTraversalForText(nsIContent* aTextNode,

View File

@ -294,8 +294,8 @@ fails-if(Android||OSX) == mathvariant-2.html mathvariant-2-ref.html # Bugs 10106
== mathvariant-4.html mathvariant-4-ref.html
== mathvariant-5.html mathvariant-5-ref.html
== dtls-1.html dtls-1-ref.html
fails-if(styloVsGecko||stylo) == dtls-2.html dtls-2-ref.html # bug 1366206
fails-if(styloVsGecko||stylo) == dtls-3.html dtls-3-ref.html # bug 1366206
== dtls-2.html dtls-2-ref.html
== dtls-3.html dtls-3-ref.html
== ssty-1.html ssty-1-ref.html
== ssty-2.html ssty-2-ref.html
== ssty-3.html ssty-3-ref.html