Title: [128135] trunk/Source/WebCore
Revision
128135
Author
[email protected]
Date
2012-09-10 17:41:13 -0700 (Mon, 10 Sep 2012)

Log Message

[V8] createFunctionOnlyCallback should be in V8Callback.h with the other callback functions
https://bugs.webkit.org/show_bug.cgi?id=96336

Patch by Adam Barth <[email protected]> on 2012-09-10
Reviewed by Kentaro Hara.

Moving this function to V8Callback.h also lets us delete
setTypeMismatchException because we no longer have a header inclusion
cycle.

* bindings/v8/V8Callback.h:
(WebCore::createFunctionOnlyCallback):
(WebCore):
* bindings/v8/V8Utilities.cpp:
* bindings/v8/V8Utilities.h:
(WebCore):
* bindings/v8/custom/V8GeolocationCustom.cpp:
* bindings/v8/custom/V8NotificationCustom.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (128134 => 128135)


--- trunk/Source/WebCore/ChangeLog	2012-09-11 00:37:06 UTC (rev 128134)
+++ trunk/Source/WebCore/ChangeLog	2012-09-11 00:41:13 UTC (rev 128135)
@@ -1,3 +1,23 @@
+2012-09-10  Adam Barth  <[email protected]>
+
+        [V8] createFunctionOnlyCallback should be in V8Callback.h with the other callback functions
+        https://bugs.webkit.org/show_bug.cgi?id=96336
+
+        Reviewed by Kentaro Hara.
+
+        Moving this function to V8Callback.h also lets us delete
+        setTypeMismatchException because we no longer have a header inclusion
+        cycle.
+
+        * bindings/v8/V8Callback.h:
+        (WebCore::createFunctionOnlyCallback):
+        (WebCore):
+        * bindings/v8/V8Utilities.cpp:
+        * bindings/v8/V8Utilities.h:
+        (WebCore):
+        * bindings/v8/custom/V8GeolocationCustom.cpp:
+        * bindings/v8/custom/V8NotificationCustom.cpp:
+
 2012-09-10  Beth Dakin  <[email protected]>
 
         https://bugs.webkit.org/show_bug.cgi?id=96158

Modified: trunk/Source/WebCore/bindings/v8/V8Callback.h (128134 => 128135)


--- trunk/Source/WebCore/bindings/v8/V8Callback.h	2012-09-11 00:37:06 UTC (rev 128134)
+++ trunk/Source/WebCore/bindings/v8/V8Callback.h	2012-09-11 00:41:13 UTC (rev 128135)
@@ -31,6 +31,8 @@
 #ifndef V8Callback_h
 #define V8Callback_h
 
+#include "ExceptionCode.h"
+#include "V8Binding.h"
 #include <v8.h>
 
 namespace WebCore {
@@ -40,6 +42,34 @@
 bool invokeCallback(v8::Persistent<v8::Object> callback, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue, ScriptExecutionContext*);
 bool invokeCallback(v8::Persistent<v8::Object> callback, v8::Handle<v8::Object> thisObject, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue, ScriptExecutionContext*);
 
+enum CallbackAllowedValueFlag {
+    CallbackAllowUndefined = 1,
+    CallbackAllowNull = 1 << 1
+};
+
+typedef unsigned CallbackAllowedValueFlags;
+
+// 'FunctionOnly' is assumed for the created callback.
+template <typename V8CallbackType>
+PassRefPtr<V8CallbackType> createFunctionOnlyCallback(v8::Local<v8::Value> value, bool& succeeded, v8::Isolate* isolate, CallbackAllowedValueFlags acceptedValues = 0)
+{
+    succeeded = true;
+
+    if (value->IsUndefined() && (acceptedValues & CallbackAllowUndefined))
+        return 0;
+
+    if (value->IsNull() && (acceptedValues & CallbackAllowNull))
+        return 0;
+
+    if (!value->IsFunction()) {
+        succeeded = false;
+        setDOMException(TYPE_MISMATCH_ERR, isolate);
+        return 0;
+    }
+
+    return V8CallbackType::create(value, getScriptExecutionContext());
+}
+
 } // namespace WebCore
 
 #endif // V8Callback_h

Modified: trunk/Source/WebCore/bindings/v8/V8Utilities.cpp (128134 => 128135)


--- trunk/Source/WebCore/bindings/v8/V8Utilities.cpp	2012-09-11 00:37:06 UTC (rev 128134)
+++ trunk/Source/WebCore/bindings/v8/V8Utilities.cpp	2012-09-11 00:41:13 UTC (rev 128135)
@@ -163,9 +163,4 @@
     return currentDocument(BindingState::instance());
 }
 
-void setTypeMismatchException(v8::Isolate* isolate)
-{
-    setDOMException(TYPE_MISMATCH_ERR, isolate);
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/v8/V8Utilities.h (128134 => 128135)


--- trunk/Source/WebCore/bindings/v8/V8Utilities.h	2012-09-11 00:37:06 UTC (rev 128134)
+++ trunk/Source/WebCore/bindings/v8/V8Utilities.h	2012-09-11 00:41:13 UTC (rev 128135)
@@ -53,15 +53,6 @@
 
     ScriptExecutionContext* getScriptExecutionContext();
 
-    void setTypeMismatchException(v8::Isolate*);
-
-    enum CallbackAllowedValueFlag {
-        CallbackAllowUndefined = 1,
-        CallbackAllowNull = 1 << 1
-    };
-
-    typedef unsigned CallbackAllowedValueFlags;
-
     typedef WTF::Vector<RefPtr<MessagePort>, 1> MessagePortArray;
     typedef WTF::Vector<RefPtr<ArrayBuffer>, 1> ArrayBufferArray;
 
@@ -72,27 +63,6 @@
     bool extractTransferables(v8::Local<v8::Value>, MessagePortArray&, ArrayBufferArray&, v8::Isolate*); 
     bool getMessagePortArray(v8::Local<v8::Value>, MessagePortArray&, v8::Isolate*);
 
-    // 'FunctionOnly' is assumed for the created callback.
-    template <typename V8CallbackType>
-    PassRefPtr<V8CallbackType> createFunctionOnlyCallback(v8::Local<v8::Value> value, bool& succeeded, v8::Isolate* isolate, CallbackAllowedValueFlags acceptedValues = 0)
-    {
-        succeeded = true;
-
-        if (value->IsUndefined() && (acceptedValues & CallbackAllowUndefined))
-            return 0;
-
-        if (value->IsNull() && (acceptedValues & CallbackAllowNull))
-            return 0;
-
-        if (!value->IsFunction()) {
-            succeeded = false;
-            setTypeMismatchException(isolate);
-            return 0;
-        }
-
-        return V8CallbackType::create(value, getScriptExecutionContext());
-    }
-
 } // namespace WebCore
 
 #endif // V8Utilities_h

Modified: trunk/Source/WebCore/bindings/v8/custom/V8GeolocationCustom.cpp (128134 => 128135)


--- trunk/Source/WebCore/bindings/v8/custom/V8GeolocationCustom.cpp	2012-09-11 00:37:06 UTC (rev 128134)
+++ trunk/Source/WebCore/bindings/v8/custom/V8GeolocationCustom.cpp	2012-09-11 00:41:13 UTC (rev 128135)
@@ -31,6 +31,7 @@
 #include "Frame.h"
 #include "Geolocation.h"
 #include "V8Binding.h"
+#include "V8Callback.h"
 #include "V8PositionCallback.h"
 #include "V8PositionErrorCallback.h"
 #include "V8Utilities.h"

Modified: trunk/Source/WebCore/bindings/v8/custom/V8NotificationCustom.cpp (128134 => 128135)


--- trunk/Source/WebCore/bindings/v8/custom/V8NotificationCustom.cpp	2012-09-11 00:37:06 UTC (rev 128134)
+++ trunk/Source/WebCore/bindings/v8/custom/V8NotificationCustom.cpp	2012-09-11 00:41:13 UTC (rev 128135)
@@ -29,6 +29,7 @@
 #include "V8Notification.h"
 
 #include "ExceptionCode.h"
+#include "V8Callback.h"
 #include "V8NotificationPermissionCallback.h"
 
 namespace WebCore {
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to