[V8] Add an optional Isolate argument to setDOMException() and throwError()
authorharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Apr 2012 17:47:54 +0000 (17:47 +0000)
committerharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Apr 2012 17:47:54 +0000 (17:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=84310

Reviewed by Nate Chapin.

The objective is to pass Isolate to setDOMException()
and throwError(). This patch adds an optional Isolate argument
to setDOMException() and throwError(). I'll pass the Isolate
to these methods in the following patches.

No tests. No change in behavior.

* bindings/v8/V8Proxy.cpp:
(WebCore):
(WebCore::V8Proxy::setDOMException):
(WebCore::V8Proxy::throwError):
* bindings/v8/V8Proxy.h:
(V8Proxy):
(WebCore):
(WebCore::throwError):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@114919 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/bindings/v8/V8Proxy.cpp
Source/WebCore/bindings/v8/V8Proxy.h

index d819b57..41aa208 100644 (file)
@@ -1,3 +1,26 @@
+2012-04-23  Kentaro Hara  <haraken@chromium.org>
+
+        [V8] Add an optional Isolate argument to setDOMException() and throwError()
+        https://bugs.webkit.org/show_bug.cgi?id=84310
+
+        Reviewed by Nate Chapin.
+
+        The objective is to pass Isolate to setDOMException()
+        and throwError(). This patch adds an optional Isolate argument
+        to setDOMException() and throwError(). I'll pass the Isolate
+        to these methods in the following patches.
+
+        No tests. No change in behavior.
+
+        * bindings/v8/V8Proxy.cpp:
+        (WebCore):
+        (WebCore::V8Proxy::setDOMException):
+        (WebCore::V8Proxy::throwError):
+        * bindings/v8/V8Proxy.h:
+        (V8Proxy):
+        (WebCore):
+        (WebCore::throwError):
+
 2012-04-23  Ian Vollick  <vollick@chromium.org>
 
         [chromium] Properly ignore unsupported animation directions.
index d48f8ea..82d740a 100644 (file)
@@ -542,10 +542,10 @@ void V8Proxy::clearForNavigation()
 
 #define TRY_TO_CREATE_EXCEPTION(interfaceName) \
     case interfaceName##Type: \
-        exception = toV8(interfaceName::create(description)); \
+        exception = toV8(interfaceName::create(description), isolate); \
         break;
 
-void V8Proxy::setDOMException(int ec)
+void V8Proxy::setDOMException(int ec, v8::Isolate* isolate)
 {
     if (ec <= 0)
         return;
@@ -563,19 +563,19 @@ void V8Proxy::setDOMException(int ec)
 
 #undef TRY_TO_CREATE_EXCEPTION
 
-v8::Handle<v8::Value> V8Proxy::throwError(ErrorType type, const char* message)
+v8::Handle<v8::Value> V8Proxy::throwError(ErrorType type, const char* message, v8::Isolate* isolate)
 {
     switch (type) {
     case RangeError:
-        return v8::ThrowException(v8::Exception::RangeError(v8String(message)));
+        return v8::ThrowException(v8::Exception::RangeError(v8String(message, isolate)));
     case ReferenceError:
-        return v8::ThrowException(v8::Exception::ReferenceError(v8String(message)));
+        return v8::ThrowException(v8::Exception::ReferenceError(v8String(message, isolate)));
     case SyntaxError:
-        return v8::ThrowException(v8::Exception::SyntaxError(v8String(message)));
+        return v8::ThrowException(v8::Exception::SyntaxError(v8String(message, isolate)));
     case TypeError:
-        return v8::ThrowException(v8::Exception::TypeError(v8String(message)));
+        return v8::ThrowException(v8::Exception::TypeError(v8String(message, isolate)));
     case GeneralError:
-        return v8::ThrowException(v8::Exception::Error(v8String(message)));
+        return v8::ThrowException(v8::Exception::Error(v8String(message, isolate)));
     default:
         ASSERT_NOT_REACHED();
         return notHandledByInterceptor();
index 21edf5d..ee5a571 100644 (file)
@@ -235,10 +235,10 @@ namespace WebCore {
 
         // If the exception code is different from zero, a DOM exception is
         // schedule to be thrown.
-        static void setDOMException(int exceptionCode);
+        static void setDOMException(int exceptionCode, v8::Isolate* = 0);
 
         // Schedule an error object to be thrown.
-        static v8::Handle<v8::Value> throwError(ErrorType, const char* message);
+        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();
@@ -324,21 +324,29 @@ namespace WebCore {
     {
         return v8::Local<v8::Boolean>();
     }
-    inline v8::Handle<v8::Primitive> throwError(const char* message, V8Proxy::ErrorType type = V8Proxy::TypeError)
+
+    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())
-            V8Proxy::throwError(type, message);
+            V8Proxy::throwError(type, message, isolate);
         return v8::Undefined();
     }
 
-    inline v8::Handle<v8::Primitive> throwError(ExceptionCode ec)
+    inline v8::Handle<v8::Primitive> throwError(ExceptionCode ec, v8::Isolate* isolate = 0)
     {
         if (!v8::V8::IsExecutionTerminating())
-            V8Proxy::setDOMException(ec);
+            V8Proxy::setDOMException(ec, isolate);
         return v8::Undefined();
     }
 
-    inline v8::Handle<v8::Primitive> throwError(v8::Local<v8::Value> exception)
+    inline v8::Handle<v8::Primitive> throwError(v8::Local<v8::Value> exception, v8::Isolate* isolate = 0)
     {
         if (!v8::V8::IsExecutionTerminating())
             v8::ThrowException(exception);