Bug 71503 - Remove RequiresAllArguments
Summary: Remove RequiresAllArguments
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Erik Arvidsson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-03 13:45 PDT by Erik Arvidsson
Modified: 2011-11-14 11:12 PST (History)
5 users (show)

See Also:


Attachments
Patch (32.57 KB, patch)
2011-11-11 13:23 PST, Erik Arvidsson
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Erik Arvidsson 2011-11-03 13:45:12 PDT
All method arguments are now required by default. We can annotate optional arguments using [Optional], [Optional=CallWithDefaultValue] and [Optional=CallWithNullValue]

Annotating a method with [RequiresAllArguments=Raise] throws a TypeError when arguments are missing. This is the default behavior of all methods. [RequiresAllArguments=Raise] is not used anywhere.

Annotating a method with [RequiresAllArguments] makes the method return undefined if any argument is missing.

Source/WebCore/dom/Clipboard.idl:        // FIXME: RequiresAllArguments is probably bogus here.
Source/WebCore/dom/Clipboard.idl:        [RequiresAllArguments] boolean setData(in DOMString type, in DOMString data);
Source/WebCore/page/DOMWindow.idl:        [RequiresAllArguments] void scrollBy(in long x, in long y);
Source/WebCore/page/DOMWindow.idl:        [RequiresAllArguments] void scrollTo(in long x, in long y);
Source/WebCore/page/DOMWindow.idl:        [RequiresAllArguments] void scroll(in long x, in long y);
Source/WebCore/page/DOMWindow.idl:        [RequiresAllArguments] void moveBy(in float x, in float y); // FIXME: this should take longs not floats.
Source/WebCore/page/DOMWindow.idl:        [RequiresAllArguments] void moveTo(in float x, in float y); // FIXME: this should take longs not floats.
Source/WebCore/page/DOMWindow.idl:        [RequiresAllArguments] void resizeBy(in float x, in float y); // FIXME: this should take longs not floats.
Source/WebCore/page/DOMWindow.idl:        [RequiresAllArguments] void resizeTo(in float width, in float height); // FIXME: this should take longs not floats.
Source/WebCore/websockets/WebSocket.idl:        // [RequiresAllArguments] boolean send(in ArrayBuffer data) raises(DOMException);
Source/WebCore/websockets/WebSocket.idl:        // [RequiresAllArguments] boolean send(in Blob data) raises(DOMException);
Source/WebCore/websockets/WebSocket.idl:        // [RequiresAllArguments] boolean send(in DOMString data) raises(DOMException);

It seems like we could change the DOMWindow methods to just use [Optional] and not do anything in case not enough arguments are passed.

Another option is to keep [RequiresAllArguments] (but not [RequiresAllArguments=Raise]) and rename it to something more correct.
Comment 1 Adam Barth 2011-11-03 15:50:23 PDT
Can we test these interfaces in other browsers?  Perhaps we're actually supposed to raise an exception in these cases.
Comment 2 Adam Barth 2011-11-03 15:50:50 PDT
For example, I'd be surprised if this goofy behavior was required for WebSocket.
Comment 3 Erik Arvidsson 2011-11-09 17:15:45 PST
Firefox 8 throws for all of these when wrong number of arguments are provided

IE9 treats missing arguments as 0 for all the window methods.

IE9 throws "argument is not optional" for missing arguments for setData.

Based on this I think we are pretty safe to remove RequiresAllArguments and change the window methods to [Optional=CallWithDefaultValue]
Comment 4 Erik Arvidsson 2011-11-11 13:23:18 PST
Created attachment 114760 [details]
Patch
Comment 5 Adam Barth 2011-11-13 22:31:57 PST
Sounds great.
Comment 6 WebKit Review Bot 2011-11-14 11:12:14 PST
Comment on attachment 114760 [details]
Patch

Clearing flags on attachment: 114760

Committed r100163: <http://trac.webkit.org/changeset/100163>
Comment 7 WebKit Review Bot 2011-11-14 11:12:19 PST
All reviewed patches have been landed.  Closing bug.