Bug 1352306 - Part 1: stylo: Only snapshot attributes if there is some rule that depends on that attribute. r=emilio

MozReview-Commit-ID: Emey96ovc2a

--HG--
extra : rebase_source : b60b5114e8faf5bb39bf34fd0d985b071b9ec2dc
This commit is contained in:
Cameron McCormack 2017-05-08 16:04:31 +08:00
Родитель 24efbaf908
Коммит baddd12434
4 изменённых файлов: 31 добавлений и 1 удалений

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

@ -611,6 +611,17 @@ ServoRestyleManager::AttributeWillChange(Element* aElement,
}
ServoElementSnapshot& snapshot = SnapshotFor(aElement);
if (snapshot.HasAttrs()) {
return;
}
if (!((aNameSpaceID == kNameSpaceID_None &&
(aAttribute == nsGkAtoms::id ||
aAttribute == nsGkAtoms::_class)) ||
StyleSet()->MightHaveAttributeDependency(aAttribute))) {
return;
}
snapshot.AddAttrs(aElement);
if (Element* parent = aElement->GetFlattenedTreeParentElementForStyle()) {
@ -624,7 +635,6 @@ ServoRestyleManager::AttributeChanged(Element* aElement, int32_t aNameSpaceID,
const nsAttrValue* aOldValue)
{
MOZ_ASSERT(!mInStyleRefresh);
MOZ_ASSERT_IF(mSnapshots.Get(aElement), mSnapshots.Get(aElement)->HasAttrs());
nsIFrame* primaryFrame = aElement->GetPrimaryFrame();
if (primaryFrame) {

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

@ -82,6 +82,10 @@ 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,

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

@ -1155,4 +1155,10 @@ ServoStyleSet::RunPostTraversalTasks()
}
}
bool
ServoStyleSet::MightHaveAttributeDependency(nsIAtom* aAttribute)
{
return Servo_StyleSet_MightHaveAttributeDependency(mRawSet.get(), aAttribute);
}
ServoStyleSet* ServoStyleSet::sInServoTraversal = nullptr;

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

@ -339,6 +339,16 @@ public:
mPostTraversalTasks.AppendElement(aTask);
}
/**
* 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.