Bug 157882 - Generate bindings code for EventTarget.addEventListener() / removeEventListener()
Summary: Generate bindings code for EventTarget.addEventListener() / removeEventListen...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Bindings (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords:
Depends on:
Blocks: 149466
  Show dependency treegraph
 
Reported: 2016-05-18 21:18 PDT by Chris Dumez
Modified: 2016-05-23 17:16 PDT (History)
6 users (show)

See Also:


Attachments
Patch (64.63 KB, patch)
2016-05-18 22:11 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (65.74 KB, patch)
2016-05-18 22:25 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (66.26 KB, patch)
2016-05-18 22:32 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (67.39 KB, patch)
2016-05-18 22:40 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (71.87 KB, patch)
2016-05-18 22:45 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (74.57 KB, patch)
2016-05-18 22:54 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (74.58 KB, patch)
2016-05-18 23:06 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (75.71 KB, patch)
2016-05-18 23:19 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (75.59 KB, patch)
2016-05-19 16:58 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (72.68 KB, patch)
2016-05-23 16:29 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2016-05-18 21:18:27 PDT
Generate bindings code for EventTarget.addEventListener() / removeEventListener(). Custom code is current hardcoded in the bindings generator, we need to clean this up.
Comment 1 Chris Dumez 2016-05-18 22:11:14 PDT
Created attachment 279347 [details]
Patch
Comment 2 Chris Dumez 2016-05-18 22:25:06 PDT
Created attachment 279349 [details]
Patch
Comment 3 Chris Dumez 2016-05-18 22:32:23 PDT
Created attachment 279351 [details]
Patch
Comment 4 Chris Dumez 2016-05-18 22:40:55 PDT
Created attachment 279352 [details]
Patch
Comment 5 Chris Dumez 2016-05-18 22:45:07 PDT
Created attachment 279353 [details]
Patch
Comment 6 Chris Dumez 2016-05-18 22:54:51 PDT
Created attachment 279354 [details]
Patch
Comment 7 Chris Dumez 2016-05-18 23:06:27 PDT
Created attachment 279356 [details]
Patch
Comment 8 Chris Dumez 2016-05-18 23:19:39 PDT
Created attachment 279358 [details]
Patch
Comment 9 Darin Adler 2016-05-19 14:31:13 PDT
Comment on attachment 279358 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=279358&action=review

> Source/WebCore/dom/EventListenerMap.h:58
> +    bool remove(const AtomicString& eventType, EventListener&, bool useCapture, size_t& indexOfRemovedListener);

There’s no question that this is a step in the right direction. But really I think the remove functions should take a predicate (std::function, probably) telling them what to remove rather than an EventListener&. Expressing that predicate as a == function on an EventListener object is not the best way to do it. We should talk about this in person at some point.

> Source/WebCore/dom/RegisteredEventListener.h:34
> +        RegisteredEventListener(Ref<EventListener> listener, bool useCapture)

Should this be Ref&& instead of just Ref?

> LayoutTests/ChangeLog:11
> +        Rebaseline existing test now that the 'length' property of those functions
> +        have changed. This is because the IDL has been updated to match our
> +        implementation (all parameters are optional). While this does not match
> +        the specification, the new length now matches our actual behavior.

I don’t think this is good. I’d prefer that we still return length 2. Is there some easy way to do that?
Comment 10 Chris Dumez 2016-05-19 16:36:39 PDT
Comment on attachment 279358 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=279358&action=review

>> LayoutTests/ChangeLog:11
>> +        the specification, the new length now matches our actual behavior.
> 
> I don’t think this is good. I’d prefer that we still return length 2. Is there some easy way to do that?

I don't think people actually rely on this. I do agree this is not great though.
The length computation relies on arguments being marked as optional or not in the IDL. Besides adding a new IDL extended attribute, I am not quite sure how to maintain the length.
Comment 11 Chris Dumez 2016-05-19 16:58:44 PDT
Created attachment 279453 [details]
Patch
Comment 12 Chris Dumez 2016-05-19 17:10:51 PDT
(In reply to comment #10)
> Comment on attachment 279358 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=279358&action=review
> 
> >> LayoutTests/ChangeLog:11
> >> +        the specification, the new length now matches our actual behavior.
> > 
> > I don’t think this is good. I’d prefer that we still return length 2. Is there some easy way to do that?
> 
> I don't think people actually rely on this. I do agree this is not great
> though.
> The length computation relies on arguments being marked as optional or not
> in the IDL. Besides adding a new IDL extended attribute, I am not quite sure
> how to maintain the length.

I have't found an easy way to fix this one. Do you think it is worth maintaining the previous length at the cost of adding some kind of IDL attribute, e.g. [Length=2])?
Comment 13 Chris Dumez 2016-05-19 18:46:40 PDT
(In reply to comment #12)
> (In reply to comment #10)
> > Comment on attachment 279358 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=279358&action=review
> > 
> > >> LayoutTests/ChangeLog:11
> > >> +        the specification, the new length now matches our actual behavior.
> > > 
> > > I don’t think this is good. I’d prefer that we still return length 2. Is there some easy way to do that?
> > 
> > I don't think people actually rely on this. I do agree this is not great
> > though.
> > The length computation relies on arguments being marked as optional or not
> > in the IDL. Besides adding a new IDL extended attribute, I am not quite sure
> > how to maintain the length.
> 
> I have't found an easy way to fix this one. Do you think it is worth
> maintaining the previous length at the cost of adding some kind of IDL
> attribute, e.g. [Length=2])?

Alternatively, we could align our behavior with the spec (and with Firefox and Chrome) and mark the 2 first parameters as mandatory. This is a bit riskier but this is right thing.
Comment 14 Darin Adler 2016-05-23 15:57:54 PDT
Seems like we can add a temporary IDL extended attribute or temporary hard coded exception in the bindings script. Then we can remove it when we change behavior to not have the arguments be optional. No reason to temporarily return 0 since we have always returned 2 and we think that 2 is the right value long term.
Comment 15 Chris Dumez 2016-05-23 16:29:50 PDT
Created attachment 279605 [details]
Patch
Comment 16 WebKit Commit Bot 2016-05-23 17:15:58 PDT
Comment on attachment 279605 [details]
Patch

Clearing flags on attachment: 279605

Committed r201305: <http://trac.webkit.org/changeset/201305>
Comment 17 WebKit Commit Bot 2016-05-23 17:16:04 PDT
All reviewed patches have been landed.  Closing bug.