Changeset 121817 in webkit


Ignore:
Timestamp:
Jul 3, 2012 5:23:35 PM (12 years ago)
Author:
jsbell@chromium.org
Message:

Binding: IDL type DOMString[] shouldn't match null
https://bugs.webkit.org/show_bug.cgi?id=84217

Reviewed by Kentaro Hara.

Similar to r121714, IDL overloads with T[] (which is only minimally supported)
were being treated as Nullable by default during overloaded method dispatching,
which deviates from the WebIDL specification. Extend the previous change to
look for Nullable (specified by "?" type suffix in the IDL) for array types.

Also, after inspection of the spec, use a strict "is this an Array?" test in
the JS generator rather than an "inherits from Array.prototype?" test, to
match the WebIDL spec.

IDL files with affected overloads are modified to include the "?" suffix
so that no behavior changes are introduced by this patch - the JS and V8
generator results before/after the change show no diffs apart from the stricter
isJSArray() test.

Test: bindings/scripts/test/TestObj.idl (a non-Nullable T[] overload)

  • Modules/indexeddb/IDBDatabase.idl: Tag T[] overloads with ? suffix.
  • Modules/indexeddb/IDBObjectStore.idl: Ditto.
  • Modules/vibration/NavigatorVibration.idl: Ditto.
  • bindings/scripts/CodeGeneratorJS.pm: Check isNullable for T[].

(GenerateParametersCheckExpression):

  • bindings/scripts/CodeGeneratorV8.pm: Ditto.

(GenerateParametersCheckExpression):

  • bindings/scripts/test/JS/JSTestObj.cpp: Rebaselined.

(WebCore::jsTestObjPrototypeFunctionOverloadedMethod9):
(WebCore):
(WebCore::jsTestObjPrototypeFunctionOverloadedMethod):

  • bindings/scripts/test/TestObj.idl: Tag existing T[] with ?, add non-? T[].
  • bindings/scripts/test/V8/V8TestObj.cpp: Rebaselined.

(WebCore::TestObjV8Internal::overloadedMethod9Callback):
(TestObjV8Internal):
(WebCore::TestObjV8Internal::overloadedMethodCallback):

Location:
trunk/Source/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r121813 r121817  
     12012-07-03  Joshua Bell  <jsbell@chromium.org>
     2
     3        Binding: IDL type DOMString[] shouldn't match null
     4        https://bugs.webkit.org/show_bug.cgi?id=84217
     5
     6        Reviewed by Kentaro Hara.
     7
     8        Similar to r121714, IDL overloads with T[] (which is only minimally supported)
     9        were being treated as Nullable by default during overloaded method dispatching,
     10        which deviates from the WebIDL specification. Extend the previous change to
     11        look for Nullable (specified by "?" type suffix in the IDL) for array types.
     12
     13        Also, after inspection of the spec, use a strict "is this an Array?" test in
     14        the JS generator rather than an "inherits from Array.prototype?" test, to
     15        match the WebIDL spec.
     16
     17        IDL files with affected overloads are modified to include the "?" suffix
     18        so that no behavior changes are introduced by this patch - the JS and V8
     19        generator results before/after the change show no diffs apart from the stricter
     20        isJSArray() test.
     21
     22        Test: bindings/scripts/test/TestObj.idl (a non-Nullable T[] overload)
     23
     24        * Modules/indexeddb/IDBDatabase.idl: Tag T[] overloads with ? suffix.
     25        * Modules/indexeddb/IDBObjectStore.idl: Ditto.
     26        * Modules/vibration/NavigatorVibration.idl: Ditto.
     27        * bindings/scripts/CodeGeneratorJS.pm: Check isNullable for T[].
     28        (GenerateParametersCheckExpression):
     29        * bindings/scripts/CodeGeneratorV8.pm: Ditto.
     30        (GenerateParametersCheckExpression):
     31        * bindings/scripts/test/JS/JSTestObj.cpp: Rebaselined.
     32        (WebCore::jsTestObjPrototypeFunctionOverloadedMethod9):
     33        (WebCore):
     34        (WebCore::jsTestObjPrototypeFunctionOverloadedMethod):
     35        * bindings/scripts/test/TestObj.idl: Tag existing T[] with ?, add non-? T[].
     36        * bindings/scripts/test/V8/V8TestObj.cpp: Rebaselined.
     37        (WebCore::TestObjV8Internal::overloadedMethod9Callback):
     38        (TestObjV8Internal):
     39        (WebCore::TestObjV8Internal::overloadedMethodCallback):
     40
    1412012-07-03  Nate Chapin  <japhet@chromium.org>
    242
  • trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.idl

    r121714 r121817  
    4848        [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMStringList? storeNames, in [Optional=DefaultIsNullString] DOMString mode)
    4949            raises (IDBDatabaseException);
    50         [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMString[] storeNames, in [Optional=DefaultIsNullString] DOMString mode)
     50        [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMString[]? storeNames, in [Optional=DefaultIsNullString] DOMString mode)
    5151            raises (IDBDatabaseException);
    5252        [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMString storeName, in [Optional=DefaultIsNullString] DOMString mode)
     
    5656        [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMStringList? storeNames, in unsigned short mode)
    5757            raises (IDBDatabaseException);
    58         [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMString[] storeNames, in unsigned short mode)
     58        [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMString[]? storeNames, in unsigned short mode)
    5959            raises (IDBDatabaseException);
    6060        [CallWith=ScriptExecutionContext] IDBTransaction transaction(in DOMString storeName, in unsigned short mode)
  • trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.idl

    r121714 r121817  
    6060            raises (IDBDatabaseException);
    6161
    62         IDBIndex createIndex(in DOMString name, in DOMString[] keyPath, in [Optional] Dictionary options)
     62        IDBIndex createIndex(in DOMString name, in DOMString[]? keyPath, in [Optional] Dictionary options)
    6363            raises (IDBDatabaseException);
    6464        IDBIndex createIndex(in DOMString name, in DOMString keyPath, in [Optional] Dictionary options)
  • trunk/Source/WebCore/Modules/vibration/NavigatorVibration.idl

    r108272 r121817  
    2424        Supplemental=Navigator
    2525    ] NavigatorVibration {
    26         void webkitVibrate(in unsigned long[] pattern) raises(DOMException);
     26        void webkitVibrate(in unsigned long[]? pattern) raises(DOMException);
    2727        void webkitVibrate(in unsigned long time) raises(DOMException);
    2828    };
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r121714 r121817  
    12611261        } elsif (IsArrayType($type)) {
    12621262            # FIXME: Add proper support for T[], T[]?, sequence<T>
    1263             push(@andExpression, "(${value}.isNull() || (${value}.isObject() && asObject(${value})->inherits(&JSArray::s_info)))");
     1263            if ($parameter->isNullable) {
     1264                push(@andExpression, "(${value}.isNull() || (${value}.isObject() && isJSArray(${value})))");
     1265            } else {
     1266                push(@andExpression, "(${value}.isObject() && isJSArray(${value}))");
     1267            }
    12641268            $usedArguments{$parameterIndex} = 1;
    12651269        } elsif (!IsNativeType($type)) {
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r121714 r121817  
    13581358        } elsif (IsArrayType($type)) {
    13591359            # FIXME: Add proper support for T[], T[]?, sequence<T>.
    1360             push(@andExpression, "(${value}->IsNull() || ${value}->IsArray())");
     1360            if ($parameter->isNullable) {
     1361                push(@andExpression, "(${value}->IsNull() || ${value}->IsArray())");
     1362            } else {
     1363                push(@andExpression, "(${value}->IsArray())");
     1364            }
    13611365        } elsif (IsWrapperType($type)) {
    13621366            if ($parameter->isNullable) {
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r121714 r121817  
    21612161}
    21622162
     2163static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod9(ExecState* exec)
     2164{
     2165    JSValue thisValue = exec->hostThisValue();
     2166    if (!thisValue.inherits(&JSTestObj::s_info))
     2167        return throwVMTypeError(exec);
     2168    JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue));
     2169    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
     2170    TestObj* impl = static_cast<TestObj*>(castedThis->impl());
     2171    if (exec->argumentCount() < 1)
     2172        return throwVMError(exec, createNotEnoughArgumentsError(exec));
     2173    RefPtr<DOMStringList> arrayArg(toDOMStringList(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
     2174    if (exec->hadException())
     2175        return JSValue::encode(jsUndefined());
     2176    impl->overloadedMethod(arrayArg);
     2177    return JSValue::encode(jsUndefined());
     2178}
     2179
    21632180EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod(ExecState* exec)
    21642181{
     
    21782195    if ((argsCount == 1 && (arg0.isNull() || (arg0.isObject() && asObject(arg0)->inherits(&JSDOMStringList::s_info)))))
    21792196        return jsTestObjPrototypeFunctionOverloadedMethod6(exec);
    2180     if ((argsCount == 1 && (arg0.isNull() || (arg0.isObject() && asObject(arg0)->inherits(&JSArray::s_info)))))
     2197    if ((argsCount == 1 && (arg0.isNull() || (arg0.isObject() && isJSArray(arg0)))))
    21812198        return jsTestObjPrototypeFunctionOverloadedMethod7(exec);
    21822199    if ((argsCount == 1 && (arg0.isObject() && asObject(arg0)->inherits(&JSTestObj::s_info))))
    21832200        return jsTestObjPrototypeFunctionOverloadedMethod8(exec);
     2201    if ((argsCount == 1 && (arg0.isObject() && isJSArray(arg0))))
     2202        return jsTestObjPrototypeFunctionOverloadedMethod9(exec);
    21842203    return throwVMTypeError(exec);
    21852204}
  • trunk/Source/WebCore/bindings/scripts/test/TestObj.idl

    r121714 r121817  
    170170        void    overloadedMethod(in [Callback] TestCallback callback);
    171171        void    overloadedMethod(in DOMStringList? listArg);
     172        void    overloadedMethod(in DOMString[]? arrayArg);
     173        void    overloadedMethod(in TestObj objArg);
    172174        void    overloadedMethod(in DOMString[] arrayArg);
    173         void    overloadedMethod(in TestObj objArg);
    174175#endif
    175176
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp

    r121714 r121817  
    15831583}
    15841584
     1585static v8::Handle<v8::Value> overloadedMethod9Callback(const v8::Arguments& args)
     1586{
     1587    INC_STATS("DOM.TestObj.overloadedMethod9");
     1588    if (args.Length() < 1)
     1589        return V8Proxy::throwNotEnoughArgumentsError(args.GetIsolate());
     1590    TestObj* imp = V8TestObj::toNative(args.Holder());
     1591    EXCEPTION_BLOCK(RefPtr<DOMStringList>, arrayArg, v8ValueToWebCoreDOMStringList(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)));
     1592    imp->overloadedMethod(arrayArg);
     1593    return v8::Handle<v8::Value>();
     1594}
     1595
    15851596static v8::Handle<v8::Value> overloadedMethodCallback(const v8::Arguments& args)
    15861597{
     
    16021613    if ((args.Length() == 1 && (V8TestObj::HasInstance(args[0]))))
    16031614        return overloadedMethod8Callback(args);
     1615    if ((args.Length() == 1 && (args[0]->IsArray())))
     1616        return overloadedMethod9Callback(args);
    16041617    return V8Proxy::throwTypeError(0, args.GetIsolate());
    16051618}
Note: See TracChangeset for help on using the changeset viewer.