Bug 71503

Summary: Remove RequiresAllArguments
Product: WebKit Reporter: Erik Arvidsson <arv>
Component: WebCore JavaScriptAssignee: Erik Arvidsson <arv>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, japhet, ojan, pilgrim, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

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.