Title: [117536] trunk/Source/WebCore
Revision
117536
Author
hara...@chromium.org
Date
2012-05-17 20:39:09 -0700 (Thu, 17 May 2012)

Log Message

[V8][Refactoring] Remove V8Proxy::throwError(const char*, v8::Isolate* = 0)
https://bugs.webkit.org/show_bug.cgi?id=86794

Reviewed by Adam Barth.

As commented here (https://bugs.webkit.org/show_bug.cgi?id=84074#c5),
I am refactoring a series of confusing throwError()s.
This patch removes V8Proxy::throwError(const char*, v8::Isolate* = 0).

No tests. No change in behavior.

* bindings/v8/V8Utilities.cpp:
(WebCore::extractTransferables):
(WebCore::getMessagePortArray):
* bindings/v8/custom/V8ArrayBufferViewCustom.h:
(WebCore::constructWebGLArrayWithArrayBufferArgument):
(WebCore::constructWebGLArray):
* bindings/v8/custom/V8AudioBufferSourceNodeCustom.cpp:
(WebCore::V8AudioBufferSourceNode::bufferAccessorSetter):
* bindings/v8/custom/V8ClipboardCustom.cpp:
(WebCore::V8Clipboard::setDragImageCallback):
* bindings/v8/custom/V8HTMLDocumentCustom.cpp:
(WebCore::V8HTMLDocument::openCallback):
* bindings/v8/custom/V8HTMLInputElementCustom.cpp:
(WebCore::V8HTMLInputElement::selectionStartAccessorGetter):
(WebCore::V8HTMLInputElement::selectionStartAccessorSetter):
(WebCore::V8HTMLInputElement::selectionEndAccessorGetter):
(WebCore::V8HTMLInputElement::selectionEndAccessorSetter):
(WebCore::V8HTMLInputElement::selectionDirectionAccessorGetter):
(WebCore::V8HTMLInputElement::selectionDirectionAccessorSetter):
(WebCore::V8HTMLInputElement::setSelectionRangeCallback):
* bindings/v8/custom/V8HTMLMediaElementCustom.cpp:
(WebCore::V8HTMLMediaElement::controllerAccessorSetter):
* bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
(WebCore::V8InjectedScriptHost::inspectedObjectCallback):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (117535 => 117536)


--- trunk/Source/WebCore/ChangeLog	2012-05-18 03:36:12 UTC (rev 117535)
+++ trunk/Source/WebCore/ChangeLog	2012-05-18 03:39:09 UTC (rev 117536)
@@ -1,3 +1,41 @@
+2012-05-17  Kentaro Hara  <hara...@chromium.org>
+
+        [V8][Refactoring] Remove V8Proxy::throwError(const char*, v8::Isolate* = 0)
+        https://bugs.webkit.org/show_bug.cgi?id=86794
+
+        Reviewed by Adam Barth.
+
+        As commented here (https://bugs.webkit.org/show_bug.cgi?id=84074#c5),
+        I am refactoring a series of confusing throwError()s.
+        This patch removes V8Proxy::throwError(const char*, v8::Isolate* = 0).
+
+        No tests. No change in behavior.
+
+        * bindings/v8/V8Utilities.cpp:
+        (WebCore::extractTransferables):
+        (WebCore::getMessagePortArray):
+        * bindings/v8/custom/V8ArrayBufferViewCustom.h:
+        (WebCore::constructWebGLArrayWithArrayBufferArgument):
+        (WebCore::constructWebGLArray):
+        * bindings/v8/custom/V8AudioBufferSourceNodeCustom.cpp:
+        (WebCore::V8AudioBufferSourceNode::bufferAccessorSetter):
+        * bindings/v8/custom/V8ClipboardCustom.cpp:
+        (WebCore::V8Clipboard::setDragImageCallback):
+        * bindings/v8/custom/V8HTMLDocumentCustom.cpp:
+        (WebCore::V8HTMLDocument::openCallback):
+        * bindings/v8/custom/V8HTMLInputElementCustom.cpp:
+        (WebCore::V8HTMLInputElement::selectionStartAccessorGetter):
+        (WebCore::V8HTMLInputElement::selectionStartAccessorSetter):
+        (WebCore::V8HTMLInputElement::selectionEndAccessorGetter):
+        (WebCore::V8HTMLInputElement::selectionEndAccessorSetter):
+        (WebCore::V8HTMLInputElement::selectionDirectionAccessorGetter):
+        (WebCore::V8HTMLInputElement::selectionDirectionAccessorSetter):
+        (WebCore::V8HTMLInputElement::setSelectionRangeCallback):
+        * bindings/v8/custom/V8HTMLMediaElementCustom.cpp:
+        (WebCore::V8HTMLMediaElement::controllerAccessorSetter):
+        * bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
+        (WebCore::V8InjectedScriptHost::inspectedObjectCallback):
+
 2012-05-17  Dana Jansens  <dan...@chromium.org>
 
         [chromium] Scale all compositor output by the defaultDeviceScaleFactor

Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.h (117535 => 117536)


--- trunk/Source/WebCore/bindings/v8/V8Proxy.h	2012-05-18 03:36:12 UTC (rev 117535)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.h	2012-05-18 03:39:09 UTC (rev 117536)
@@ -325,13 +325,6 @@
         return v8::Local<v8::Boolean>();
     }
 
-    inline v8::Handle<v8::Primitive> throwError(const char* message, v8::Isolate* isolate = 0)
-    {
-        if (!v8::V8::IsExecutionTerminating())
-            V8Proxy::throwError(V8Proxy::TypeError, message, isolate);
-        return v8::Undefined();
-    }
-
     inline v8::Handle<v8::Primitive> throwError(const char* message, V8Proxy::ErrorType type, v8::Isolate* isolate = 0)
     {
         if (!v8::V8::IsExecutionTerminating())

Modified: trunk/Source/WebCore/bindings/v8/V8Utilities.cpp (117535 => 117536)


--- trunk/Source/WebCore/bindings/v8/V8Utilities.cpp	2012-05-18 03:36:12 UTC (rev 117535)
+++ trunk/Source/WebCore/bindings/v8/V8Utilities.cpp	2012-05-18 03:39:09 UTC (rev 117536)
@@ -94,7 +94,7 @@
     }
 
     if (!value->IsObject()) {
-        throwError("TransferArray argument must be an object");
+        V8Proxy::throwTypeError("TransferArray argument must be an object");
         return false;
     }
     uint32_t length = 0;
@@ -107,7 +107,7 @@
         // Sequence-type object - get the length attribute
         v8::Local<v8::Value> sequenceLength = transferrables->Get(v8::String::New("length"));
         if (!sequenceLength->IsNumber()) {
-            throwError("TransferArray argument has no length attribute");
+            V8Proxy::throwTypeError("TransferArray argument has no length attribute");
             return false;
         }
         length = sequenceLength->Uint32Value();
@@ -127,7 +127,7 @@
         else if (V8ArrayBuffer::HasInstance(transferrable))
             arrayBuffers.append(V8ArrayBuffer::toNative(v8::Handle<v8::Object>::Cast(transferrable)));
         else {
-            throwError("TransferArray argument must contain only Transferables");
+            V8Proxy::throwTypeError("TransferArray argument must contain only Transferables");
             return false;
         }
     }
@@ -141,7 +141,7 @@
     if (!result)
         return false;
     if (arrayBuffers.size() > 0) {
-        throwError("MessagePortArray argument must contain only MessagePorts");
+        V8Proxy::throwTypeError("MessagePortArray argument must contain only MessagePorts");
         return false;
     }
     return true;

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


--- trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h	2012-05-18 03:36:12 UTC (rev 117535)
+++ trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h	2012-05-18 03:39:09 UTC (rev 117536)
@@ -60,20 +60,20 @@
 {
     ArrayBuffer* buf = V8ArrayBuffer::toNative(args[0]->ToObject());
     if (!buf)
-        return throwError("Could not convert argument 0 to a ArrayBuffer");
+        return V8Proxy::throwTypeError("Could not convert argument 0 to a ArrayBuffer");
     bool ok;
     uint32_t offset = 0;
     int argLen = args.Length();
     if (argLen > 1) {
         offset = toUInt32(args[1], ok);
         if (!ok)
-            return throwError("Could not convert argument 1 to a number");
+            return V8Proxy::throwTypeError("Could not convert argument 1 to a number");
     }
     uint32_t length = 0;
     if (argLen > 2) {
         length = toUInt32(args[2], ok);
         if (!ok)
-            return throwError("Could not convert argument 2 to a number");
+            return V8Proxy::throwTypeError("Could not convert argument 2 to a number");
     } else {
         if ((buf->byteLength() - offset) % sizeof(ElementType))
             return V8Proxy::throwError(V8Proxy::RangeError, "ArrayBuffer length minus the byteOffset is not a multiple of the element size.");
@@ -153,7 +153,7 @@
     if (args[0]->IsObject()) {
         srcArray = args[0]->ToObject();
         if (srcArray.IsEmpty())
-            return throwError("Could not convert argument 0 to an array");
+            return V8Proxy::throwTypeError("Could not convert argument 0 to an array");
         len = toUInt32(srcArray->Get(v8::String::New("length")));
         doInstantiation = true;
     } else {

Modified: trunk/Source/WebCore/bindings/v8/custom/V8AudioBufferSourceNodeCustom.cpp (117535 => 117536)


--- trunk/Source/WebCore/bindings/v8/custom/V8AudioBufferSourceNodeCustom.cpp	2012-05-18 03:36:12 UTC (rev 117535)
+++ trunk/Source/WebCore/bindings/v8/custom/V8AudioBufferSourceNodeCustom.cpp	2012-05-18 03:39:09 UTC (rev 117536)
@@ -47,13 +47,13 @@
     if (V8AudioBuffer::HasInstance(value)) {
         buffer = V8AudioBuffer::toNative(value->ToObject());
         if (buffer && !imp->setBuffer(buffer)) {
-            throwError("AudioBuffer unsupported number of channels");
+            V8Proxy::throwTypeError("AudioBuffer unsupported number of channels");
             return;
         }
     }
     
     if (!buffer) {
-        throwError("Value is not of type AudioBuffer");
+        V8Proxy::throwTypeError("Value is not of type AudioBuffer");
         return;
     }
 }

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


--- trunk/Source/WebCore/bindings/v8/custom/V8ClipboardCustom.cpp	2012-05-18 03:36:12 UTC (rev 117535)
+++ trunk/Source/WebCore/bindings/v8/custom/V8ClipboardCustom.cpp	2012-05-18 03:39:09 UTC (rev 117536)
@@ -99,7 +99,7 @@
         node = V8Node::toNative(v8::Handle<v8::Object>::Cast(args[0]));
 
     if (!node || !node->isElementNode())
-        return throwError("setDragImageFromElement: Invalid first argument");
+        return V8Proxy::throwTypeError("setDragImageFromElement: Invalid first argument");
 
     if (static_cast<Element*>(node)->hasLocalName(HTMLNames::imgTag) && !node->inDocument())
         clipboard->setDragImage(static_cast<HTMLImageElement*>(node)->cachedImage(), IntPoint(x, y));

Modified: trunk/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp (117535 => 117536)


--- trunk/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp	2012-05-18 03:36:12 UTC (rev 117535)
+++ trunk/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp	2012-05-18 03:39:09 UTC (rev 117536)
@@ -149,7 +149,7 @@
             v8::Local<v8::Value> function = global->Get(v8::String::New("open"));
             // If the open property is not a function throw a type error.
             if (!function->IsFunction()) {
-                throwError("open is not a function");
+                V8Proxy::throwTypeError("open is not a function");
                 return v8::Undefined();
             }
             // Wrap up the arguments and call the function.

Modified: trunk/Source/WebCore/bindings/v8/custom/V8HTMLInputElementCustom.cpp (117535 => 117536)


--- trunk/Source/WebCore/bindings/v8/custom/V8HTMLInputElementCustom.cpp	2012-05-18 03:36:12 UTC (rev 117535)
+++ trunk/Source/WebCore/bindings/v8/custom/V8HTMLInputElementCustom.cpp	2012-05-18 03:39:09 UTC (rev 117536)
@@ -45,7 +45,7 @@
     HTMLInputElement* imp = V8HTMLInputElement::toNative(holder);
 
     if (!imp->canHaveSelection())
-        return throwError("Accessing selectionStart on an input element that cannot have a selection.");
+        return V8Proxy::throwTypeError("Accessing selectionStart on an input element that cannot have a selection.");
 
     int v = imp->selectionStart();
     return v8::Integer::New(v);
@@ -58,7 +58,7 @@
     HTMLInputElement* imp = V8HTMLInputElement::toNative(holder);
 
     if (!imp->canHaveSelection()) {
-        throwError("Accessing selectionStart on an input element that cannot have a selection.");
+        V8Proxy::throwTypeError("Accessing selectionStart on an input element that cannot have a selection.");
         return;
     }
     imp->setSelectionStart(value->Int32Value());
@@ -71,7 +71,7 @@
     HTMLInputElement* imp = V8HTMLInputElement::toNative(holder);
 
     if (!imp->canHaveSelection())
-        return throwError("Accessing selectionEnd on an input element that cannot have a selection.");
+        return V8Proxy::throwTypeError("Accessing selectionEnd on an input element that cannot have a selection.");
 
     int v = imp->selectionEnd();
     return v8::Integer::New(v);
@@ -84,7 +84,7 @@
     HTMLInputElement* imp = V8HTMLInputElement::toNative(holder);
 
     if (!imp->canHaveSelection()) {
-        throwError("Accessing selectionEnd on an input element that cannot have a selection.");
+        V8Proxy::throwTypeError("Accessing selectionEnd on an input element that cannot have a selection.");
         return;
     }
 
@@ -98,7 +98,7 @@
     HTMLInputElement* imp = V8HTMLInputElement::toNative(holder);
 
     if (!imp->canHaveSelection())
-        return throwError("Accessing selectionDirection on an input element that cannot have a selection.");
+        return V8Proxy::throwTypeError("Accessing selectionDirection on an input element that cannot have a selection.");
 
     return v8String(imp->selectionDirection());
 }
@@ -110,7 +110,7 @@
     HTMLInputElement* imp = V8HTMLInputElement::toNative(holder);
 
     if (!imp->canHaveSelection()) {
-        throwError("Accessing selectionDirection on an input element that cannot have a selection.");
+        V8Proxy::throwTypeError("Accessing selectionDirection on an input element that cannot have a selection.");
         return;
     }
 
@@ -124,7 +124,7 @@
     HTMLInputElement* imp = V8HTMLInputElement::toNative(holder);
 
     if (!imp->canHaveSelection())
-        return throwError("Calling setSelectionRange on an input element that cannot have a selection.");
+        return V8Proxy::throwTypeError("Calling setSelectionRange on an input element that cannot have a selection.");
 
     int start = args[0]->Int32Value();
     int end = args[1]->Int32Value();

Modified: trunk/Source/WebCore/bindings/v8/custom/V8HTMLMediaElementCustom.cpp (117535 => 117536)


--- trunk/Source/WebCore/bindings/v8/custom/V8HTMLMediaElementCustom.cpp	2012-05-18 03:36:12 UTC (rev 117535)
+++ trunk/Source/WebCore/bindings/v8/custom/V8HTMLMediaElementCustom.cpp	2012-05-18 03:39:09 UTC (rev 117536)
@@ -43,7 +43,7 @@
         controller = V8MediaController::toNative(value->ToObject());
     
     if (!controller) {
-        throwError("Value is not of type MediaController");
+        V8Proxy::throwTypeError("Value is not of type MediaController");
         return;
     }
 

Modified: trunk/Source/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp (117535 => 117536)


--- trunk/Source/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp	2012-05-18 03:36:12 UTC (rev 117535)
+++ trunk/Source/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp	2012-05-18 03:39:09 UTC (rev 117536)
@@ -83,7 +83,7 @@
         return v8::Undefined();
 
     if (!args[0]->IsInt32()) {
-        throwError("argument has to be an integer");
+        V8Proxy::throwTypeError("argument has to be an integer");
         return v8::Undefined();
     }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to