Changeset 200242 in webkit


Ignore:
Timestamp:
Apr 29, 2016, 9:08:00 AM (9 years ago)
Author:
Chris Dumez
Message:

[Web IDL] Drop 'any' type handling from CanUseWTFOptionalForParameter()
https://bugs.webkit.org/show_bug.cgi?id=157152

Reviewed by Darin Adler.

Drop 'any' type handling from CanUseWTFOptionalForParameter(). Always
use undefined as default value for parameters of type 'any' unless
specified otherwise.

  • Modules/indexeddb/IDBCursor.cpp:

(WebCore::IDBCursor::continueFunction): Deleted.

  • Modules/indexeddb/IDBCursor.h:
  • Modules/indexeddb/IDBObjectStore.cpp:

(WebCore::IDBObjectStore::add): Deleted.
(WebCore::IDBObjectStore::putOrAdd): Deleted.

  • Modules/indexeddb/IDBObjectStore.h:
  • bindings/scripts/CodeGeneratorJS.pm:

(WillConvertUndefinedToDefaultParameterValue):
Fix optimization for optional DOMString attributes whose default value
is the string "undefined". I also added bindings test coverage for it.

(GenerateParametersCheck):
(CanUseWTFOptionalForParameter): Deleted.

  • bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:

(webkit_dom_test_obj_method_with_optional_string_is_undefined):
(webkit_dom_test_obj_method_with_optional_any):

  • bindings/scripts/test/GObject/WebKitDOMTestObj.h:
  • bindings/scripts/test/JS/JSTestObj.cpp:

(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalStringIsUndefined):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalAny):

  • bindings/scripts/test/ObjC/DOMTestObj.h:
  • bindings/scripts/test/ObjC/DOMTestObj.mm:

(-[DOMTestObj methodWithOptionalStringIsUndefined:]):
(-[DOMTestObj methodWithOptionalAny:]):

  • bindings/scripts/test/TestObj.idl:
  • testing/Internals.h:
Location:
trunk/Source/WebCore
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r200240 r200242  
     12016-04-29  Chris Dumez  <cdumez@apple.com>
     2
     3        [Web IDL] Drop 'any' type handling from CanUseWTFOptionalForParameter()
     4        https://bugs.webkit.org/show_bug.cgi?id=157152
     5
     6        Reviewed by Darin Adler.
     7
     8        Drop 'any' type handling from CanUseWTFOptionalForParameter(). Always
     9        use undefined as default value for parameters of type 'any' unless
     10        specified otherwise.
     11
     12        * Modules/indexeddb/IDBCursor.cpp:
     13        (WebCore::IDBCursor::continueFunction): Deleted.
     14        * Modules/indexeddb/IDBCursor.h:
     15        * Modules/indexeddb/IDBObjectStore.cpp:
     16        (WebCore::IDBObjectStore::add): Deleted.
     17        (WebCore::IDBObjectStore::putOrAdd): Deleted.
     18        * Modules/indexeddb/IDBObjectStore.h:
     19        * bindings/scripts/CodeGeneratorJS.pm:
     20
     21        (WillConvertUndefinedToDefaultParameterValue):
     22        Fix optimization for optional DOMString attributes whose default value
     23        is the string "undefined". I also added bindings test coverage for it.
     24
     25        (GenerateParametersCheck):
     26        (CanUseWTFOptionalForParameter): Deleted.
     27        * bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:
     28        (webkit_dom_test_obj_method_with_optional_string_is_undefined):
     29        (webkit_dom_test_obj_method_with_optional_any):
     30        * bindings/scripts/test/GObject/WebKitDOMTestObj.h:
     31        * bindings/scripts/test/JS/JSTestObj.cpp:
     32        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalStringIsUndefined):
     33        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalAny):
     34        * bindings/scripts/test/ObjC/DOMTestObj.h:
     35        * bindings/scripts/test/ObjC/DOMTestObj.mm:
     36        (-[DOMTestObj methodWithOptionalStringIsUndefined:]):
     37        (-[DOMTestObj methodWithOptionalAny:]):
     38        * bindings/scripts/test/TestObj.idl:
     39        * testing/Internals.h:
     40
    1412016-04-29  Joanmarie Diggs  <jdiggs@igalia.com>
    242
  • trunk/Source/WebCore/Modules/indexeddb/IDBCursor.cpp

    r199668 r200242  
    256256}
    257257
    258 void IDBCursor::continueFunction(ScriptExecutionContext&, ExceptionCodeWithMessage& ec)
    259 {
    260     continueFunction(IDBKeyData(), ec);
    261 }
    262 
    263258void IDBCursor::continueFunction(ScriptExecutionContext& context, JSValue keyValue, ExceptionCodeWithMessage& ec)
    264259{
  • trunk/Source/WebCore/Modules/indexeddb/IDBCursor.h

    r200036 r200242  
    6565    RefPtr<IDBRequest> update(JSC::ExecState&, JSC::JSValue, ExceptionCodeWithMessage&);
    6666    void advance(unsigned, ExceptionCodeWithMessage&);
    67     void continueFunction(ScriptExecutionContext&, ExceptionCodeWithMessage&);
    6867    void continueFunction(ScriptExecutionContext&, JSC::JSValue key, ExceptionCodeWithMessage&);
    6968    RefPtr<IDBRequest> deleteFunction(ScriptExecutionContext&, ExceptionCodeWithMessage&);
  • trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp

    r200192 r200242  
    204204}
    205205
    206 RefPtr<IDBRequest> IDBObjectStore::add(ExecState& state, JSValue value, ExceptionCodeWithMessage& ec)
    207 {
    208     return putOrAdd(state, value, nullptr, IndexedDB::ObjectStoreOverwriteMode::NoOverwrite, InlineKeyCheck::Perform, ec);
    209 }
    210 
    211206RefPtr<IDBRequest> IDBObjectStore::add(ExecState& execState, JSValue value, JSValue key, ExceptionCodeWithMessage& ec)
    212207{
     
    223218        idbKey = scriptValueToIDBKey(execState, key);
    224219    return putOrAdd(execState, value, idbKey, IndexedDB::ObjectStoreOverwriteMode::Overwrite, InlineKeyCheck::Perform, ec);
    225 }
    226 
    227 RefPtr<IDBRequest> IDBObjectStore::put(ExecState& state, JSValue value, ExceptionCodeWithMessage& ec)
    228 {
    229     return putOrAdd(state, value, nullptr, IndexedDB::ObjectStoreOverwriteMode::Overwrite, InlineKeyCheck::Perform, ec);
    230220}
    231221
  • trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h

    r200192 r200242  
    6363    bool autoIncrement() const;
    6464
    65     RefPtr<IDBRequest> add(JSC::ExecState&, JSC::JSValue, ExceptionCodeWithMessage&);
    66     RefPtr<IDBRequest> put(JSC::ExecState&, JSC::JSValue, ExceptionCodeWithMessage&);
    6765    RefPtr<IDBRequest> openCursor(ScriptExecutionContext&, IDBKeyRange*, const String& direction, ExceptionCodeWithMessage&);
    6866    RefPtr<IDBRequest> openCursor(ScriptExecutionContext&, JSC::JSValue key, const String& direction, ExceptionCodeWithMessage&);
  • trunk/Source/WebCore/bindings/js/JSIDBObjectStoreCustom.cpp

    r199643 r200242  
    6767    ExceptionCodeWithMessage ec;
    6868    auto value = state.uncheckedArgument(0);
    69 
    70     if (argsCount == 1) {
    71         JSValue result;
    72         if (overwrite)
    73             result = toJS(&state, castedThis->globalObject(), wrapped.put(state, value, ec).get());
    74         else
    75             result = toJS(&state, castedThis->globalObject(), wrapped.add(state, value, ec).get());
    76 
    77         setDOMException(&state, ec);
    78         return result;
    79     }
    80 
    81     auto key = state.uncheckedArgument(1);
     69    auto key = state.argument(1);
    8270    JSValue result;
    8371    if (overwrite)
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r200192 r200242  
    33823382    return 0 if $codeGenerator->IsEnumType($type);
    33833383    return 0 if $codeGenerator->IsWrapperType($type);
    3384     return 0 if $type eq "any";
    33853384
    33863385    return 1;
     
    34013400
    34023401    # toString() will convert undefined to the string "undefined";
    3403     return 1 if $parameterType eq "DOMString" and $defaultValue eq "undefined";
     3402    return 1 if $parameterType eq "DOMString" and $defaultValue eq "\"undefined\"";
     3403
     3404    return 1 if $parameterType eq "any" and $defaultValue eq "undefined";
    34043405
    34053406    # JSValue::toBoolean() will convert undefined to false.
     
    34743475        # We use the null string as default value for non-nullable parameters of type DOMString unless specified otherwise.
    34753476        $parameter->default("null") if ($optional && !defined($parameter->default) && $argType eq "DOMString" && !$parameter->isNullable);
     3477
     3478        # We use undefined as default value for optional parameters of type 'any' unless specified otherwise.
     3479        $parameter->default("undefined") if ($optional && !defined($parameter->default) && $argType eq "any");
    34763480
    34773481        # FIXME: We should eventually stop generating any early calls, and instead use either default parameter values or WTF::Optional<>.
     
    36443648                        $defaultValue = "PNaN" if $defaultValue eq "NaN";
    36453649                        $defaultValue = "$nativeType()" if $defaultValue eq "[]";
     3650                        $defaultValue = "JSValue::JSUndefined" if $defaultValue eq "undefined";
    36463651                    }
    36473652
  • trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp

    r200131 r200242  
    16371637}
    16381638
     1639void webkit_dom_test_obj_method_with_optional_string_is_undefined(WebKitDOMTestObj* self, const gchar* str)
     1640{
     1641    WebCore::JSMainThreadNullState state;
     1642    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self));
     1643    g_return_if_fail(str);
     1644    WebCore::TestObj* item = WebKit::core(self);
     1645    WTF::String convertedStr = WTF::String::fromUTF8(str);
     1646    item->methodWithOptionalStringIsUndefined(convertedStr);
     1647}
     1648
    16391649void webkit_dom_test_obj_method_with_optional_atomic_string_is_null(WebKitDOMTestObj* self, const gchar* str)
    16401650{
     
    17491759    WebCore::TestObj* item = WebKit::core(self);
    17501760    item->methodWithOptionalBooleanIsFalse(b);
     1761}
     1762
     1763void webkit_dom_test_obj_method_with_optional_any(WebKitDOMTestObj* self, WebKitDOMany* a)
     1764{
     1765    WebCore::JSMainThreadNullState state;
     1766    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self));
     1767    g_return_if_fail(WEBKIT_DOM_IS_ANY(a));
     1768    WebCore::TestObj* item = WebKit::core(self);
     1769    WebCore::any* convertedA = WebKit::core(a);
     1770    item->methodWithOptionalAny(convertedA);
    17511771}
    17521772
  • trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h

    r200131 r200242  
    560560
    561561/**
     562 * webkit_dom_test_obj_method_with_optional_string_is_undefined:
     563 * @self: A #WebKitDOMTestObj
     564 * @str: A #gchar
     565 *
     566 * Stability: Unstable
     567**/
     568WEBKIT_API void
     569webkit_dom_test_obj_method_with_optional_string_is_undefined(WebKitDOMTestObj* self, const gchar* str);
     570
     571/**
    562572 * webkit_dom_test_obj_method_with_optional_atomic_string_is_null:
    563573 * @self: A #WebKitDOMTestObj
     
    688698WEBKIT_API void
    689699webkit_dom_test_obj_method_with_optional_boolean_is_false(WebKitDOMTestObj* self, gboolean b);
     700
     701/**
     702 * webkit_dom_test_obj_method_with_optional_any:
     703 * @self: A #WebKitDOMTestObj
     704 * @a: A #WebKitDOMany
     705 *
     706 * Stability: Unstable
     707**/
     708WEBKIT_API void
     709webkit_dom_test_obj_method_with_optional_any(WebKitDOMTestObj* self, WebKitDOMany* a);
    690710
    691711/**
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r200192 r200242  
    143143JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalAtomicStringAndDefaultValue(JSC::ExecState*);
    144144JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalStringIsNull(JSC::ExecState*);
     145JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalStringIsUndefined(JSC::ExecState*);
    145146JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalAtomicStringIsNull(JSC::ExecState*);
    146147JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalStringIsEmptyString(JSC::ExecState*);
     
    157158JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalBoolean(JSC::ExecState*);
    158159JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalBooleanIsFalse(JSC::ExecState*);
     160JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalAny(JSC::ExecState*);
    159161JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithCallbackArg(JSC::ExecState*);
    160162JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArg(JSC::ExecState*);
     
    717719    { "methodWithOptionalAtomicStringAndDefaultValue", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalAtomicStringAndDefaultValue), (intptr_t) (0) } },
    718720    { "methodWithOptionalStringIsNull", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalStringIsNull), (intptr_t) (0) } },
     721    { "methodWithOptionalStringIsUndefined", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalStringIsUndefined), (intptr_t) (0) } },
    719722    { "methodWithOptionalAtomicStringIsNull", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalAtomicStringIsNull), (intptr_t) (0) } },
    720723    { "methodWithOptionalStringIsEmptyString", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalStringIsEmptyString), (intptr_t) (0) } },
     
    731734    { "methodWithOptionalBoolean", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalBoolean), (intptr_t) (0) } },
    732735    { "methodWithOptionalBooleanIsFalse", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalBooleanIsFalse), (intptr_t) (0) } },
     736    { "methodWithOptionalAny", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalAny), (intptr_t) (0) } },
    733737    { "methodWithCallbackArg", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithCallbackArg), (intptr_t) (1) } },
    734738    { "methodWithNonCallbackArgAndCallbackArg", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArg), (intptr_t) (2) } },
     
    42004204}
    42014205
     4206EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalStringIsUndefined(ExecState* state)
     4207{
     4208    JSValue thisValue = state->thisValue();
     4209    auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
     4210    if (UNLIKELY(!castedThis))
     4211        return throwThisTypeError(*state, "TestObj", "methodWithOptionalStringIsUndefined");
     4212    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
     4213    auto& impl = castedThis->wrapped();
     4214    String str = state->argument(0).toString(state)->value(state);
     4215    if (UNLIKELY(state->hadException()))
     4216        return JSValue::encode(jsUndefined());
     4217    impl.methodWithOptionalStringIsUndefined(str);
     4218    return JSValue::encode(jsUndefined());
     4219}
     4220
    42024221EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalAtomicStringIsNull(ExecState* state)
    42034222{
     
    44074426        return JSValue::encode(jsUndefined());
    44084427    impl.methodWithOptionalBooleanIsFalse(b);
     4428    return JSValue::encode(jsUndefined());
     4429}
     4430
     4431EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalAny(ExecState* state)
     4432{
     4433    JSValue thisValue = state->thisValue();
     4434    auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
     4435    if (UNLIKELY(!castedThis))
     4436        return throwThisTypeError(*state, "TestObj", "methodWithOptionalAny");
     4437    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
     4438    auto& impl = castedThis->wrapped();
     4439    JSC::JSValue a = state->argument(0);
     4440    if (UNLIKELY(state->hadException()))
     4441        return JSValue::encode(jsUndefined());
     4442    impl.methodWithOptionalAny(a);
    44094443    return JSValue::encode(jsUndefined());
    44104444}
  • trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h

    r200131 r200242  
    182182- (void)methodWithOptionalAtomicStringAndDefaultValue:(NSString *)str;
    183183- (void)methodWithOptionalStringIsNull:(NSString *)str;
     184- (void)methodWithOptionalStringIsUndefined:(NSString *)str;
    184185- (void)methodWithOptionalAtomicStringIsNull:(NSString *)str;
    185186- (void)methodWithOptionalStringIsEmptyString:(NSString *)str;
     
    193194- (void)methodWithOptionalBoolean:(BOOL)b;
    194195- (void)methodWithOptionalBooleanIsFalse:(BOOL)b;
     196- (void)methodWithOptionalAny:(DOMany *)a;
    195197- (void)classMethod;
    196198- (int)classMethodWithOptional:(int)arg;
  • trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm

    r200131 r200242  
    13111311}
    13121312
     1313- (void)methodWithOptionalStringIsUndefined:(NSString *)str
     1314{
     1315    WebCore::JSMainThreadNullState state;
     1316    IMPL->methodWithOptionalStringIsUndefined(str);
     1317}
     1318
    13131319- (void)methodWithOptionalAtomicStringIsNull:(NSString *)str
    13141320{
     
    13751381    WebCore::JSMainThreadNullState state;
    13761382    IMPL->methodWithOptionalBooleanIsFalse(b);
     1383}
     1384
     1385- (void)methodWithOptionalAny:(DOMany *)a
     1386{
     1387    WebCore::JSMainThreadNullState state;
     1388    IMPL->methodWithOptionalAny(core(a));
    13771389}
    13781390
  • trunk/Source/WebCore/bindings/scripts/test/TestObj.idl

    r200131 r200242  
    186186    void    methodWithOptionalAtomicStringAndDefaultValue([AtomicString] optional DOMString str = "foo");
    187187    void    methodWithOptionalStringIsNull(optional DOMString str = null);
     188    void    methodWithOptionalStringIsUndefined(optional DOMString str = "undefined");
    188189    void    methodWithOptionalAtomicStringIsNull([AtomicString] optional DOMString str = null);
    189190    void    methodWithOptionalStringIsEmptyString(optional DOMString str = "");
     
    200201    void    methodWithOptionalBoolean(optional boolean b);
    201202    void    methodWithOptionalBooleanIsFalse(optional boolean b = false);
     203    void    methodWithOptionalAny(optional any a);
    202204
    203205#if defined(TESTING_JS)
  • trunk/Source/WebCore/testing/Internals.h

    r200232 r200242  
    201201        unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allowShadowContent, bool allowChildFrameContent, ExceptionCode&) const;
    202202
    203     String parserMetaData(JSC::JSValue = { });
     203    String parserMetaData(JSC::JSValue = JSC::JSValue::JSUndefined);
    204204
    205205    void updateEditorUINowIfScheduled();
Note: See TracChangeset for help on using the changeset viewer.