Correct dictionary bindings handling of optional, null, and undefined
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 8 May 2016 16:54:09 +0000 (16:54 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 8 May 2016 16:54:09 +0000 (16:54 +0000)
commit799cf7aced1b27ac35a3e98d61235f0f13b1e36f
tree304ee04a64a158f25e1a914898f083074ee5daff
parentebc3d08833ad68b65b7737b3c26545df9aed0131
Correct dictionary bindings handling of optional, null, and undefined
https://bugs.webkit.org/show_bug.cgi?id=157463

Reviewed by Chris Dumez.

Source/WebCore:

* bindings/js/JSDOMBinding.cpp:
(WebCore::propertyValue): Deleted.
* bindings/js/JSDOMBinding.h: Deleted propertyValue, not all that helpful for now.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateDictionaryImplementationContent): Added a new early exit for convert to
a dictionary type when the value is undefined or null and all members are either
optional or have a default value. This returns the default values for everything
without raising an exception. Added checking that requires that the dictionary
argument is an object and not a regular expression, since that's also called for
in the latest draft of the Web IDL specification. This ends up speeding up the
code a bit since we now use JSObject::get for properties instead of JSValue::get.
(GenerateParametersCheck): Renamed some local variables. Taught the code that
optional dictionaries all have a default value; before it was doing that for the
type "Dictionary" but not the real dictionary types (IsDictionaryType).

* bindings/scripts/test/JS/JSTestObj.cpp: Regenerated.

* css/FontFace.cpp:
(WebCore::FontFace::create): Changed argument to be Descriptors instead of
Optional<Descriptors>. It would have compiled the other way, but there is now
no caller that will pass a null. Because the IDL dictionary support was new,
this was the only place that was doing it wrong. Good that we "nipped it in the bud"
before doing this in more places.
* css/FontFace.h: Ditto.

LayoutTests:

* fast/dom/MutationObserver/observe-exceptions-expected.txt: Reverted that
change to expect a more specific TypeError just as it was a day ago before
my last patch. The TypeError is back to being a problem with the specifics
of the arguments passed rather than a problem with null and undefined
themselves being invalid.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200555 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/dom/MutationObserver/observe-exceptions-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSDOMBinding.cpp
Source/WebCore/bindings/js/JSDOMBinding.h
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/css/FontFace.cpp
Source/WebCore/css/FontFace.h