diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index f602e36b0065..fe24f9755856 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -609,6 +609,27 @@ nsDOMTokenList* Element::Part() { return slots->mPart; } +void Element::RecompileScriptEventListeners() { + int32_t i, count = mAttrs.AttrCount(); + for (i = 0; i < count; ++i) { + const nsAttrName* name = mAttrs.AttrNameAt(i); + + // Eventlistenener-attributes are always in the null namespace + if (!name->IsAtom()) { + continue; + } + + nsAtom* attr = name->Atom(); + if (!IsEventAttributeName(attr)) { + continue; + } + + nsAutoString value; + GetAttr(attr, value); + SetEventHandler(GetEventNameForAttr(attr), value, true); + } +} + void Element::GetAttributeNames(nsTArray& aResult) { uint32_t count = mAttrs.AttrCount(); for (uint32_t i = 0; i < count; ++i) { diff --git a/dom/base/Element.h b/dom/base/Element.h index b829aa9d9e59..65e7e87b606c 100644 --- a/dom/base/Element.h +++ b/dom/base/Element.h @@ -1479,7 +1479,7 @@ class Element : public FragmentOrElement { return slots ? slots->mAttributeMap.get() : nullptr; } - virtual void RecompileScriptEventListeners() {} + void RecompileScriptEventListeners(); /** * Get the attr info for the given namespace ID and attribute name. The @@ -1978,7 +1978,7 @@ class Element : public FragmentOrElement { * content attribute name and returns the corresponding event name, to be used * for adding the actual event listener. */ - static nsAtom* GetEventNameForAttr(nsAtom* aAttr); + virtual nsAtom* GetEventNameForAttr(nsAtom* aAttr); /** * Register/unregister this element to accesskey map if it supports accesskey. diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index 0006b332192d..0f652e987979 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -2303,27 +2303,6 @@ void nsGenericHTMLElement::SyncEditorsOnSubtree(nsIContent* content) { } } -void nsGenericHTMLElement::RecompileScriptEventListeners() { - int32_t i, count = mAttrs.AttrCount(); - for (i = 0; i < count; ++i) { - const nsAttrName* name = mAttrs.AttrNameAt(i); - - // Eventlistenener-attributes are always in the null namespace - if (!name->IsAtom()) { - continue; - } - - nsAtom* attr = name->Atom(); - if (!IsEventAttributeName(attr)) { - continue; - } - - nsAutoString value; - GetAttr(kNameSpaceID_None, attr, value); - SetEventHandler(GetEventNameForAttr(attr), value, true); - } -} - bool nsGenericHTMLElement::IsEditableRoot() const { if (!IsInComposedDoc()) { return false; diff --git a/dom/html/nsGenericHTMLElement.h b/dom/html/nsGenericHTMLElement.h index e33ca8e0d547..44f6fc9ced6e 100644 --- a/dom/html/nsGenericHTMLElement.h +++ b/dom/html/nsGenericHTMLElement.h @@ -609,8 +609,6 @@ class nsGenericHTMLElement : public nsGenericHTMLElementBase { mozilla::dom::HTMLFormElement* FindAncestorForm( mozilla::dom::HTMLFormElement* aCurrentForm = nullptr); - virtual void RecompileScriptEventListeners() override; - /** * See if the document being tested has nav-quirks mode enabled. * @param doc the document diff --git a/dom/mathml/MathMLElement.cpp b/dom/mathml/MathMLElement.cpp index 29ff58b61518..5a01774586e4 100644 --- a/dom/mathml/MathMLElement.cpp +++ b/dom/mathml/MathMLElement.cpp @@ -979,28 +979,6 @@ already_AddRefed MathMLElement::GetHrefURI() const { return IsLink(getter_AddRefs(hrefURI)) ? hrefURI.forget() : nullptr; } -// XXX Bug 1586014: Share logic with other element classes. -void MathMLElement::RecompileScriptEventListeners() { - int32_t i, count = mAttrs.AttrCount(); - for (i = 0; i < count; ++i) { - const nsAttrName* name = mAttrs.AttrNameAt(i); - - // Eventlistenener-attributes are always in the null namespace - if (!name->IsAtom()) { - continue; - } - - nsAtom* attr = name->Atom(); - if (!IsEventAttributeName(attr)) { - continue; - } - - nsAutoString value; - GetAttr(kNameSpaceID_None, attr, value); - SetEventHandler(GetEventNameForAttr(attr), value, true); - } -} - bool MathMLElement::IsEventAttributeNameInternal(nsAtom* aName) { // The intent is to align MathML event attributes on HTML5, so the flag // EventNameType_HTML is used here. diff --git a/dom/mathml/MathMLElement.h b/dom/mathml/MathMLElement.h index b2a990bb4b3a..ef39e3d8432b 100644 --- a/dom/mathml/MathMLElement.h +++ b/dom/mathml/MathMLElement.h @@ -86,7 +86,6 @@ class MathMLElement final : public MathMLElementBase, MathMLElementBase::NodeInfoChanged(aOldDoc); } - void RecompileScriptEventListeners() final; bool IsEventAttributeNameInternal(nsAtom* aName) final; protected: diff --git a/dom/svg/SVGElement.cpp b/dom/svg/SVGElement.cpp index df8aba8097a9..8b497ba7a4bb 100644 --- a/dom/svg/SVGElement.cpp +++ b/dom/svg/SVGElement.cpp @@ -2269,27 +2269,6 @@ nsresult SVGElement::ReportAttributeParseFailure(Document* aDocument, strings); } -void SVGElement::RecompileScriptEventListeners() { - int32_t i, count = mAttrs.AttrCount(); - for (i = 0; i < count; ++i) { - const nsAttrName* name = mAttrs.AttrNameAt(i); - - // Eventlistenener-attributes are always in the null namespace - if (!name->IsAtom()) { - continue; - } - - nsAtom* attr = name->Atom(); - if (!IsEventAttributeName(attr)) { - continue; - } - - nsAutoString value; - GetAttr(attr, value); - SetEventHandler(GetEventNameForAttr(attr), value, true); - } -} - UniquePtr SVGElement::GetAnimatedAttr(int32_t aNamespaceID, nsAtom* aName) { if (aNamespaceID == kNameSpaceID_None) { diff --git a/dom/svg/SVGElement.h b/dom/svg/SVGElement.h index 2ed04ecd698a..461dbeaf0650 100644 --- a/dom/svg/SVGElement.h +++ b/dom/svg/SVGElement.h @@ -325,8 +325,6 @@ class SVGElement : public SVGElementBase // nsIContent void AnimationNeedsResample(); void FlushAnimations(); - virtual void RecompileScriptEventListeners() override; - void GetStringBaseValue(uint8_t aAttrEnum, nsAString& aResult) const; void SetStringBaseValue(uint8_t aAttrEnum, const nsAString& aValue); @@ -384,7 +382,7 @@ class SVGElement : public SVGElementBase // nsIContent const mozAutoDocUpdate& aProofOfUpdate); void MaybeSerializeAttrBeforeRemoval(nsAtom* aName, bool aNotify); - nsAtom* GetEventNameForAttr(nsAtom* aAttr); + nsAtom* GetEventNameForAttr(nsAtom* aAttr) override; struct LengthInfo { nsStaticAtom* const mName; diff --git a/dom/xul/nsXULElement.cpp b/dom/xul/nsXULElement.cpp index ee03ba922d20..d5e9ddc2fd50 100644 --- a/dom/xul/nsXULElement.cpp +++ b/dom/xul/nsXULElement.cpp @@ -1172,27 +1172,6 @@ bool nsXULElement::BoolAttrIsTrue(nsAtom* aName) const { attr->GetAtomValue() == nsGkAtoms::_true; } -void nsXULElement::RecompileScriptEventListeners() { - int32_t i, count = mAttrs.AttrCount(); - for (i = 0; i < count; ++i) { - const nsAttrName* name = mAttrs.AttrNameAt(i); - - // Eventlistenener-attributes are always in the null namespace - if (!name->IsAtom()) { - continue; - } - - nsAtom* attr = name->Atom(); - if (!nsContentUtils::IsEventAttributeName(attr, EventNameType_XUL)) { - continue; - } - - nsAutoString value; - GetAttr(kNameSpaceID_None, attr, value); - SetEventHandler(attr, value, true); - } -} - bool nsXULElement::IsEventAttributeNameInternal(nsAtom* aName) { return nsContentUtils::IsEventAttributeName(aName, EventNameType_XUL); } diff --git a/dom/xul/nsXULElement.h b/dom/xul/nsXULElement.h index beac569b83dd..d8c4cf67c675 100644 --- a/dom/xul/nsXULElement.h +++ b/dom/xul/nsXULElement.h @@ -377,8 +377,6 @@ class nsXULElement : public nsStyledElement { virtual nsresult Clone(mozilla::dom::NodeInfo*, nsINode** aResult) const override; - virtual void RecompileScriptEventListeners() override; - virtual bool IsEventAttributeNameInternal(nsAtom* aName) override; using DOMString = mozilla::dom::DOMString;