mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-26 19:55:39 +00:00
Bug 1352306 - Part 1: stylo: Only snapshot attributes if there is some rule that depends on that attribute. r=emilio
MozReview-Commit-ID: Emey96ovc2a
This commit is contained in:
parent
690fa8991e
commit
1ba1986481
@ -815,10 +815,22 @@ ServoRestyleManager::AttributeWillChange(Element* aElement,
|
||||
return;
|
||||
}
|
||||
|
||||
bool influencesOtherPseudoClassState =
|
||||
AttributeInfluencesOtherPseudoClassState(aElement, aAttribute);
|
||||
|
||||
if (!influencesOtherPseudoClassState &&
|
||||
!((aNameSpaceID == kNameSpaceID_None &&
|
||||
(aAttribute == nsGkAtoms::id ||
|
||||
aAttribute == nsGkAtoms::_class)) ||
|
||||
aAttribute == nsGkAtoms::lang ||
|
||||
StyleSet()->MightHaveAttributeDependency(aAttribute))) {
|
||||
return;
|
||||
}
|
||||
|
||||
ServoElementSnapshot& snapshot = SnapshotFor(aElement);
|
||||
snapshot.AddAttrs(aElement, aNameSpaceID, aAttribute);
|
||||
|
||||
if (AttributeInfluencesOtherPseudoClassState(aElement, aAttribute)) {
|
||||
if (influencesOtherPseudoClassState) {
|
||||
snapshot.AddOtherPseudoClassState(aElement);
|
||||
}
|
||||
|
||||
@ -833,7 +845,6 @@ ServoRestyleManager::AttributeChanged(Element* aElement, int32_t aNameSpaceID,
|
||||
const nsAttrValue* aOldValue)
|
||||
{
|
||||
MOZ_ASSERT(!mInStyleRefresh);
|
||||
MOZ_ASSERT(!mSnapshots.Get(aElement) || mSnapshots.Get(aElement)->HasAttrs());
|
||||
|
||||
nsIFrame* primaryFrame = aElement->GetPrimaryFrame();
|
||||
if (primaryFrame) {
|
||||
|
@ -96,6 +96,9 @@ SERVO_BINDING_FUNC(Servo_StyleSet_ResolveForDeclarations,
|
||||
RawServoStyleSetBorrowed set,
|
||||
ServoComputedValuesBorrowedOrNull parent_style,
|
||||
RawServoDeclarationBlockBorrowed declarations)
|
||||
SERVO_BINDING_FUNC(Servo_StyleSet_MightHaveAttributeDependency, bool,
|
||||
RawServoStyleSetBorrowed set,
|
||||
nsIAtom* local_name)
|
||||
|
||||
// CSSRuleList
|
||||
SERVO_BINDING_FUNC(Servo_CssRules_ListTypes, void,
|
||||
|
@ -1356,4 +1356,10 @@ ServoStyleSet::RunPostTraversalTasks()
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
ServoStyleSet::MightHaveAttributeDependency(nsIAtom* aAttribute)
|
||||
{
|
||||
return Servo_StyleSet_MightHaveAttributeDependency(mRawSet.get(), aAttribute);
|
||||
}
|
||||
|
||||
ServoStyleSet* ServoStyleSet::sInServoTraversal = nullptr;
|
||||
|
@ -432,6 +432,16 @@ public:
|
||||
mNeedsRestyleAfterEnsureUniqueInner = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if a modification to an an attribute with the specified
|
||||
* local name might require us to restyle the element.
|
||||
*
|
||||
* This function allows us to skip taking a an attribute snapshot when
|
||||
* the modified attribute doesn't appear in an attribute selector in
|
||||
* a style sheet.
|
||||
*/
|
||||
bool MightHaveAttributeDependency(nsIAtom* aAttribute);
|
||||
|
||||
private:
|
||||
// On construction, sets sInServoTraversal to the given ServoStyleSet.
|
||||
// On destruction, clears sInServoTraversal and calls RunPostTraversalTasks.
|
||||
|
Loading…
Reference in New Issue
Block a user