Changeset 128135 in webkit


Ignore:
Timestamp:
Sep 10, 2012 5:41:13 PM (12 years ago)
Author:
commit-queue@webkit.org
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 <abarth@chromium.org> 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:
Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r128134 r128135  
     12012-09-10  Adam Barth  <abarth@chromium.org>
     2
     3        [V8] createFunctionOnlyCallback should be in V8Callback.h with the other callback functions
     4        https://bugs.webkit.org/show_bug.cgi?id=96336
     5
     6        Reviewed by Kentaro Hara.
     7
     8        Moving this function to V8Callback.h also lets us delete
     9        setTypeMismatchException because we no longer have a header inclusion
     10        cycle.
     11
     12        * bindings/v8/V8Callback.h:
     13        (WebCore::createFunctionOnlyCallback):
     14        (WebCore):
     15        * bindings/v8/V8Utilities.cpp:
     16        * bindings/v8/V8Utilities.h:
     17        (WebCore):
     18        * bindings/v8/custom/V8GeolocationCustom.cpp:
     19        * bindings/v8/custom/V8NotificationCustom.cpp:
     20
    1212012-09-10  Beth Dakin  <bdakin@apple.com>
    222
  • trunk/Source/WebCore/bindings/v8/V8Callback.h

    r125745 r128135  
    3232#define V8Callback_h
    3333
     34#include "ExceptionCode.h"
     35#include "V8Binding.h"
    3436#include <v8.h>
    3537
     
    4143bool invokeCallback(v8::Persistent<v8::Object> callback, v8::Handle<v8::Object> thisObject, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue, ScriptExecutionContext*);
    4244
     45enum CallbackAllowedValueFlag {
     46    CallbackAllowUndefined = 1,
     47    CallbackAllowNull = 1 << 1
     48};
     49
     50typedef unsigned CallbackAllowedValueFlags;
     51
     52// 'FunctionOnly' is assumed for the created callback.
     53template <typename V8CallbackType>
     54PassRefPtr<V8CallbackType> createFunctionOnlyCallback(v8::Local<v8::Value> value, bool& succeeded, v8::Isolate* isolate, CallbackAllowedValueFlags acceptedValues = 0)
     55{
     56    succeeded = true;
     57
     58    if (value->IsUndefined() && (acceptedValues & CallbackAllowUndefined))
     59        return 0;
     60
     61    if (value->IsNull() && (acceptedValues & CallbackAllowNull))
     62        return 0;
     63
     64    if (!value->IsFunction()) {
     65        succeeded = false;
     66        setDOMException(TYPE_MISMATCH_ERR, isolate);
     67        return 0;
     68    }
     69
     70    return V8CallbackType::create(value, getScriptExecutionContext());
     71}
     72
    4373} // namespace WebCore
    4474
  • trunk/Source/WebCore/bindings/v8/V8Utilities.cpp

    r128125 r128135  
    164164}
    165165
    166 void setTypeMismatchException(v8::Isolate* isolate)
    167 {
    168     setDOMException(TYPE_MISMATCH_ERR, isolate);
    169 }
    170 
    171166} // namespace WebCore
  • trunk/Source/WebCore/bindings/v8/V8Utilities.h

    r128125 r128135  
    5454    ScriptExecutionContext* getScriptExecutionContext();
    5555
    56     void setTypeMismatchException(v8::Isolate*);
    57 
    58     enum CallbackAllowedValueFlag {
    59         CallbackAllowUndefined = 1,
    60         CallbackAllowNull = 1 << 1
    61     };
    62 
    63     typedef unsigned CallbackAllowedValueFlags;
    64 
    6556    typedef WTF::Vector<RefPtr<MessagePort>, 1> MessagePortArray;
    6657    typedef WTF::Vector<RefPtr<ArrayBuffer>, 1> ArrayBufferArray;
     
    7364    bool getMessagePortArray(v8::Local<v8::Value>, MessagePortArray&, v8::Isolate*);
    7465
    75     // 'FunctionOnly' is assumed for the created callback.
    76     template <typename V8CallbackType>
    77     PassRefPtr<V8CallbackType> createFunctionOnlyCallback(v8::Local<v8::Value> value, bool& succeeded, v8::Isolate* isolate, CallbackAllowedValueFlags acceptedValues = 0)
    78     {
    79         succeeded = true;
    80 
    81         if (value->IsUndefined() && (acceptedValues & CallbackAllowUndefined))
    82             return 0;
    83 
    84         if (value->IsNull() && (acceptedValues & CallbackAllowNull))
    85             return 0;
    86 
    87         if (!value->IsFunction()) {
    88             succeeded = false;
    89             setTypeMismatchException(isolate);
    90             return 0;
    91         }
    92 
    93         return V8CallbackType::create(value, getScriptExecutionContext());
    94     }
    95 
    9666} // namespace WebCore
    9767
  • trunk/Source/WebCore/bindings/v8/custom/V8GeolocationCustom.cpp

    r117730 r128135  
    3232#include "Geolocation.h"
    3333#include "V8Binding.h"
     34#include "V8Callback.h"
    3435#include "V8PositionCallback.h"
    3536#include "V8PositionErrorCallback.h"
  • trunk/Source/WebCore/bindings/v8/custom/V8NotificationCustom.cpp

    r126399 r128135  
    3030
    3131#include "ExceptionCode.h"
     32#include "V8Callback.h"
    3233#include "V8NotificationPermissionCallback.h"
    3334
Note: See TracChangeset for help on using the changeset viewer.