2011-04-06 Leandro Gracia Gil <leandrogracia@chromium.org>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Apr 2011 23:01:30 +0000 (23:01 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Apr 2011 23:01:30 +0000 (23:01 +0000)
        Reviewed by Steve Block.

        Make the style of createFunctionOnlyCallback in V8 consistent with the JavaScriptCore version.
        https://bugs.webkit.org/show_bug.cgi?id=57963

        No new tests. LayoutTests/fast/dom/Geolocation/argument-types.html

        * bindings/v8/V8Utilities.h:
        (WebCore::createFunctionOnlyCallback):
        * bindings/v8/custom/V8GeolocationCustom.cpp:
        (WebCore::V8Geolocation::getCurrentPositionCallback):
        (WebCore::V8Geolocation::watchPositionCallback):

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

Source/WebCore/ChangeLog
Source/WebCore/bindings/v8/V8Utilities.h
Source/WebCore/bindings/v8/custom/V8GeolocationCustom.cpp

index ea288e8..c15d2de 100644 (file)
@@ -1,3 +1,18 @@
+2011-04-06  Leandro Gracia Gil  <leandrogracia@chromium.org>
+
+        Reviewed by Steve Block.
+
+        Make the style of createFunctionOnlyCallback in V8 consistent with the JavaScriptCore version.
+        https://bugs.webkit.org/show_bug.cgi?id=57963
+
+        No new tests. LayoutTests/fast/dom/Geolocation/argument-types.html
+
+        * bindings/v8/V8Utilities.h:
+        (WebCore::createFunctionOnlyCallback):
+        * bindings/v8/custom/V8GeolocationCustom.cpp:
+        (WebCore::V8Geolocation::getCurrentPositionCallback):
+        (WebCore::V8Geolocation::watchPositionCallback):
+
 2011-04-06  Brian Weinstein  <bweinstein@apple.com>
 
         Reviewed by Adam Roben.
index 6507f61..4a44f3c 100644 (file)
@@ -58,7 +58,6 @@ namespace WebCore {
     void throwTypeMismatchException();
 
     enum CallbackAllowedValueFlag {
-        CallbackAllowFunction = 0,
         CallbackAllowUndefined = 1,
         CallbackAllowNull = 1 << 1
     };
@@ -67,12 +66,14 @@ namespace WebCore {
 
     // 'FunctionOnly' is assumed for the created callback.
     template <typename V8CallbackType>
-    PassRefPtr<V8CallbackType> createFunctionOnlyCallback(v8::Local<v8::Value> value, CallbackAllowedValueFlags acceptedValues, bool& succeeded)
+    PassRefPtr<V8CallbackType> createFunctionOnlyCallback(v8::Local<v8::Value> value, bool& succeeded, CallbackAllowedValueFlags acceptedValues = 0)
     {
         succeeded = true;
 
-        if ((value->IsUndefined() && (acceptedValues & CallbackAllowUndefined))
-            || (value->IsNull() && (acceptedValues & CallbackAllowNull)))
+        if (value->IsUndefined() && (acceptedValues & CallbackAllowUndefined))
+            return 0;
+
+        if (value->IsNull() && (acceptedValues & CallbackAllowNull))
             return 0;
 
         if (!value->IsFunction()) {
index 19d1e72..91389d8 100644 (file)
@@ -133,13 +133,13 @@ v8::Handle<v8::Value> V8Geolocation::getCurrentPositionCallback(const v8::Argume
 
     bool succeeded = false;
 
-    RefPtr<PositionCallback> positionCallback = createFunctionOnlyCallback<V8CustomPositionCallback>(args[0], CallbackAllowFunction, succeeded);
+    RefPtr<PositionCallback> positionCallback = createFunctionOnlyCallback<V8CustomPositionCallback>(args[0], succeeded);
     if (!succeeded)
         return v8::Undefined();
     ASSERT(positionCallback);
 
     // Argument is optional (hence undefined is allowed), and null is allowed.
-    RefPtr<PositionErrorCallback> positionErrorCallback = createFunctionOnlyCallback<V8CustomPositionErrorCallback>(args[1], CallbackAllowUndefined | CallbackAllowNull, succeeded);
+    RefPtr<PositionErrorCallback> positionErrorCallback = createFunctionOnlyCallback<V8CustomPositionErrorCallback>(args[1], succeeded, CallbackAllowUndefined | CallbackAllowNull);
     if (!succeeded)
         return v8::Undefined();
 
@@ -159,13 +159,13 @@ v8::Handle<v8::Value> V8Geolocation::watchPositionCallback(const v8::Arguments&
 
     bool succeeded = false;
 
-    RefPtr<PositionCallback> positionCallback = createFunctionOnlyCallback<V8CustomPositionCallback>(args[0], CallbackAllowFunction, succeeded);
+    RefPtr<PositionCallback> positionCallback = createFunctionOnlyCallback<V8CustomPositionCallback>(args[0], succeeded);
     if (!succeeded)
         return v8::Undefined();
     ASSERT(positionCallback);
 
     // Argument is optional (hence undefined is allowed), and null is allowed.
-    RefPtr<PositionErrorCallback> positionErrorCallback = createFunctionOnlyCallback<V8CustomPositionErrorCallback>(args[1], CallbackAllowUndefined | CallbackAllowNull, succeeded);
+    RefPtr<PositionErrorCallback> positionErrorCallback = createFunctionOnlyCallback<V8CustomPositionErrorCallback>(args[1], succeeded, CallbackAllowUndefined | CallbackAllowNull);
     if (!succeeded)
         return v8::Undefined();