Bug 1365092 - Move side effects of SetAttr and ParseAttribute to BeforeSetAttr and AfterSetAttr

* Moves side effects of nsGenericHTMLElement and Element's SetAttr, UnsetAttr, and ParseAttribute functions to the corresponding BeforeSetAttr and AfterSetAttr functions
* Moves side effects of HTMLAnchorElement's SetAttr, UnsetAttr, and ParseAttribute functions to the corresponding BeforeSetAttr and AfterSetAttr functions
* Moves side effects of HTMLImageElement's SetAttr function to the corresponding BeforeSetAttr and AfterSetAttr functions
* Moves side effects of SetAttr, UnsetAttr, and ParseAttribute functions to BeforeSetAttr and AfterSetAttr

Tag #1375
This commit is contained in:
Matt A. Tobin 2020-04-17 05:33:06 -04:00 committed by Roy Tam
commit 6aa436b588
41 changed files with 983 additions and 956 deletions

View file

@ -446,38 +446,37 @@ NS_IMPL_UINT_ATTR_DEFAULT_VALUE(HTMLCanvasElement, Height, height, DEFAULT_CANVA
NS_IMPL_BOOL_ATTR(HTMLCanvasElement, MozOpaque, moz_opaque)
nsresult
HTMLCanvasElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAString& aValue,
bool aNotify)
HTMLCanvasElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
const nsAttrValue* aValue,
const nsAttrValue* aOldValue, bool aNotify)
{
nsresult rv = nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix, aValue,
aNotify);
if (NS_SUCCEEDED(rv) && mCurrentContext &&
aNameSpaceID == kNameSpaceID_None &&
(aName == nsGkAtoms::width || aName == nsGkAtoms::height || aName == nsGkAtoms::moz_opaque))
{
ErrorResult dummy;
rv = UpdateContext(nullptr, JS::NullHandleValue, dummy);
NS_ENSURE_SUCCESS(rv, rv);
}
AfterMaybeChangeAttr(aNamespaceID, aName, aNotify);
return rv;
return nsGenericHTMLElement::AfterSetAttr(aNamespaceID, aName, aValue,
aOldValue, aNotify);
}
nsresult
HTMLCanvasElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aName,
bool aNotify)
HTMLCanvasElement::OnAttrSetButNotChanged(int32_t aNamespaceID, nsIAtom* aName,
const nsAttrValueOrString& aValue,
bool aNotify)
{
nsresult rv = nsGenericHTMLElement::UnsetAttr(aNameSpaceID, aName, aNotify);
if (NS_SUCCEEDED(rv) && mCurrentContext &&
aNameSpaceID == kNameSpaceID_None &&
(aName == nsGkAtoms::width || aName == nsGkAtoms::height || aName == nsGkAtoms::moz_opaque))
{
AfterMaybeChangeAttr(aNamespaceID, aName, aNotify);
return nsGenericHTMLElement::OnAttrSetButNotChanged(aNamespaceID, aName,
aValue, aNotify);
}
void
HTMLCanvasElement::AfterMaybeChangeAttr(int32_t aNamespaceID, nsIAtom* aName,
bool aNotify)
{
if (mCurrentContext && aNamespaceID == kNameSpaceID_None &&
(aName == nsGkAtoms::width || aName == nsGkAtoms::height ||
aName == nsGkAtoms::moz_opaque)) {
ErrorResult dummy;
rv = UpdateContext(nullptr, JS::NullHandleValue, dummy);
NS_ENSURE_SUCCESS(rv, rv);
UpdateContext(nullptr, JS::NullHandleValue, dummy);
}
return rv;
}
void