Bug 1586014- Factor out RecompileScriptEventListeners r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D129974
This commit is contained in:
somdatta 2021-11-04 18:24:58 +00:00
Родитель 012a09c534
Коммит 98b05fd89a
10 изменённых файлов: 24 добавлений и 95 удалений

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

@ -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<nsString>& aResult) {
uint32_t count = mAttrs.AttrCount();
for (uint32_t i = 0; i < count; ++i) {

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

@ -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.

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

@ -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;

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

@ -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

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

@ -979,28 +979,6 @@ already_AddRefed<nsIURI> 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.

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

@ -86,7 +86,6 @@ class MathMLElement final : public MathMLElementBase,
MathMLElementBase::NodeInfoChanged(aOldDoc);
}
void RecompileScriptEventListeners() final;
bool IsEventAttributeNameInternal(nsAtom* aName) final;
protected:

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

@ -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<SMILAttr> SVGElement::GetAnimatedAttr(int32_t aNamespaceID,
nsAtom* aName) {
if (aNamespaceID == kNameSpaceID_None) {

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

@ -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;

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

@ -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);
}

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

@ -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;