Closed Bug 957429 Opened 6 years ago Closed 6 years ago

WebIDL: [TreatNonCallableAsNone] should apply to method parameters too

Categories

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

x86_64
Linux
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla29

People

(Reporter: nsm, Assigned: nsm)

References

Details

(Whiteboard: [qa-])

Attachments

(1 file, 2 obsolete files)

When a callback type marked as [TreatNonCallableAsNone] is used as a method parameter, non callable values should be allowed. This is useful for some APIs like Promise then()/catch()
Assignee: nobody → nsm.nikhil
Comment on attachment 8356920 [details] [diff] [review]
Method parameters that are callbacks obey [TreatNonCallableAsNull] semantics.

No, this is basically just backing out bug 821177 but in a very obfuscated way.

What we were talking about was being able to flag specific method parameters as allowing TreatNonCallableAsNull, so you'd write:

  Promise then([TreatNonCallableAsNull] optional AnyCallback? arg)

and whatnot.
Attachment #8356920 - Flags: review?(bzbarsky) → review-
Type should have [TreatNonCallableAsNull] annotation, just like the default for setters.
Arguments which want to exercise that should opt in by using the same annotation in the signature.
Attachment #8357285 - Flags: review?(bzbarsky)
Comment on attachment 8357285 [details] [diff] [review]
Method parameters that are callbacks obey [TreatNonCallableAsNull] semantics.

We can actually simplify the code here somewhat, I think.  In particular:

1)  Add a allowTreatNonCallableAsNull() accessor to FakeArgument, returning a
    value passed to its __init__, default False.
2)  Have the CGSetterCall case construct a FakeArgument that has True for the
    value.
3)  Rip out the allowTreatNonCallableAsNull arg to CGArgumentConverter and have
    it just grab the state from the "argument" it has.
Attachment #8357285 - Flags: review?(bzbarsky) → review-
Comment on attachment 8357601 [details] [diff] [review]
Method parameters that are callbacks obey [TreatNonCallableAsNull] semantics.

Yes, perfect.  r=me
Attachment #8357601 - Flags: review?(bzbarsky) → review+
https://hg.mozilla.org/mozilla-central/rev/d95652cb6e24
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla29
Whiteboard: [qa-]
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.