Diff
Modified: trunk/Source/WebCore/ChangeLog (117925 => 117926)
--- trunk/Source/WebCore/ChangeLog 2012-05-22 07:40:05 UTC (rev 117925)
+++ trunk/Source/WebCore/ChangeLog 2012-05-22 07:42:10 UTC (rev 117926)
@@ -1,3 +1,56 @@
+2012-05-22 Kentaro Hara <[email protected]>
+
+ [V8] setDOMException() should return v8::Handle<v8::Value>()
+ https://bugs.webkit.org/show_bug.cgi?id=87083
+
+ Reviewed by Adam Barth.
+
+ The following patterns are used here and there in V8 bindings:
+
+ setDOMException();
+ return v8::Handle<v8::Value>();
+
+ and
+
+ setDOMException();
+ return v8::Undefined();
+
+ By returning v8::Handle<v8::Value>() from setDOMException(), we can simplify the above patterns into this:
+
+ return setDOMException();
+
+ This patch just replaces the code in CodeGeneratorV8.pm. I'll replace
+ all other custom bindings in a follow-up patch.
+
+ No tests. No change in behavior.
+
+ * bindings/scripts/CodeGeneratorV8.pm:
+ (GenerateSetDOMException):
+ (GenerateFunctionCallback):
+ (GenerateFunctionCallString):
+ * bindings/scripts/test/V8/V8TestEventTarget.cpp:
+ (WebCore::TestEventTargetV8Internal::itemCallback):
+ (WebCore::TestEventTargetV8Internal::dispatchEventCallback):
+ * bindings/scripts/test/V8/V8TestInterface.cpp:
+ (WebCore::TestInterfaceV8Internal::supplementalMethod2Callback):
+ * bindings/scripts/test/V8/V8TestObj.cpp:
+ (WebCore::TestObjV8Internal::attrWithGetterExceptionAttrGetter):
+ (WebCore::TestObjV8Internal::stringAttrWithGetterExceptionAttrGetter):
+ (WebCore::TestObjV8Internal::withScriptStateAttributeRaisesAttrGetter):
+ (WebCore::TestObjV8Internal::withScriptExecutionContextAttributeRaisesAttrGetter):
+ (WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateAttributeRaisesAttrGetter):
+ (WebCore::TestObjV8Internal::methodThatRequiresAllArgsAndThrowsCallback):
+ (WebCore::TestObjV8Internal::methodWithExceptionCallback):
+ (WebCore::TestObjV8Internal::withScriptStateVoidExceptionCallback):
+ (WebCore::TestObjV8Internal::withScriptStateObjExceptionCallback):
+ (WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateObjExceptionCallback):
+ (WebCore::TestObjV8Internal::getSVGDocumentCallback):
+ (WebCore::TestObjV8Internal::strictFunctionCallback):
+ * bindings/v8/V8Proxy.cpp:
+ (WebCore::V8Proxy::setDOMException):
+ * bindings/v8/V8Proxy.h:
+ (V8Proxy):
+
2012-05-22 MORITA Hajime <[email protected]>
Unreviewed expectations update against r117989.
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (117925 => 117926)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2012-05-22 07:40:05 UTC (rev 117925)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2012-05-22 07:42:10 UTC (rev 117926)
@@ -650,11 +650,8 @@
my $getIsolate = shift;
my $result = "";
- $result .= $indent . "if (UNLIKELY(ec)) {\n";
- $result .= $indent . " V8Proxy::setDOMException(ec, $getIsolate);\n";
- $result .= $indent . " return v8::Handle<v8::Value>();\n";
- $result .= $indent . "}\n";
-
+ $result .= $indent . "if (UNLIKELY(ec))\n";
+ $result .= $indent . " return V8Proxy::setDOMException(ec, $getIsolate);\n";
return $result;
}
@@ -1408,10 +1405,8 @@
} else {
AddToImplIncludes("ExceptionCode.h");
push(@implContentDecls, " $nativeClassName wrapper = V8${implClassName}::toNative(args.Holder());\n");
- push(@implContentDecls, " if (wrapper->role() == AnimValRole) {\n");
- push(@implContentDecls, " V8Proxy::setDOMException(NO_MODIFICATION_ALLOWED_ERR, args.GetIsolate());\n");
- push(@implContentDecls, " return v8::Handle<v8::Value>();\n");
- push(@implContentDecls, " }\n");
+ push(@implContentDecls, " if (wrapper->role() == AnimValRole)\n");
+ push(@implContentDecls, " return V8Proxy::setDOMException(NO_MODIFICATION_ALLOWED_ERR, args.GetIsolate());\n");
my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearOff($implClassName);
push(@implContentDecls, " $svgWrappedNativeType& impInstance = wrapper->propertyReference();\n");
push(@implContentDecls, " $svgWrappedNativeType* imp = &impInstance;\n");
@@ -1466,8 +1461,7 @@
if ($raisesExceptions) {
push(@implContentDecls, " }\n");
push(@implContentDecls, " fail:\n");
- push(@implContentDecls, " V8Proxy::setDOMException(ec, args.GetIsolate());\n");
- push(@implContentDecls, " return v8::Handle<v8::Value>();\n");
+ push(@implContentDecls, " return V8Proxy::setDOMException(ec, args.GetIsolate());\n");
}
push(@implContentDecls, "}\n\n");
@@ -3333,10 +3327,8 @@
push @arguments, "$paramName.get()";
} elsif ($codeGenerator->IsSVGTypeNeedingTearOff($parameter->type) and not $implClassName =~ /List$/) {
push @arguments, "$paramName->propertyReference()";
- $result .= $indent . "if (!$paramName) {\n";
- $result .= $indent . " V8Proxy::setDOMException(WebCore::TYPE_MISMATCH_ERR, args.GetIsolate());\n";
- $result .= $indent . " return v8::Handle<v8::Value>();\n";
- $result .= $indent . "}\n";
+ $result .= $indent . "if (!$paramName)\n";
+ $result .= $indent . " return V8Proxy::setDOMException(WebCore::TYPE_MISMATCH_ERR, args.GetIsolate());\n";
} elsif ($parameter->type eq "SVGMatrix" and $implClassName eq "SVGTransformList") {
push @arguments, "$paramName.get()";
} else {
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.cpp (117925 => 117926)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.cpp 2012-05-22 07:40:05 UTC (rev 117925)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.cpp 2012-05-22 07:42:10 UTC (rev 117926)
@@ -59,8 +59,7 @@
return toV8(imp->item(index), args.GetIsolate());
}
fail:
- V8Proxy::setDOMException(ec, args.GetIsolate());
- return v8::Handle<v8::Value>();
+ return V8Proxy::setDOMException(ec, args.GetIsolate());
}
static v8::Handle<v8::Value> addEventListenerCallback(const v8::Arguments& args)
@@ -100,8 +99,7 @@
return v8Boolean(result);
}
fail:
- V8Proxy::setDOMException(ec, args.GetIsolate());
- return v8::Handle<v8::Value>();
+ return V8Proxy::setDOMException(ec, args.GetIsolate());
}
} // namespace TestEventTargetV8Internal
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp (117925 => 117926)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp 2012-05-22 07:40:05 UTC (rev 117925)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp 2012-05-22 07:42:10 UTC (rev 117926)
@@ -140,8 +140,7 @@
return toV8(result.release(), args.GetIsolate());
}
fail:
- V8Proxy::setDOMException(ec, args.GetIsolate());
- return v8::Handle<v8::Value>();
+ return V8Proxy::setDOMException(ec, args.GetIsolate());
}
#endif // ENABLE(Condition11) || ENABLE(Condition12)
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp (117925 => 117926)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp 2012-05-22 07:40:05 UTC (rev 117925)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp 2012-05-22 07:42:10 UTC (rev 117926)
@@ -626,10 +626,8 @@
TestObj* imp = V8TestObj::toNative(info.Holder());
ExceptionCode ec = 0;
int v = imp->attrWithGetterException(ec);
- if (UNLIKELY(ec)) {
- V8Proxy::setDOMException(ec, info.GetIsolate());
- return v8::Handle<v8::Value>();
- }
+ if (UNLIKELY(ec))
+ return V8Proxy::setDOMException(ec, info.GetIsolate());
return v8::Integer::New(v);
}
@@ -670,10 +668,8 @@
TestObj* imp = V8TestObj::toNative(info.Holder());
ExceptionCode ec = 0;
String v = imp->stringAttrWithGetterException(ec);
- if (UNLIKELY(ec)) {
- V8Proxy::setDOMException(ec, info.GetIsolate());
- return v8::Handle<v8::Value>();
- }
+ if (UNLIKELY(ec))
+ return V8Proxy::setDOMException(ec, info.GetIsolate());
return v8String(v, info.GetIsolate());
}
@@ -763,10 +759,8 @@
if (!state)
return v8::Undefined();
RefPtr<TestObj> v = imp->withScriptStateAttributeRaises(state, ec);
- if (UNLIKELY(ec)) {
- V8Proxy::setDOMException(ec, info.GetIsolate());
- return v8::Handle<v8::Value>();
- }
+ if (UNLIKELY(ec))
+ return V8Proxy::setDOMException(ec, info.GetIsolate());
if (state.hadException())
return throwError(state.exception(), info.GetIsolate());
return toV8(v.release(), info.GetIsolate());
@@ -798,10 +792,8 @@
if (!scriptContext)
return v8::Undefined();
RefPtr<TestObj> v = imp->withScriptExecutionContextAttributeRaises(scriptContext, ec);
- if (UNLIKELY(ec)) {
- V8Proxy::setDOMException(ec, info.GetIsolate());
- return v8::Handle<v8::Value>();
- }
+ if (UNLIKELY(ec))
+ return V8Proxy::setDOMException(ec, info.GetIsolate());
return toV8(v.release(), info.GetIsolate());
}
@@ -862,10 +854,8 @@
if (!scriptContext)
return v8::Undefined();
RefPtr<TestObj> v = imp->withScriptExecutionContextAndScriptStateAttributeRaises(state, scriptContext, ec);
- if (UNLIKELY(ec)) {
- V8Proxy::setDOMException(ec, info.GetIsolate());
- return v8::Handle<v8::Value>();
- }
+ if (UNLIKELY(ec))
+ return V8Proxy::setDOMException(ec, info.GetIsolate());
if (state.hadException())
return throwError(state.exception(), info.GetIsolate());
return toV8(v.release(), info.GetIsolate());
@@ -1347,8 +1337,7 @@
return toV8(result.release(), args.GetIsolate());
}
fail:
- V8Proxy::setDOMException(ec, args.GetIsolate());
- return v8::Handle<v8::Value>();
+ return V8Proxy::setDOMException(ec, args.GetIsolate());
}
static v8::Handle<v8::Value> serializedValueCallback(const v8::Arguments& args)
@@ -1410,8 +1399,7 @@
return v8::Handle<v8::Value>();
}
fail:
- V8Proxy::setDOMException(ec, args.GetIsolate());
- return v8::Handle<v8::Value>();
+ return V8Proxy::setDOMException(ec, args.GetIsolate());
}
static v8::Handle<v8::Value> addEventListenerCallback(const v8::Arguments& args)
@@ -1473,8 +1461,7 @@
return v8::Handle<v8::Value>();
}
fail:
- V8Proxy::setDOMException(ec, args.GetIsolate());
- return v8::Handle<v8::Value>();
+ return V8Proxy::setDOMException(ec, args.GetIsolate());
}
static v8::Handle<v8::Value> withScriptStateObjExceptionCallback(const v8::Arguments& args)
@@ -1492,8 +1479,7 @@
return toV8(result.release(), args.GetIsolate());
}
fail:
- V8Proxy::setDOMException(ec, args.GetIsolate());
- return v8::Handle<v8::Value>();
+ return V8Proxy::setDOMException(ec, args.GetIsolate());
}
static v8::Handle<v8::Value> withScriptExecutionContextCallback(const v8::Arguments& args)
@@ -1539,8 +1525,7 @@
return toV8(result.release(), args.GetIsolate());
}
fail:
- V8Proxy::setDOMException(ec, args.GetIsolate());
- return v8::Handle<v8::Value>();
+ return V8Proxy::setDOMException(ec, args.GetIsolate());
}
static v8::Handle<v8::Value> withScriptExecutionContextAndScriptStateWithSpacesCallback(const v8::Arguments& args)
@@ -1928,8 +1913,7 @@
return toV8(result.release(), args.GetIsolate());
}
fail:
- V8Proxy::setDOMException(ec, args.GetIsolate());
- return v8::Handle<v8::Value>();
+ return V8Proxy::setDOMException(ec, args.GetIsolate());
}
static v8::Handle<v8::Value> convert1Callback(const v8::Arguments& args)
@@ -2026,8 +2010,7 @@
return toV8(result.release(), args.GetIsolate());
}
fail:
- V8Proxy::setDOMException(ec, args.GetIsolate());
- return v8::Handle<v8::Value>();
+ return V8Proxy::setDOMException(ec, args.GetIsolate());
}
} // namespace TestObjV8Internal
Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.cpp (117925 => 117926)
--- trunk/Source/WebCore/bindings/v8/V8Proxy.cpp 2012-05-22 07:40:05 UTC (rev 117925)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.cpp 2012-05-22 07:42:10 UTC (rev 117926)
@@ -586,10 +586,10 @@
exception = toV8(interfaceName::create(description), isolate); \
break;
-void V8Proxy::setDOMException(int ec, v8::Isolate* isolate)
+v8::Handle<v8::Value> V8Proxy::setDOMException(int ec, v8::Isolate* isolate)
{
if (ec <= 0)
- return;
+ return v8::Handle<v8::Value>();
ExceptionCodeDescription description(ec);
@@ -599,7 +599,7 @@
}
if (exception.IsEmpty())
- return;
+ return v8::Handle<v8::Value>();
// Attach an Error object to the DOMException. This is then lazily used to get the stack value.
v8::Handle<v8::Value> error = v8::Exception::Error(v8String(description.description, isolate));
@@ -607,7 +607,7 @@
ASSERT(exception->IsObject());
exception->ToObject()->SetAccessor(v8String("stack", isolate), DOMExceptionStackGetter, DOMExceptionStackSetter, error);
- v8::ThrowException(exception);
+ return v8::ThrowException(exception);
}
#undef TRY_TO_CREATE_EXCEPTION
Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.h (117925 => 117926)
--- trunk/Source/WebCore/bindings/v8/V8Proxy.h 2012-05-22 07:40:05 UTC (rev 117925)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.h 2012-05-22 07:42:10 UTC (rev 117926)
@@ -234,7 +234,7 @@
// If the exception code is different from zero, a DOM exception is
// schedule to be thrown.
- static void setDOMException(int exceptionCode, v8::Isolate*);
+ static v8::Handle<v8::Value> setDOMException(int exceptionCode, v8::Isolate*);
// Schedule an error object to be thrown.
static v8::Handle<v8::Value> throwError(ErrorType, const char* message, v8::Isolate* = 0);