Changeset 200242 in webkit
- Timestamp:
- Apr 29, 2016, 9:08:00 AM (9 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r200240 r200242 1 2016-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 1 41 2016-04-29 Joanmarie Diggs <jdiggs@igalia.com> 2 42 -
trunk/Source/WebCore/Modules/indexeddb/IDBCursor.cpp
r199668 r200242 256 256 } 257 257 258 void IDBCursor::continueFunction(ScriptExecutionContext&, ExceptionCodeWithMessage& ec)259 {260 continueFunction(IDBKeyData(), ec);261 }262 263 258 void IDBCursor::continueFunction(ScriptExecutionContext& context, JSValue keyValue, ExceptionCodeWithMessage& ec) 264 259 { -
trunk/Source/WebCore/Modules/indexeddb/IDBCursor.h
r200036 r200242 65 65 RefPtr<IDBRequest> update(JSC::ExecState&, JSC::JSValue, ExceptionCodeWithMessage&); 66 66 void advance(unsigned, ExceptionCodeWithMessage&); 67 void continueFunction(ScriptExecutionContext&, ExceptionCodeWithMessage&);68 67 void continueFunction(ScriptExecutionContext&, JSC::JSValue key, ExceptionCodeWithMessage&); 69 68 RefPtr<IDBRequest> deleteFunction(ScriptExecutionContext&, ExceptionCodeWithMessage&); -
trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp
r200192 r200242 204 204 } 205 205 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 211 206 RefPtr<IDBRequest> IDBObjectStore::add(ExecState& execState, JSValue value, JSValue key, ExceptionCodeWithMessage& ec) 212 207 { … … 223 218 idbKey = scriptValueToIDBKey(execState, key); 224 219 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);230 220 } 231 221 -
trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h
r200192 r200242 63 63 bool autoIncrement() const; 64 64 65 RefPtr<IDBRequest> add(JSC::ExecState&, JSC::JSValue, ExceptionCodeWithMessage&);66 RefPtr<IDBRequest> put(JSC::ExecState&, JSC::JSValue, ExceptionCodeWithMessage&);67 65 RefPtr<IDBRequest> openCursor(ScriptExecutionContext&, IDBKeyRange*, const String& direction, ExceptionCodeWithMessage&); 68 66 RefPtr<IDBRequest> openCursor(ScriptExecutionContext&, JSC::JSValue key, const String& direction, ExceptionCodeWithMessage&); -
trunk/Source/WebCore/bindings/js/JSIDBObjectStoreCustom.cpp
r199643 r200242 67 67 ExceptionCodeWithMessage ec; 68 68 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); 82 70 JSValue result; 83 71 if (overwrite) -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r200192 r200242 3382 3382 return 0 if $codeGenerator->IsEnumType($type); 3383 3383 return 0 if $codeGenerator->IsWrapperType($type); 3384 return 0 if $type eq "any";3385 3384 3386 3385 return 1; … … 3401 3400 3402 3401 # 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"; 3404 3405 3405 3406 # JSValue::toBoolean() will convert undefined to false. … … 3474 3475 # We use the null string as default value for non-nullable parameters of type DOMString unless specified otherwise. 3475 3476 $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"); 3476 3480 3477 3481 # FIXME: We should eventually stop generating any early calls, and instead use either default parameter values or WTF::Optional<>. … … 3644 3648 $defaultValue = "PNaN" if $defaultValue eq "NaN"; 3645 3649 $defaultValue = "$nativeType()" if $defaultValue eq "[]"; 3650 $defaultValue = "JSValue::JSUndefined" if $defaultValue eq "undefined"; 3646 3651 } 3647 3652 -
trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp
r200131 r200242 1637 1637 } 1638 1638 1639 void 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 1639 1649 void webkit_dom_test_obj_method_with_optional_atomic_string_is_null(WebKitDOMTestObj* self, const gchar* str) 1640 1650 { … … 1749 1759 WebCore::TestObj* item = WebKit::core(self); 1750 1760 item->methodWithOptionalBooleanIsFalse(b); 1761 } 1762 1763 void 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); 1751 1771 } 1752 1772 -
trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h
r200131 r200242 560 560 561 561 /** 562 * webkit_dom_test_obj_method_with_optional_string_is_undefined: 563 * @self: A #WebKitDOMTestObj 564 * @str: A #gchar 565 * 566 * Stability: Unstable 567 **/ 568 WEBKIT_API void 569 webkit_dom_test_obj_method_with_optional_string_is_undefined(WebKitDOMTestObj* self, const gchar* str); 570 571 /** 562 572 * webkit_dom_test_obj_method_with_optional_atomic_string_is_null: 563 573 * @self: A #WebKitDOMTestObj … … 688 698 WEBKIT_API void 689 699 webkit_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 **/ 708 WEBKIT_API void 709 webkit_dom_test_obj_method_with_optional_any(WebKitDOMTestObj* self, WebKitDOMany* a); 690 710 691 711 /** -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r200192 r200242 143 143 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalAtomicStringAndDefaultValue(JSC::ExecState*); 144 144 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalStringIsNull(JSC::ExecState*); 145 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalStringIsUndefined(JSC::ExecState*); 145 146 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalAtomicStringIsNull(JSC::ExecState*); 146 147 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalStringIsEmptyString(JSC::ExecState*); … … 157 158 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalBoolean(JSC::ExecState*); 158 159 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalBooleanIsFalse(JSC::ExecState*); 160 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalAny(JSC::ExecState*); 159 161 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithCallbackArg(JSC::ExecState*); 160 162 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArg(JSC::ExecState*); … … 717 719 { "methodWithOptionalAtomicStringAndDefaultValue", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalAtomicStringAndDefaultValue), (intptr_t) (0) } }, 718 720 { "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) } }, 719 722 { "methodWithOptionalAtomicStringIsNull", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalAtomicStringIsNull), (intptr_t) (0) } }, 720 723 { "methodWithOptionalStringIsEmptyString", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalStringIsEmptyString), (intptr_t) (0) } }, … … 731 734 { "methodWithOptionalBoolean", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalBoolean), (intptr_t) (0) } }, 732 735 { "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) } }, 733 737 { "methodWithCallbackArg", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithCallbackArg), (intptr_t) (1) } }, 734 738 { "methodWithNonCallbackArgAndCallbackArg", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArg), (intptr_t) (2) } }, … … 4200 4204 } 4201 4205 4206 EncodedJSValue 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 4202 4221 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalAtomicStringIsNull(ExecState* state) 4203 4222 { … … 4407 4426 return JSValue::encode(jsUndefined()); 4408 4427 impl.methodWithOptionalBooleanIsFalse(b); 4428 return JSValue::encode(jsUndefined()); 4429 } 4430 4431 EncodedJSValue 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); 4409 4443 return JSValue::encode(jsUndefined()); 4410 4444 } -
trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h
r200131 r200242 182 182 - (void)methodWithOptionalAtomicStringAndDefaultValue:(NSString *)str; 183 183 - (void)methodWithOptionalStringIsNull:(NSString *)str; 184 - (void)methodWithOptionalStringIsUndefined:(NSString *)str; 184 185 - (void)methodWithOptionalAtomicStringIsNull:(NSString *)str; 185 186 - (void)methodWithOptionalStringIsEmptyString:(NSString *)str; … … 193 194 - (void)methodWithOptionalBoolean:(BOOL)b; 194 195 - (void)methodWithOptionalBooleanIsFalse:(BOOL)b; 196 - (void)methodWithOptionalAny:(DOMany *)a; 195 197 - (void)classMethod; 196 198 - (int)classMethodWithOptional:(int)arg; -
trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm
r200131 r200242 1311 1311 } 1312 1312 1313 - (void)methodWithOptionalStringIsUndefined:(NSString *)str 1314 { 1315 WebCore::JSMainThreadNullState state; 1316 IMPL->methodWithOptionalStringIsUndefined(str); 1317 } 1318 1313 1319 - (void)methodWithOptionalAtomicStringIsNull:(NSString *)str 1314 1320 { … … 1375 1381 WebCore::JSMainThreadNullState state; 1376 1382 IMPL->methodWithOptionalBooleanIsFalse(b); 1383 } 1384 1385 - (void)methodWithOptionalAny:(DOMany *)a 1386 { 1387 WebCore::JSMainThreadNullState state; 1388 IMPL->methodWithOptionalAny(core(a)); 1377 1389 } 1378 1390 -
trunk/Source/WebCore/bindings/scripts/test/TestObj.idl
r200131 r200242 186 186 void methodWithOptionalAtomicStringAndDefaultValue([AtomicString] optional DOMString str = "foo"); 187 187 void methodWithOptionalStringIsNull(optional DOMString str = null); 188 void methodWithOptionalStringIsUndefined(optional DOMString str = "undefined"); 188 189 void methodWithOptionalAtomicStringIsNull([AtomicString] optional DOMString str = null); 189 190 void methodWithOptionalStringIsEmptyString(optional DOMString str = ""); … … 200 201 void methodWithOptionalBoolean(optional boolean b); 201 202 void methodWithOptionalBooleanIsFalse(optional boolean b = false); 203 void methodWithOptionalAny(optional any a); 202 204 203 205 #if defined(TESTING_JS) -
trunk/Source/WebCore/testing/Internals.h
r200232 r200242 201 201 unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allowShadowContent, bool allowChildFrameContent, ExceptionCode&) const; 202 202 203 String parserMetaData(JSC::JSValue = { });203 String parserMetaData(JSC::JSValue = JSC::JSValue::JSUndefined); 204 204 205 205 void updateEditorUINowIfScheduled();
Note:
See TracChangeset
for help on using the changeset viewer.