Closed Bug 1586014 Opened 5 years ago Closed 3 years ago

Factor out RecompileScriptEventListeners

Categories

(Core :: DOM: Events, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
96 Branch
Tracking Status
firefox96 --- fixed

People

(Reporter: fredw, Assigned: sd2187)

References

Details

(Keywords: good-first-bug, helpwanted)

Attachments

(2 files)

RecompileScriptEventListeners is implemented very similarly in SVG, HTML, XUL and (after bug 1571487) MathML. We should try to avoid duplicate code.

Type: defect → enhancement

Checking now... First, nsXULElement::RecompileScriptEventListeners can be modified to just call "IsEventAttributeName(attr)" (without the XUL namespace parameter).

Then the only difference between

SVGElement::RecompileScriptEventListeners
MathMLElement::RecompileScriptEventListeners
nsGenericHTMLElement::RecompileScriptEventListeners
nsXULElement::RecompileScriptEventListeners

is that SVG uses GetEventNameForAttr(attr).

One can easily declare a default Element::GetEventNameForAttr function that just returns its parameter and override it in the SVGElement class. However per bug 1571487 comment 5, maybe we just want to drop this renaming...

Hello,
I am Somdatta and I am an outreachy applicant.I would like to work on this bug.

Could you please clarify the following statement-
One can easily declare a default Element::GetEventNameForAttr function that just returns its parameter and override it in the SVGElement class. However per bug 1571487 comment 5, maybe we just want to drop this renaming...

Flags: needinfo?(fwang)

(In reply to Somdatta from comment #3)

Could you please clarify the following statement-
One can easily declare a default Element::GetEventNameForAttr function that just returns its parameter and override it in the SVGElement class.

However per bug 1571487 comment 5, maybe we just want to drop this renaming...

Hi, yes so SVG has SVGElement::GetEventNameForAttr has some special renaming, for example <svg onload="..."> will register an onSVGLoad event.

https://searchfox.org/mozilla-central/rev/daa5c195e5efe45a63bf79f97ae77419b16f62f1/dom/svg/SVGElement.cpp#1487

So IIRC, I was thinking create a method

Element::GetEventNameForAttr(nsAtom* aAttr) { return aAttr; }

then

either (a) override it in SVGElement::GetEventNameForAttr to keep the special renaming
or (b) wait clarification on the spec side, hopefully we don't need this kind of renaming https://github.com/w3c/svgwg/issues/467

That said, it seems since then Boris introduced Element::GetEventNameForAttr in bug 1607918, so you can probably just directly merge the RecompileScriptEventListeners implementations now.

(would still be nice to clarify the event thing in the SVG spec though)

Flags: needinfo?(fwang)

First off, I don't think this bug should change any behavior.

It makes sense to me to make Element::GetEventNameForAttr virtual rather than static, and make Element::RecompileScriptEventListeners non-virtual. That would lead to slightly more virtual calls (one more per event handler attribute), but it's only called from nsINode::CloneAndAdopt, so that's probably fine.

Assignee: nobody → sd2187
Status: NEW → ASSIGNED
Attachment #9248525 - Attachment description: Bug 1586014- Factor out RecompileScriptEventListeners r?#dom-workers-and-storage-reviewers → Bug 1586014- Factor out RecompileScriptEventListeners r?hsivonen
Attachment #9248525 - Attachment description: Bug 1586014- Factor out RecompileScriptEventListeners r?hsivonen → Bug 1586014- Factor out RecompileScriptEventListeners r?#document-object-model-reviewers
Attachment #9248525 - Attachment description: Bug 1586014- Factor out RecompileScriptEventListeners r?#document-object-model-reviewers → Bug 1586014- Factor out RecompileScriptEventListeners r?Core#Document_Object_Model
Attachment #9248525 - Attachment description: Bug 1586014- Factor out RecompileScriptEventListeners r?Core#Document_Object_Model → Bug 1586014- Factor out RecompileScriptEventListeners r?#Document_Object_Model
Attachment #9248525 - Attachment description: Bug 1586014- Factor out RecompileScriptEventListeners r?#Document_Object_Model → Bug 1586014- Factor out RecompileScriptEventListeners r?emilio

Hello,I am an outreachy applicant.Actually you(Emilio) reviewed my revision for this bug and requested some changes.I have made the required changes.Tomorrow(5th nov) is the deadline for my final application.So,I was wondering if you could look into the revision so that if it is okay,I can add this.Thanks in advance@emilio

Flags: needinfo?(emilio)
Flags: needinfo?(emilio)
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/043b85dea615 Factor out RecompileScriptEventListeners r=emilio
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 96 Branch
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/19d60f319a66 Minor follow-up: don't do unnecessary attribute lookups. r=smaug
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: