Changeset 58333 in webkit


Ignore:
Timestamp:
Apr 27, 2010 1:55:11 PM (14 years ago)
Author:
abarth@webkit.org
Message:

2010-04-27 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Remove custom NodeIterator bindings
https://bugs.webkit.org/show_bug.cgi?id=38188

Another example of CallWith=ScriptState. This case shows us the right
way to handle the interaction with exception codes.

In my previous patch, I put the exception code handling after the
ScriptState exception handling. It turns out this was a mistake
(although a harmless one at the time because no IDL caused us to
generate that code). Now that we're generating both kinds of exception
handling, we need to generate them in the right order.

  • WebCore.gypi:
  • bindings/js/JSNodeIteratorCustom.cpp:
  • bindings/scripts/CodeGeneratorJS.pm:
  • bindings/scripts/CodeGeneratorV8.pm:
  • bindings/scripts/test/GObject/WebKitDOMTestObj.cpp: (webkit_dom_test_obj_with_script_state_void_exception): (webkit_dom_test_obj_with_script_state_obj_exception):
  • bindings/scripts/test/GObject/WebKitDOMTestObj.h:
  • bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::): (WebCore::jsTestObjPrototypeFunctionWithScriptStateVoidException): (WebCore::jsTestObjPrototypeFunctionWithScriptStateObjException):
  • bindings/scripts/test/JS/JSTestObj.h:
  • bindings/scripts/test/ObjC/DOMTestObj.h:
  • bindings/scripts/test/ObjC/DOMTestObj.mm: (-[DOMTestObj withScriptStateVoidException]): (-[DOMTestObj withScriptStateObjException]):
  • bindings/scripts/test/TestObj.idl:
  • bindings/scripts/test/V8/V8TestObj.cpp: (WebCore::TestObjInternal::withScriptStateVoidCallback): (WebCore::TestObjInternal::withScriptStateObjCallback): (WebCore::TestObjInternal::withScriptStateVoidExceptionCallback): (WebCore::TestObjInternal::withScriptStateObjExceptionCallback): (WebCore::):
  • bindings/v8/custom/V8NodeIteratorCustom.cpp: Removed.
  • dom/NodeIterator.idl:
Location:
trunk/WebCore
Files:
1 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r58330 r58333  
     12010-04-27  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Remove custom NodeIterator bindings
     6        https://bugs.webkit.org/show_bug.cgi?id=38188
     7
     8        Another example of CallWith=ScriptState.  This case shows us the right
     9        way to handle the interaction with exception codes.
     10
     11        In my previous patch, I put the exception code handling after the
     12        ScriptState exception handling.  It turns out this was a mistake
     13        (although a harmless one at the time because no IDL caused us to
     14        generate that code).  Now that we're generating both kinds of exception
     15        handling, we need to generate them in the right order.
     16
     17        * WebCore.gypi:
     18        * bindings/js/JSNodeIteratorCustom.cpp:
     19        * bindings/scripts/CodeGeneratorJS.pm:
     20        * bindings/scripts/CodeGeneratorV8.pm:
     21        * bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:
     22        (webkit_dom_test_obj_with_script_state_void_exception):
     23        (webkit_dom_test_obj_with_script_state_obj_exception):
     24        * bindings/scripts/test/GObject/WebKitDOMTestObj.h:
     25        * bindings/scripts/test/JS/JSTestObj.cpp:
     26        (WebCore::):
     27        (WebCore::jsTestObjPrototypeFunctionWithScriptStateVoidException):
     28        (WebCore::jsTestObjPrototypeFunctionWithScriptStateObjException):
     29        * bindings/scripts/test/JS/JSTestObj.h:
     30        * bindings/scripts/test/ObjC/DOMTestObj.h:
     31        * bindings/scripts/test/ObjC/DOMTestObj.mm:
     32        (-[DOMTestObj withScriptStateVoidException]):
     33        (-[DOMTestObj withScriptStateObjException]):
     34        * bindings/scripts/test/TestObj.idl:
     35        * bindings/scripts/test/V8/V8TestObj.cpp:
     36        (WebCore::TestObjInternal::withScriptStateVoidCallback):
     37        (WebCore::TestObjInternal::withScriptStateObjCallback):
     38        (WebCore::TestObjInternal::withScriptStateVoidExceptionCallback):
     39        (WebCore::TestObjInternal::withScriptStateObjExceptionCallback):
     40        (WebCore::):
     41        * bindings/v8/custom/V8NodeIteratorCustom.cpp: Removed.
     42        * dom/NodeIterator.idl:
     43
    1442010-04-27  Adam Barth  <abarth@webkit.org>
    245
  • trunk/WebCore/WebCore.gypi

    r58298 r58333  
    771771            'bindings/v8/custom/V8NodeCustom.cpp',
    772772            'bindings/v8/custom/V8NodeFilterCustom.cpp',
    773             'bindings/v8/custom/V8NodeIteratorCustom.cpp',
    774773            'bindings/v8/custom/V8NodeListCustom.cpp',
    775774            'bindings/v8/custom/V8NotificationCenterCustom.cpp',
  • trunk/WebCore/bindings/js/JSNodeIteratorCustom.cpp

    r47022 r58333  
    3838}
    3939
    40 JSValue JSNodeIterator::nextNode(ExecState* exec, const ArgList&)
    41 {
    42     ExceptionCode ec = 0;
    43     RefPtr<Node> node = impl()->nextNode(exec, ec);
    44     if (ec) {
    45         setDOMException(exec, ec);
    46         return jsUndefined();
    47     }
    48 
    49     if (exec->hadException())
    50         return jsUndefined();
    51 
    52     return toJS(exec, node.get());
    5340}
    54 
    55 JSValue JSNodeIterator::previousNode(ExecState* exec, const ArgList&)
    56 {
    57     ExceptionCode ec = 0;
    58     RefPtr<Node> node = impl()->previousNode(exec, ec);
    59     if (ec) {
    60         setDOMException(exec, ec);
    61         return jsUndefined();
    62     }
    63 
    64     if (exec->hadException())
    65         return jsUndefined();
    66 
    67     return toJS(exec, node.get());
    68 }
    69 
    70 }
  • trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r58330 r58333  
    19171917    } else {
    19181918        push(@implContent, "\n" . $indent . "JSC::JSValue result = " . NativeToJSValue($function->signature, 1, $implClassName, "", $functionString, "castedThisObj") . ";\n");
     1919        push(@implContent, $indent . "setDOMException(exec, ec);\n") if @{$function->raisesExceptions};
     1920
    19191921        $callWith = $function->signature->extendedAttributes->{"CallWith"};
    19201922        if ($callWith and $callWith eq "ScriptState") {
     
    19221924            push(@implContent, $indent . "    return jsUndefined();\n");
    19231925        }
    1924         push(@implContent, $indent . "setDOMException(exec, ec);\n") if @{$function->raisesExceptions};
    19251926
    19261927        if ($podType and not $function->signature->extendedAttributes->{"Immutable"}) {
  • trunk/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r58298 r58333  
    24152415    }
    24162416
     2417    if (@{$function->raisesExceptions}) {
     2418        $result .= $indent . "if (UNLIKELY(ec))\n";
     2419        $result .= $indent . "    goto fail;\n";
     2420    }
     2421
    24172422    if ($hasScriptState) {
    24182423        $result .= $indent . "if (state.hadException())\n";
    24192424        $result .= $indent . "    return throwError(state.exception());\n"
    2420     }
    2421 
    2422     if (@{$function->raisesExceptions}) {
    2423         $result .= $indent . "if (UNLIKELY(ec))\n";
    2424         $result .= $indent . "    goto fail;\n";
    24252425    }
    24262426
  • trunk/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp

    r58330 r58333  
    208208    WebCore::TestObj * item = WebKit::core(self);
    209209    PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->withScriptStateObj());
     210    WebKitDOMTestObj*  res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get()));
     211    return res;
     212
     213}
     214
     215void
     216webkit_dom_test_obj_with_script_state_void_exception (WebKitDOMTestObj *self, GError **error)
     217{
     218    g_return_if_fail (self);
     219    WebCore::TestObj * item = WebKit::core(self);
     220    WebCore::ExceptionCode ec = 0;
     221    item->withScriptStateVoidException(ec);
     222    if (ec) {
     223        WebCore::ExceptionCodeDescription ecdesc;
     224        WebCore::getExceptionCodeDescription(ec, ecdesc);
     225        g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
     226    }
     227
     228}
     229
     230WebKitDOMTestObj*
     231webkit_dom_test_obj_with_script_state_obj_exception (WebKitDOMTestObj *self, GError **error)
     232{
     233    g_return_val_if_fail (self, 0);
     234    WebCore::TestObj * item = WebKit::core(self);
     235    WebCore::ExceptionCode ec = 0;
     236    PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->withScriptStateObjException(ec));
     237    if (ec) {
     238        WebCore::ExceptionCodeDescription ecdesc;
     239        WebCore::getExceptionCodeDescription(ec, ecdesc);
     240        g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name);
     241    }
    210242    WebKitDOMTestObj*  res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get()));
    211243    return res;
  • trunk/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h

    r58330 r58333  
    9999
    100100WEBKIT_API void
     101webkit_dom_test_obj_with_script_state_void_exception (WebKitDOMTestObj *self, GError **error);
     102
     103WEBKIT_API WebKitDOMTestObj*
     104webkit_dom_test_obj_with_script_state_obj_exception (WebKitDOMTestObj *self, GError **error);
     105
     106WEBKIT_API void
    101107webkit_dom_test_obj_method_with_optional_arg (WebKitDOMTestObj *self, glong opt);
    102108
  • trunk/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r58330 r58333  
    130130#endif
    131131
    132 static const HashTableValue JSTestObjPrototypeTableValues[23] =
     132static const HashTableValue JSTestObjPrototypeTableValues[25] =
    133133{
    134134    { "voidMethod", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVoidMethod), (intptr_t)0 THUNK_GENERATOR(0) },
     
    151151    { "withScriptStateVoid", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateVoid), (intptr_t)0 THUNK_GENERATOR(0) },
    152152    { "withScriptStateObj", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateObj), (intptr_t)0 THUNK_GENERATOR(0) },
     153    { "withScriptStateVoidException", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateVoidException), (intptr_t)0 THUNK_GENERATOR(0) },
     154    { "withScriptStateObjException", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateObjException), (intptr_t)0 THUNK_GENERATOR(0) },
    153155    { "methodWithOptionalArg", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalArg), (intptr_t)1 THUNK_GENERATOR(0) },
    154156    { "methodWithNonOptionalArgAndOptionalArg", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg), (intptr_t)2 THUNK_GENERATOR(0) },
     
    162164    { 8191, JSTestObjPrototypeTableValues, 0 };
    163165#else
    164     { 66, 63, JSTestObjPrototypeTableValues, 0 };
     166    { 67, 63, JSTestObjPrototypeTableValues, 0 };
    165167#endif
    166168
     
    642644}
    643645
     646JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateVoidException(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
     647{
     648    UNUSED_PARAM(args);
     649    if (!thisValue.inherits(&JSTestObj::s_info))
     650        return throwError(exec, TypeError);
     651    JSTestObj* castedThisObj = static_cast<JSTestObj*>(asObject(thisValue));
     652    TestObj* imp = static_cast<TestObj*>(castedThisObj->impl());
     653    ExceptionCode ec = 0;
     654
     655    imp->withScriptStateVoidException(exec, ec);
     656    setDOMException(exec, ec);
     657    return jsUndefined();
     658}
     659
     660JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateObjException(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
     661{
     662    UNUSED_PARAM(args);
     663    if (!thisValue.inherits(&JSTestObj::s_info))
     664        return throwError(exec, TypeError);
     665    JSTestObj* castedThisObj = static_cast<JSTestObj*>(asObject(thisValue));
     666    TestObj* imp = static_cast<TestObj*>(castedThisObj->impl());
     667    ExceptionCode ec = 0;
     668
     669
     670    JSC::JSValue result = toJS(exec, castedThisObj->globalObject(), WTF::getPtr(imp->withScriptStateObjException(exec, ec)));
     671    setDOMException(exec, ec);
     672    if (exec->hadException())
     673        return jsUndefined();
     674    return result;
     675}
     676
    644677JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArg(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
    645678{
  • trunk/WebCore/bindings/scripts/test/JS/JSTestObj.h

    r58330 r58333  
    105105JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateVoid(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&);
    106106JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateObj(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&);
     107JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateVoidException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&);
     108JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateObjException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&);
    107109JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArg(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&);
    108110JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&);
  • trunk/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h

    r58330 r58333  
    7171- (void)withScriptStateVoid;
    7272- (DOMTestObj *)withScriptStateObj;
     73- (void)withScriptStateVoidException;
     74- (DOMTestObj *)withScriptStateObjException;
    7375- (void)methodWithOptionalArg:(int)opt;
    7476- (void)methodWithNonOptionalArgAndOptionalArg:(int)nonOpt opt:(int)opt;
  • trunk/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm

    r58330 r58333  
    258258}
    259259
     260- (void)withScriptStateVoidException
     261{
     262    WebCore::ExceptionCode ec = 0;
     263    IMPL->withScriptStateVoidException(ec);
     264    WebCore::raiseOnDOMError(ec);
     265}
     266
     267- (DOMTestObj *)withScriptStateObjException
     268{
     269    WebCore::ExceptionCode ec = 0;
     270    DOMTestObj *result = kit(WTF::getPtr(IMPL->withScriptStateObjException(ec)));
     271    WebCore::raiseOnDOMError(ec);
     272    return result;
     273}
     274
    260275- (void)methodWithOptionalArg:(int)opt
    261276{
  • trunk/WebCore/bindings/scripts/test/TestObj.idl

    r58330 r58333  
    7676        [CallWith=ScriptState] void withScriptStateVoid();
    7777        [CallWith=ScriptState] TestObj withScriptStateObj();
     78        [CallWith=ScriptState] void withScriptStateVoidException()
     79            raises(DOMException);
     80        [CallWith=ScriptState] TestObj withScriptStateObjException()
     81            raises(DOMException);
    7882
    7983        // 'Optional' extended attribute
  • trunk/WebCore/bindings/scripts/test/V8/V8TestObj.cpp

    r58330 r58333  
    373373        return throwError(state.exception());
    374374    return toV8(result.release());
     375}
     376
     377static v8::Handle<v8::Value> withScriptStateVoidExceptionCallback(const v8::Arguments& args)
     378{
     379    INC_STATS("DOM.TestObj.withScriptStateVoidException");
     380    TestObj* imp = V8TestObj::toNative(args.Holder());
     381    ExceptionCode ec = 0;
     382    {
     383    EmptyScriptState state;
     384    imp->withScriptStateVoidException(&state, ec);
     385    if (UNLIKELY(ec))
     386        goto fail;
     387    if (state.hadException())
     388        return throwError(state.exception());
     389    return v8::Handle<v8::Value>();
     390    }
     391    fail:
     392    V8Proxy::setDOMException(ec);
     393    return v8::Handle<v8::Value>();
     394}
     395
     396static v8::Handle<v8::Value> withScriptStateObjExceptionCallback(const v8::Arguments& args)
     397{
     398    INC_STATS("DOM.TestObj.withScriptStateObjException");
     399    TestObj* imp = V8TestObj::toNative(args.Holder());
     400    ExceptionCode ec = 0;
     401    {
     402    EmptyScriptState state;
     403    RefPtr<TestObj> result = imp->withScriptStateObjException(&state, ec);
     404    if (UNLIKELY(ec))
     405        goto fail;
     406    if (state.hadException())
     407        return throwError(state.exception());
     408    return toV8(result.release());
     409    }
     410    fail:
     411    V8Proxy::setDOMException(ec);
     412    return v8::Handle<v8::Value>();
    375413}
    376414
     
    514552    {"withScriptStateVoid", TestObjInternal::withScriptStateVoidCallback},
    515553    {"withScriptStateObj", TestObjInternal::withScriptStateObjCallback},
     554    {"withScriptStateVoidException", TestObjInternal::withScriptStateVoidExceptionCallback},
     555    {"withScriptStateObjException", TestObjInternal::withScriptStateObjExceptionCallback},
    516556    {"methodWithOptionalArg", TestObjInternal::methodWithOptionalArgCallback},
    517557    {"methodWithNonOptionalArgAndOptionalArg", TestObjInternal::methodWithNonOptionalArgAndOptionalArgCallback},
  • trunk/WebCore/dom/NodeIterator.idl

    r52537 r58333  
    3232        readonly attribute boolean pointerBeforeReferenceNode;
    3333
    34         [Custom] Node nextNode()
     34        [CallWith=ScriptState] Node nextNode()
    3535            raises (DOMException);
    36         [Custom] Node previousNode()
     36        [CallWith=ScriptState] Node previousNode()
    3737            raises (DOMException);
    3838        void detach();
Note: See TracChangeset for help on using the changeset viewer.