Bug 1184842. Route aOldValue/aNewValue to AttributeData. r=heycam

This commit is contained in:
Robert O'Callahan 2015-07-22 15:54:07 +12:00
parent b3e6c8c4ff
commit 79b91c410e
6 changed files with 28 additions and 13 deletions

View File

@ -1161,13 +1161,15 @@ void
RestyleManager::AttributeWillChange(Element* aElement,
int32_t aNameSpaceID,
nsIAtom* aAttribute,
int32_t aModType)
int32_t aModType,
const nsAttrValue* aNewValue)
{
nsRestyleHint rshint =
mPresContext->StyleSet()->HasAttributeDependentStyle(aElement,
aAttribute,
aModType,
false);
false,
aNewValue);
PostRestyleEvent(aElement, rshint, NS_STYLE_HINT_NONE);
}
@ -1177,7 +1179,8 @@ void
RestyleManager::AttributeChanged(Element* aElement,
int32_t aNameSpaceID,
nsIAtom* aAttribute,
int32_t aModType)
int32_t aModType,
const nsAttrValue* aOldValue)
{
// Hold onto the PresShell to prevent ourselves from being destroyed.
// XXXbz how, exactly, would this attribute change cause us to be
@ -1254,7 +1257,8 @@ RestyleManager::AttributeChanged(Element* aElement,
mPresContext->StyleSet()->HasAttributeDependentStyle(aElement,
aAttribute,
aModType,
true);
true,
aOldValue);
PostRestyleEvent(aElement, rshint, hint);
}

View File

@ -79,13 +79,15 @@ public:
void AttributeWillChange(Element* aElement,
int32_t aNameSpaceID,
nsIAtom* aAttribute,
int32_t aModType);
int32_t aModType,
const nsAttrValue* aNewValue);
// Forwarded nsIMutationObserver method, to handle restyling (and
// passing the notification to the frame).
void AttributeChanged(Element* aElement,
int32_t aNameSpaceID,
nsIAtom* aAttribute,
int32_t aModType);
int32_t aModType,
const nsAttrValue* aOldValue);
// Get an integer that increments every time there is a style change
// as a result of a change to the :hover content state.

View File

@ -4248,7 +4248,8 @@ PresShell::AttributeWillChange(nsIDocument* aDocument,
if (mDidInitialize) {
nsAutoCauseReflowNotifier crNotifier(this);
mPresContext->RestyleManager()->AttributeWillChange(aElement, aNameSpaceID,
aAttribute, aModType);
aAttribute, aModType,
aNewValue);
VERIFY_STYLE_TREE;
}
}
@ -4270,7 +4271,8 @@ PresShell::AttributeChanged(nsIDocument* aDocument,
if (mDidInitialize) {
nsAutoCauseReflowNotifier crNotifier(this);
mPresContext->RestyleManager()->AttributeChanged(aElement, aNameSpaceID,
aAttribute, aModType);
aAttribute, aModType,
aOldValue);
VERIFY_STYLE_TREE;
}
}

View File

@ -574,16 +574,20 @@ struct MOZ_STACK_CLASS AttributeRuleProcessorData :
nsIAtom* aAttribute,
int32_t aModType,
bool aAttrHasChanged,
const nsAttrValue* aOtherValue,
TreeMatchContext& aTreeMatchContext)
: ElementDependentRuleProcessorData(aPresContext, aElement, nullptr,
aTreeMatchContext),
mAttribute(aAttribute),
mOtherValue(aOtherValue),
mModType(aModType),
mAttrHasChanged(aAttrHasChanged)
{
NS_PRECONDITION(!aTreeMatchContext.mForStyling, "Not styling here!");
}
nsIAtom* mAttribute; // |HasAttributeDependentStyle| for which attribute?
// non-null if we have the value.
const nsAttrValue* mOtherValue;
int32_t mModType; // The type of modification (see nsIDOMMutationEvent).
bool mAttrHasChanged; // Whether the attribute has already changed.
};

View File

@ -2371,9 +2371,10 @@ nsStyleSet::HasStateDependentStyle(Element* aElement,
struct MOZ_STACK_CLASS AttributeData : public AttributeRuleProcessorData {
AttributeData(nsPresContext* aPresContext,
Element* aElement, nsIAtom* aAttribute, int32_t aModType,
bool aAttrHasChanged, TreeMatchContext& aTreeMatchContext)
bool aAttrHasChanged, const nsAttrValue* aOtherValue,
TreeMatchContext& aTreeMatchContext)
: AttributeRuleProcessorData(aPresContext, aElement, aAttribute, aModType,
aAttrHasChanged, aTreeMatchContext),
aAttrHasChanged, aOtherValue, aTreeMatchContext),
mHint(nsRestyleHint(0))
{}
nsRestyleHint mHint;
@ -2393,13 +2394,14 @@ nsRestyleHint
nsStyleSet::HasAttributeDependentStyle(Element* aElement,
nsIAtom* aAttribute,
int32_t aModType,
bool aAttrHasChanged)
bool aAttrHasChanged,
const nsAttrValue* aOtherValue)
{
TreeMatchContext treeContext(false, nsRuleWalker::eLinksVisitedOrUnvisited,
aElement->OwnerDoc());
InitStyleScopes(treeContext, aElement);
AttributeData data(PresContext(), aElement, aAttribute,
aModType, aAttrHasChanged, treeContext);
aModType, aAttrHasChanged, aOtherValue, treeContext);
WalkRuleProcessors(SheetHasAttributeStyle, &data, false);
return data.mHint;
}

View File

@ -285,7 +285,8 @@ class nsStyleSet final
nsRestyleHint HasAttributeDependentStyle(mozilla::dom::Element* aElement,
nsIAtom* aAttribute,
int32_t aModType,
bool aAttrHasChanged);
bool aAttrHasChanged,
const nsAttrValue* aOtherValue);
/*
* Do any processing that needs to happen as a result of a change in