RESOLVED FIXED86426
Refactor SVG parts of Node::addEventListener/removeEventListener
https://bugs.webkit.org/show_bug.cgi?id=86426
Summary Refactor SVG parts of Node::addEventListener/removeEventListener
Rob Buis
Reported 2012-05-14 18:59:32 PDT
The SVG code in Node::addEventListener/removeEventListener does not seem to have to be in Node.cpp
Attachments
Patch (12.69 KB, patch)
2012-05-14 19:11 PDT, Rob Buis
no flags
Patch (13.46 KB, patch)
2012-05-15 05:54 PDT, Rob Buis
no flags
Patch (12.55 KB, patch)
2012-05-15 09:07 PDT, Rob Buis
zimmermann: review+
Rob Buis
Comment 1 2012-05-14 19:02:43 PDT
Benefits of this approach: - code in Node::addEventListener/removeEventListener is easier to read - SVG parts can be hosted in svg/, much more intuitive - no SVG includes in Node.cpp - SVGElement() checks not needed anymore, since it is called from SVGElement. Drawback is losing the static on tryAddEventListener/tryRemoveEventListener, not sure that would lead to performance loss though.
Rob Buis
Comment 2 2012-05-14 19:11:17 PDT
Early Warning System Bot
Comment 3 2012-05-14 19:26:24 PDT
Early Warning System Bot
Comment 4 2012-05-14 19:33:49 PDT
Gyuyoung Kim
Comment 5 2012-05-14 20:25:36 PDT
Build Bot
Comment 6 2012-05-14 20:35:50 PDT
WebKit Review Bot
Comment 7 2012-05-14 22:37:03 PDT
Comment on attachment 141842 [details] Patch Attachment 141842 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/12705297
Nikolas Zimmermann
Comment 8 2012-05-15 00:11:09 PDT
Comment on attachment 141842 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=141842&action=review Great patch, long time nobody looked at this piece of code! You need to look into the build issues, reported by EWS, and I have some further suggestions: > Source/WebCore/svg/SVGElement.cpp:351 > +static inline HashSet<SVGElementInstance*> instancesForSVGElement(Node* node) While you're at it: stop copying the HashSet, instead pass it as reference. Also use SVGElement* as parameter, instead of Node*. static inline void collectInstancesForSVGElement(SVGElement* element, HashSet<SVGElementInstance*>& instances) > Source/WebCore/svg/SVGElement.cpp:369 > +extern inline bool tryAddEventListener(Node* targetNode, const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture); I'd rather expose tryAddEventListener as protected method in Node.h. But make sure its still inlined, so there's no performance regression for Node::addEventLIstener. > Source/WebCore/svg/SVGElement.cpp:398 > +extern inline bool tryRemoveEventListener(Node* targetNode, const AtomicString& eventType, EventListener*, bool useCapture); Ditto. > Source/WebCore/svg/SVGElement.h:117 > + virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture); > + virtual bool removeEventListener(const AtomicString& eventType, EventListener*, bool useCapture); I think you should mark them as OVERRIDE, that seems to be new idiom when overriding parent classes virtual functions.
Rob Buis
Comment 9 2012-05-15 05:54:35 PDT
Rob Buis
Comment 10 2012-05-15 06:42:38 PDT
Hi Niko, (In reply to comment #8) > (From update of attachment 141842 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=141842&action=review > > Great patch, long time nobody looked at this piece of code! You need to look into the build issues, reported by EWS, and I have some further suggestions: > > > Source/WebCore/svg/SVGElement.cpp:351 > > +static inline HashSet<SVGElementInstance*> instancesForSVGElement(Node* node) > > While you're at it: stop copying the HashSet, instead pass it as reference. Also use SVGElement* as parameter, instead of Node*. > static inline void collectInstancesForSVGElement(SVGElement* element, HashSet<SVGElementInstance*>& instances) > > > Source/WebCore/svg/SVGElement.cpp:369 > > +extern inline bool tryAddEventListener(Node* targetNode, const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture); > > I'd rather expose tryAddEventListener as protected method in Node.h. But make sure its still inlined, so there's no performance regression for Node::addEventLIstener. > > > Source/WebCore/svg/SVGElement.cpp:398 > > +extern inline bool tryRemoveEventListener(Node* targetNode, const AtomicString& eventType, EventListener*, bool useCapture); > > Ditto. > > > Source/WebCore/svg/SVGElement.h:117 > > + virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture); > > + virtual bool removeEventListener(const AtomicString& eventType, EventListener*, bool useCapture); > > I think you should mark them as OVERRIDE, that seems to be new idiom when overriding parent classes virtual functions. Good points! I think all of the above is fixed now with my latest patch.
Early Warning System Bot
Comment 11 2012-05-15 06:46:42 PDT
Build Bot
Comment 12 2012-05-15 06:52:07 PDT
Early Warning System Bot
Comment 13 2012-05-15 06:57:29 PDT
WebKit Review Bot
Comment 14 2012-05-15 07:38:28 PDT
Comment on attachment 141938 [details] Patch Attachment 141938 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/12709079
Gyuyoung Kim
Comment 15 2012-05-15 07:48:04 PDT
Rob Buis
Comment 16 2012-05-15 09:07:14 PDT
Nikolas Zimmermann
Comment 17 2012-05-15 09:47:38 PDT
Comment on attachment 141985 [details] Patch r=me!
Rob Buis
Comment 18 2012-05-15 10:04:30 PDT
Note You need to log in before you can comment on or make changes to this bug.