Title: [200555] trunk
Revision
200555
Author
[email protected]
Date
2016-05-08 09:54:09 -0700 (Sun, 08 May 2016)

Log Message

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.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (200554 => 200555)


--- trunk/LayoutTests/ChangeLog	2016-05-08 15:22:36 UTC (rev 200554)
+++ trunk/LayoutTests/ChangeLog	2016-05-08 16:54:09 UTC (rev 200555)
@@ -1,3 +1,16 @@
+2016-05-08  Darin Adler  <[email protected]>
+
+        Correct dictionary bindings handling of optional, null, and undefined
+        https://bugs.webkit.org/show_bug.cgi?id=157463
+
+        Reviewed by Chris Dumez.
+
+        * 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.
+
 2016-05-07  Darin Adler  <[email protected]>
 
         Change MutationObserver::observe to take an IDL dictionary, rather than WebCore::Dictionary

Modified: trunk/LayoutTests/fast/dom/MutationObserver/observe-exceptions-expected.txt (200554 => 200555)


--- trunk/LayoutTests/fast/dom/MutationObserver/observe-exceptions-expected.txt	2016-05-08 15:22:36 UTC (rev 200554)
+++ trunk/LayoutTests/fast/dom/MutationObserver/observe-exceptions-expected.txt	2016-05-08 16:54:09 UTC (rev 200555)
@@ -7,8 +7,8 @@
 PASS observer.observe(null) threw exception TypeError: Not enough arguments.
 PASS observer.observe(undefined) threw exception TypeError: Not enough arguments.
 PASS observer.observe(document.body) threw exception TypeError: Not enough arguments.
-PASS observer.observe(document.body, null) threw exception TypeError: null is not an object (evaluating 'observer.observe(document.body, null)').
-PASS observer.observe(document.body, undefined) threw exception TypeError: undefined is not an object (evaluating 'observer.observe(document.body, undefined)').
+PASS observer.observe(document.body, null) threw exception TypeError: Type error.
+PASS observer.observe(document.body, undefined) threw exception TypeError: Type error.
 PASS observer.observe(null, {attributes: true}) threw exception TypeError: Type error.
 PASS observer.observe(undefined, {attributes: true}) threw exception TypeError: Type error.
 PASS observer.observe(document.body, {subtree: true}) threw exception TypeError: Type error.

Modified: trunk/Source/WebCore/ChangeLog (200554 => 200555)


--- trunk/Source/WebCore/ChangeLog	2016-05-08 15:22:36 UTC (rev 200554)
+++ trunk/Source/WebCore/ChangeLog	2016-05-08 16:54:09 UTC (rev 200555)
@@ -1,3 +1,36 @@
+2016-05-08  Darin Adler  <[email protected]>
+
+        Correct dictionary bindings handling of optional, null, and undefined
+        https://bugs.webkit.org/show_bug.cgi?id=157463
+
+        Reviewed by Chris Dumez.
+
+        * 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.
+
 2016-05-08  David Kilzer  <[email protected]>
 
         ThreadSanitizer: Data race and thread leak in WebCore::ScrollingThread::createThreadIfNeeded

Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp (200554 => 200555)


--- trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp	2016-05-08 15:22:36 UTC (rev 200554)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp	2016-05-08 16:54:09 UTC (rev 200555)
@@ -840,9 +840,4 @@
     return CallType::Host;
 }
 
-JSValue propertyValue(ExecState& state, JSValue value, const char* propertyName)
-{
-    return value.get(&state, Identifier::fromString(&state, propertyName));
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (200554 => 200555)


--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h	2016-05-08 15:22:36 UTC (rev 200554)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h	2016-05-08 16:54:09 UTC (rev 200555)
@@ -298,8 +298,6 @@
 template<typename DOMClass> const JSC::HashTableValue* getStaticValueSlotEntryWithoutCaching(JSC::ExecState*, JSC::PropertyName);
 template<JSC::NativeFunction, int length> JSC::EncodedJSValue nonCachingStaticFunctionGetter(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
 
-JSC::JSValue propertyValue(JSC::ExecState&, JSC::JSValue, const char* propertyName);
-
 // Inline functions and template definitions.
 
 inline JSC::Structure* DOMConstructorObject::createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (200554 => 200555)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-05-08 15:22:36 UTC (rev 200554)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-05-08 16:54:09 UTC (rev 200555)
@@ -958,8 +958,27 @@
         # FIXME: A little ugly to have this be a side effect instead of a return value.
         AddToImplIncludes("JSDOMConvert.h");
 
+        my $defaultValues = "";
+        my $comma = "";
+        foreach my $member (@{$dictionary->members}) {
+            if (!$member->isOptional) {
+                $defaultValues = "";
+                last;
+            }
+            $defaultValues .= $comma . (defined $member->default ? $member->default : "Nullopt");
+            $comma = ", ";
+        }
+
         $result .= "template<> $className convert<$className>(ExecState& state, JSValue value)\n";
         $result .= "{\n";
+        $result .= "    if (value.isUndefinedOrNull())\n" if $defaultValues;
+        $result .= "        return { " . $defaultValues . " };\n" if $defaultValues;
+        $result .= "    auto* object = value.getObject();\n";
+        $result .= "    if (UNLIKELY(!object || object->type() == RegExpObjectType)) {\n";
+        $result .= "        throwTypeError(&state);\n";
+        $result .= "        return { };\n";
+        $result .= "    }\n";
+
         my $needExceptionCheck = 0;
         foreach my $member (@{$dictionary->members}) {
             if ($needExceptionCheck) {
@@ -970,16 +989,18 @@
             my $function = $member->isOptional ? "convertOptional" : "convert";
             my $defaultValueWithLeadingComma = $member->isOptional && defined $member->default ? ", " . $member->default : "";
             $result .= "    auto " . $member->name . " = " . $function . "<" . GetNativeTypeFromSignature($interface, $member) . ">"
-                . "(state, propertyValue(state, value, \"" . $member->name . "\")" . $defaultValueWithLeadingComma . ");\n";
+                . "(state, object->get(&state, Identifier::fromString(&state, \"" . $member->name . "\"))" . $defaultValueWithLeadingComma . ");\n";
             $needExceptionCheck = 1;
         }
-        $result .= "    return { ";
-        my $comma = "";
+
+        my $arguments = "";
+        $comma = "";
         foreach my $member (@{$dictionary->members}) {
-            $result .= $comma . "WTFMove(" . $member->name . ")";
+            $arguments .= $comma . "WTFMove(" . $member->name . ")";
             $comma = ", ";
         }
-        $result .= " };\n";
+
+        $result .= "    return { " . $arguments . " };\n";
         $result .= "}\n\n";
 
         $result .= "#endif\n\n" if $conditionalString;
@@ -3592,90 +3613,90 @@
     $implIncludes{"ExceptionCode.h"} = 1;
     $implIncludes{"JSDOMBinding.h"} = 1;
 
-    my $argsIndex = 0;
+    my $argumentIndex = 0;
     foreach my $parameter (@{$function->parameters}) {
-        my $argType = $parameter->type;
+        my $type = $parameter->type;
 
-        die "Optional parameters of non-nullable wrapper types are not supported" if $parameter->isOptional && !$parameter->isNullable && $codeGenerator->IsWrapperType($argType);
+        die "Optional parameters of non-nullable wrapper types are not supported" if $parameter->isOptional && !$parameter->isNullable && $codeGenerator->IsWrapperType($type);
 
         if ($parameter->isOptional && !defined($parameter->default)) {
             # As per Web IDL, optional dictionary parameters are always considered to have a default value of an empty dictionary, unless otherwise specified.
-            $parameter->default("[]") if $argType eq "Dictionary";
-            
+            $parameter->default("[]") if $type eq "Dictionary" or $codeGenerator->IsDictionaryType($type);
+
             # We use undefined as default value for optional parameters of type 'any' unless specified otherwise.
-            $parameter->default("undefined") if $argType eq "any";
+            $parameter->default("undefined") if $type eq "any";
 
             # We use the null string as default value for parameters of type DOMString unless specified otherwise.
-            $parameter->default("null") if $argType eq "DOMString";
+            $parameter->default("null") if $type eq "DOMString";
 
             # As per Web IDL, passing undefined for a nullable parameter is treated as null. Therefore, use null as
             # default value for nullable parameters unless otherwise specified.
             $parameter->default("null") if $parameter->isNullable;
 
             # For callback parameters, the generated bindings treat undefined as null, so use null as implicit default value.
-            $parameter->default("null") if $codeGenerator->IsCallbackInterface($argType);
+            $parameter->default("null") if $codeGenerator->IsCallbackInterface($type);
         }
 
         my $name = $parameter->name;
         my $value = $name;
 
-        if ($codeGenerator->IsCallbackInterface($argType)) {
-            my $callbackClassName = GetCallbackClassName($argType);
+        if ($codeGenerator->IsCallbackInterface($type)) {
+            my $callbackClassName = GetCallbackClassName($type);
             $implIncludes{"$callbackClassName.h"} = 1;
             if ($parameter->isOptional) {
-                push(@$outputArray, "    RefPtr<$argType> $name;\n");
-                push(@$outputArray, "    if (!state->argument($argsIndex).isUndefinedOrNull()) {\n");
-                if ($codeGenerator->IsFunctionOnlyCallbackInterface($argType)) {
-                    push(@$outputArray, "        if (!state->uncheckedArgument($argsIndex).isFunction())\n");
+                push(@$outputArray, "    RefPtr<$type> $name;\n");
+                push(@$outputArray, "    if (!state->argument($argumentIndex).isUndefinedOrNull()) {\n");
+                if ($codeGenerator->IsFunctionOnlyCallbackInterface($type)) {
+                    push(@$outputArray, "        if (!state->uncheckedArgument($argumentIndex).isFunction())\n");
                 } else {
-                    push(@$outputArray, "        if (!state->uncheckedArgument($argsIndex).isObject())\n");
+                    push(@$outputArray, "        if (!state->uncheckedArgument($argumentIndex).isObject())\n");
                 }
-                push(@$outputArray, "            return throwArgumentMustBeFunctionError(*state, $argsIndex, \"$name\", \"$interfaceName\", $quotedFunctionName);\n");
+                push(@$outputArray, "            return throwArgumentMustBeFunctionError(*state, $argumentIndex, \"$name\", \"$interfaceName\", $quotedFunctionName);\n");
                 if ($function->isStatic) {
                     AddToImplIncludes("CallbackFunction.h");
-                    push(@$outputArray, "        $name = createFunctionOnlyCallback<${callbackClassName}>(state, jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), state->uncheckedArgument($argsIndex));\n");
+                    push(@$outputArray, "        $name = createFunctionOnlyCallback<${callbackClassName}>(state, jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), state->uncheckedArgument($argumentIndex));\n");
                 } else {
-                    push(@$outputArray, "        $name = ${callbackClassName}::create(asObject(state->uncheckedArgument($argsIndex)), castedThis->globalObject());\n");
+                    push(@$outputArray, "        $name = ${callbackClassName}::create(asObject(state->uncheckedArgument($argumentIndex)), castedThis->globalObject());\n");
                 }
                 push(@$outputArray, "    }\n");
             } else {
-                if ($codeGenerator->IsFunctionOnlyCallbackInterface($argType)) {
-                    push(@$outputArray, "    if (UNLIKELY(!state->argument($argsIndex).isFunction()))\n");
+                if ($codeGenerator->IsFunctionOnlyCallbackInterface($type)) {
+                    push(@$outputArray, "    if (UNLIKELY(!state->argument($argumentIndex).isFunction()))\n");
                 } else {
-                    push(@$outputArray, "    if (UNLIKELY(!state->argument($argsIndex).isObject()))\n");
+                    push(@$outputArray, "    if (UNLIKELY(!state->argument($argumentIndex).isObject()))\n");
                 }
-                push(@$outputArray, "        return throwArgumentMustBeFunctionError(*state, $argsIndex, \"$name\", \"$interfaceName\", $quotedFunctionName);\n");
+                push(@$outputArray, "        return throwArgumentMustBeFunctionError(*state, $argumentIndex, \"$name\", \"$interfaceName\", $quotedFunctionName);\n");
                 if ($function->isStatic) {
                     AddToImplIncludes("CallbackFunction.h");
-                    push(@$outputArray, "    RefPtr<$argType> $name = createFunctionOnlyCallback<${callbackClassName}>(state, jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), state->uncheckedArgument($argsIndex));\n");
+                    push(@$outputArray, "    RefPtr<$type> $name = createFunctionOnlyCallback<${callbackClassName}>(state, jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), state->uncheckedArgument($argumentIndex));\n");
                 } else {
-                    push(@$outputArray, "    RefPtr<$argType> $name = ${callbackClassName}::create(asObject(state->uncheckedArgument($argsIndex)), castedThis->globalObject());\n");
+                    push(@$outputArray, "    RefPtr<$type> $name = ${callbackClassName}::create(asObject(state->uncheckedArgument($argumentIndex)), castedThis->globalObject());\n");
                 }
             }
             $value = "WTFMove($name)";
         } elsif ($parameter->isVariadic) {
             my $nativeElementType;
-            if ($argType eq "DOMString") {
+            if ($type eq "DOMString") {
                 $nativeElementType = "String";
             } else {
-                $nativeElementType = GetNativeType($interface, $argType);
+                $nativeElementType = GetNativeType($interface, $type);
             }
 
-            if (!IsNativeType($argType)) {
+            if (!IsNativeType($type)) {
                 push(@$outputArray, "    Vector<$nativeElementType> $name;\n");
-                push(@$outputArray, "    for (unsigned i = $argsIndex, count = state->argumentCount(); i < count; ++i) {\n");
-                push(@$outputArray, "        if (!state->uncheckedArgument(i).inherits(JS${argType}::info()))\n");
-                push(@$outputArray, "            return throwArgumentTypeError(*state, i, \"$name\", \"$interfaceName\", $quotedFunctionName, \"$argType\");\n");
-                push(@$outputArray, "        $name.append(JS${argType}::toWrapped(state->uncheckedArgument(i)));\n");
+                push(@$outputArray, "    for (unsigned i = $argumentIndex, count = state->argumentCount(); i < count; ++i) {\n");
+                push(@$outputArray, "        if (!state->uncheckedArgument(i).inherits(JS${type}::info()))\n");
+                push(@$outputArray, "            return throwArgumentTypeError(*state, i, \"$name\", \"$interfaceName\", $quotedFunctionName, \"$type\");\n");
+                push(@$outputArray, "        $name.append(JS${type}::toWrapped(state->uncheckedArgument(i)));\n");
                 push(@$outputArray, "    }\n")
             } else {
-                push(@$outputArray, "    Vector<$nativeElementType> $name = toNativeArguments<$nativeElementType>(state, $argsIndex);\n");
+                push(@$outputArray, "    Vector<$nativeElementType> $name = toNativeArguments<$nativeElementType>(state, $argumentIndex);\n");
                 # Check if the type conversion succeeded.
                 push(@$outputArray, "    if (UNLIKELY(state->hadException()))\n");
                 push(@$outputArray, "        return JSValue::encode(jsUndefined());\n");
             }
-        } elsif ($codeGenerator->IsEnumType($argType)) {
-            my $className = GetEnumerationClassName($interface, $argType);
+        } elsif ($codeGenerator->IsEnumType($type)) {
+            my $className = GetEnumerationClassName($interface, $type);
 
             $implIncludes{"<runtime/Error.h>"} = 1;
 
@@ -3690,7 +3711,7 @@
                 $defineOptionalValue = $name;
             }
 
-            push(@$outputArray, "    auto ${name}Value = state->argument($argsIndex);\n");
+            push(@$outputArray, "    auto ${name}Value = state->argument($argumentIndex);\n");
             push(@$outputArray, "    $nativeType $name;\n");
 
             if ($parameter->isOptional) {
@@ -3707,7 +3728,7 @@
             push(@$outputArray, "$indent    if (UNLIKELY(state->hadException()))\n");
             push(@$outputArray, "$indent        return JSValue::encode(jsUndefined());\n");
             push(@$outputArray, "$indent    if (UNLIKELY(!$optionalValue))\n");
-            push(@$outputArray, "$indent        return throwArgumentMustBeEnumError(*state, $argsIndex, \"$name\", \"$interfaceName\", $quotedFunctionName, expectedEnumerationValues<$className>());\n");
+            push(@$outputArray, "$indent        return throwArgumentMustBeEnumError(*state, $argumentIndex, \"$name\", \"$interfaceName\", $quotedFunctionName, expectedEnumerationValues<$className>());\n");
             push(@$outputArray, "$indent    $name = optionalValue.value();\n") if $optionalValue ne $name;
 
             push(@$outputArray, "    }\n") if $indent ne "";
@@ -3720,16 +3741,16 @@
             if ($function->signature->extendedAttributes->{"StrictTypeChecking"}) {
                 $implIncludes{"<runtime/Error.h>"} = 1;
 
-                my $argValue = "state->argument($argsIndex)";
-                if ($codeGenerator->IsWrapperType($argType)) {
-                    push(@$outputArray, "    if (UNLIKELY(!${argValue}.isUndefinedOrNull() && !${argValue}.inherits(JS${argType}::info())))\n");
-                    push(@$outputArray, "        return throwArgumentTypeError(*state, $argsIndex, \"$name\", \"$interfaceName\", $quotedFunctionName, \"$argType\");\n");
+                my $argValue = "state->argument($argumentIndex)";
+                if ($codeGenerator->IsWrapperType($type)) {
+                    push(@$outputArray, "    if (UNLIKELY(!${argValue}.isUndefinedOrNull() && !${argValue}.inherits(JS${type}::info())))\n");
+                    push(@$outputArray, "        return throwArgumentTypeError(*state, $argumentIndex, \"$name\", \"$interfaceName\", $quotedFunctionName, \"$type\");\n");
                 }
             }
 
             if ($parameter->extendedAttributes->{"RequiresExistingAtomicString"}) {
                 # FIXME: This could be made slightly more efficient if we added an AtomicString(RefPtr<AtomicStringImpl>&&) constructor and removed the call to get() here.
-                push(@$outputArray, "    AtomicString $name = state->argument($argsIndex).toString(state)->toExistingAtomicString(state).get();\n");
+                push(@$outputArray, "    AtomicString $name = state->argument($argumentIndex).toString(state)->toExistingAtomicString(state).get();\n");
                 push(@$outputArray, "    if ($name.isNull())\n");
                 push(@$outputArray, "        return JSValue::encode(jsNull());\n");
                 push(@$outputArray, "    if (UNLIKELY(state->hadException()))\n");
@@ -3739,11 +3760,11 @@
                 my $inner;
                 my $nativeType = GetNativeTypeFromSignature($interface, $parameter);
 
-                if ($parameter->isOptional && defined($parameter->default) && !WillConvertUndefinedToDefaultParameterValue($parameter->type, $parameter->default)) {
+                if ($parameter->isOptional && defined($parameter->default) && !WillConvertUndefinedToDefaultParameterValue($type, $parameter->default)) {
                     my $defaultValue = $parameter->default;
 
                     # String-related optimizations.
-                    if ($parameter->type eq "DOMString") {
+                    if ($type eq "DOMString") {
                         my $useAtomicString = $parameter->extendedAttributes->{"AtomicString"};
                         if ($defaultValue eq "null") {
                             $defaultValue = $useAtomicString ? "nullAtom" : "String()";
@@ -3759,16 +3780,15 @@
                         $defaultValue = "JSValue::JSUndefined" if $defaultValue eq "undefined";
                     }
 
-                    $outer = "state->argument($argsIndex).isUndefined() ? $defaultValue : ";
-                    $inner = "state->uncheckedArgument($argsIndex)";
+                    $outer = "state->argument($argumentIndex).isUndefined() ? $defaultValue : ";
+                    $inner = "state->uncheckedArgument($argumentIndex)";
                 } elsif ($parameter->isOptional && !defined($parameter->default)) {
-                    # Use WTF::Optional<>() for optional parameters that are missing or undefined and that do not have
-                    # a default value in the IDL.
-                    $outer = "state->argument($argsIndex).isUndefined() ? Optional<$nativeType>() : ";
-                    $inner = "state->uncheckedArgument($argsIndex)";
+                    # Use WTF::Optional<>() for optional parameters that are missing or undefined and that do not have a default value in the IDL.
+                    $outer = "state->argument($argumentIndex).isUndefined() ? Optional<$nativeType>() : ";
+                    $inner = "state->uncheckedArgument($argumentIndex)";
                 } else {
                     $outer = "";
-                    $inner = "state->argument($argsIndex)";
+                    $inner = "state->argument($argumentIndex)";
                 }
                 my ($nativeValue, $mayThrowException) = JSValueToNative($interface, $parameter, $inner, $function->signature->extendedAttributes->{"Conditional"});
                 push(@$outputArray, "    auto $name = ${outer}${nativeValue};\n");
@@ -3779,7 +3799,7 @@
                 }
             }
 
-            my $isTearOff = $codeGenerator->IsSVGTypeNeedingTearOff($argType) && $interfaceName !~ /List$/;
+            my $isTearOff = $codeGenerator->IsSVGTypeNeedingTearOff($type) && $interfaceName !~ /List$/;
             my $shouldPassByReference = ShouldPassWrapperByReference($parameter, $interface);
             if ($isTearOff or $shouldPassByReference) {
                 push(@$outputArray, "    if (UNLIKELY(!$name))\n");
@@ -3787,13 +3807,13 @@
                 $value = $isTearOff ? "$name->propertyReference()" : "*$name";
             }
 
-            if ($codeGenerator->IsTypedArrayType($argType) and $argType ne "ArrayBuffer") {
+            if ($codeGenerator->IsTypedArrayType($type) and $parameter->type ne "ArrayBuffer") {
                $value = $shouldPassByReference ? "$name.releaseNonNull()" : "WTFMove($name)";
             }
         }
 
         push(@arguments, $value);
-        $argsIndex++;
+        $argumentIndex++;
     }
 
     push @arguments, GenerateReturnParameters($function);

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (200554 => 200555)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2016-05-08 15:22:36 UTC (rev 200554)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2016-05-08 16:54:09 UTC (rev 200555)
@@ -486,28 +486,47 @@
 
 template<> TestObj::ShadowRootInit convert<TestObj::ShadowRootInit>(ExecState& state, JSValue value)
 {
-    auto mode = convert<TestObj::ShadowRootMode>(state, propertyValue(state, value, "mode"));
+    auto* object = value.getObject();
+    if (UNLIKELY(!object || object->type() == RegExpObjectType)) {
+        throwTypeError(&state);
+        return { };
+    }
+    auto mode = convert<TestObj::ShadowRootMode>(state, object->get(&state, Identifier::fromString(&state, "mode")));
     return { WTFMove(mode) };
 }
 
 template<> TestObj::FontFaceDescriptors convert<TestObj::FontFaceDescriptors>(ExecState& state, JSValue value)
 {
-    auto style = convertOptional<String>(state, propertyValue(state, value, "style"), "normal");
+    if (value.isUndefinedOrNull())
+        return { "normal", "U+0-10FFFF" };
+    auto* object = value.getObject();
+    if (UNLIKELY(!object || object->type() == RegExpObjectType)) {
+        throwTypeError(&state);
+        return { };
+    }
+    auto style = convertOptional<String>(state, object->get(&state, Identifier::fromString(&state, "style")), "normal");
     if (UNLIKELY(state.hadException()))
         return { };
-    auto unicodeRange = convertOptional<String>(state, propertyValue(state, value, "unicodeRange"), "U+0-10FFFF");
+    auto unicodeRange = convertOptional<String>(state, object->get(&state, Identifier::fromString(&state, "unicodeRange")), "U+0-10FFFF");
     return { WTFMove(style), WTFMove(unicodeRange) };
 }
 
 template<> TestObj::MutationObserverInit convert<TestObj::MutationObserverInit>(ExecState& state, JSValue value)
 {
-    auto childList = convertOptional<bool>(state, propertyValue(state, value, "childList"), false);
+    if (value.isUndefinedOrNull())
+        return { false, Nullopt, Nullopt };
+    auto* object = value.getObject();
+    if (UNLIKELY(!object || object->type() == RegExpObjectType)) {
+        throwTypeError(&state);
+        return { };
+    }
+    auto childList = convertOptional<bool>(state, object->get(&state, Identifier::fromString(&state, "childList")), false);
     if (UNLIKELY(state.hadException()))
         return { };
-    auto attributes = convertOptional<bool>(state, propertyValue(state, value, "attributes"));
+    auto attributes = convertOptional<bool>(state, object->get(&state, Identifier::fromString(&state, "attributes")));
     if (UNLIKELY(state.hadException()))
         return { };
-    auto attributeFilter = convertOptional<Vector<String>>(state, propertyValue(state, value, "attributeFilter"));
+    auto attributeFilter = convertOptional<Vector<String>>(state, object->get(&state, Identifier::fromString(&state, "attributeFilter")));
     return { WTFMove(childList), WTFMove(attributes), WTFMove(attributeFilter) };
 }
 

Modified: trunk/Source/WebCore/css/FontFace.cpp (200554 => 200555)


--- trunk/Source/WebCore/css/FontFace.cpp	2016-05-08 15:22:36 UTC (rev 200554)
+++ trunk/Source/WebCore/css/FontFace.cpp	2016-05-08 16:54:09 UTC (rev 200555)
@@ -36,7 +36,7 @@
 
 namespace WebCore {
 
-RefPtr<FontFace> FontFace::create(JSC::ExecState& state, Document& document, const String& family, JSC::JSValue source, const Optional<Descriptors>& descriptors, ExceptionCode& ec)
+RefPtr<FontFace> FontFace::create(JSC::ExecState& state, Document& document, const String& family, JSC::JSValue source, const Descriptors& descriptors, ExceptionCode& ec)
 {
     auto result = adoptRef(*new FontFace(document.fontSelector()));
 
@@ -54,26 +54,24 @@
         CSSFontFace::appendSources(result->backing(), downcast<CSSValueList>(*value), &document, false);
     }
 
-    if (descriptors) {
-        result->setStyle(descriptors->style, ec);
-        if (ec)
-            return nullptr;
-        result->setWeight(descriptors->weight, ec);
-        if (ec)
-            return nullptr;
-        result->setStretch(descriptors->stretch, ec);
-        if (ec)
-            return nullptr;
-        result->setUnicodeRange(descriptors->unicodeRange, ec);
-        if (ec)
-            return nullptr;
-        result->setVariant(descriptors->variant, ec);
-        if (ec)
-            return nullptr;
-        result->setFeatureSettings(descriptors->featureSettings, ec);
-        if (ec)
-            return nullptr;
-    }
+    result->setStyle(descriptors.style, ec);
+    if (ec)
+        return nullptr;
+    result->setWeight(descriptors.weight, ec);
+    if (ec)
+        return nullptr;
+    result->setStretch(descriptors.stretch, ec);
+    if (ec)
+        return nullptr;
+    result->setUnicodeRange(descriptors.unicodeRange, ec);
+    if (ec)
+        return nullptr;
+    result->setVariant(descriptors.variant, ec);
+    if (ec)
+        return nullptr;
+    result->setFeatureSettings(descriptors.featureSettings, ec);
+    if (ec)
+        return nullptr;
 
     return WTFMove(result);
 }

Modified: trunk/Source/WebCore/css/FontFace.h (200554 => 200555)


--- trunk/Source/WebCore/css/FontFace.h	2016-05-08 15:22:36 UTC (rev 200554)
+++ trunk/Source/WebCore/css/FontFace.h	2016-05-08 16:54:09 UTC (rev 200555)
@@ -42,7 +42,7 @@
         String variant;
         String featureSettings;
     };
-    static RefPtr<FontFace> create(JSC::ExecState&, Document&, const String& family, JSC::JSValue source, const Optional<Descriptors>&, ExceptionCode&);
+    static RefPtr<FontFace> create(JSC::ExecState&, Document&, const String& family, JSC::JSValue source, const Descriptors&, ExceptionCode&);
     static Ref<FontFace> create(CSSFontFace&);
     virtual ~FontFace();
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to