Closed Bug 1395421 Opened 7 years ago Closed 7 years ago

Add a notification when get() is called on a JS-implemented maplike

Categories

(Core :: DOM: Core & HTML, enhancement)

53 Branch
enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla57
Tracking Status
firefox57 --- fixed

People

(Reporter: bzbarsky, Assigned: bzbarsky)

References

Details

Attachments

(2 files)

This is needed in bug 1393306.
Assignee: nobody → bzbarsky
Status: NEW → ASSIGNED
Comment on attachment 8902992 [details] [diff] [review]
part 1.  Don't codegen JS-implemented-webidl glue for methods that use maplike/setlike/iterable codegen (and hence wouldn't call into that clue anyway)

Review of attachment 8902992 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/bindings/Codegen.py
@@ +15919,5 @@
>                     for a in attrs if not a.readonly]
>          methods = [m for m in iface.members
> +                   if (m.isMethod() and not m.isStatic() and
> +                       not m.isIdentifierLess() and
> +                       not m.isMaplikeOrSetlikeOrIterableMethod())]

So I think maplike is allowed on callback interfaces according to spec. Not sure that makes sense, but if so should we limit this to iface.isJSImplemented()?
Attachment #8902992 - Flags: review?(peterv) → review+
Comment on attachment 8902993 [details] [diff] [review]
part 2.  When a get() happens on a JS-implemented maplike, notify the JS implementation so it can take some sort of action (e.g. logging or warning)

Review of attachment 8902993 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/bindings/Codegen.py
@@ +15953,1 @@
>          if any(m.isAttr() or m.isMethod() for m in iface.members) or (iface.isJSImplemented() and iface.ctor()):

This might not be true even though needOnGetId is? Might make more sense to just fill idList with the additional ids instead of using these booleans and then append initIdsClassMethod if idList is not empty?

@@ +16483,5 @@
> +    happening on a JS-implemented maplike.  This method takes two arguments
> +    (key and value) and returns nothing.
> +    """
> +    def __init__(self, descriptor):
> +        CallbackOperationBase.__init__(

I sort of expected this to be optional, but it'll throw if __onget is missing, right? I guess we'd need to change GetCallableProperty to make that not throw. Not sure it's worth it.
Attachment #8902993 - Flags: review?(peterv) → review+
> but if so should we limit this to iface.isJSImplemented()?

Yeah, probably we should.  Done.

> This might not be true even though needOnGetId is? 

Oh, good catch.  I should have used my two new booleans, but I like your suggestion more.  Will do that.

> I sort of expected this to be optional, but it'll throw if __onget is missing, right?

Yes.  In practice, we have precisely one non-test JS-implemented maplike and that one is the one that wants __onget, so this is OK, I think.

> I guess we'd need to change GetCallableProperty to make that not throw. Not sure it's worth it.

Exactly my reasoning.  ;)
Pushed by bzbarsky@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/196ede21eb28
part 1.  Don't codegen JS-implemented-webidl glue for methods that use maplike/setlike/iterable codegen (and hence wouldn't call into that clue anyway).  r=peterv
https://hg.mozilla.org/integration/mozilla-inbound/rev/dad6d3dd7404
part 2.  When a get() happens on a JS-implemented maplike, notify the JS implementation so it can take some sort of action (e.g. logging or warning).  r=peterv
https://hg.mozilla.org/mozilla-central/rev/196ede21eb28
https://hg.mozilla.org/mozilla-central/rev/dad6d3dd7404
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: