[Web IDL] Specify default values for optional parameters of wrapper types
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Apr 2016 16:51:58 +0000 (16:51 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Apr 2016 16:51:58 +0000 (16:51 +0000)
commitf0eb58fc37b27267ffbc3f18af3e32fda313bcd5
tree9a4586b0ffecf5b4589d9dc3464c164b6a156ff9
parentb9dedac1e386113b6f4038d6a4034fb478689928
[Web IDL] Specify default values for optional parameters of wrapper types
https://bugs.webkit.org/show_bug.cgi?id=157161

Reviewed by Darin Adler.

Source/WebCore:

Specify default values for optional parameters of wrapper types.

* Modules/indexeddb/IDBIndex.cpp:
(WebCore::IDBIndex::count): Deleted.
* Modules/indexeddb/IDBIndex.h:
* Modules/indexeddb/IDBIndex.idl:
* Modules/indexeddb/IDBObjectStore.cpp:
(WebCore::IDBObjectStore::count): Deleted.
* Modules/indexeddb/IDBObjectStore.h:
* Modules/indexeddb/IDBObjectStore.idl:
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::createDataChannel): Deleted.
* Modules/mediastream/RTCPeerConnection.h:
* Modules/mediastream/RTCPeerConnection.idl:

* bindings/scripts/CodeGeneratorJS.pm:
(WillConvertUndefinedToDefaultParameterValue):
Optimization to avoid generating a ternary if the default
value of a wrapper type parameter is null, since undefined
will already convert to null for those.

(GenerateParametersCheck):
Use null as implicit default value for nullable parameters, given that Web IDL
converts undefined to null for such parameters:
http://heycam.github.io/webidl/#es-nullable-type

(CanUseWTFOptionalForParameter):
Drop the check for wrapper types.

* bindings/scripts/test/*:
Improve bindings tests coverage / rebaseline.

* css/MediaQueryList.idl:
* css/MediaQueryListListener.idl:
* dom/Document.idl:

* html/canvas/DOMPath.idl:
The previous syntax was working because the bindings was generating an early
return if addPath() was called with only one parameter, calling the
implementation method with only 1 parameter. However, since we no longer
generate early returns for optional parameters, we now have to use a slightly
different syntax to maintain the previous behavior. This is only temporary,
I just did not want to deal with SVG tear off types in this patch since they
are very special in the bindings generator.

* page/DOMSelection.idl:
The node parameter to extend() was confusingly marked as optional. However,
when omitted, it would get translated into null, which would throw an
exception since the type is not nullable. Since the specification says 'node'
should not be optional, and since there is no behavior change, I dropped
the 'optional'. The only web-exposed difference is the message provided with
the TypeError that is thrown when called without enough parameters. The new
message is more accurate (see rebaselined layout test).

* svg/SVGMarkerElement.idl:
The parameter for setOrientToAngle() was confusingly marked as optional and
having a default value of null. However, the bindings would throw a TypeError
if called with no parameters or when calling it with null. This is because
this is an SVG Tear off type and the bindings always throw when passing null
for an SVG Tear off type. I therefore updated the IDL to reflect the actual
behavior (no actual behavior change). The new IDL also now matches the spec:
http://www.w3.org/TR/SVG2/painting.html#InterfaceSVGMarkerElement

* svg/SVGSVGElement.idl:
Same comments as for SVGMarkerElement. The new IDL matches the actual
behavior and is closer to the specification. I added FIXME comments for when
it does not match the specification:
http://www.w3.org/TR/SVG2/struct.html#InterfaceSVGSVGElement
I did not change web-exposed behavior in this patch.

* svg/SVGTextContentElement.idl:
Same as above. No actual behavior change.

* testing/Internals.cpp:
* testing/Internals.h:
* testing/Internals.idl:
* xml/XPathEvaluator.idl:

LayoutTests:

Rebaseline as a different exception message is now given when calling
Selection.extend() without enough parameters.

* editing/selection/extend-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200246 268f45cc-cd09-0410-ab3c-d52691b4dbfc
31 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/selection/extend-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBIndex.cpp
Source/WebCore/Modules/indexeddb/IDBIndex.h
Source/WebCore/Modules/indexeddb/IDBIndex.idl
Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp
Source/WebCore/Modules/indexeddb/IDBObjectStore.h
Source/WebCore/Modules/indexeddb/IDBObjectStore.idl
Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
Source/WebCore/Modules/mediastream/RTCPeerConnection.h
Source/WebCore/Modules/mediastream/RTCPeerConnection.idl
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h
Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm
Source/WebCore/bindings/scripts/test/TestObj.idl
Source/WebCore/css/MediaQueryList.idl
Source/WebCore/css/MediaQueryListListener.idl
Source/WebCore/dom/Document.idl
Source/WebCore/html/canvas/DOMPath.idl
Source/WebCore/page/DOMSelection.idl
Source/WebCore/svg/SVGMarkerElement.idl
Source/WebCore/svg/SVGSVGElement.idl
Source/WebCore/svg/SVGTextContentElement.idl
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebCore/xml/XPathEvaluator.idl