Title: [94891] trunk
Revision
94891
Author
rolandstei...@chromium.org
Date
2011-09-09 17:29:10 -0700 (Fri, 09 Sep 2011)

Log Message

Generate a WebKitCSSMatrix constructor of V8 using the IDL 'Constructor' extended attribute
https://bugs.webkit.org/show_bug.cgi?id=67458

Patch by Kentaro Hara <hara...@google.com> on 2011-09-09
Reviewed by Adam Barth.

Source/WebCore:

Added a 'CallWithNullValue' extended attribute.
If a parameter is optional and missing, 'CallWithDefaultValue'
handles it as a string "undefined". On the other hand,
'CallWithNullValue' handles it as a null string
(Note: not a string "null", but a null string).

Tests: fast/dom/Window/custom-constructors.html
       transforms/svg-vs-css.xhtml
       transforms/cssmatrix-2d-interface.xhtml
       transforms/cssmatrix-3d-interface.xhtmlGenerate a WebKitCSSMatrix constructor

* WebCore.gypi: Removed V8WebKitCSSMatrixConstructor.cpp.
* WebCore.pro: Removed V8WebKitCSSMatrixConstructor.cpp.
* bindings/scripts/CodeGeneratorV8.pm:
(GenerateParametersCheck): If the 'CallWithNullValue' extended attribute is set, we call MAYBE_MISSING_PARAMETER() with MissingIsEmpty mode to obtain a maybe missing parameter. Otherwise, we call MAYBE_MISSING_PARAMETER() with MissingIsUndefined mode.
(RequiresCustomSignature):
* bindings/scripts/test/V8/V8TestInterface.cpp: Updated test results.
(WebCore::V8TestInterface::constructorCallback):
* bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp: Ditto.
(WebCore::TestMediaQueryListListenerInternal::methodCallback):
* bindings/scripts/test/V8/V8TestObj.cpp: Ditto.
(WebCore::TestObjInternal::voidMethodWithArgsCallback):
(WebCore::TestObjInternal::intMethodWithArgsCallback):
(WebCore::TestObjInternal::objMethodWithArgsCallback):
(WebCore::TestObjInternal::methodThatRequiresAllArgsCallback):
(WebCore::TestObjInternal::methodThatRequiresAllArgsAndThrowsCallback):
(WebCore::TestObjInternal::optionsObjectCallback):
(WebCore::TestObjInternal::customArgsAndExceptionCallback):
(WebCore::TestObjInternal::withDynamicFrameAndArgCallback):
(WebCore::TestObjInternal::withDynamicFrameAndOptionalArgCallback):
(WebCore::TestObjInternal::withDynamicFrameAndUserGestureCallback):
(WebCore::TestObjInternal::withDynamicFrameAndUserGestureASADCallback):
(WebCore::TestObjInternal::methodWithOptionalArgCallback):
(WebCore::TestObjInternal::methodWithNonOptionalArgAndOptionalArgCallback):
(WebCore::TestObjInternal::methodWithNonOptionalArgAndTwoOptionalArgsCallback):
(WebCore::TestObjInternal::methodWithNonCallbackArgAndCallbackArgCallback):
(WebCore::TestObjInternal::overloadedMethod1Callback):
(WebCore::TestObjInternal::overloadedMethod2Callback):
(WebCore::TestObjInternal::overloadedMethod3Callback):
(WebCore::TestObjInternal::overloadedMethod4Callback):
(WebCore::TestObjInternal::classMethodWithOptionalCallback):
(WebCore::TestObjInternal::enabledAtRuntimeMethod1Callback):
(WebCore::TestObjInternal::enabledAtRuntimeMethod2Callback):
* bindings/v8/V8Binding.h:
(WebCore::V8ParameterBase::prepareBase): The fact that V8ParameterBase does not have any object means that we do not need to prepare anything, i.e. we should just return true in this case.
(WebCore::::prepare): If V8ParameterBase does not have any object, then we set a null string.
* bindings/v8/custom/V8BindingMacros.h: MAYBE_MISSING_PARAMETER() returns the parameter of a given index if the parameter exists. If the parameter does not exist and MissingIsUndefined is set, this macro returns an object that represents undefined. If the parameter does not exist and MissingIsEmpty is set, this macro returns an empty object.
* bindings/v8/custom/V8WebKitCSSMatrixConstructor.cpp: Removed.
* css/WebKitCSSMatrix.idl: Added the 'Constructor' extended attribute.

LayoutTests:

Added a test case for "new WebKitCSSMatrix(null)" and "new WebKitCSSMatrix(undefined)".

* fast/dom/Window/custom-constructors-expected.txt:
* fast/dom/Window/custom-constructors.html:

Modified Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (94890 => 94891)


--- trunk/LayoutTests/ChangeLog	2011-09-10 00:05:28 UTC (rev 94890)
+++ trunk/LayoutTests/ChangeLog	2011-09-10 00:29:10 UTC (rev 94891)
@@ -1,3 +1,15 @@
+2011-09-09  Kentaro Hara  <hara...@google.com>
+
+        Generate a WebKitCSSMatrix constructor of V8 using the IDL 'Constructor' extended attribute
+        https://bugs.webkit.org/show_bug.cgi?id=67458
+
+        Reviewed by Adam Barth.
+
+        Added a test case for "new WebKitCSSMatrix(null)" and "new WebKitCSSMatrix(undefined)".
+
+        * fast/dom/Window/custom-constructors-expected.txt:
+        * fast/dom/Window/custom-constructors.html:
+
 2011-09-09  Dominic Mazzoni  <dmazz...@google.com>
 
         Add a test to catch a case where an assertion failure or

Modified: trunk/LayoutTests/fast/dom/Window/custom-constructors-expected.txt (94890 => 94891)


--- trunk/LayoutTests/fast/dom/Window/custom-constructors-expected.txt	2011-09-10 00:05:28 UTC (rev 94890)
+++ trunk/LayoutTests/fast/dom/Window/custom-constructors-expected.txt	2011-09-10 00:29:10 UTC (rev 94891)
@@ -7,6 +7,9 @@
 PASS Option.prototype.toString.call(new Option) is '[object HTMLOptionElement]'
 PASS WebKitPoint.prototype.toString.call(new WebKitPoint) is '[object WebKitPoint]'
 PASS WebKitCSSMatrix.prototype.toString.call(new WebKitCSSMatrix) is 'matrix(1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000)'
+PASS WebKitCSSMatrix.prototype.toString.call(new WebKitCSSMatrix()) is 'matrix(1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000)'
+PASS new WebKitCSSMatrix(null) threw exception Error: SYNTAX_ERR: DOM Exception 12.
+PASS new WebKitCSSMatrix(undefined) threw exception Error: SYNTAX_ERR: DOM Exception 12.
 PASS XMLHttpRequest.prototype.toString.call(new XMLHttpRequest) is '[object XMLHttpRequest]'
 PASS XSLTProcessor.prototype.toString.call(new XSLTProcessor) is '[object XSLTProcessor]'
 PASS successfullyParsed is true

Modified: trunk/LayoutTests/fast/dom/Window/custom-constructors.html (94890 => 94891)


--- trunk/LayoutTests/fast/dom/Window/custom-constructors.html	2011-09-10 00:05:28 UTC (rev 94890)
+++ trunk/LayoutTests/fast/dom/Window/custom-constructors.html	2011-09-10 00:29:10 UTC (rev 94891)
@@ -17,6 +17,9 @@
     shouldBe("Option.prototype.toString.call(new Option)", "'[object HTMLOptionElement]'");
     shouldBe("WebKitPoint.prototype.toString.call(new WebKitPoint)", "'[object WebKitPoint]'");
     shouldBe("WebKitCSSMatrix.prototype.toString.call(new WebKitCSSMatrix)", "'matrix(1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000)'");
+    shouldBe("WebKitCSSMatrix.prototype.toString.call(new WebKitCSSMatrix())", "'matrix(1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000)'");
+    shouldThrow("new WebKitCSSMatrix(null)");
+    shouldThrow("new WebKitCSSMatrix(undefined)");
     shouldBe("XMLHttpRequest.prototype.toString.call(new XMLHttpRequest)", "'[object XMLHttpRequest]'");
     shouldBe("XSLTProcessor.prototype.toString.call(new XSLTProcessor)", "'[object XSLTProcessor]'");
 

Modified: trunk/Source/WebCore/ChangeLog (94890 => 94891)


--- trunk/Source/WebCore/ChangeLog	2011-09-10 00:05:28 UTC (rev 94890)
+++ trunk/Source/WebCore/ChangeLog	2011-09-10 00:29:10 UTC (rev 94891)
@@ -1,3 +1,60 @@
+2011-09-09  Kentaro Hara  <hara...@google.com>
+
+        Generate a WebKitCSSMatrix constructor of V8 using the IDL 'Constructor' extended attribute
+        https://bugs.webkit.org/show_bug.cgi?id=67458
+
+        Reviewed by Adam Barth.
+
+        Added a 'CallWithNullValue' extended attribute.
+        If a parameter is optional and missing, 'CallWithDefaultValue'
+        handles it as a string "undefined". On the other hand,
+        'CallWithNullValue' handles it as a null string
+        (Note: not a string "null", but a null string).
+
+        Tests: fast/dom/Window/custom-constructors.html
+               transforms/svg-vs-css.xhtml
+               transforms/cssmatrix-2d-interface.xhtml
+               transforms/cssmatrix-3d-interface.xhtmlGenerate a WebKitCSSMatrix constructor
+
+        * WebCore.gypi: Removed V8WebKitCSSMatrixConstructor.cpp.
+        * WebCore.pro: Removed V8WebKitCSSMatrixConstructor.cpp.
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateParametersCheck): If the 'CallWithNullValue' extended attribute is set, we call MAYBE_MISSING_PARAMETER() with MissingIsEmpty mode to obtain a maybe missing parameter. Otherwise, we call MAYBE_MISSING_PARAMETER() with MissingIsUndefined mode.
+        (RequiresCustomSignature):
+        * bindings/scripts/test/V8/V8TestInterface.cpp: Updated test results.
+        (WebCore::V8TestInterface::constructorCallback):
+        * bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp: Ditto.
+        (WebCore::TestMediaQueryListListenerInternal::methodCallback):
+        * bindings/scripts/test/V8/V8TestObj.cpp: Ditto.
+        (WebCore::TestObjInternal::voidMethodWithArgsCallback):
+        (WebCore::TestObjInternal::intMethodWithArgsCallback):
+        (WebCore::TestObjInternal::objMethodWithArgsCallback):
+        (WebCore::TestObjInternal::methodThatRequiresAllArgsCallback):
+        (WebCore::TestObjInternal::methodThatRequiresAllArgsAndThrowsCallback):
+        (WebCore::TestObjInternal::optionsObjectCallback):
+        (WebCore::TestObjInternal::customArgsAndExceptionCallback):
+        (WebCore::TestObjInternal::withDynamicFrameAndArgCallback):
+        (WebCore::TestObjInternal::withDynamicFrameAndOptionalArgCallback):
+        (WebCore::TestObjInternal::withDynamicFrameAndUserGestureCallback):
+        (WebCore::TestObjInternal::withDynamicFrameAndUserGestureASADCallback):
+        (WebCore::TestObjInternal::methodWithOptionalArgCallback):
+        (WebCore::TestObjInternal::methodWithNonOptionalArgAndOptionalArgCallback):
+        (WebCore::TestObjInternal::methodWithNonOptionalArgAndTwoOptionalArgsCallback):
+        (WebCore::TestObjInternal::methodWithNonCallbackArgAndCallbackArgCallback):
+        (WebCore::TestObjInternal::overloadedMethod1Callback):
+        (WebCore::TestObjInternal::overloadedMethod2Callback):
+        (WebCore::TestObjInternal::overloadedMethod3Callback):
+        (WebCore::TestObjInternal::overloadedMethod4Callback):
+        (WebCore::TestObjInternal::classMethodWithOptionalCallback):
+        (WebCore::TestObjInternal::enabledAtRuntimeMethod1Callback):
+        (WebCore::TestObjInternal::enabledAtRuntimeMethod2Callback):
+        * bindings/v8/V8Binding.h:
+        (WebCore::V8ParameterBase::prepareBase): The fact that V8ParameterBase does not have any object means that we do not need to prepare anything, i.e. we should just return true in this case.
+        (WebCore::::prepare): If V8ParameterBase does not have any object, then we set a null string.
+        * bindings/v8/custom/V8BindingMacros.h: MAYBE_MISSING_PARAMETER() returns the parameter of a given index if the parameter exists. If the parameter does not exist and MissingIsUndefined is set, this macro returns an object that represents undefined. If the parameter does not exist and MissingIsEmpty is set, this macro returns an empty object.
+        * bindings/v8/custom/V8WebKitCSSMatrixConstructor.cpp: Removed.
+        * css/WebKitCSSMatrix.idl: Added the 'Constructor' extended attribute.
+
 2011-09-09  Geoffrey Garen  <gga...@apple.com>
 
         Reviewed by Dan Bernstein.

Modified: trunk/Source/WebCore/WebCore.gypi (94890 => 94891)


--- trunk/Source/WebCore/WebCore.gypi	2011-09-10 00:05:28 UTC (rev 94890)
+++ trunk/Source/WebCore/WebCore.gypi	2011-09-10 00:29:10 UTC (rev 94891)
@@ -2222,7 +2222,6 @@
             'bindings/v8/custom/V8Uint8ArrayCustom.cpp',
             'bindings/v8/custom/V8WebGLRenderingContextCustom.cpp',
             'bindings/v8/custom/V8WebKitAnimationCustom.cpp',
-            'bindings/v8/custom/V8WebKitCSSMatrixConstructor.cpp',
             'bindings/v8/custom/V8WebKitPointConstructor.cpp',
             'bindings/v8/custom/V8WebSocketCustom.cpp',
             'bindings/v8/custom/V8WorkerContextCustom.cpp',

Modified: trunk/Source/WebCore/WebCore.pro (94890 => 94891)


--- trunk/Source/WebCore/WebCore.pro	2011-09-10 00:05:28 UTC (rev 94890)
+++ trunk/Source/WebCore/WebCore.pro	2011-09-10 00:29:10 UTC (rev 94891)
@@ -208,7 +208,6 @@
         bindings/v8/custom/V8StyleSheetCustom.cpp \
         bindings/v8/custom/V8StyleSheetListCustom.cpp \
         bindings/v8/custom/V8WebKitAnimationCustom.cpp \
-        bindings/v8/custom/V8WebKitCSSMatrixConstructor.cpp \
         bindings/v8/custom/V8WebKitPointConstructor.cpp \
         bindings/v8/custom/V8WorkerContextCustom.cpp \
         bindings/v8/custom/V8WorkerCustom.cpp \

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (94890 => 94891)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2011-09-10 00:05:28 UTC (rev 94890)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2011-09-10 00:29:10 UTC (rev 94891)
@@ -1416,9 +1416,9 @@
 
         # Optional callbacks should be treated differently, because they always have a default value (0),
         # and we can reduce the number of overloaded functions that take a different number of parameters.
-        # Optional arguments with default values [Optional=CallWithDefaultValue] should not generate an early call.
+        # Optional arguments with default values [Optional=CallWithDefaultValue] or [Optional=CallWithNullValue] should not generate an early call.
         my $optional = $parameter->extendedAttributes->{"Optional"};        
-        if ($optional && $optional ne "CallWithDefaultValue" && !$parameter->extendedAttributes->{"Callback"}) {
+        if ($optional && $optional ne "CallWithDefaultValue" && $optional ne "CallWithNullValue" && !$parameter->extendedAttributes->{"Callback"}) {
             # Generate early call if there are not enough parameters.
             $parameterCheckString .= "    if (args.Length() <= $paramIndex) {\n";
             my $functionCall = GenerateFunctionCallString($function, $paramIndex, "    " x 2, $implClassName);
@@ -1426,6 +1426,11 @@
             $parameterCheckString .= "    }\n";
         }
 
+        my $parameterMissingPolicy = "MissingIsUndefined";
+        if ($optional && $optional eq "CallWithNullValue") {
+            $parameterMissingPolicy = "MissingIsEmpty";
+        }
+
         AddToImplIncludes("ExceptionCode.h");
         my $nativeType = GetNativeTypeFromSignature($parameter, $paramIndex);
         if ($parameter->extendedAttributes->{"Callback"}) {
@@ -1457,7 +1462,7 @@
             $parameterCheckString .= "        goto fail;\n";
             $parameterCheckString .= "    }\n";
         } elsif ($nativeType =~ /^V8Parameter/) {
-            my $value = JSValueToNative($parameter, "args[$paramIndex]");
+            my $value = JSValueToNative($parameter, "MAYBE_MISSING_PARAMETER(args, $paramIndex, $parameterMissingPolicy)");
             $parameterCheckString .= "    " . ConvertToV8Parameter($parameter, $nativeType, $parameterName, $value) . "\n";
         } else {
             AddToImplIncludes("V8BindingMacros.h");
@@ -1478,7 +1483,7 @@
                 }
             }
             $parameterCheckString .= "    EXCEPTION_BLOCK($nativeType, $parameterName, " .
-                 JSValueToNative($parameter, "args[$paramIndex]") . ");\n";
+                 JSValueToNative($parameter, "MAYBE_MISSING_PARAMETER(args, $paramIndex, $parameterMissingPolicy)") . ");\n";
         }
 
         if ($parameter->extendedAttributes->{"IsIndex"}) {
@@ -3268,7 +3273,7 @@
     }
     foreach my $parameter (@{$function->parameters}) {
         my $optional = $parameter->extendedAttributes->{"Optional"};
-        if (($optional && ($optional ne "CallWithDefaultValue")) || $parameter->extendedAttributes->{"Callback"}) {
+        if (($optional && $optional ne "CallWithDefaultValue" && $optional ne "CallWithNullValue") || $parameter->extendedAttributes->{"Callback"}) {
             return 0;
         }
     }

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp (94890 => 94891)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp	2011-09-10 00:05:28 UTC (rev 94890)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp	2011-09-10 00:29:10 UTC (rev 94891)
@@ -54,8 +54,8 @@
         return throwError("Not enough arguments", V8Proxy::TypeError);
 
     ExceptionCode ec = 0;
-    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, str1, args[0]);
-    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, str2, args[1]);
+    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, str1, MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined));
+    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, str2, MAYBE_MISSING_PARAMETER(args, 1, MissingIsUndefined));
 
     ScriptExecutionContext* context = getScriptExecutionContext();
     if (!context)

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp (94890 => 94891)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp	2011-09-10 00:05:28 UTC (rev 94890)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp	2011-09-10 00:29:10 UTC (rev 94891)
@@ -43,7 +43,7 @@
 {
     INC_STATS("DOM.TestMediaQueryListListener.method");
     TestMediaQueryListListener* imp = V8TestMediaQueryListListener::toNative(args.Holder());
-    EXCEPTION_BLOCK(RefPtr<MediaQueryListListener>, listener, MediaQueryListListener::create(args[0]));
+    EXCEPTION_BLOCK(RefPtr<MediaQueryListListener>, listener, MediaQueryListListener::create(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)));
     imp->method(listener);
     return v8::Handle<v8::Value>();
 }

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp (94890 => 94891)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2011-09-10 00:05:28 UTC (rev 94890)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2011-09-10 00:29:10 UTC (rev 94891)
@@ -662,9 +662,9 @@
 {
     INC_STATS("DOM.TestObj.voidMethodWithArgs");
     TestObj* imp = V8TestObj::toNative(args.Holder());
-    EXCEPTION_BLOCK(int, intArg, toInt32(args[0]));
-    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[1]);
-    EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0);
+    EXCEPTION_BLOCK(int, intArg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)));
+    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, MAYBE_MISSING_PARAMETER(args, 1, MissingIsUndefined));
+    EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(MAYBE_MISSING_PARAMETER(args, 2, MissingIsUndefined)) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 2, MissingIsUndefined))) : 0);
     imp->voidMethodWithArgs(intArg, strArg, objArg);
     return v8::Handle<v8::Value>();
 }
@@ -680,9 +680,9 @@
 {
     INC_STATS("DOM.TestObj.intMethodWithArgs");
     TestObj* imp = V8TestObj::toNative(args.Holder());
-    EXCEPTION_BLOCK(int, intArg, toInt32(args[0]));
-    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[1]);
-    EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0);
+    EXCEPTION_BLOCK(int, intArg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)));
+    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, MAYBE_MISSING_PARAMETER(args, 1, MissingIsUndefined));
+    EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(MAYBE_MISSING_PARAMETER(args, 2, MissingIsUndefined)) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 2, MissingIsUndefined))) : 0);
     return v8::Integer::New(imp->intMethodWithArgs(intArg, strArg, objArg));
 }
 
@@ -697,9 +697,9 @@
 {
     INC_STATS("DOM.TestObj.objMethodWithArgs");
     TestObj* imp = V8TestObj::toNative(args.Holder());
-    EXCEPTION_BLOCK(int, intArg, toInt32(args[0]));
-    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[1]);
-    EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0);
+    EXCEPTION_BLOCK(int, intArg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)));
+    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, MAYBE_MISSING_PARAMETER(args, 1, MissingIsUndefined));
+    EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(MAYBE_MISSING_PARAMETER(args, 2, MissingIsUndefined)) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 2, MissingIsUndefined))) : 0);
     return toV8(imp->objMethodWithArgs(intArg, strArg, objArg));
 }
 
@@ -709,8 +709,8 @@
     if (args.Length() < 2)
         return v8::Handle<v8::Value>();
     TestObj* imp = V8TestObj::toNative(args.Holder());
-    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[0]);
-    EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[1]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0);
+    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined));
+    EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(MAYBE_MISSING_PARAMETER(args, 1, MissingIsUndefined)) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 1, MissingIsUndefined))) : 0);
     return toV8(imp->methodThatRequiresAllArgs(strArg, objArg));
 }
 
@@ -722,8 +722,8 @@
     TestObj* imp = V8TestObj::toNative(args.Holder());
     ExceptionCode ec = 0;
     {
-    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[0]);
-    EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[1]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0);
+    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined));
+    EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(MAYBE_MISSING_PARAMETER(args, 1, MissingIsUndefined)) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 1, MissingIsUndefined))) : 0);
     RefPtr<TestObj> result = imp->methodThatRequiresAllArgsAndThrows(strArg, objArg, ec);
     if (UNLIKELY(ec))
         goto fail;
@@ -769,12 +769,12 @@
 {
     INC_STATS("DOM.TestObj.optionsObject");
     TestObj* imp = V8TestObj::toNative(args.Holder());
-    EXCEPTION_BLOCK(OptionsObject, oo, args[0]);
+    EXCEPTION_BLOCK(OptionsObject, oo, MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined));
     if (args.Length() <= 1) {
         imp->optionsObject(oo);
         return v8::Handle<v8::Value>();
     }
-    EXCEPTION_BLOCK(OptionsObject, ooo, args[1]);
+    EXCEPTION_BLOCK(OptionsObject, ooo, MAYBE_MISSING_PARAMETER(args, 1, MissingIsUndefined));
     imp->optionsObject(oo, ooo);
     return v8::Handle<v8::Value>();
 }
@@ -806,7 +806,7 @@
     RefPtr<ScriptCallStack> callStack(createScriptCallStack(maxStackSize));
     if (!callStack)
         return v8::Undefined();
-    EXCEPTION_BLOCK(log*, intArg, V8log::HasInstance(args[0]) ? V8log::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0);
+    EXCEPTION_BLOCK(log*, intArg, V8log::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)) ? V8log::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined))) : 0);
     imp->customArgsAndException(intArg, scriptArguments, callStack, ec);
     if (UNLIKELY(ec))
         goto fail;
@@ -854,7 +854,7 @@
 {
     INC_STATS("DOM.TestObj.withDynamicFrameAndArg");
     TestObj* imp = V8TestObj::toNative(args.Holder());
-    EXCEPTION_BLOCK(int, intArg, toInt32(args[0]));
+    EXCEPTION_BLOCK(int, intArg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)));
     Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
     if (!enteredFrame)
         return v8::Undefined();
@@ -866,7 +866,7 @@
 {
     INC_STATS("DOM.TestObj.withDynamicFrameAndOptionalArg");
     TestObj* imp = V8TestObj::toNative(args.Holder());
-    EXCEPTION_BLOCK(int, intArg, toInt32(args[0]));
+    EXCEPTION_BLOCK(int, intArg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)));
     if (args.Length() <= 1) {
         Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
         if (!enteredFrame)
@@ -874,7 +874,7 @@
         imp->withDynamicFrameAndOptionalArg(enteredFrame, intArg);
         return v8::Handle<v8::Value>();
     }
-    EXCEPTION_BLOCK(int, optionalArg, toInt32(args[1]));
+    EXCEPTION_BLOCK(int, optionalArg, toInt32(MAYBE_MISSING_PARAMETER(args, 1, MissingIsUndefined)));
     Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
     if (!enteredFrame)
         return v8::Undefined();
@@ -886,7 +886,7 @@
 {
     INC_STATS("DOM.TestObj.withDynamicFrameAndUserGesture");
     TestObj* imp = V8TestObj::toNative(args.Holder());
-    EXCEPTION_BLOCK(int, intArg, toInt32(args[0]));
+    EXCEPTION_BLOCK(int, intArg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)));
     Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
     if (!enteredFrame)
         return v8::Undefined();
@@ -898,7 +898,7 @@
 {
     INC_STATS("DOM.TestObj.withDynamicFrameAndUserGestureASAD");
     TestObj* imp = V8TestObj::toNative(args.Holder());
-    EXCEPTION_BLOCK(int, intArg, toInt32(args[0]));
+    EXCEPTION_BLOCK(int, intArg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)));
     if (args.Length() <= 1) {
         Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
         if (!enteredFrame)
@@ -906,7 +906,7 @@
         imp->withDynamicFrameAndUserGestureASAD(enteredFrame, intArg, ScriptController::processingUserGesture());
         return v8::Handle<v8::Value>();
     }
-    EXCEPTION_BLOCK(int, optionalArg, toInt32(args[1]));
+    EXCEPTION_BLOCK(int, optionalArg, toInt32(MAYBE_MISSING_PARAMETER(args, 1, MissingIsUndefined)));
     Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
     if (!enteredFrame)
         return v8::Undefined();
@@ -993,7 +993,7 @@
         imp->methodWithOptionalArg();
         return v8::Handle<v8::Value>();
     }
-    EXCEPTION_BLOCK(int, opt, toInt32(args[0]));
+    EXCEPTION_BLOCK(int, opt, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)));
     imp->methodWithOptionalArg(opt);
     return v8::Handle<v8::Value>();
 }
@@ -1002,12 +1002,12 @@
 {
     INC_STATS("DOM.TestObj.methodWithNonOptionalArgAndOptionalArg");
     TestObj* imp = V8TestObj::toNative(args.Holder());
-    EXCEPTION_BLOCK(int, nonOpt, toInt32(args[0]));
+    EXCEPTION_BLOCK(int, nonOpt, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)));
     if (args.Length() <= 1) {
         imp->methodWithNonOptionalArgAndOptionalArg(nonOpt);
         return v8::Handle<v8::Value>();
     }
-    EXCEPTION_BLOCK(int, opt, toInt32(args[1]));
+    EXCEPTION_BLOCK(int, opt, toInt32(MAYBE_MISSING_PARAMETER(args, 1, MissingIsUndefined)));
     imp->methodWithNonOptionalArgAndOptionalArg(nonOpt, opt);
     return v8::Handle<v8::Value>();
 }
@@ -1016,13 +1016,13 @@
 {
     INC_STATS("DOM.TestObj.methodWithNonOptionalArgAndTwoOptionalArgs");
     TestObj* imp = V8TestObj::toNative(args.Holder());
-    EXCEPTION_BLOCK(int, nonOpt, toInt32(args[0]));
+    EXCEPTION_BLOCK(int, nonOpt, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)));
     if (args.Length() <= 1) {
         imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt);
         return v8::Handle<v8::Value>();
     }
-    EXCEPTION_BLOCK(int, opt1, toInt32(args[1]));
-    EXCEPTION_BLOCK(int, opt2, toInt32(args[2]));
+    EXCEPTION_BLOCK(int, opt1, toInt32(MAYBE_MISSING_PARAMETER(args, 1, MissingIsUndefined)));
+    EXCEPTION_BLOCK(int, opt2, toInt32(MAYBE_MISSING_PARAMETER(args, 2, MissingIsUndefined)));
     imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1, opt2);
     return v8::Handle<v8::Value>();
 }
@@ -1042,7 +1042,7 @@
 {
     INC_STATS("DOM.TestObj.methodWithNonCallbackArgAndCallbackArg");
     TestObj* imp = V8TestObj::toNative(args.Holder());
-    EXCEPTION_BLOCK(int, nonCallback, toInt32(args[0]));
+    EXCEPTION_BLOCK(int, nonCallback, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)));
     if (args.Length() <= 1 || !args[1]->IsObject())
         return throwError(TYPE_MISMATCH_ERR);
     RefPtr<TestCallback> callback = V8TestCallback::create(args[1], getScriptExecutionContext());
@@ -1091,8 +1091,8 @@
 {
     INC_STATS("DOM.TestObj.overloadedMethod1");
     TestObj* imp = V8TestObj::toNative(args.Holder());
-    EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[0]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0);
-    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[1]);
+    EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined))) : 0);
+    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, MAYBE_MISSING_PARAMETER(args, 1, MissingIsUndefined));
     imp->overloadedMethod(objArg, strArg);
     return v8::Handle<v8::Value>();
 }
@@ -1101,12 +1101,12 @@
 {
     INC_STATS("DOM.TestObj.overloadedMethod2");
     TestObj* imp = V8TestObj::toNative(args.Holder());
-    EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[0]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0);
+    EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined))) : 0);
     if (args.Length() <= 1) {
         imp->overloadedMethod(objArg);
         return v8::Handle<v8::Value>();
     }
-    EXCEPTION_BLOCK(int, intArg, toInt32(args[1]));
+    EXCEPTION_BLOCK(int, intArg, toInt32(MAYBE_MISSING_PARAMETER(args, 1, MissingIsUndefined)));
     imp->overloadedMethod(objArg, intArg);
     return v8::Handle<v8::Value>();
 }
@@ -1115,7 +1115,7 @@
 {
     INC_STATS("DOM.TestObj.overloadedMethod3");
     TestObj* imp = V8TestObj::toNative(args.Holder());
-    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[0]);
+    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined));
     imp->overloadedMethod(strArg);
     return v8::Handle<v8::Value>();
 }
@@ -1124,7 +1124,7 @@
 {
     INC_STATS("DOM.TestObj.overloadedMethod4");
     TestObj* imp = V8TestObj::toNative(args.Holder());
-    EXCEPTION_BLOCK(int, intArg, toInt32(args[0]));
+    EXCEPTION_BLOCK(int, intArg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)));
     imp->overloadedMethod(intArg);
     return v8::Handle<v8::Value>();
 }
@@ -1170,7 +1170,7 @@
     if (args.Length() <= 0) {
         return v8::Integer::New(TestObj::classMethodWithOptional());
     }
-    EXCEPTION_BLOCK(int, arg, toInt32(args[0]));
+    EXCEPTION_BLOCK(int, arg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)));
     return v8::Integer::New(TestObj::classMethodWithOptional(arg));
 }
 
@@ -1178,7 +1178,7 @@
 {
     INC_STATS("DOM.TestObj.enabledAtRuntimeMethod1");
     TestObj* imp = V8TestObj::toNative(args.Holder());
-    EXCEPTION_BLOCK(int, intArg, V8int::HasInstance(args[0]) ? V8int::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0);
+    EXCEPTION_BLOCK(int, intArg, V8int::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)) ? V8int::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined))) : 0);
     imp->enabledAtRuntimeMethod1(intArg);
     return v8::Handle<v8::Value>();
 }
@@ -1187,7 +1187,7 @@
 {
     INC_STATS("DOM.TestObj.enabledAtRuntimeMethod2");
     TestObj* imp = V8TestObj::toNative(args.Holder());
-    EXCEPTION_BLOCK(int, intArg, V8int::HasInstance(args[0]) ? V8int::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0);
+    EXCEPTION_BLOCK(int, intArg, V8int::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)) ? V8int::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined))) : 0);
     imp->enabledAtRuntimeMethod2(intArg);
     return v8::Handle<v8::Value>();
 }

Modified: trunk/Source/WebCore/bindings/v8/V8Binding.h (94890 => 94891)


--- trunk/Source/WebCore/bindings/v8/V8Binding.h	2011-09-10 00:05:28 UTC (rev 94890)
+++ trunk/Source/WebCore/bindings/v8/V8Binding.h	2011-09-10 00:29:10 UTC (rev 94891)
@@ -386,6 +386,9 @@
 
         bool prepareBase()
         {
+            if (m_v8Object.IsEmpty())
+                return true;
+
             if (LIKELY(m_v8Object->IsString()))
                 return true;
 
@@ -402,15 +405,6 @@
                 block.ReThrow();
                 return false;
             }
-
-            // This path is unexpected.  However there is hypothesis that it
-            // might be combination of v8 and v8 bindings bugs.  For now
-            // just bailout as we'll crash if attempt to convert empty handle into a string.
-            if (m_v8Object.IsEmpty()) {
-                ASSERT_NOT_REACHED();
-                return false;
-            }
-
             return true;
         }
 
@@ -460,7 +454,7 @@
 
     template<> inline bool V8Parameter<WithNullCheck>::prepare()
     {
-        if (object()->IsNull()) {
+        if (object().IsEmpty() || object()->IsNull()) {
             setString(String());
             return true;
         }
@@ -470,7 +464,7 @@
 
     template<> inline bool V8Parameter<WithUndefinedOrNullCheck>::prepare()
     {
-        if (object()->IsNull() || object()->IsUndefined()) {
+        if (object().IsEmpty() || object()->IsNull() || object()->IsUndefined()) {
             setString(String());
             return true;
         }
@@ -478,6 +472,11 @@
         return V8ParameterBase::prepareBase();
     }
 
+    enum ParameterMissingPolicy {
+        MissingIsUndefined,
+        MissingIsEmpty
+    };
+
 } // namespace WebCore
 
 #endif // V8Binding_h

Modified: trunk/Source/WebCore/bindings/v8/custom/V8BindingMacros.h (94890 => 94891)


--- trunk/Source/WebCore/bindings/v8/custom/V8BindingMacros.h	2011-09-10 00:05:28 UTC (rev 94890)
+++ trunk/Source/WebCore/bindings/v8/custom/V8BindingMacros.h	2011-09-10 00:29:10 UTC (rev 94891)
@@ -46,3 +46,6 @@
     type var(value);                                                 \
     if (!var.prepare())                                              \
         return;
+
+#define MAYBE_MISSING_PARAMETER(args, index, policy) \
+    (((policy) == MissingIsEmpty && (index) >= (args).Length()) ? (v8::Local<v8::Value>()) : ((args)[(index)]))

Deleted: trunk/Source/WebCore/bindings/v8/custom/V8WebKitCSSMatrixConstructor.cpp (94890 => 94891)


--- trunk/Source/WebCore/bindings/v8/custom/V8WebKitCSSMatrixConstructor.cpp	2011-09-10 00:05:28 UTC (rev 94890)
+++ trunk/Source/WebCore/bindings/v8/custom/V8WebKitCSSMatrixConstructor.cpp	2011-09-10 00:29:10 UTC (rev 94891)
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "V8WebKitCSSMatrix.h"
-
-#include "Document.h"
-#include "DocumentFragment.h"
-#include "Node.h"
-
-#include "V8Binding.h"
-#include "V8Document.h"
-#include "V8Node.h"
-#include "V8Proxy.h"
-
-#include <wtf/RefPtr.h>
-
-namespace WebCore {
-
-v8::Handle<v8::Value> V8WebKitCSSMatrix::constructorCallback(const v8::Arguments& args)
-{
-    INC_STATS("DOM.WebKitCSSMatrix.Constructor");
-
-    if (!args.IsConstructCall())
-        return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
-
-    // FIXME: The logic here is almost exact duplicate of V8::constructDOMObject.
-    // Consider refactoring to reduce duplication.
-    String cssValue;
-    if (args.Length() >= 1)
-        cssValue = toWebCoreString(args[0]);
-
-    ExceptionCode ec = 0;
-    RefPtr<WebKitCSSMatrix> matrix = WebKitCSSMatrix::create(cssValue, ec);
-    if (ec)
-        throwError(ec);
-
-    // Transform the holder into a wrapper object for the matrix.
-    V8DOMWrapper::setDOMWrapper(args.Holder(), &info, matrix.get());
-    return toV8(matrix.release(), args.Holder());
-}
-
-} // namespace WebCore

Modified: trunk/Source/WebCore/css/WebKitCSSMatrix.idl (94890 => 94891)


--- trunk/Source/WebCore/css/WebKitCSSMatrix.idl	2011-09-10 00:05:28 UTC (rev 94890)
+++ trunk/Source/WebCore/css/WebKitCSSMatrix.idl	2011-09-10 00:29:10 UTC (rev 94891)
@@ -30,7 +30,8 @@
         CanBeConstructed,
         CustomConstructFunction,
         ConstructorParameters=1,
-        V8CustomConstructor
+        Constructor(in [Optional=CallWithNullValue] DOMString cssValue),
+        ConstructorRaisesException,
     ] WebKitCSSMatrix {
 
         // These attributes are simple aliases for certain elements of the 4x4 matrix
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to