LayoutTests/ChangeLog

 12011-09-09 Kentaro Hara <haraken@google.com>
 2
 3 Generate a WebKitCSSMatrix constructor of V8 using the IDL 'Constructor' extended attribute
 4 https://bugs.webkit.org/show_bug.cgi?id=67458
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Added a test case for "new WebKitCSSMatrix(null)" and "new WebKitCSSMatrix(undefined)".
 9
 10 * fast/dom/Window/custom-constructors-expected.txt:
 11 * fast/dom/Window/custom-constructors.html:
 12
1132011-09-09 Cary Clark <caryclark@google.com>
214
315 Unreviewed; new baselines (Skia on Mac, GPU edition)

LayoutTests/fast/dom/Window/custom-constructors-expected.txt

@@PASS Image.prototype.toString.call(new Image) is '[object HTMLImageElement]'
77PASS Option.prototype.toString.call(new Option) is '[object HTMLOptionElement]'
88PASS WebKitPoint.prototype.toString.call(new WebKitPoint) is '[object WebKitPoint]'
99PASS WebKitCSSMatrix.prototype.toString.call(new WebKitCSSMatrix) is 'matrix(1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000)'
 10PASS WebKitCSSMatrix.prototype.toString.call(new WebKitCSSMatrix()) is 'matrix(1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000)'
 11PASS new WebKitCSSMatrix(null) threw exception Error: SYNTAX_ERR: DOM Exception 12.
 12PASS new WebKitCSSMatrix(undefined) threw exception Error: SYNTAX_ERR: DOM Exception 12.
1013PASS XMLHttpRequest.prototype.toString.call(new XMLHttpRequest) is '[object XMLHttpRequest]'
1114PASS XSLTProcessor.prototype.toString.call(new XSLTProcessor) is '[object XSLTProcessor]'
1215PASS successfullyParsed is true

LayoutTests/fast/dom/Window/custom-constructors.html

1717 shouldBe("Option.prototype.toString.call(new Option)", "'[object HTMLOptionElement]'");
1818 shouldBe("WebKitPoint.prototype.toString.call(new WebKitPoint)", "'[object WebKitPoint]'");
1919 shouldBe("WebKitCSSMatrix.prototype.toString.call(new WebKitCSSMatrix)", "'matrix(1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000)'");
 20 shouldBe("WebKitCSSMatrix.prototype.toString.call(new WebKitCSSMatrix())", "'matrix(1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000)'");
 21 shouldThrow("new WebKitCSSMatrix(null)");
 22 shouldThrow("new WebKitCSSMatrix(undefined)");
2023 shouldBe("XMLHttpRequest.prototype.toString.call(new XMLHttpRequest)", "'[object XMLHttpRequest]'");
2124 shouldBe("XSLTProcessor.prototype.toString.call(new XSLTProcessor)", "'[object XSLTProcessor]'");
2225

Source/WebCore/ChangeLog

 12011-09-09 Kentaro Hara <haraken@google.com>
 2
 3 Generate a WebKitCSSMatrix constructor of V8 using the IDL 'Constructor' extended attribute
 4 https://bugs.webkit.org/show_bug.cgi?id=67458
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Added a 'CallWithNullValue' extended attribute.
 9 If a parameter is optional and missing, 'CallWithDefaultValue'
 10 handles it as a string "undefined". On the other hand,
 11 'CallWithNullValue' handles it as a null string
 12 (Note: not a string "null", but a null string).
 13
 14 Tests: fast/dom/Window/custom-constructors.html
 15 transforms/svg-vs-css.xhtml
 16 transforms/cssmatrix-2d-interface.xhtml
 17 transforms/cssmatrix-3d-interface.xhtmlGenerate a WebKitCSSMatrix constructor
 18
 19 * WebCore.gypi: Removed V8WebKitCSSMatrixConstructor.cpp.
 20 * WebCore.pro: Removed V8WebKitCSSMatrixConstructor.cpp.
 21 * bindings/scripts/CodeGeneratorV8.pm:
 22 (GenerateParametersCheck): If the 'CallWithNullValue' extended attribute is set, we call MAYBE_MISSING_PARAMETER() with MISSING_IS_EMPTY mode to obtain a maybe missing parameter. Otherwise, we call MAYBE_MISSING_PARAMETER() with MISSING_IS_UNDEFINED mode.
 23 (RequiresCustomSignature):
 24 * bindings/scripts/test/V8/V8TestInterface.cpp: Updated test results.
 25 (WebCore::V8TestInterface::constructorCallback):
 26 * bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp: Ditto.
 27 (WebCore::TestMediaQueryListListenerInternal::methodCallback):
 28 * bindings/scripts/test/V8/V8TestObj.cpp: Ditto.
 29 (WebCore::TestObjInternal::voidMethodWithArgsCallback):
 30 (WebCore::TestObjInternal::intMethodWithArgsCallback):
 31 (WebCore::TestObjInternal::objMethodWithArgsCallback):
 32 (WebCore::TestObjInternal::methodThatRequiresAllArgsCallback):
 33 (WebCore::TestObjInternal::methodThatRequiresAllArgsAndThrowsCallback):
 34 (WebCore::TestObjInternal::optionsObjectCallback):
 35 (WebCore::TestObjInternal::customArgsAndExceptionCallback):
 36 (WebCore::TestObjInternal::withDynamicFrameAndArgCallback):
 37 (WebCore::TestObjInternal::withDynamicFrameAndOptionalArgCallback):
 38 (WebCore::TestObjInternal::withDynamicFrameAndUserGestureCallback):
 39 (WebCore::TestObjInternal::withDynamicFrameAndUserGestureASADCallback):
 40 (WebCore::TestObjInternal::methodWithOptionalArgCallback):
 41 (WebCore::TestObjInternal::methodWithNonOptionalArgAndOptionalArgCallback):
 42 (WebCore::TestObjInternal::methodWithNonOptionalArgAndTwoOptionalArgsCallback):
 43 (WebCore::TestObjInternal::methodWithNonCallbackArgAndCallbackArgCallback):
 44 (WebCore::TestObjInternal::overloadedMethod1Callback):
 45 (WebCore::TestObjInternal::overloadedMethod2Callback):
 46 (WebCore::TestObjInternal::overloadedMethod3Callback):
 47 (WebCore::TestObjInternal::overloadedMethod4Callback):
 48 (WebCore::TestObjInternal::classMethodWithOptionalCallback):
 49 (WebCore::TestObjInternal::enabledAtRuntimeMethod1Callback):
 50 (WebCore::TestObjInternal::enabledAtRuntimeMethod2Callback):
 51 * bindings/v8/V8Binding.h:
 52 (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.
 53 (WebCore::::prepare): If V8ParameterBase does not have any object, then we set a null string.
 54 * 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 MISSING_IS_UNDEFINED is set, this macro returns an object that represents undefined. If the parameter does not exist and MISSING_IS_EMPTY is set, this macro returns an empty object.
 55 * bindings/v8/custom/V8WebKitCSSMatrixConstructor.cpp: Removed.
 56 * css/WebKitCSSMatrix.idl: Added the 'Constructor' extended attribute.
 57
1582011-09-09 Pavel Podivilov <podivilov@chromium.org>
259
360 Web Inspector: introduce JavaScriptSourceFrame class.

Source/WebCore/WebCore.gypi

22212221 'bindings/v8/custom/V8Uint8ArrayCustom.cpp',
22222222 'bindings/v8/custom/V8WebGLRenderingContextCustom.cpp',
22232223 'bindings/v8/custom/V8WebKitAnimationCustom.cpp',
2224  'bindings/v8/custom/V8WebKitCSSMatrixConstructor.cpp',
22252224 'bindings/v8/custom/V8WebKitPointConstructor.cpp',
22262225 'bindings/v8/custom/V8WebSocketCustom.cpp',
22272226 'bindings/v8/custom/V8WorkerContextCustom.cpp',

Source/WebCore/WebCore.pro

@@v8 {
208208 bindings/v8/custom/V8StyleSheetCustom.cpp \
209209 bindings/v8/custom/V8StyleSheetListCustom.cpp \
210210 bindings/v8/custom/V8WebKitAnimationCustom.cpp \
211  bindings/v8/custom/V8WebKitCSSMatrixConstructor.cpp \
212211 bindings/v8/custom/V8WebKitPointConstructor.cpp \
213212 bindings/v8/custom/V8WorkerContextCustom.cpp \
214213 bindings/v8/custom/V8WorkerCustom.cpp \

Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

@@sub GenerateParametersCheck
14161416
14171417 # Optional callbacks should be treated differently, because they always have a default value (0),
14181418 # and we can reduce the number of overloaded functions that take a different number of parameters.
1419  # Optional arguments with default values [Optional=CallWithDefaultValue] should not generate an early call.
 1419 # Optional arguments with default values [Optional=CallWithDefaultValue] or [Optional=CallWithNullValue] should not generate an early call.
14201420 my $optional = $parameter->extendedAttributes->{"Optional"};
1421  if ($optional && $optional ne "CallWithDefaultValue" && !$parameter->extendedAttributes->{"Callback"}) {
 1421 if ($optional && $optional ne "CallWithDefaultValue" && $optional ne "CallWithNullValue" && !$parameter->extendedAttributes->{"Callback"}) {
14221422 # Generate early call if there are not enough parameters.
14231423 $parameterCheckString .= " if (args.Length() <= $paramIndex) {\n";
14241424 my $functionCall = GenerateFunctionCallString($function, $paramIndex, " " x 2, $implClassName);

@@sub GenerateParametersCheck
14261426 $parameterCheckString .= " }\n";
14271427 }
14281428
 1429 my $parameterMissingPolicy = "MISSING_IS_UNDEFINED";
 1430 if ($optional && $optional eq "CallWithNullValue") {
 1431 $parameterMissingPolicy = "MISSING_IS_EMPTY";
 1432 }
 1433
14291434 AddToImplIncludes("ExceptionCode.h");
14301435 my $nativeType = GetNativeTypeFromSignature($parameter, $paramIndex);
14311436 if ($parameter->extendedAttributes->{"Callback"}) {

@@sub GenerateParametersCheck
14571462 $parameterCheckString .= " goto fail;\n";
14581463 $parameterCheckString .= " }\n";
14591464 } elsif ($nativeType =~ /^V8Parameter/) {
1460  my $value = JSValueToNative($parameter, "args[$paramIndex]");
 1465 my $value = JSValueToNative($parameter, "MAYBE_MISSING_PARAMETER(args, $paramIndex, $parameterMissingPolicy)");
14611466 $parameterCheckString .= " " . ConvertToV8Parameter($parameter, $nativeType, $parameterName, $value) . "\n";
14621467 } else {
14631468 AddToImplIncludes("V8BindingMacros.h");

@@sub GenerateParametersCheck
14781483 }
14791484 }
14801485 $parameterCheckString .= " EXCEPTION_BLOCK($nativeType, $parameterName, " .
1481  JSValueToNative($parameter, "args[$paramIndex]") . ");\n";
 1486 JSValueToNative($parameter, "MAYBE_MISSING_PARAMETER(args, $paramIndex, $parameterMissingPolicy)") . ");\n";
14821487 }
14831488
14841489 if ($parameter->extendedAttributes->{"IsIndex"}) {

@@sub RequiresCustomSignature
32683273 }
32693274 foreach my $parameter (@{$function->parameters}) {
32703275 my $optional = $parameter->extendedAttributes->{"Optional"};
3271  if (($optional && ($optional ne "CallWithDefaultValue")) || $parameter->extendedAttributes->{"Callback"}) {
 3276 if (($optional && $optional ne "CallWithDefaultValue" && $optional ne "CallWithNullValue") || $parameter->extendedAttributes->{"Callback"}) {
32723277 return 0;
32733278 }
32743279 }

Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp

@@v8::Handle<v8::Value> V8TestInterface::constructorCallback(const v8::Arguments&
5454 return throwError("Not enough arguments", V8Proxy::TypeError);
5555
5656 ExceptionCode ec = 0;
57  STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, str1, args[0]);
58  STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, str2, args[1]);
 57 STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, str1, MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED));
 58 STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, str2, MAYBE_MISSING_PARAMETER(args, 1, MISSING_IS_UNDEFINED));
5959
6060 ScriptExecutionContext* context = getScriptExecutionContext();
6161 if (!context)

Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp

@@static v8::Handle<v8::Value> methodCallback(const v8::Arguments& args)
4343{
4444 INC_STATS("DOM.TestMediaQueryListListener.method");
4545 TestMediaQueryListListener* imp = V8TestMediaQueryListListener::toNative(args.Holder());
46  EXCEPTION_BLOCK(RefPtr<MediaQueryListListener>, listener, MediaQueryListListener::create(args[0]));
 46 EXCEPTION_BLOCK(RefPtr<MediaQueryListListener>, listener, MediaQueryListListener::create(MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED)));
4747 imp->method(listener);
4848 return v8::Handle<v8::Value>();
4949}

Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp

@@static v8::Handle<v8::Value> voidMethodWithArgsCallback(const v8::Arguments& arg
662662{
663663 INC_STATS("DOM.TestObj.voidMethodWithArgs");
664664 TestObj* imp = V8TestObj::toNative(args.Holder());
665  EXCEPTION_BLOCK(int, intArg, toInt32(args[0]));
666  STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[1]);
667  EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0);
 665 EXCEPTION_BLOCK(int, intArg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED)));
 666 STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, MAYBE_MISSING_PARAMETER(args, 1, MISSING_IS_UNDEFINED));
 667 EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(MAYBE_MISSING_PARAMETER(args, 2, MISSING_IS_UNDEFINED)) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 2, MISSING_IS_UNDEFINED))) : 0);
668668 imp->voidMethodWithArgs(intArg, strArg, objArg);
669669 return v8::Handle<v8::Value>();
670670}

@@static v8::Handle<v8::Value> intMethodWithArgsCallback(const v8::Arguments& args
680680{
681681 INC_STATS("DOM.TestObj.intMethodWithArgs");
682682 TestObj* imp = V8TestObj::toNative(args.Holder());
683  EXCEPTION_BLOCK(int, intArg, toInt32(args[0]));
684  STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[1]);
685  EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0);
 683 EXCEPTION_BLOCK(int, intArg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED)));
 684 STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, MAYBE_MISSING_PARAMETER(args, 1, MISSING_IS_UNDEFINED));
 685 EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(MAYBE_MISSING_PARAMETER(args, 2, MISSING_IS_UNDEFINED)) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 2, MISSING_IS_UNDEFINED))) : 0);
686686 return v8::Integer::New(imp->intMethodWithArgs(intArg, strArg, objArg));
687687}
688688

@@static v8::Handle<v8::Value> objMethodWithArgsCallback(const v8::Arguments& args
697697{
698698 INC_STATS("DOM.TestObj.objMethodWithArgs");
699699 TestObj* imp = V8TestObj::toNative(args.Holder());
700  EXCEPTION_BLOCK(int, intArg, toInt32(args[0]));
701  STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[1]);
702  EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0);
 700 EXCEPTION_BLOCK(int, intArg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED)));
 701 STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, MAYBE_MISSING_PARAMETER(args, 1, MISSING_IS_UNDEFINED));
 702 EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(MAYBE_MISSING_PARAMETER(args, 2, MISSING_IS_UNDEFINED)) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 2, MISSING_IS_UNDEFINED))) : 0);
703703 return toV8(imp->objMethodWithArgs(intArg, strArg, objArg));
704704}
705705

@@static v8::Handle<v8::Value> methodThatRequiresAllArgsCallback(const v8::Argumen
709709 if (args.Length() < 2)
710710 return v8::Handle<v8::Value>();
711711 TestObj* imp = V8TestObj::toNative(args.Holder());
712  STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[0]);
713  EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[1]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0);
 712 STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED));
 713 EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(MAYBE_MISSING_PARAMETER(args, 1, MISSING_IS_UNDEFINED)) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 1, MISSING_IS_UNDEFINED))) : 0);
714714 return toV8(imp->methodThatRequiresAllArgs(strArg, objArg));
715715}
716716

@@static v8::Handle<v8::Value> methodThatRequiresAllArgsAndThrowsCallback(const v8
722722 TestObj* imp = V8TestObj::toNative(args.Holder());
723723 ExceptionCode ec = 0;
724724 {
725  STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[0]);
726  EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[1]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0);
 725 STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED));
 726 EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(MAYBE_MISSING_PARAMETER(args, 1, MISSING_IS_UNDEFINED)) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 1, MISSING_IS_UNDEFINED))) : 0);
727727 RefPtr<TestObj> result = imp->methodThatRequiresAllArgsAndThrows(strArg, objArg, ec);
728728 if (UNLIKELY(ec))
729729 goto fail;

@@static v8::Handle<v8::Value> optionsObjectCallback(const v8::Arguments& args)
769769{
770770 INC_STATS("DOM.TestObj.optionsObject");
771771 TestObj* imp = V8TestObj::toNative(args.Holder());
772  EXCEPTION_BLOCK(OptionsObject, oo, args[0]);
 772 EXCEPTION_BLOCK(OptionsObject, oo, MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED));
773773 if (args.Length() <= 1) {
774774 imp->optionsObject(oo);
775775 return v8::Handle<v8::Value>();
776776 }
777  EXCEPTION_BLOCK(OptionsObject, ooo, args[1]);
 777 EXCEPTION_BLOCK(OptionsObject, ooo, MAYBE_MISSING_PARAMETER(args, 1, MISSING_IS_UNDEFINED));
778778 imp->optionsObject(oo, ooo);
779779 return v8::Handle<v8::Value>();
780780}

@@static v8::Handle<v8::Value> customArgsAndExceptionCallback(const v8::Arguments&
806806 RefPtr<ScriptCallStack> callStack(createScriptCallStack(maxStackSize));
807807 if (!callStack)
808808 return v8::Undefined();
809  EXCEPTION_BLOCK(log*, intArg, V8log::HasInstance(args[0]) ? V8log::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0);
 809 EXCEPTION_BLOCK(log*, intArg, V8log::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED)) ? V8log::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED))) : 0);
810810 imp->customArgsAndException(intArg, scriptArguments, callStack, ec);
811811 if (UNLIKELY(ec))
812812 goto fail;

@@static v8::Handle<v8::Value> withDynamicFrameAndArgCallback(const v8::Arguments&
854854{
855855 INC_STATS("DOM.TestObj.withDynamicFrameAndArg");
856856 TestObj* imp = V8TestObj::toNative(args.Holder());
857  EXCEPTION_BLOCK(int, intArg, toInt32(args[0]));
 857 EXCEPTION_BLOCK(int, intArg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED)));
858858 Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
859859 if (!enteredFrame)
860860 return v8::Undefined();

@@static v8::Handle<v8::Value> withDynamicFrameAndOptionalArgCallback(const v8::Ar
866866{
867867 INC_STATS("DOM.TestObj.withDynamicFrameAndOptionalArg");
868868 TestObj* imp = V8TestObj::toNative(args.Holder());
869  EXCEPTION_BLOCK(int, intArg, toInt32(args[0]));
 869 EXCEPTION_BLOCK(int, intArg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED)));
870870 if (args.Length() <= 1) {
871871 Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
872872 if (!enteredFrame)

@@static v8::Handle<v8::Value> withDynamicFrameAndOptionalArgCallback(const v8::Ar
874874 imp->withDynamicFrameAndOptionalArg(enteredFrame, intArg);
875875 return v8::Handle<v8::Value>();
876876 }
877  EXCEPTION_BLOCK(int, optionalArg, toInt32(args[1]));
 877 EXCEPTION_BLOCK(int, optionalArg, toInt32(MAYBE_MISSING_PARAMETER(args, 1, MISSING_IS_UNDEFINED)));
878878 Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
879879 if (!enteredFrame)
880880 return v8::Undefined();

@@static v8::Handle<v8::Value> withDynamicFrameAndUserGestureCallback(const v8::Ar
886886{
887887 INC_STATS("DOM.TestObj.withDynamicFrameAndUserGesture");
888888 TestObj* imp = V8TestObj::toNative(args.Holder());
889  EXCEPTION_BLOCK(int, intArg, toInt32(args[0]));
 889 EXCEPTION_BLOCK(int, intArg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED)));
890890 Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
891891 if (!enteredFrame)
892892 return v8::Undefined();

@@static v8::Handle<v8::Value> withDynamicFrameAndUserGestureASADCallback(const v8
898898{
899899 INC_STATS("DOM.TestObj.withDynamicFrameAndUserGestureASAD");
900900 TestObj* imp = V8TestObj::toNative(args.Holder());
901  EXCEPTION_BLOCK(int, intArg, toInt32(args[0]));
 901 EXCEPTION_BLOCK(int, intArg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED)));
902902 if (args.Length() <= 1) {
903903 Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
904904 if (!enteredFrame)

@@static v8::Handle<v8::Value> withDynamicFrameAndUserGestureASADCallback(const v8
906906 imp->withDynamicFrameAndUserGestureASAD(enteredFrame, intArg, ScriptController::processingUserGesture());
907907 return v8::Handle<v8::Value>();
908908 }
909  EXCEPTION_BLOCK(int, optionalArg, toInt32(args[1]));
 909 EXCEPTION_BLOCK(int, optionalArg, toInt32(MAYBE_MISSING_PARAMETER(args, 1, MISSING_IS_UNDEFINED)));
910910 Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
911911 if (!enteredFrame)
912912 return v8::Undefined();

@@static v8::Handle<v8::Value> methodWithOptionalArgCallback(const v8::Arguments&
993993 imp->methodWithOptionalArg();
994994 return v8::Handle<v8::Value>();
995995 }
996  EXCEPTION_BLOCK(int, opt, toInt32(args[0]));
 996 EXCEPTION_BLOCK(int, opt, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED)));
997997 imp->methodWithOptionalArg(opt);
998998 return v8::Handle<v8::Value>();
999999}

@@static v8::Handle<v8::Value> methodWithNonOptionalArgAndOptionalArgCallback(cons
10021002{
10031003 INC_STATS("DOM.TestObj.methodWithNonOptionalArgAndOptionalArg");
10041004 TestObj* imp = V8TestObj::toNative(args.Holder());
1005  EXCEPTION_BLOCK(int, nonOpt, toInt32(args[0]));
 1005 EXCEPTION_BLOCK(int, nonOpt, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED)));
10061006 if (args.Length() <= 1) {
10071007 imp->methodWithNonOptionalArgAndOptionalArg(nonOpt);
10081008 return v8::Handle<v8::Value>();
10091009 }
1010  EXCEPTION_BLOCK(int, opt, toInt32(args[1]));
 1010 EXCEPTION_BLOCK(int, opt, toInt32(MAYBE_MISSING_PARAMETER(args, 1, MISSING_IS_UNDEFINED)));
10111011 imp->methodWithNonOptionalArgAndOptionalArg(nonOpt, opt);
10121012 return v8::Handle<v8::Value>();
10131013}

@@static v8::Handle<v8::Value> methodWithNonOptionalArgAndTwoOptionalArgsCallback(
10161016{
10171017 INC_STATS("DOM.TestObj.methodWithNonOptionalArgAndTwoOptionalArgs");
10181018 TestObj* imp = V8TestObj::toNative(args.Holder());
1019  EXCEPTION_BLOCK(int, nonOpt, toInt32(args[0]));
 1019 EXCEPTION_BLOCK(int, nonOpt, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED)));
10201020 if (args.Length() <= 1) {
10211021 imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt);
10221022 return v8::Handle<v8::Value>();
10231023 }
1024  EXCEPTION_BLOCK(int, opt1, toInt32(args[1]));
1025  EXCEPTION_BLOCK(int, opt2, toInt32(args[2]));
 1024 EXCEPTION_BLOCK(int, opt1, toInt32(MAYBE_MISSING_PARAMETER(args, 1, MISSING_IS_UNDEFINED)));
 1025 EXCEPTION_BLOCK(int, opt2, toInt32(MAYBE_MISSING_PARAMETER(args, 2, MISSING_IS_UNDEFINED)));
10261026 imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1, opt2);
10271027 return v8::Handle<v8::Value>();
10281028}

@@static v8::Handle<v8::Value> methodWithNonCallbackArgAndCallbackArgCallback(cons
10421042{
10431043 INC_STATS("DOM.TestObj.methodWithNonCallbackArgAndCallbackArg");
10441044 TestObj* imp = V8TestObj::toNative(args.Holder());
1045  EXCEPTION_BLOCK(int, nonCallback, toInt32(args[0]));
 1045 EXCEPTION_BLOCK(int, nonCallback, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED)));
10461046 if (args.Length() <= 1 || !args[1]->IsObject())
10471047 return throwError(TYPE_MISMATCH_ERR);
10481048 RefPtr<TestCallback> callback = V8TestCallback::create(args[1], getScriptExecutionContext());

@@static v8::Handle<v8::Value> overloadedMethod1Callback(const v8::Arguments& args
10911091{
10921092 INC_STATS("DOM.TestObj.overloadedMethod1");
10931093 TestObj* imp = V8TestObj::toNative(args.Holder());
1094  EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[0]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0);
1095  STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[1]);
 1094 EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED)) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED))) : 0);
 1095 STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, MAYBE_MISSING_PARAMETER(args, 1, MISSING_IS_UNDEFINED));
10961096 imp->overloadedMethod(objArg, strArg);
10971097 return v8::Handle<v8::Value>();
10981098}

@@static v8::Handle<v8::Value> overloadedMethod2Callback(const v8::Arguments& args
11011101{
11021102 INC_STATS("DOM.TestObj.overloadedMethod2");
11031103 TestObj* imp = V8TestObj::toNative(args.Holder());
1104  EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(args[0]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0);
 1104 EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED)) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED))) : 0);
11051105 if (args.Length() <= 1) {
11061106 imp->overloadedMethod(objArg);
11071107 return v8::Handle<v8::Value>();
11081108 }
1109  EXCEPTION_BLOCK(int, intArg, toInt32(args[1]));
 1109 EXCEPTION_BLOCK(int, intArg, toInt32(MAYBE_MISSING_PARAMETER(args, 1, MISSING_IS_UNDEFINED)));
11101110 imp->overloadedMethod(objArg, intArg);
11111111 return v8::Handle<v8::Value>();
11121112}

@@static v8::Handle<v8::Value> overloadedMethod3Callback(const v8::Arguments& args
11151115{
11161116 INC_STATS("DOM.TestObj.overloadedMethod3");
11171117 TestObj* imp = V8TestObj::toNative(args.Holder());
1118  STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, args[0]);
 1118 STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED));
11191119 imp->overloadedMethod(strArg);
11201120 return v8::Handle<v8::Value>();
11211121}

@@static v8::Handle<v8::Value> overloadedMethod4Callback(const v8::Arguments& args
11241124{
11251125 INC_STATS("DOM.TestObj.overloadedMethod4");
11261126 TestObj* imp = V8TestObj::toNative(args.Holder());
1127  EXCEPTION_BLOCK(int, intArg, toInt32(args[0]));
 1127 EXCEPTION_BLOCK(int, intArg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED)));
11281128 imp->overloadedMethod(intArg);
11291129 return v8::Handle<v8::Value>();
11301130}

@@static v8::Handle<v8::Value> classMethodWithOptionalCallback(const v8::Arguments
11701170 if (args.Length() <= 0) {
11711171 return v8::Integer::New(TestObj::classMethodWithOptional());
11721172 }
1173  EXCEPTION_BLOCK(int, arg, toInt32(args[0]));
 1173 EXCEPTION_BLOCK(int, arg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED)));
11741174 return v8::Integer::New(TestObj::classMethodWithOptional(arg));
11751175}
11761176

@@static v8::Handle<v8::Value> enabledAtRuntimeMethod1Callback(const v8::Arguments
11781178{
11791179 INC_STATS("DOM.TestObj.enabledAtRuntimeMethod1");
11801180 TestObj* imp = V8TestObj::toNative(args.Holder());
1181  EXCEPTION_BLOCK(int, intArg, V8int::HasInstance(args[0]) ? V8int::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0);
 1181 EXCEPTION_BLOCK(int, intArg, V8int::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED)) ? V8int::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED))) : 0);
11821182 imp->enabledAtRuntimeMethod1(intArg);
11831183 return v8::Handle<v8::Value>();
11841184}

@@static v8::Handle<v8::Value> enabledAtRuntimeMethod2Callback(const v8::Arguments
11871187{
11881188 INC_STATS("DOM.TestObj.enabledAtRuntimeMethod2");
11891189 TestObj* imp = V8TestObj::toNative(args.Holder());
1190  EXCEPTION_BLOCK(int, intArg, V8int::HasInstance(args[0]) ? V8int::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0);
 1190 EXCEPTION_BLOCK(int, intArg, V8int::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED)) ? V8int::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, MISSING_IS_UNDEFINED))) : 0);
11911191 imp->enabledAtRuntimeMethod2(intArg);
11921192 return v8::Handle<v8::Value>();
11931193}

Source/WebCore/bindings/v8/V8Binding.h

@@namespace WebCore {
386386
387387 bool prepareBase()
388388 {
 389 if (m_v8Object.IsEmpty())
 390 return true;
 391
389392 if (LIKELY(m_v8Object->IsString()))
390393 return true;
391394

@@namespace WebCore {
402405 block.ReThrow();
403406 return false;
404407 }
405 
406  // This path is unexpected. However there is hypothesis that it
407  // might be combination of v8 and v8 bindings bugs. For now
408  // just bailout as we'll crash if attempt to convert empty handle into a string.
409  if (m_v8Object.IsEmpty()) {
410  ASSERT_NOT_REACHED();
411  return false;
412  }
413 
414408 return true;
415409 }
416410

@@namespace WebCore {
460454
461455 template<> inline bool V8Parameter<WithNullCheck>::prepare()
462456 {
463  if (object()->IsNull()) {
 457 if (object().IsEmpty() || object()->IsNull()) {
464458 setString(String());
465459 return true;
466460 }

@@namespace WebCore {
470464
471465 template<> inline bool V8Parameter<WithUndefinedOrNullCheck>::prepare()
472466 {
473  if (object()->IsNull() || object()->IsUndefined()) {
 467 if (object().IsEmpty() || object()->IsNull() || object()->IsUndefined()) {
474468 setString(String());
475469 return true;
476470 }

@@namespace WebCore {
478472 return V8ParameterBase::prepareBase();
479473 }
480474
 475 enum ParameterMissingPolicy {
 476 MISSING_IS_UNDEFINED,
 477 MISSING_IS_EMPTY
 478 };
 479
481480} // namespace WebCore
482481
483482#endif // V8Binding_h

Source/WebCore/bindings/v8/custom/V8BindingMacros.h

4646 type var(value); \
4747 if (!var.prepare()) \
4848 return;
 49
 50#define MAYBE_MISSING_PARAMETER(args, index, policy) \
 51 (((policy) == MISSING_IS_EMPTY && (index) >= (args).Length()) ? (v8::Local<v8::Value>()) : ((args)[(index)]))

Source/WebCore/bindings/v8/custom/V8WebKitCSSMatrixConstructor.cpp

1 /*
2  * Copyright (C) 2009 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  * * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #include "config.h"
32 #include "V8WebKitCSSMatrix.h"
33 
34 #include "Document.h"
35 #include "DocumentFragment.h"
36 #include "Node.h"
37 
38 #include "V8Binding.h"
39 #include "V8Document.h"
40 #include "V8Node.h"
41 #include "V8Proxy.h"
42 
43 #include <wtf/RefPtr.h>
44 
45 namespace WebCore {
46 
47 v8::Handle<v8::Value> V8WebKitCSSMatrix::constructorCallback(const v8::Arguments& args)
48 {
49  INC_STATS("DOM.WebKitCSSMatrix.Constructor");
50 
51  if (!args.IsConstructCall())
52  return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
53 
54  // FIXME: The logic here is almost exact duplicate of V8::constructDOMObject.
55  // Consider refactoring to reduce duplication.
56  String cssValue;
57  if (args.Length() >= 1)
58  cssValue = toWebCoreString(args[0]);
59 
60  ExceptionCode ec = 0;
61  RefPtr<WebKitCSSMatrix> matrix = WebKitCSSMatrix::create(cssValue, ec);
62  if (ec)
63  throwError(ec);
64 
65  // Transform the holder into a wrapper object for the matrix.
66  V8DOMWrapper::setDOMWrapper(args.Holder(), &info, matrix.get());
67  return toV8(matrix.release(), args.Holder());
68 }
69 
70 } // namespace WebCore

Source/WebCore/css/WebKitCSSMatrix.idl

@@module css {
3030 CanBeConstructed,
3131 CustomConstructFunction,
3232 ConstructorParameters=1,
33  V8CustomConstructor
 33 Constructor(in [Optional=CallWithNullValue] DOMString cssValue),
 34 ConstructorRaisesException,
3435 ] WebKitCSSMatrix {
3536
3637 // These attributes are simple aliases for certain elements of the 4x4 matrix