Title: [117383] trunk/Source/WebCore
Revision
117383
Author
hara...@chromium.org
Date
2012-05-16 20:14:09 -0700 (Wed, 16 May 2012)

Log Message

[V8][Refactoring] Replace throwError("message", XXXError)
with throwError(XXXError, "message")
https://bugs.webkit.org/show_bug.cgi?id=86579

Reviewed by Adam Barth.

This is one of a series of refactoring commented in
https://bugs.webkit.org/show_bug.cgi?id=84074#c5

Currently there are two equivalent throwError()s; i.e. throwError("message", XXXError)
and throwError(XXXError, "message"). In this bug we replace
throwError("message", XXXError) with throwError(XXXError, "message")
(except for the case where XXXError == TypeError. This is because
throwError("message", TypeError) will be replaced with throwTypeError("message")
in a follow-up patch).

No tests. No change in behavior.

* bindings/v8/V8NPObject.cpp:
(WebCore::npObjectInvokeImpl):
(WebCore::npObjectGetProperty):
(WebCore::npObjectSetProperty):
(WebCore::npObjectPropertyEnumerator):
* bindings/v8/V8Proxy.cpp:
(WebCore::handleMaxRecursionDepthExceeded):
* bindings/v8/custom/V8ArrayBufferCustom.cpp:
(WebCore::V8ArrayBuffer::constructorCallback):
* bindings/v8/custom/V8ArrayBufferViewCustom.h:
(WebCore::constructWebGLArrayWithArrayBufferArgument):
(WebCore::constructWebGLArray):
* bindings/v8/custom/V8AudioContextCustom.cpp:
(WebCore::V8AudioContext::constructorCallback):
* bindings/v8/custom/V8BlobCustom.cpp:
(WebCore::V8Blob::constructorCallback):
* bindings/v8/custom/V8ClipboardCustom.cpp:
(WebCore::V8Clipboard::clearDataCallback):
(WebCore::V8Clipboard::setDragImageCallback):
* bindings/v8/custom/V8DOMFormDataCustom.cpp:
(WebCore::V8DOMFormData::appendCallback):
* bindings/v8/custom/V8HTMLImageElementConstructor.cpp:
(WebCore::v8HTMLImageElementConstructorCallback):
* bindings/v8/custom/V8WebKitMutationObserverCustom.cpp:
(WebCore::V8WebKitMutationObserver::constructorCallback):
* bindings/v8/custom/V8WebSocketCustom.cpp:
(WebCore::V8WebSocket::constructorCallback):
* bindings/v8/custom/V8XMLHttpRequestConstructor.cpp:
(WebCore::V8XMLHttpRequest::constructorCallback):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (117382 => 117383)


--- trunk/Source/WebCore/ChangeLog	2012-05-17 02:59:02 UTC (rev 117382)
+++ trunk/Source/WebCore/ChangeLog	2012-05-17 03:14:09 UTC (rev 117383)
@@ -1,5 +1,55 @@
 2012-05-16  Kentaro Hara  <hara...@chromium.org>
 
+        [V8][Refactoring] Replace throwError("message", XXXError)
+        with throwError(XXXError, "message")
+        https://bugs.webkit.org/show_bug.cgi?id=86579
+
+        Reviewed by Adam Barth.
+
+        This is one of a series of refactoring commented in
+        https://bugs.webkit.org/show_bug.cgi?id=84074#c5
+
+        Currently there are two equivalent throwError()s; i.e. throwError("message", XXXError)
+        and throwError(XXXError, "message"). In this bug we replace
+        throwError("message", XXXError) with throwError(XXXError, "message")
+        (except for the case where XXXError == TypeError. This is because
+        throwError("message", TypeError) will be replaced with throwTypeError("message")
+        in a follow-up patch).
+
+        No tests. No change in behavior.
+
+        * bindings/v8/V8NPObject.cpp:
+        (WebCore::npObjectInvokeImpl):
+        (WebCore::npObjectGetProperty):
+        (WebCore::npObjectSetProperty):
+        (WebCore::npObjectPropertyEnumerator):
+        * bindings/v8/V8Proxy.cpp:
+        (WebCore::handleMaxRecursionDepthExceeded):
+        * bindings/v8/custom/V8ArrayBufferCustom.cpp:
+        (WebCore::V8ArrayBuffer::constructorCallback):
+        * bindings/v8/custom/V8ArrayBufferViewCustom.h:
+        (WebCore::constructWebGLArrayWithArrayBufferArgument):
+        (WebCore::constructWebGLArray):
+        * bindings/v8/custom/V8AudioContextCustom.cpp:
+        (WebCore::V8AudioContext::constructorCallback):
+        * bindings/v8/custom/V8BlobCustom.cpp:
+        (WebCore::V8Blob::constructorCallback):
+        * bindings/v8/custom/V8ClipboardCustom.cpp:
+        (WebCore::V8Clipboard::clearDataCallback):
+        (WebCore::V8Clipboard::setDragImageCallback):
+        * bindings/v8/custom/V8DOMFormDataCustom.cpp:
+        (WebCore::V8DOMFormData::appendCallback):
+        * bindings/v8/custom/V8HTMLImageElementConstructor.cpp:
+        (WebCore::v8HTMLImageElementConstructorCallback):
+        * bindings/v8/custom/V8WebKitMutationObserverCustom.cpp:
+        (WebCore::V8WebKitMutationObserver::constructorCallback):
+        * bindings/v8/custom/V8WebSocketCustom.cpp:
+        (WebCore::V8WebSocket::constructorCallback):
+        * bindings/v8/custom/V8XMLHttpRequestConstructor.cpp:
+        (WebCore::V8XMLHttpRequest::constructorCallback):
+
+2012-05-16  Kentaro Hara  <hara...@chromium.org>
+
         [V8] Pass Isolate to remaining toV8()
         https://bugs.webkit.org/show_bug.cgi?id=86570
 

Modified: trunk/Source/WebCore/bindings/v8/V8NPObject.cpp (117382 => 117383)


--- trunk/Source/WebCore/bindings/v8/V8NPObject.cpp	2012-05-17 02:59:02 UTC (rev 117382)
+++ trunk/Source/WebCore/bindings/v8/V8NPObject.cpp	2012-05-17 03:14:09 UTC (rev 117383)
@@ -92,14 +92,14 @@
         // The holder object is not a subtype of HTMLPlugInElement, it must be an NPObject which has three
         // internal fields.
         if (args.Holder()->InternalFieldCount() != npObjectInternalFieldCount)
-          return throwError("NPMethod called on non-NPObject", V8Proxy::ReferenceError);
+            return V8Proxy::throwError(V8Proxy::ReferenceError, "NPMethod called on non-NPObject");
 
         npObject = v8ObjectToNPObject(args.Holder());
     }
 
     // Verify that our wrapper wasn't using a NPObject which has already been deleted.
     if (!npObject || !_NPN_IsAlive(npObject))
-        return throwError("NPObject deleted", V8Proxy::ReferenceError);
+        return V8Proxy::throwError(V8Proxy::ReferenceError, "NPObject deleted");
 
     // Wrap up parameters.
     int numArgs = args.Length();
@@ -133,7 +133,7 @@
     }
 
     if (!retval)
-        throwError("Error calling method on NPObject.", V8Proxy::GeneralError);
+        V8Proxy::throwError(V8Proxy::GeneralError, "Error calling method on NPObject.");
 
     for (int i = 0; i < numArgs; i++)
         _NPN_ReleaseVariantValue(&npArgs[i]);
@@ -190,12 +190,12 @@
     // Verify that our wrapper wasn't using a NPObject which
     // has already been deleted.
     if (!npObject || !_NPN_IsAlive(npObject))
-        return throwError("NPObject deleted", V8Proxy::ReferenceError);
+        return V8Proxy::throwError(V8Proxy::ReferenceError, "NPObject deleted");
 
 
     if (npObject->_class->hasProperty && npObject->_class->getProperty && npObject->_class->hasProperty(npObject, identifier)) {
         if (!_NPN_IsAlive(npObject))
-            return throwError("NPObject deleted", V8Proxy::ReferenceError);
+            return V8Proxy::throwError(V8Proxy::ReferenceError, "NPObject deleted");
 
         NPVariant result;
         VOID_TO_NPVARIANT(result);
@@ -211,11 +211,11 @@
     }
 
     if (!_NPN_IsAlive(npObject))
-        return throwError("NPObject deleted", V8Proxy::ReferenceError);
+        return V8Proxy::throwError(V8Proxy::ReferenceError, "NPObject deleted");
 
     if (key->IsString() && npObject->_class->hasMethod && npObject->_class->hasMethod(npObject, identifier)) {
         if (!_NPN_IsAlive(npObject))
-            return throwError("NPObject deleted", V8Proxy::ReferenceError);
+            return V8Proxy::throwError(V8Proxy::ReferenceError, "NPObject deleted");
 
         PrivateIdentifier* id = static_cast<PrivateIdentifier*>(identifier);
         v8::Persistent<v8::FunctionTemplate> functionTemplate = staticTemplateMap().get(id);
@@ -273,13 +273,13 @@
 
     // Verify that our wrapper wasn't using a NPObject which has already been deleted.
     if (!npObject || !_NPN_IsAlive(npObject)) {
-        throwError("NPObject deleted", V8Proxy::ReferenceError);
+        V8Proxy::throwError(V8Proxy::ReferenceError, "NPObject deleted");
         return value;  // Intercepted, but an exception was thrown.
     }
 
     if (npObject->_class->hasProperty && npObject->_class->setProperty && npObject->_class->hasProperty(npObject, identifier)) {
         if (!_NPN_IsAlive(npObject))
-            return throwError("NPObject deleted", V8Proxy::ReferenceError);
+            return V8Proxy::throwError(V8Proxy::ReferenceError, "NPObject deleted");
 
         NPVariant npValue;
         VOID_TO_NPVARIANT(npValue);
@@ -325,7 +325,7 @@
     // Verify that our wrapper wasn't using a NPObject which
     // has already been deleted.
     if (!npObject || !_NPN_IsAlive(npObject))
-        throwError("NPObject deleted", V8Proxy::ReferenceError);
+        V8Proxy::throwError(V8Proxy::ReferenceError, "NPObject deleted");
 
     if (NP_CLASS_STRUCT_VERSION_HAS_ENUM(npObject->_class) && npObject->_class->enumerate) {
         uint32_t count;

Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.cpp (117382 => 117383)


--- trunk/Source/WebCore/bindings/v8/V8Proxy.cpp	2012-05-17 02:59:02 UTC (rev 117382)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.cpp	2012-05-17 03:14:09 UTC (rev 117383)
@@ -160,7 +160,7 @@
 
 static v8::Local<v8::Value> handleMaxRecursionDepthExceeded()
 {
-    throwError("Maximum call stack size exceeded.", V8Proxy::RangeError);
+    V8Proxy::throwError(V8Proxy::RangeError, "Maximum call stack size exceeded.");
     return v8::Local<v8::Value>();
 }
 

Modified: trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp (117382 => 117383)


--- trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp	2012-05-17 02:59:02 UTC (rev 117382)
+++ trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp	2012-05-17 03:14:09 UTC (rev 117383)
@@ -70,7 +70,7 @@
     if (length >= 0)
         buffer = ArrayBuffer::create(static_cast<unsigned>(length), 1);
     if (!buffer.get())
-        return throwError("ArrayBuffer size is not a small enough positive integer.", V8Proxy::RangeError);
+        return V8Proxy::throwError(V8Proxy::RangeError, "ArrayBuffer size is not a small enough positive integer.");
     // Transform the holder into a wrapper object for the array.
     V8DOMWrapper::setDOMWrapper(args.Holder(), &info, buffer.get());
     V8DOMWrapper::setJSWrapperForDOMObject(buffer.release(), v8::Persistent<v8::Object>::New(args.Holder()));

Modified: trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h (117382 => 117383)


--- trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h	2012-05-17 02:59:02 UTC (rev 117382)
+++ trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h	2012-05-17 03:14:09 UTC (rev 117383)
@@ -76,7 +76,7 @@
             return throwError("Could not convert argument 2 to a number");
     } else {
         if ((buf->byteLength() - offset) % sizeof(ElementType))
-            return throwError("ArrayBuffer length minus the byteOffset is not a multiple of the element size.", V8Proxy::RangeError);
+            return V8Proxy::throwError(V8Proxy::RangeError, "ArrayBuffer length minus the byteOffset is not a multiple of the element size.");
         length = (buf->byteLength() - offset) / sizeof(ElementType);
     }
     RefPtr<ArrayClass> array = ArrayClass::create(buf, offset, length);
@@ -169,7 +169,7 @@
     if (doInstantiation)
         array = ArrayClass::create(len);
     if (!array.get())
-        return throwError("ArrayBufferView size is not a small enough positive integer.", V8Proxy::RangeError);
+        return V8Proxy::throwError(V8Proxy::RangeError, "ArrayBufferView size is not a small enough positive integer.");
 
 
     // Transform the holder into a wrapper object for the array.

Modified: trunk/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp (117382 => 117383)


--- trunk/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp	2012-05-17 02:59:02 UTC (rev 117382)
+++ trunk/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp	2012-05-17 03:14:09 UTC (rev 117383)
@@ -51,11 +51,11 @@
 
     Frame* frame = V8Proxy::retrieveFrameForCurrentContext();
     if (!frame)
-        return throwError("AudioContext constructor associated frame is unavailable", V8Proxy::ReferenceError);
+        return V8Proxy::throwError(V8Proxy::ReferenceError, "AudioContext constructor associated frame is unavailable");
 
     Document* document = frame->document();
     if (!document)
-        return throwError("AudioContext constructor associated document is unavailable", V8Proxy::ReferenceError);
+        return V8Proxy::throwError(V8Proxy::ReferenceError, "AudioContext constructor associated document is unavailable");
 
     RefPtr<AudioContext> audioContext;
     
@@ -66,7 +66,7 @@
         if (ec)
             return throwError(ec);
         if (!audioContext.get())
-            return throwError("audio resources unavailable for AudioContext construction", V8Proxy::SyntaxError);
+            return V8Proxy::throwError(V8Proxy::SyntaxError, "audio resources unavailable for AudioContext construction");
     } else {
         // Constructor for offline (render-target) AudioContext which renders into an AudioBuffer.
         // new AudioContext(in unsigned long numberOfChannels, in unsigned long numberOfFrames, in float sampleRate);
@@ -77,15 +77,15 @@
 
         int32_t numberOfChannels = toInt32(args[0], ok);
         if (!ok || numberOfChannels <= 0 || numberOfChannels > 10)
-            return throwError("Invalid number of channels", V8Proxy::SyntaxError);
+            return V8Proxy::throwError(V8Proxy::SyntaxError, "Invalid number of channels");
 
         int32_t numberOfFrames = toInt32(args[1], ok);
         if (!ok || numberOfFrames <= 0)
-            return throwError("Invalid number of frames", V8Proxy::SyntaxError);
+            return V8Proxy::throwError(V8Proxy::SyntaxError, "Invalid number of frames");
 
         float sampleRate = toFloat(args[2]);
         if (sampleRate <= 0)
-            return throwError("Invalid sample rate", V8Proxy::SyntaxError);
+            return V8Proxy::throwError(V8Proxy::SyntaxError, "Invalid sample rate");
 
         ExceptionCode ec = 0;
         audioContext = AudioContext::createOfflineContext(document, numberOfChannels, numberOfFrames, sampleRate, ec);
@@ -94,7 +94,7 @@
     }
 
     if (!audioContext.get())
-        return throwError("Error creating AudioContext", V8Proxy::SyntaxError);
+        return V8Proxy::throwError(V8Proxy::SyntaxError, "Error creating AudioContext");
     
     // Transform the holder into a wrapper object for the audio context.
     V8DOMWrapper::setDOMWrapper(args.Holder(), &info, audioContext.get());

Modified: trunk/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp (117382 => 117383)


--- trunk/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp	2012-05-17 02:59:02 UTC (rev 117382)
+++ trunk/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp	2012-05-17 03:14:09 UTC (rev 117383)
@@ -68,7 +68,7 @@
     // Get the script execution context.
     ScriptExecutionContext* context = getScriptExecutionContext();
     if (!context)
-        return throwError("Blob constructor associated document is unavailable", V8Proxy::ReferenceError);
+        return V8Proxy::throwError(V8Proxy::ReferenceError, "Blob constructor associated document is unavailable");
 
     if (!args.Length()) {
         RefPtr<Blob> blob = Blob::create();

Modified: trunk/Source/WebCore/bindings/v8/custom/V8ClipboardCustom.cpp (117382 => 117383)


--- trunk/Source/WebCore/bindings/v8/custom/V8ClipboardCustom.cpp	2012-05-17 02:59:02 UTC (rev 117382)
+++ trunk/Source/WebCore/bindings/v8/custom/V8ClipboardCustom.cpp	2012-05-17 03:14:09 UTC (rev 117383)
@@ -73,7 +73,7 @@
     }
 
     if (args.Length() != 1)
-        return throwError("clearData: Invalid number of arguments", V8Proxy::SyntaxError);
+        return V8Proxy::throwError(V8Proxy::SyntaxError, "clearData: Invalid number of arguments");
 
     String type = toWebCoreString(args[0]);
     clipboard->clearData(type);
@@ -89,7 +89,7 @@
         return v8::Undefined();
 
     if (args.Length() != 3)
-        return throwError("setDragImage: Invalid number of arguments", V8Proxy::SyntaxError);
+        return V8Proxy::throwError(V8Proxy::SyntaxError, "setDragImage: Invalid number of arguments");
 
     int x = toInt32(args[1]);
     int y = toInt32(args[2]);

Modified: trunk/Source/WebCore/bindings/v8/custom/V8DOMFormDataCustom.cpp (117382 => 117383)


--- trunk/Source/WebCore/bindings/v8/custom/V8DOMFormDataCustom.cpp	2012-05-17 02:59:02 UTC (rev 117382)
+++ trunk/Source/WebCore/bindings/v8/custom/V8DOMFormDataCustom.cpp	2012-05-17 03:14:09 UTC (rev 117383)
@@ -65,7 +65,7 @@
     INC_STATS("DOM.FormData.append()");
     
     if (args.Length() < 2)
-        return throwError("Not enough arguments", V8Proxy::SyntaxError);
+        return V8Proxy::throwError(V8Proxy::SyntaxError, "Not enough arguments");
 
     DOMFormData* domFormData = V8DOMFormData::toNative(args.Holder());
 

Modified: trunk/Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp (117382 => 117383)


--- trunk/Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp	2012-05-17 02:59:02 UTC (rev 117382)
+++ trunk/Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp	2012-05-17 03:14:09 UTC (rev 117383)
@@ -58,11 +58,11 @@
 
     Frame* frame = V8Proxy::retrieveFrameForCurrentContext();
     if (!frame)
-        return throwError("Image constructor associated frame is unavailable", V8Proxy::ReferenceError);
+        return V8Proxy::throwError(V8Proxy::ReferenceError, "Image constructor associated frame is unavailable");
 
     Document* document = frame->document();
     if (!document)
-        return throwError("Image constructor associated document is unavailable", V8Proxy::ReferenceError);
+        return V8Proxy::throwError(V8Proxy::ReferenceError, "Image constructor associated document is unavailable");
 
     // Make sure the document is added to the DOM Node map. Otherwise, the HTMLImageElement instance
     // may end up being the only node in the map and get garbage-ccollected prematurely.

Modified: trunk/Source/WebCore/bindings/v8/custom/V8WebKitMutationObserverCustom.cpp (117382 => 117383)


--- trunk/Source/WebCore/bindings/v8/custom/V8WebKitMutationObserverCustom.cpp	2012-05-17 02:59:02 UTC (rev 117382)
+++ trunk/Source/WebCore/bindings/v8/custom/V8WebKitMutationObserverCustom.cpp	2012-05-17 03:14:09 UTC (rev 117383)
@@ -69,7 +69,7 @@
 
     ScriptExecutionContext* context = getScriptExecutionContext();
     if (!context)
-        return throwError("WebKitMutationObserver constructor's associated frame unavailable", V8Proxy::ReferenceError);
+        return V8Proxy::throwError(V8Proxy::ReferenceError, "WebKitMutationObserver constructor's associated frame unavailable");
 
     RefPtr<MutationCallback> callback = V8MutationCallback::create(arg, context);
     RefPtr<WebKitMutationObserver> observer = WebKitMutationObserver::create(callback.release());

Modified: trunk/Source/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp (117382 => 117383)


--- trunk/Source/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp	2012-05-17 02:59:02 UTC (rev 117382)
+++ trunk/Source/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp	2012-05-17 03:14:09 UTC (rev 117383)
@@ -69,12 +69,12 @@
     if (tryCatch.HasCaught())
         return throwError(tryCatch.Exception());
     if (urlstring.IsEmpty())
-        return throwError("Empty URL", V8Proxy::SyntaxError);
+        return V8Proxy::throwError(V8Proxy::SyntaxError, "Empty URL");
 
     // Get the script execution context.
     ScriptExecutionContext* context = getScriptExecutionContext();
     if (!context)
-        return throwError("WebSocket constructor's associated frame is not available", V8Proxy::ReferenceError);
+        return V8Proxy::throwError(V8Proxy::ReferenceError, "WebSocket constructor's associated frame is not available");
 
     const KURL& url = ""
 

Modified: trunk/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp (117382 => 117383)


--- trunk/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp	2012-05-17 02:59:02 UTC (rev 117382)
+++ trunk/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp	2012-05-17 03:14:09 UTC (rev 117383)
@@ -57,7 +57,7 @@
     // Allocate a XMLHttpRequest object as its internal field.
     ScriptExecutionContext* context = getScriptExecutionContext();
     if (!context)
-        return throwError("XMLHttpRequest constructor's associated context is not available", V8Proxy::ReferenceError);
+        return V8Proxy::throwError(V8Proxy::ReferenceError, "XMLHttpRequest constructor's associated context is not available");
 
     RefPtr<SecurityOrigin> securityOrigin;
     if (V8IsolatedContext* isolatedContext = V8IsolatedContext::getEntered())
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to