Bug 1203973 - Move <style> and <link> attribute change handling to AfterSetAttr so that it doesn't trigger for no-op attribute changes. r=smaug

This commit is contained in:
Boris Zbarsky
2015-09-22 21:19:49 -04:00
parent e5e9b48646
commit 27c98bc9a3
4 changed files with 72 additions and 125 deletions

View File

@@ -172,42 +172,22 @@ HTMLStyleElement::UnbindFromTree(bool aDeep, bool aNullParent)
}
nsresult
HTMLStyleElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAString& aValue,
bool aNotify)
HTMLStyleElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
const nsAttrValue* aValue, bool aNotify)
{
nsresult rv = nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix,
aValue, aNotify);
if (NS_SUCCEEDED(rv) && aNameSpaceID == kNameSpaceID_None) {
if (aNameSpaceID == kNameSpaceID_None) {
if (aName == nsGkAtoms::title ||
aName == nsGkAtoms::media ||
aName == nsGkAtoms::type) {
UpdateStyleSheetInternal(nullptr, nullptr, true);
} else if (aName == nsGkAtoms::scoped) {
UpdateStyleSheetScopedness(true);
bool isScoped = aValue;
UpdateStyleSheetScopedness(isScoped);
}
}
return rv;
}
nsresult
HTMLStyleElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
bool aNotify)
{
nsresult rv = nsGenericHTMLElement::UnsetAttr(aNameSpaceID, aAttribute,
aNotify);
if (NS_SUCCEEDED(rv) && aNameSpaceID == kNameSpaceID_None) {
if (aAttribute == nsGkAtoms::title ||
aAttribute == nsGkAtoms::media ||
aAttribute == nsGkAtoms::type) {
UpdateStyleSheetInternal(nullptr, nullptr, true);
} else if (aAttribute == nsGkAtoms::scoped) {
UpdateStyleSheetScopedness(false);
}
}
return rv;
return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, aValue,
aNotify);
}
NS_IMETHODIMP