Diff
Modified: trunk/Source/WebCore/ChangeLog (117447 => 117448)
--- trunk/Source/WebCore/ChangeLog 2012-05-17 14:21:41 UTC (rev 117447)
+++ trunk/Source/WebCore/ChangeLog 2012-05-17 15:17:20 UTC (rev 117448)
@@ -1,3 +1,51 @@
+2012-05-17 Kentaro Hara <hara...@chromium.org>
+
+ [V8][Refactoring] Support an optional 'message' argument for throwTypeError()
+ https://bugs.webkit.org/show_bug.cgi?id=86576
+
+ Reviewed by Adam Barth.
+
+ As commented in https://bugs.webkit.org/show_bug.cgi?id=84074#c5,
+ I am planning to refactor a series of confusing throwError()s into
+ throwError() and throwTypeError().
+
+ This patch supports an optional 'message' argument for V8Proxy::throwTypeError().
+ Also this patch replaces throwError("message", V8Proxy::TypeError) in custom bindings
+ with V8Proxy::throwTypeError("message").
+
+ No tests. No change in behavior.
+
+ * bindings/v8/V8Proxy.cpp:
+ (WebCore::V8Proxy::throwTypeError):
+ * bindings/v8/V8Proxy.h:
+ (V8Proxy):
+ * bindings/v8/custom/V8ArrayBufferViewCustom.h:
+ (WebCore::constructWebGLArray):
+ * bindings/v8/custom/V8AudioContextCustom.cpp:
+ (WebCore::V8AudioContext::constructorCallback):
+ * bindings/v8/custom/V8BlobCustom.cpp:
+ (WebCore::V8Blob::constructorCallback):
+ * bindings/v8/custom/V8DOMFormDataCustom.cpp:
+ (WebCore::V8DOMFormData::constructorCallback):
+ * bindings/v8/custom/V8DataViewCustom.cpp:
+ (WebCore::V8DataView::constructorCallback):
+ * bindings/v8/custom/V8HTMLImageElementConstructor.cpp:
+ (WebCore::v8HTMLImageElementConstructorCallback):
+ * bindings/v8/custom/V8IntentConstructor.cpp:
+ (WebCore::V8Intent::constructorCallback):
+ * bindings/v8/custom/V8MessageChannelConstructor.cpp:
+ (WebCore::V8MessageChannel::constructorCallback):
+ * bindings/v8/custom/V8NotificationCenterCustom.cpp:
+ (WebCore::V8NotificationCenter::requestPermissionCallback):
+ * bindings/v8/custom/V8WebKitMutationObserverCustom.cpp:
+ (WebCore::V8WebKitMutationObserver::constructorCallback):
+ * bindings/v8/custom/V8WebKitPointConstructor.cpp:
+ (WebCore::V8WebKitPoint::constructorCallback):
+ * bindings/v8/custom/V8WebSocketCustom.cpp:
+ (WebCore::V8WebSocket::constructorCallback):
+ * bindings/v8/custom/V8XMLHttpRequestConstructor.cpp:
+ (WebCore::V8XMLHttpRequest::constructorCallback):
+
2012-05-16 Andrey Kosyakov <ca...@chromium.org>
Web Inspector: [Extensions API] pages shown in sidebar are limited in height to 150px
Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.cpp (117447 => 117448)
--- trunk/Source/WebCore/bindings/v8/V8Proxy.cpp 2012-05-17 14:21:41 UTC (rev 117447)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.cpp 2012-05-17 15:17:20 UTC (rev 117448)
@@ -609,9 +609,9 @@
}
}
-v8::Handle<v8::Value> V8Proxy::throwTypeError()
+v8::Handle<v8::Value> V8Proxy::throwTypeError(const char* message)
{
- return throwError(TypeError, "Type error");
+ return throwError(TypeError, (message ? message : "Type error"));
}
v8::Handle<v8::Value> V8Proxy::throwNotEnoughArgumentsError()
Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.h (117447 => 117448)
--- trunk/Source/WebCore/bindings/v8/V8Proxy.h 2012-05-17 14:21:41 UTC (rev 117447)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.h 2012-05-17 15:17:20 UTC (rev 117448)
@@ -239,7 +239,7 @@
static v8::Handle<v8::Value> throwError(ErrorType, const char* message, v8::Isolate* = 0);
// Helpers for throwing syntax and type errors with predefined messages.
- static v8::Handle<v8::Value> throwTypeError();
+ static v8::Handle<v8::Value> throwTypeError(const char* = 0);
static v8::Handle<v8::Value> throwNotEnoughArgumentsError();
v8::Local<v8::Context> context();
Modified: trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h (117447 => 117448)
--- trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h 2012-05-17 14:21:41 UTC (rev 117447)
+++ trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h 2012-05-17 15:17:20 UTC (rev 117448)
@@ -99,7 +99,7 @@
v8::Handle<v8::Value> constructWebGLArray(const v8::Arguments& args, WrapperTypeInfo* type, v8::ExternalArrayType arrayType)
{
if (!args.IsConstructCall())
- return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
+ return V8Proxy::throwTypeError("DOM object constructor cannot be called as a function.");
if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
return args.Holder();
Modified: trunk/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp (117447 => 117448)
--- trunk/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp 2012-05-17 14:21:41 UTC (rev 117447)
+++ trunk/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp 2012-05-17 15:17:20 UTC (rev 117448)
@@ -44,7 +44,7 @@
INC_STATS("DOM.AudioContext.Contructor");
if (!args.IsConstructCall())
- return throwError("AudioContext constructor cannot be called as a function.", V8Proxy::TypeError);
+ return V8Proxy::throwTypeError("AudioContext constructor cannot be called as a function.");
if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
return args.Holder();
Modified: trunk/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp (117447 => 117448)
--- trunk/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp 2012-05-17 14:21:41 UTC (rev 117447)
+++ trunk/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp 2012-05-17 15:17:20 UTC (rev 117448)
@@ -60,7 +60,7 @@
INC_STATS("DOM.Blob.Constructor");
if (!args.IsConstructCall())
- return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
+ return V8Proxy::throwTypeError("DOM object constructor cannot be called as a function.");
if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
return args.Holder();
@@ -77,14 +77,14 @@
v8::Local<v8::Value> firstArg = args[0];
if (!firstArg->IsArray())
- return throwError("First argument of the constructor is not of type Array", V8Proxy::TypeError);
+ return V8Proxy::throwTypeError("First argument of the constructor is not of type Array");
String type;
String endings = "transparent";
if (args.Length() > 1) {
if (!args[1]->IsObject())
- return throwError("Second argument of the constructor is not of type Object", V8Proxy::TypeError);
+ return V8Proxy::throwTypeError("Second argument of the constructor is not of type Object");
Dictionary dictionary(args[1]);
@@ -95,7 +95,7 @@
if (containsEndings) {
if (endings != "transparent" && endings != "native")
- return throwError("The endings property must be either \"transparent\" or \"native\"", V8Proxy::TypeError);
+ return V8Proxy::throwTypeError("The endings property must be either \"transparent\" or \"native\"");
}
v8::TryCatch tryCatchType;
Modified: trunk/Source/WebCore/bindings/v8/custom/V8DOMFormDataCustom.cpp (117447 => 117448)
--- trunk/Source/WebCore/bindings/v8/custom/V8DOMFormDataCustom.cpp 2012-05-17 14:21:41 UTC (rev 117447)
+++ trunk/Source/WebCore/bindings/v8/custom/V8DOMFormDataCustom.cpp 2012-05-17 15:17:20 UTC (rev 117448)
@@ -45,7 +45,7 @@
INC_STATS("DOM.FormData.Constructor");
if (!args.IsConstructCall())
- return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
+ return V8Proxy::throwTypeError("DOM object constructor cannot be called as a function.");
if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
return args.Holder();
Modified: trunk/Source/WebCore/bindings/v8/custom/V8DataViewCustom.cpp (117447 => 117448)
--- trunk/Source/WebCore/bindings/v8/custom/V8DataViewCustom.cpp 2012-05-17 14:21:41 UTC (rev 117447)
+++ trunk/Source/WebCore/bindings/v8/custom/V8DataViewCustom.cpp 2012-05-17 15:17:20 UTC (rev 117448)
@@ -39,7 +39,7 @@
INC_STATS("DOM.DataView.Constructor");
if (!args.IsConstructCall())
- return throwError("DOM object constructor cannot be called as a function", V8Proxy::TypeError);
+ return V8Proxy::throwTypeError("DOM object constructor cannot be called as a function");
if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
return args.Holder();
Modified: trunk/Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp (117447 => 117448)
--- trunk/Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp 2012-05-17 14:21:41 UTC (rev 117447)
+++ trunk/Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp 2012-05-17 15:17:20 UTC (rev 117448)
@@ -51,7 +51,7 @@
INC_STATS("DOM.HTMLImageElement.Contructor");
if (!args.IsConstructCall())
- return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
+ return V8Proxy::throwTypeError("DOM object constructor cannot be called as a function.");
if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
return args.Holder();
Modified: trunk/Source/WebCore/bindings/v8/custom/V8IntentConstructor.cpp (117447 => 117448)
--- trunk/Source/WebCore/bindings/v8/custom/V8IntentConstructor.cpp 2012-05-17 14:21:41 UTC (rev 117447)
+++ trunk/Source/WebCore/bindings/v8/custom/V8IntentConstructor.cpp 2012-05-17 15:17:20 UTC (rev 117448)
@@ -48,7 +48,7 @@
INC_STATS("DOM.Intent.Constructor");
if (!args.IsConstructCall())
- return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
+ return V8Proxy::throwTypeError("DOM object constructor cannot be called as a function.");
if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
return args.Holder();
@@ -76,7 +76,7 @@
ArrayBufferArray arrayBufferArrayTransferList;
if (args.Length() > 3) {
if (!extractTransferables(args[3], messagePortArrayTransferList, arrayBufferArrayTransferList))
- return throwError("Could not extract transferables", V8Proxy::TypeError);
+ return V8Proxy::throwTypeError("Could not extract transferables");
}
bool dataDidThrow = false;
RefPtr<SerializedScriptValue> data = "" &messagePortArrayTransferList, &arrayBufferArrayTransferList, dataDidThrow);
Modified: trunk/Source/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp (117447 => 117448)
--- trunk/Source/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp 2012-05-17 14:21:41 UTC (rev 117447)
+++ trunk/Source/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp 2012-05-17 15:17:20 UTC (rev 117448)
@@ -51,7 +51,7 @@
// FIXME: The logic here is almost exact duplicate of V8::constructDOMObject.
// Consider refactoring to reduce duplication.
if (!args.IsConstructCall())
- return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
+ return V8Proxy::throwTypeError("DOM object constructor cannot be called as a function.");
if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
return args.Holder();
Modified: trunk/Source/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp (117447 => 117448)
--- trunk/Source/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp 2012-05-17 14:21:41 UTC (rev 117447)
+++ trunk/Source/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp 2012-05-17 15:17:20 UTC (rev 117448)
@@ -95,7 +95,7 @@
RefPtr<V8CustomVoidCallback> callback;
if (args.Length() > 0) {
if (!args[0]->IsObject())
- return throwError("Callback must be of valid type.", V8Proxy::TypeError);
+ return V8Proxy::throwTypeError("Callback must be of valid type.");
callback = V8CustomVoidCallback::create(args[0], context);
}
Modified: trunk/Source/WebCore/bindings/v8/custom/V8WebKitMutationObserverCustom.cpp (117447 => 117448)
--- trunk/Source/WebCore/bindings/v8/custom/V8WebKitMutationObserverCustom.cpp 2012-05-17 14:21:41 UTC (rev 117447)
+++ trunk/Source/WebCore/bindings/v8/custom/V8WebKitMutationObserverCustom.cpp 2012-05-17 15:17:20 UTC (rev 117448)
@@ -55,7 +55,7 @@
INC_STATS("DOM.WebKitMutationObserver.Constructor");
if (!args.IsConstructCall())
- return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
+ return V8Proxy::throwTypeError("DOM object constructor cannot be called as a function.");
if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
return args.Holder();
Modified: trunk/Source/WebCore/bindings/v8/custom/V8WebKitPointConstructor.cpp (117447 => 117448)
--- trunk/Source/WebCore/bindings/v8/custom/V8WebKitPointConstructor.cpp 2012-05-17 14:21:41 UTC (rev 117447)
+++ trunk/Source/WebCore/bindings/v8/custom/V8WebKitPointConstructor.cpp 2012-05-17 15:17:20 UTC (rev 117448)
@@ -45,7 +45,7 @@
INC_STATS("DOM.WebKitPoint.Constructor");
if (!args.IsConstructCall())
- return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
+ return V8Proxy::throwTypeError("DOM object constructor cannot be called as a function.");
if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
return args.Holder();
Modified: trunk/Source/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp (117447 => 117448)
--- trunk/Source/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp 2012-05-17 14:21:41 UTC (rev 117447)
+++ trunk/Source/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp 2012-05-17 15:17:20 UTC (rev 117448)
@@ -56,7 +56,7 @@
INC_STATS("DOM.WebSocket.Constructor");
if (!args.IsConstructCall())
- return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
+ return V8Proxy::throwTypeError("DOM object constructor cannot be called as a function.");
if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
return args.Holder();
Modified: trunk/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp (117447 => 117448)
--- trunk/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp 2012-05-17 14:21:41 UTC (rev 117447)
+++ trunk/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp 2012-05-17 15:17:20 UTC (rev 117448)
@@ -48,7 +48,7 @@
INC_STATS("DOM.XMLHttpRequest.Constructor");
if (!args.IsConstructCall())
- return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
+ return V8Proxy::throwTypeError("DOM object constructor cannot be called as a function.");
if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
return args.Holder();