Changeset 117448 in webkit


Ignore:
Timestamp:
May 17, 2012 8:17:20 AM (12 years ago)
Author:
haraken@chromium.org
Message:

[V8][Refactoring] Support an optional 'message' argument for throwTypeError()
https://bugs.webkit.org/show_bug.cgi?id=86576

Reviewed by Adam Barth.

As commented in https://bugs.webkit.org/show_bug.cgi?id=84074#c5,
I am planning to refactor a series of confusing throwError()s into
throwError() and throwTypeError().

This patch supports an optional 'message' argument for V8Proxy::throwTypeError().
Also this patch replaces throwError("message", V8Proxy::TypeError) in custom bindings
with V8Proxy::throwTypeError("message").

No tests. No change in behavior.

  • bindings/v8/V8Proxy.cpp:

(WebCore::V8Proxy::throwTypeError):

  • bindings/v8/V8Proxy.h:

(V8Proxy):

  • bindings/v8/custom/V8ArrayBufferViewCustom.h:

(WebCore::constructWebGLArray):

  • bindings/v8/custom/V8AudioContextCustom.cpp:

(WebCore::V8AudioContext::constructorCallback):

  • bindings/v8/custom/V8BlobCustom.cpp:

(WebCore::V8Blob::constructorCallback):

  • bindings/v8/custom/V8DOMFormDataCustom.cpp:

(WebCore::V8DOMFormData::constructorCallback):

  • bindings/v8/custom/V8DataViewCustom.cpp:

(WebCore::V8DataView::constructorCallback):

  • bindings/v8/custom/V8HTMLImageElementConstructor.cpp:

(WebCore::v8HTMLImageElementConstructorCallback):

  • bindings/v8/custom/V8IntentConstructor.cpp:

(WebCore::V8Intent::constructorCallback):

  • bindings/v8/custom/V8MessageChannelConstructor.cpp:

(WebCore::V8MessageChannel::constructorCallback):

  • bindings/v8/custom/V8NotificationCenterCustom.cpp:

(WebCore::V8NotificationCenter::requestPermissionCallback):

  • bindings/v8/custom/V8WebKitMutationObserverCustom.cpp:

(WebCore::V8WebKitMutationObserver::constructorCallback):

  • bindings/v8/custom/V8WebKitPointConstructor.cpp:

(WebCore::V8WebKitPoint::constructorCallback):

  • bindings/v8/custom/V8WebSocketCustom.cpp:

(WebCore::V8WebSocket::constructorCallback):

  • bindings/v8/custom/V8XMLHttpRequestConstructor.cpp:

(WebCore::V8XMLHttpRequest::constructorCallback):

Location:
trunk/Source/WebCore
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r117447 r117448  
     12012-05-17  Kentaro Hara  <haraken@chromium.org>
     2
     3        [V8][Refactoring] Support an optional 'message' argument for throwTypeError()
     4        https://bugs.webkit.org/show_bug.cgi?id=86576
     5
     6        Reviewed by Adam Barth.
     7
     8        As commented in https://bugs.webkit.org/show_bug.cgi?id=84074#c5,
     9        I am planning to refactor a series of confusing throwError()s into
     10        throwError() and throwTypeError().
     11
     12        This patch supports an optional 'message' argument for V8Proxy::throwTypeError().
     13        Also this patch replaces throwError("message", V8Proxy::TypeError) in custom bindings
     14        with V8Proxy::throwTypeError("message").
     15
     16        No tests. No change in behavior.
     17
     18        * bindings/v8/V8Proxy.cpp:
     19        (WebCore::V8Proxy::throwTypeError):
     20        * bindings/v8/V8Proxy.h:
     21        (V8Proxy):
     22        * bindings/v8/custom/V8ArrayBufferViewCustom.h:
     23        (WebCore::constructWebGLArray):
     24        * bindings/v8/custom/V8AudioContextCustom.cpp:
     25        (WebCore::V8AudioContext::constructorCallback):
     26        * bindings/v8/custom/V8BlobCustom.cpp:
     27        (WebCore::V8Blob::constructorCallback):
     28        * bindings/v8/custom/V8DOMFormDataCustom.cpp:
     29        (WebCore::V8DOMFormData::constructorCallback):
     30        * bindings/v8/custom/V8DataViewCustom.cpp:
     31        (WebCore::V8DataView::constructorCallback):
     32        * bindings/v8/custom/V8HTMLImageElementConstructor.cpp:
     33        (WebCore::v8HTMLImageElementConstructorCallback):
     34        * bindings/v8/custom/V8IntentConstructor.cpp:
     35        (WebCore::V8Intent::constructorCallback):
     36        * bindings/v8/custom/V8MessageChannelConstructor.cpp:
     37        (WebCore::V8MessageChannel::constructorCallback):
     38        * bindings/v8/custom/V8NotificationCenterCustom.cpp:
     39        (WebCore::V8NotificationCenter::requestPermissionCallback):
     40        * bindings/v8/custom/V8WebKitMutationObserverCustom.cpp:
     41        (WebCore::V8WebKitMutationObserver::constructorCallback):
     42        * bindings/v8/custom/V8WebKitPointConstructor.cpp:
     43        (WebCore::V8WebKitPoint::constructorCallback):
     44        * bindings/v8/custom/V8WebSocketCustom.cpp:
     45        (WebCore::V8WebSocket::constructorCallback):
     46        * bindings/v8/custom/V8XMLHttpRequestConstructor.cpp:
     47        (WebCore::V8XMLHttpRequest::constructorCallback):
     48
    1492012-05-16  Andrey Kosyakov  <caseq@chromium.org>
    250
  • trunk/Source/WebCore/bindings/v8/V8Proxy.cpp

    r117383 r117448  
    610610}
    611611
    612 v8::Handle<v8::Value> V8Proxy::throwTypeError()
    613 {
    614     return throwError(TypeError, "Type error");
     612v8::Handle<v8::Value> V8Proxy::throwTypeError(const char* message)
     613{
     614    return throwError(TypeError, (message ? message : "Type error"));
    615615}
    616616
  • trunk/Source/WebCore/bindings/v8/V8Proxy.h

    r116744 r117448  
    240240
    241241        // Helpers for throwing syntax and type errors with predefined messages.
    242         static v8::Handle<v8::Value> throwTypeError();
     242        static v8::Handle<v8::Value> throwTypeError(const char* = 0);
    243243        static v8::Handle<v8::Value> throwNotEnoughArgumentsError();
    244244
  • trunk/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h

    r117383 r117448  
    100100{
    101101    if (!args.IsConstructCall())
    102         return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
     102        return V8Proxy::throwTypeError("DOM object constructor cannot be called as a function.");
    103103
    104104    if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
  • trunk/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp

    r117383 r117448  
    4545
    4646    if (!args.IsConstructCall())
    47         return throwError("AudioContext constructor cannot be called as a function.", V8Proxy::TypeError);
     47        return V8Proxy::throwTypeError("AudioContext constructor cannot be called as a function.");
    4848
    4949    if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
  • trunk/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp

    r117383 r117448  
    6161
    6262    if (!args.IsConstructCall())
    63         return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
     63        return V8Proxy::throwTypeError("DOM object constructor cannot be called as a function.");
    6464
    6565    if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
     
    7878    v8::Local<v8::Value> firstArg = args[0];
    7979    if (!firstArg->IsArray())
    80         return throwError("First argument of the constructor is not of type Array", V8Proxy::TypeError);
     80        return V8Proxy::throwTypeError("First argument of the constructor is not of type Array");
    8181
    8282    String type;
     
    8585    if (args.Length() > 1) {
    8686        if (!args[1]->IsObject())
    87             return throwError("Second argument of the constructor is not of type Object", V8Proxy::TypeError);
     87            return V8Proxy::throwTypeError("Second argument of the constructor is not of type Object");
    8888
    8989        Dictionary dictionary(args[1]);
     
    9696        if (containsEndings) {
    9797            if (endings != "transparent" && endings != "native")
    98                 return throwError("The endings property must be either \"transparent\" or \"native\"", V8Proxy::TypeError);
     98                return V8Proxy::throwTypeError("The endings property must be either \"transparent\" or \"native\"");
    9999        }
    100100
  • trunk/Source/WebCore/bindings/v8/custom/V8DOMFormDataCustom.cpp

    r117383 r117448  
    4646
    4747    if (!args.IsConstructCall())
    48         return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
     48        return V8Proxy::throwTypeError("DOM object constructor cannot be called as a function.");
    4949
    5050    if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
  • trunk/Source/WebCore/bindings/v8/custom/V8DataViewCustom.cpp

    r115522 r117448  
    4040
    4141    if (!args.IsConstructCall())
    42         return throwError("DOM object constructor cannot be called as a function", V8Proxy::TypeError);
     42        return V8Proxy::throwTypeError("DOM object constructor cannot be called as a function");
    4343
    4444    if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
  • trunk/Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp

    r117383 r117448  
    5252
    5353    if (!args.IsConstructCall())
    54         return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
     54        return V8Proxy::throwTypeError("DOM object constructor cannot be called as a function.");
    5555
    5656    if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
  • trunk/Source/WebCore/bindings/v8/custom/V8IntentConstructor.cpp

    r115522 r117448  
    4949
    5050    if (!args.IsConstructCall())
    51         return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
     51        return V8Proxy::throwTypeError("DOM object constructor cannot be called as a function.");
    5252
    5353    if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
     
    7777    if (args.Length() > 3) {
    7878        if (!extractTransferables(args[3], messagePortArrayTransferList, arrayBufferArrayTransferList))
    79             return throwError("Could not extract transferables", V8Proxy::TypeError);
     79            return V8Proxy::throwTypeError("Could not extract transferables");
    8080    }
    8181    bool dataDidThrow = false;
  • trunk/Source/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp

    r114932 r117448  
    5252    // Consider refactoring to reduce duplication.
    5353    if (!args.IsConstructCall())
    54         return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
     54        return V8Proxy::throwTypeError("DOM object constructor cannot be called as a function.");
    5555
    5656    if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
  • trunk/Source/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp

    r114932 r117448  
    9696    if (args.Length() > 0) {
    9797        if (!args[0]->IsObject())
    98             return throwError("Callback must be of valid type.", V8Proxy::TypeError);
     98            return V8Proxy::throwTypeError("Callback must be of valid type.");
    9999 
    100100        callback = V8CustomVoidCallback::create(args[0], context);
  • trunk/Source/WebCore/bindings/v8/custom/V8WebKitMutationObserverCustom.cpp

    r117383 r117448  
    5656
    5757    if (!args.IsConstructCall())
    58         return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
     58        return V8Proxy::throwTypeError("DOM object constructor cannot be called as a function.");
    5959
    6060    if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
  • trunk/Source/WebCore/bindings/v8/custom/V8WebKitPointConstructor.cpp

    r114922 r117448  
    4646
    4747    if (!args.IsConstructCall())
    48         return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
     48        return V8Proxy::throwTypeError("DOM object constructor cannot be called as a function.");
    4949
    5050    if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
  • trunk/Source/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp

    r117383 r117448  
    5757
    5858    if (!args.IsConstructCall())
    59         return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
     59        return V8Proxy::throwTypeError("DOM object constructor cannot be called as a function.");
    6060
    6161    if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
  • trunk/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp

    r117383 r117448  
    4949
    5050    if (!args.IsConstructCall())
    51         return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
     51        return V8Proxy::throwTypeError("DOM object constructor cannot be called as a function.");
    5252
    5353    if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
Note: See TracChangeset for help on using the changeset viewer.