Changeset 206956 in webkit
- Timestamp:
- Oct 8, 2016 12:07:14 PM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 deleted
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r206917 r206956 1069 1069 bindings/js/JSCallbackData.cpp 1070 1070 bindings/js/JSCanvasRenderingContext2DCustom.cpp 1071 bindings/js/JSCharacterDataCustom.cpp1072 1071 bindings/js/JSClientRectCustom.cpp 1073 1072 bindings/js/JSCommandLineAPIHostCustom.cpp … … 1106 1105 bindings/js/JSDocumentCustom.cpp 1107 1106 bindings/js/JSDocumentFragmentCustom.cpp 1108 bindings/js/JSDocumentTypeCustom.cpp1109 1107 bindings/js/JSElementCustom.cpp 1110 1108 bindings/js/JSErrorEventCustom.cpp … … 1159 1157 bindings/js/JSNodeFilterCustom.cpp 1160 1158 bindings/js/JSNodeIteratorCustom.cpp 1161 bindings/js/JSNodeOrString.cpp1162 1159 bindings/js/JSNodeListCustom.cpp 1163 1160 bindings/js/JSPerformanceEntryCustom.cpp -
trunk/Source/WebCore/ChangeLog
r206954 r206956 1 2016-10-06 Sam Weinig <sam@webkit.org> 2 3 Autogenerate passing union types as part of a functions variadic arguments 4 https://bugs.webkit.org/show_bug.cgi?id=162919 5 6 Reviewed by Darin Adler. 7 8 * CMakeLists.txt: 9 * WebCore.xcodeproj/project.pbxproj: 10 * bindings/js/JSBindingsAllInOne.cpp: 11 Remove deleted files. 12 13 * bindings/generic/IDLTypes.h: 14 Switch to use std::reference_wrapper as it's implementation type. We may need more 15 granularity here in the future, but this will work for now. 16 17 * bindings/js/JSCharacterDataCustom.cpp: Removed. 18 * bindings/js/JSDocumentTypeCustom.cpp: Removed. 19 * bindings/js/JSNodeOrString.cpp: Removed. 20 * bindings/js/JSNodeOrString.h: Removed. 21 22 * bindings/js/JSDOMBinding.h: 23 (WebCore::VariadicHelperBase::convert): Deleted. 24 (WebCore::toArguments): Deleted. 25 Moved to JSDOMConvert.h and renamed to convertVariadicArguments and make 26 it work in terms of IDLTypes. 27 28 * bindings/js/JSDOMConvert.h: 29 (WebCore::Converter<IDLInterface<T>>::convert): 30 (WebCore::VariadicConverterBase::convert): 31 (WebCore::VariadicConverterBase<IDLInterface<T>>::convert): 32 (WebCore::convertVariadicArguments): 33 34 * bindings/js/JSDocumentCustom.cpp: 35 (WebCore::JSDocument::prepend): Deleted. 36 (WebCore::JSDocument::append): Deleted. 37 * bindings/js/JSDocumentFragmentCustom.cpp: 38 (WebCore::JSDocumentFragment::prepend): Deleted. 39 (WebCore::JSDocumentFragment::append): Deleted. 40 * bindings/js/JSElementCustom.cpp: 41 (WebCore::JSElement::before): Deleted. 42 (WebCore::JSElement::after): Deleted. 43 (WebCore::JSElement::replaceWith): Deleted. 44 (WebCore::JSElement::prepend): Deleted. 45 (WebCore::JSElement::append): Deleted. 46 Remove now generated functions. 47 48 * bindings/scripts/CodeGenerator.pm: 49 (assert): 50 Add assert to help debugging. 51 52 (ParseInterface): 53 Don't treat union types as interfaces. 54 55 (GetFlattenedMemberTypes): 56 (GetNumberOfNullableMemberTypes): 57 (GetIDLUnionMemberTypes): 58 Implement WebIDL algorithms for getting the flattened member list of union, and use it 59 to construct the c++ IDLType. 60 61 (GetBaseIDLType): 62 (GetIDLType): 63 Add helper to convert an parsed idlType to a c++ IDLType. 64 65 (IsWrapperType): 66 Don't treat union types as wrappers. 67 68 * bindings/scripts/CodeGeneratorJS.pm: 69 (AddToImplIncludesForIDLType): 70 Add helper for adding #includes based on a parsed idlType. It recursively handles union types. 71 72 (GenerateParametersCheck): 73 Use the new convertVariadicArguments function to handle all variadic arguments, including 74 union types. 75 76 * bindings/scripts/IDLParser.pm: 77 (parseDictionaryMember): 78 (parseAttributeRest): 79 (parseOptionalOrRequiredArgument): 80 (parseExceptionField): 81 Add an idlType to domSignature and populate it. 82 83 * bindings/scripts/test/JS/JSTestObj.cpp: 84 (WebCore::jsTestObjPrototypeFunctionOverloadedMethod13): 85 (WebCore::jsTestObjPrototypeFunctionVariadicStringMethod): 86 (WebCore::jsTestObjPrototypeFunctionVariadicDoubleMethod): 87 (WebCore::jsTestObjPrototypeFunctionVariadicNodeMethod): 88 (WebCore::jsTestObjPrototypeFunctionVariadicUnionMethod): 89 * bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp: 90 (WebCore::constructJSTestOverloadedConstructors5): 91 * bindings/scripts/test/TestObj.idl: 92 Add and update tests. 93 94 * dom/ChildNode.idl: 95 * dom/ParentNode.idl: 96 Remove Custom extended attribute. 97 98 * dom/ContainerNode.cpp: 99 * dom/ContainerNode.h: 100 * dom/Node.cpp: 101 * dom/Node.h: 102 Switch to using std::reference_wrapper instead of Ref<> for passed in parameters. 103 1 104 2016-10-08 Youenn Fablet <youenn@apple.com> 2 105 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r206917 r206956 2738 2738 7C2BDD3D17C7F98C0038FF15 /* JSDOMGlobalObjectTask.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C2BDD3B17C7F98B0038FF15 /* JSDOMGlobalObjectTask.cpp */; }; 2739 2739 7C2BDD3E17C7F98C0038FF15 /* JSDOMGlobalObjectTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C2BDD3C17C7F98B0038FF15 /* JSDOMGlobalObjectTask.h */; }; 2740 7C33F35A1B4A044800502CAF /* JSCharacterDataCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C33F3581B4A044800502CAF /* JSCharacterDataCustom.cpp */; };2741 7C33F35E1B4A04CE00502CAF /* JSDocumentTypeCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C33F35C1B4A04CE00502CAF /* JSDocumentTypeCustom.cpp */; };2742 2740 7C33F3621B4A050400502CAF /* JSDocumentFragmentCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C33F3601B4A050400502CAF /* JSDocumentFragmentCustom.cpp */; }; 2743 2741 7C3A91E61C963B8800D1A7E3 /* ClipboardAccessPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C3A91E51C963B8800D1A7E3 /* ClipboardAccessPolicy.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 2773 2771 7C7941E51C56C29300A4C58E /* DataDetectorsCoreSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C7941E31C56C29300A4C58E /* DataDetectorsCoreSoftLink.h */; }; 2774 2772 7C83DE861D04CC5D00FEBCF3 /* SpringSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C83DE851D04CBD400FEBCF3 /* SpringSolver.h */; }; 2775 7C91A38F1B498ABE003F9EFA /* JSNodeOrString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C91A38D1B498ABE003F9EFA /* JSNodeOrString.cpp */; };2776 7C91A3901B498ABE003F9EFA /* JSNodeOrString.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C91A38E1B498ABE003F9EFA /* JSNodeOrString.h */; };2777 2773 7C93F3491AA6BA5E00A98BAB /* CompiledContentExtension.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C93F3471AA6BA5E00A98BAB /* CompiledContentExtension.cpp */; }; 2778 2774 7C93F34A1AA6BA5E00A98BAB /* CompiledContentExtension.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C93F3481AA6BA5E00A98BAB /* CompiledContentExtension.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 9850 9846 7C2BDD3B17C7F98B0038FF15 /* JSDOMGlobalObjectTask.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMGlobalObjectTask.cpp; sourceTree = "<group>"; }; 9851 9847 7C2BDD3C17C7F98B0038FF15 /* JSDOMGlobalObjectTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMGlobalObjectTask.h; sourceTree = "<group>"; }; 9852 7C33F3581B4A044800502CAF /* JSCharacterDataCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCharacterDataCustom.cpp; sourceTree = "<group>"; };9853 7C33F35C1B4A04CE00502CAF /* JSDocumentTypeCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDocumentTypeCustom.cpp; sourceTree = "<group>"; };9854 9848 7C33F3601B4A050400502CAF /* JSDocumentFragmentCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDocumentFragmentCustom.cpp; sourceTree = "<group>"; }; 9855 9849 7C3A91E51C963B8800D1A7E3 /* ClipboardAccessPolicy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClipboardAccessPolicy.h; sourceTree = "<group>"; }; … … 9897 9891 7C7941E31C56C29300A4C58E /* DataDetectorsCoreSoftLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataDetectorsCoreSoftLink.h; sourceTree = "<group>"; }; 9898 9892 7C83DE851D04CBD400FEBCF3 /* SpringSolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpringSolver.h; sourceTree = "<group>"; }; 9899 7C91A38D1B498ABE003F9EFA /* JSNodeOrString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSNodeOrString.cpp; sourceTree = "<group>"; };9900 7C91A38E1B498ABE003F9EFA /* JSNodeOrString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSNodeOrString.h; sourceTree = "<group>"; };9901 9893 7C93F3471AA6BA5E00A98BAB /* CompiledContentExtension.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CompiledContentExtension.cpp; sourceTree = "<group>"; }; 9902 9894 7C93F3481AA6BA5E00A98BAB /* CompiledContentExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CompiledContentExtension.h; sourceTree = "<group>"; }; … … 21102 21094 C6F420A016B7164E0052A9F2 /* JSMutationCallback.cpp */, 21103 21095 C6F420A116B7164E0052A9F2 /* JSMutationCallback.h */, 21104 7C91A38D1B498ABE003F9EFA /* JSNodeOrString.cpp */,21105 7C91A38E1B498ABE003F9EFA /* JSNodeOrString.h */,21106 21096 CB38FD551CD21D5B00592A3F /* JSPerformanceEntryCustom.cpp */, 21107 21097 93B70D4F09EB0C7C009D8468 /* JSPluginElementFunctions.cpp */, … … 21155 21145 8931DE5A14C44C44000DC9D2 /* JSBlobCustom.cpp */, 21156 21146 49EED14B1051971900099FAB /* JSCanvasRenderingContext2DCustom.cpp */, 21157 7C33F3581B4A044800502CAF /* JSCharacterDataCustom.cpp */,21158 21147 46A58AC41D46B3FA00432036 /* JSClientRectCustom.cpp */, 21159 21148 A584FE371864DAC100843B10 /* JSCommandLineAPIHostCustom.cpp */, … … 21177 21166 ADDA94BF19686F8000453029 /* JSDocumentCustom.h */, 21178 21167 7C33F3601B4A050400502CAF /* JSDocumentFragmentCustom.cpp */, 21179 7C33F35C1B4A04CE00502CAF /* JSDocumentTypeCustom.cpp */,21180 21168 A9C6E6460D7465CA006442E9 /* JSDOMMimeTypeArrayCustom.cpp */, 21181 21169 A9C6E64A0D7465E7006442E9 /* JSDOMPluginArrayCustom.cpp */, … … 25264 25252 BCD9C2C30C17B69E005C90A2 /* JSNodeList.h in Headers */, 25265 25253 AD20B18D18E9D237005A8083 /* JSNodeListCustom.h in Headers */, 25266 7C91A3901B498ABE003F9EFA /* JSNodeOrString.h in Headers */,25267 25254 33503CA410179AD7003B47E1 /* JSNotification.h in Headers */, 25268 25255 33503CA610179AD7003B47E1 /* JSNotificationCenter.h in Headers */, … … 28649 28636 FDA15EA312B03EE1003A583A /* JSChannelSplitterNode.cpp in Sources */, 28650 28637 65DF31F309D1CC60000BE325 /* JSCharacterData.cpp in Sources */, 28651 7C33F35A1B4A044800502CAF /* JSCharacterDataCustom.cpp in Sources */,28652 28638 BCC065870F3CE2A700CD2D87 /* JSClientRect.cpp in Sources */, 28653 28639 46A58AC51D46B3FA00432036 /* JSClientRectCustom.cpp in Sources */, … … 28721 28707 1221E05F1C02B444006A1A00 /* JSDocumentTimeline.cpp in Sources */, 28722 28708 65DF31F509D1CC60000BE325 /* JSDocumentType.cpp in Sources */, 28723 7C33F35E1B4A04CE00502CAF /* JSDocumentTypeCustom.cpp in Sources */,28724 28709 1AC2260C0DB69F190089B669 /* JSDOMApplicationCache.cpp in Sources */, 28725 28710 93B70D6309EB0C7C009D8468 /* JSDOMBinding.cpp in Sources */, … … 28984 28969 BCD9C2C20C17B69E005C90A2 /* JSNodeList.cpp in Sources */, 28985 28970 BCD9C2650C17AA67005C90A2 /* JSNodeListCustom.cpp in Sources */, 28986 7C91A38F1B498ABE003F9EFA /* JSNodeOrString.cpp in Sources */,28987 28971 33503CA310179AD7003B47E1 /* JSNotification.cpp in Sources */, 28988 28972 33503CA510179AD7003B47E1 /* JSNotificationCenter.cpp in Sources */, -
trunk/Source/WebCore/bindings/generic/IDLTypes.h
r206812 r206956 85 85 struct IDLObject : IDLUnsupportedType { }; 86 86 87 template<typename T> struct IDLInterface : IDLType< Ref<T>> {87 template<typename T> struct IDLInterface : IDLType<std::reference_wrapper<T>> { 88 88 using RawType = T; 89 using NullableType = RefPtr<T>;89 using NullableType = T*; 90 90 }; 91 91 -
trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp
r205278 r206956 42 42 #include "JSCallbackData.cpp" 43 43 #include "JSCanvasRenderingContext2DCustom.cpp" 44 #include "JSCharacterDataCustom.cpp"45 44 #include "JSClientRectCustom.cpp" 46 45 #include "JSCommandLineAPIHostCustom.cpp" … … 70 69 #include "JSDocumentCustom.cpp" 71 70 #include "JSDocumentFragmentCustom.cpp" 72 #include "JSDocumentTypeCustom.cpp"73 71 #include "JSElementCustom.cpp" 74 72 #include "JSErrorEventCustom.cpp" … … 115 113 #include "JSNodeIteratorCustom.cpp" 116 114 #include "JSNodeListCustom.cpp" 117 #include "JSNodeOrString.cpp"118 115 #include "JSPluginElementFunctions.cpp" 119 116 #include "JSPopStateEventCustom.cpp" -
trunk/Source/WebCore/bindings/js/JSDOMBinding.h
r206954 r206956 343 343 template<typename T> struct NativeValueTraits; 344 344 345 template<typename JSClass, typename DOMClass, typename Enable = void>346 struct VariadicHelperBase {347 using Item = DOMClass;348 349 static Optional<Item> convert(JSC::ExecState& state, JSC::JSValue jsValue)350 {351 typedef NativeValueTraits<DOMClass> TraitsType;352 DOMClass indexValue;353 if (!TraitsType::nativeValue(state, jsValue, indexValue))354 return Nullopt;355 return indexValue;356 }357 };358 359 template<typename JSClass, typename DOMClass>360 struct VariadicHelperBase<JSClass, DOMClass, typename std::enable_if<!JSDOMObjectInspector<JSClass>::isBuiltin>::type> {361 using Class = typename std::remove_reference<decltype(std::declval<JSClass>().wrapped())>::type;362 using Item = std::reference_wrapper<Class>;363 364 static Optional<Item> convert(JSC::ExecState&, JSC::JSValue jsValue)365 {366 auto* value = JSClass::toWrapped(jsValue);367 if (!value)368 return Nullopt;369 return Optional<Item>(*value);370 }371 };372 373 template<typename JSClass, typename DOMClass>374 struct VariadicHelper : public VariadicHelperBase<JSClass, DOMClass> {375 using Item = typename VariadicHelperBase<JSClass, DOMClass>::Item;376 using Container = Vector<Item>;377 378 struct Result {379 size_t argumentIndex;380 Optional<Container> arguments;381 };382 };383 384 template<typename VariadicHelper> typename VariadicHelper::Result toArguments(JSC::ExecState&, size_t startIndex = 0);385 345 386 346 enum class CastedThisErrorBehavior { Throw, ReturnEarly }; … … 917 877 } 918 878 919 template<typename VariadicHelper> typename VariadicHelper::Result toArguments(JSC::ExecState& state, size_t startIndex)920 {921 size_t length = state.argumentCount();922 if (startIndex > length)923 return { 0, Nullopt };924 925 typename VariadicHelper::Container result;926 result.reserveInitialCapacity(length - startIndex);927 928 for (size_t i = startIndex; i < length; ++i) {929 auto value = VariadicHelper::convert(state, state.uncheckedArgument(i));930 if (!value)931 return { i, Nullopt };932 result.uncheckedAppend(WTFMove(value.value()));933 }934 return { length, WTFMove(result) };935 }936 937 879 template<JSC::NativeFunction nativeFunction, int length> JSC::EncodedJSValue nonCachingStaticFunctionGetter(JSC::ExecState* exec, JSC::EncodedJSValue, JSC::PropertyName propertyName) 938 880 { -
trunk/Source/WebCore/bindings/js/JSDOMConvert.h
r206812 r206956 44 44 template<typename T> Optional<T> convertDictionary(JSC::ExecState&, JSC::JSValue); 45 45 46 // Used for IDL enumerations. 47 template<typename T> Optional<T> parse(JSC::ExecState&, JSC::JSValue); 48 template<typename T> const char* expectedEnumerationValues(); 49 46 50 enum class IsNullable { No, Yes }; 47 51 template<typename T, typename JST> T* convertWrapperType(JSC::ExecState&, JSC::JSValue, IsNullable); … … 109 113 { 110 114 return valueToUSVString(&state, value); 115 } 116 }; 117 118 template<typename T> struct Converter<IDLInterface<T>> : DefaultConverter<T*> { 119 static T* convert(JSC::ExecState& state, JSC::JSValue value) 120 { 121 return convertWrapperType<T, typename JSDOMWrapperConverterTraits<T>::WrapperClass>(state, value, IsNullable::No); 111 122 } 112 123 }; … … 409 420 }; 410 421 411 // Used for IDL enumerations. 412 template<typename T> Optional<T> parse(JSC::ExecState&, JSC::JSValue); 413 template<typename T> const char* expectedEnumerationValues(); 422 template<typename IDLType> 423 struct VariadicConverterBase; 424 425 template<typename IDLType> 426 struct VariadicConverterBase { 427 using Item = typename IDLType::ImplementationType; 428 429 static Optional<Item> convert(JSC::ExecState& state, JSC::JSValue value) 430 { 431 auto& vm = state.vm(); 432 auto scope = DECLARE_THROW_SCOPE(vm); 433 434 auto result = Converter<IDLType>::convert(state, value); 435 RETURN_IF_EXCEPTION(scope, Nullopt); 436 437 return result; 438 } 439 }; 440 441 template<typename T> 442 struct VariadicConverterBase<IDLInterface<T>> { 443 using Item = typename IDLInterface<T>::ImplementationType; 444 445 static Optional<Item> convert(JSC::ExecState& state, JSC::JSValue value) 446 { 447 auto* result = Converter<IDLInterface<T>>::convert(state, value); 448 if (!result) 449 return Nullopt; 450 return Optional<Item>(*result); 451 } 452 }; 453 454 template<typename IDLType> 455 struct VariadicConverter : VariadicConverterBase<IDLType> { 456 using Item = typename VariadicConverterBase<IDLType>::Item; 457 using Container = Vector<Item>; 458 459 struct Result { 460 size_t argumentIndex; 461 Optional<Container> arguments; 462 }; 463 }; 464 465 template<typename IDLType> typename VariadicConverter<IDLType>::Result convertVariadicArguments(JSC::ExecState& state, size_t startIndex) 466 { 467 size_t length = state.argumentCount(); 468 if (startIndex > length) 469 return { 0, Nullopt }; 470 471 typename VariadicConverter<IDLType>::Container result; 472 result.reserveInitialCapacity(length - startIndex); 473 474 for (size_t i = startIndex; i < length; ++i) { 475 auto value = VariadicConverter<IDLType>::convert(state, state.uncheckedArgument(i)); 476 if (!value) 477 return { i, Nullopt }; 478 result.uncheckedAppend(WTFMove(*value)); 479 } 480 481 return { length, WTFMove(result) }; 482 } 414 483 415 484 } // namespace WebCore -
trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp
r206462 r206956 30 30 #include "JSHTMLDocument.h" 31 31 #include "JSLocation.h" 32 #include "JSNodeOrString.h"33 32 #include "JSXMLDocument.h" 34 33 #include "Location.h" … … 109 108 } 110 109 111 JSValue JSDocument::prepend(ExecState& state)112 {113 ExceptionCode ec = 0;114 wrapped().prepend(toNodeOrStringVector(state), ec);115 setDOMException(&state, ec);116 117 return jsUndefined();118 }119 120 JSValue JSDocument::append(ExecState& state)121 {122 ExceptionCode ec = 0;123 wrapped().append(toNodeOrStringVector(state), ec);124 setDOMException(&state, ec);125 126 return jsUndefined();127 }128 129 110 #if ENABLE(TOUCH_EVENTS) 130 111 JSValue JSDocument::createTouchList(ExecState& state) -
trunk/Source/WebCore/bindings/js/JSDocumentFragmentCustom.cpp
r205422 r206956 28 28 29 29 #include "ExceptionCode.h" 30 #include "JSNodeOrString.h"31 30 #include "JSShadowRoot.h" 32 31 … … 34 33 35 34 namespace WebCore { 36 37 JSValue JSDocumentFragment::prepend(ExecState& state)38 {39 ExceptionCode ec = 0;40 wrapped().prepend(toNodeOrStringVector(state), ec);41 setDOMException(&state, ec);42 43 return jsUndefined();44 }45 46 JSValue JSDocumentFragment::append(ExecState& state)47 {48 ExceptionCode ec = 0;49 wrapped().append(toNodeOrStringVector(state), ec);50 setDOMException(&state, ec);51 52 return jsUndefined();53 }54 35 55 36 JSValue toJSNewlyCreated(ExecState*, JSDOMGlobalObject* globalObject, Ref<DocumentFragment>&& impl) -
trunk/Source/WebCore/bindings/js/JSElementCustom.cpp
r205422 r206956 39 39 #include "JSHTMLElementWrapperFactory.h" 40 40 #include "JSNodeList.h" 41 #include "JSNodeOrString.h"42 41 #include "JSSVGElementWrapperFactory.h" 43 42 #include "NodeList.h" … … 76 75 } 77 76 78 JSValue JSElement::before(ExecState& state)79 {80 ExceptionCode ec = 0;81 wrapped().before(toNodeOrStringVector(state), ec);82 setDOMException(&state, ec);83 84 return jsUndefined();85 }86 87 JSValue JSElement::after(ExecState& state)88 {89 ExceptionCode ec = 0;90 wrapped().after(toNodeOrStringVector(state), ec);91 setDOMException(&state, ec);92 93 return jsUndefined();94 }95 96 JSValue JSElement::replaceWith(ExecState& state)97 {98 ExceptionCode ec = 0;99 wrapped().replaceWith(toNodeOrStringVector(state), ec);100 setDOMException(&state, ec);101 102 return jsUndefined();103 }104 105 JSValue JSElement::prepend(ExecState& state)106 {107 ExceptionCode ec = 0;108 wrapped().prepend(toNodeOrStringVector(state), ec);109 setDOMException(&state, ec);110 111 return jsUndefined();112 }113 114 JSValue JSElement::append(ExecState& state)115 {116 ExceptionCode ec = 0;117 wrapped().append(toNodeOrStringVector(state), ec);118 setDOMException(&state, ec);119 120 return jsUndefined();121 }122 123 77 } // namespace WebCore -
trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm
r206877 r206956 30 30 31 31 use File::Find; 32 use Carp qw<longmess>; 33 use Data::Dumper; 32 34 33 35 my $useDocument = ""; … … 141 143 my $cachedExternalDictionaries = {}; 142 144 145 sub assert 146 { 147 my $message = shift; 148 149 my $mess = longmess(); 150 print Dumper($mess); 151 152 die $message; 153 } 154 143 155 # Default constructor 144 156 sub new … … 322 334 323 335 return undef if $interfaceName eq 'Object'; 336 return undef if $interfaceName eq 'UNION'; 324 337 325 338 if (exists $cachedInterfaces->{$interfaceName}) { … … 329 342 # Step #1: Find the IDL file associated with 'interface' 330 343 my $filename = $object->IDLFileForInterface($interfaceName) 331 or die("Could NOT find IDL file for interface \"$interfaceName\", reachable from \"" . $outerInterface->name . "\"!\n");344 or assert("Could NOT find IDL file for interface \"$interfaceName\", reachable from \"" . $outerInterface->name . "\"!\n"); 332 345 333 346 print " | |> Parsing parent IDL \"$filename\" for interface \"$interfaceName\"\n" if $verbose; … … 663 676 return $object->GetFrozenArrayInnerType($type) if $object->IsFrozenArrayType($type); 664 677 return ""; 678 } 679 680 # http://heycam.github.io/webidl/#dfn-flattened-union-member-types 681 sub GetFlattenedMemberTypes 682 { 683 my ($object, $idlUnionType) = @_; 684 685 my @flattenedMemberTypes = (); 686 687 foreach my $memberType (@{$idlUnionType->subtypes}) { 688 if ($memberType->isUnion) { 689 push(@flattenedMemberTypes, $object->GetFlattenedMemberTypes($memberType)); 690 } else { 691 push(@flattenedMemberTypes, $memberType); 692 } 693 } 694 695 return @flattenedMemberTypes; 696 } 697 698 # http://heycam.github.io/webidl/#dfn-number-of-nullable-member-types 699 sub GetNumberOfNullableMemberTypes 700 { 701 my ($object, $idlUnionType) = @_; 702 703 my $count = 0; 704 705 foreach my $memberType (@{$idlUnionType->subtypes}) { 706 $count++ if $memberType->isNullable; 707 $count += $object->GetNumberOfNullableMemberTypes($memberType) if $memberType->isUnion; 708 } 709 710 return $count; 711 } 712 713 sub GetIDLUnionMemberTypes 714 { 715 my ($object, $interface, $idlUnionType) = @_; 716 717 my $numberOfNullableMembers = $object->GetNumberOfNullableMemberTypes($idlUnionType); 718 assert("Union types must only have 0 or 1 nullable types.") if $numberOfNullableMembers > 1; 719 720 my @idlUnionMemberTypes = (); 721 722 push(@idlUnionMemberTypes, "IDLNull") if $numberOfNullableMembers == 1; 723 724 foreach my $memberType ($object->GetFlattenedMemberTypes($idlUnionType)) { 725 push(@idlUnionMemberTypes, $object->GetBaseIDLType($interface, $memberType)); 726 } 727 728 return @idlUnionMemberTypes; 729 } 730 731 sub GetBaseIDLType 732 { 733 my ($object, $interface, $idlType) = @_; 734 735 my %IDLTypes = ( 736 "any" => "IDLAny", 737 "boolean" => "IDLBoolean", 738 "byte" => "IDLByte", 739 "octet" => "IDLOctet", 740 "short" => "IDLShort", 741 "unsigned short" => "IDLUnsignedShort", 742 "long" => "IDLLong", 743 "unsigned long" => "IDLUnsignedLong", 744 "long long" => "IDLLongLong", 745 "unsigned long long" => "IDLUnsignedLongLong", 746 "float" => "IDLFloat", 747 "unrestricted float" => "IDLUnrestrictedFloat", 748 "double" => "IDLDouble", 749 "unrestricted double" => "IDLUnrestrictedDouble", 750 "DOMString" => "IDLDOMString", 751 "ByteString" => "IDLByteString", 752 "USVString" => "IDLUSVString", 753 ); 754 755 return $IDLTypes{$idlType->name} if exists $IDLTypes{$idlType->name}; 756 return "IDLEnumeration<" . $object->GetEnumerationClassName($interface, $idlType->name) . ">" if $object->IsEnumType($idlType->name); 757 return "IDLDictionary<" . $object->GetDictionaryClassName($interface, $idlType->name) . ">" if $object->IsDictionaryType($idlType->name); 758 return "IDLSequence<" . $object->GetIDLType($interface, @{$idlType->subtypes}[0]) . ">" if $object->IsSequenceType($idlType->name); 759 return "IDLFrozenArray<" . $object->GetIDLType($interface, @{$idlType->subtypes}[0]) . ">" if $object->IsFrozenArrayType($idlType->name); 760 return "IDLUnion<" . join(", ", $object->GetIDLUnionMemberTypes($interface, $idlType)) . ">" if $idlType->isUnion; 761 return "IDLInterface<" . $idlType->name . ">"; 762 } 763 764 sub GetIDLType 765 { 766 my ($object, $interface, $idlType) = @_; 767 768 my $baseIDLType = $object->GetBaseIDLType($interface, $idlType); 769 return "IDLNullable<" . $baseIDLType . ">" if $idlType->isNullable; 770 return $baseIDLType; 665 771 } 666 772 … … 854 960 return 0 if !$object->IsRefPtrType($type); 855 961 return 0 if $object->IsTypedArrayType($type); 962 return 0 if $type eq "UNION"; 856 963 return 0 if $webCoreTypeHash{$type}; 857 964 … … 867 974 my $interfaceName = shift; 868 975 869 my $idlFile = $object->IDLFileForInterface($interfaceName) or die("Could NOT find IDL file for interface \"$interfaceName\"!\n");976 my $idlFile = $object->IDLFileForInterface($interfaceName) or assert("Could NOT find IDL file for interface \"$interfaceName\"!\n"); 870 977 871 978 open FILE, "<", $idlFile or die; … … 899 1006 return 0 unless $object->IsWrapperType($type); 900 1007 901 my $idlFile = $object->IDLFileForInterface($type) or die("Could NOT find IDL file for interface \"$type\"!\n");1008 my $idlFile = $object->IDLFileForInterface($type) or assert("Could NOT find IDL file for interface \"$type\"!\n"); 902 1009 903 1010 open FILE, "<", $idlFile or die; … … 935 1042 return 0 unless $object->IsCallbackInterface($type); 936 1043 937 my $idlFile = $object->IDLFileForInterface($type) or die("Could NOT find IDL file for interface \"$type\"!\n");1044 my $idlFile = $object->IDLFileForInterface($type) or assert("Could NOT find IDL file for interface \"$type\"!\n"); 938 1045 939 1046 open FILE, "<", $idlFile or die; -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r206953 r206956 246 246 # default, include the same named file 247 247 $includesRef->{"${type}.h"} = 1; 248 } 249 } 250 251 sub AddToImplIncludesForIDLType 252 { 253 my ($idlType, $conditional) = @_; 254 255 return if $codeGenerator->SkipIncludeHeader($idlType->name); 256 257 if ($idlType->isUnion) { 258 AddToImplIncludes("<wtf/Variant.h>", $conditional); 259 260 foreach my $memberType (@{$idlType->subtypes}) { 261 AddToImplIncludesForIDLType($memberType, $conditional); 262 } 263 264 return; 265 } 266 267 if ($codeGenerator->IsWrapperType($idlType->name)) { 268 AddToImplIncludes("JS" . $idlType->name . ".h"); 269 return; 248 270 } 249 271 } … … 4011 4033 foreach my $parameter (@{$function->parameters}) { 4012 4034 my $type = $parameter->type; 4035 my $idlType = $parameter->idlType; 4013 4036 4014 4037 die "Optional parameters of non-nullable wrapper types are not supported" if $parameter->isOptional && !$parameter->isNullable && $codeGenerator->IsWrapperType($type); … … 4072 4095 $value = "WTFMove($name)"; 4073 4096 } elsif ($parameter->isVariadic) { 4074 AddToImplIncludes("JS${type}.h", $function->signature->extendedAttributes->{Conditional}) unless $codeGenerator->SkipIncludeHeader($type) or !$codeGenerator->IsWrapperType($type); 4075 my ($wrapperType, $wrappedType) = GetVariadicType($interface, $type); 4076 push(@$outputArray, " auto $name = toArguments<VariadicHelper<$wrapperType, $wrappedType>>(*state, $argumentIndex);\n"); 4077 4078 if (IsNativeType($type)) { 4079 push(@$outputArray, " RETURN_IF_EXCEPTION(throwScope, encodedJSValue());\n"); 4080 } 4081 else { 4082 push(@$outputArray, " if (!$name.arguments)\n"); 4083 push(@$outputArray, " return throwArgumentTypeError(*state, throwScope, $name.argumentIndex, \"$name\", \"$visibleInterfaceName\", $quotedFunctionName, \"$type\");\n"); 4084 } 4097 $implIncludes{"JSDOMConvert.h"} = 1; 4098 AddToImplIncludesForIDLType($idlType, $function->signature->extendedAttributes->{Conditional}); 4099 4100 my $metaType = $codeGenerator->GetIDLType($interface, $idlType); 4101 push(@$outputArray, " auto $name = convertVariadicArguments<$metaType>(*state, $argumentIndex);\n"); 4102 push(@$outputArray, " RETURN_IF_EXCEPTION(throwScope, encodedJSValue());\n"); 4103 4085 4104 $value = "WTFMove($name.arguments.value())"; 4086 4105 -
trunk/Source/WebCore/bindings/scripts/IDLParser.pm
r206776 r206956 45 45 }); 46 46 47 struct( domType => { 48 name => '$', # Type identifier 49 isNullable => '$', # Is the type Nullable (T?) 50 isUnion => '$', # Is the type a union (T or U) 51 subtypes => '@', # Array of subtypes, only valid if isUnion or sequence 52 }); 53 47 54 # Used to represent 'interface' blocks 48 55 struct( domInterface => { … … 80 87 }); 81 88 82 struct( domType => {83 name => '$', # Type identifier84 isNullable => '$', # Is the type Nullable (T?)85 isUnion => '$', # Is the type a union (T or U)86 subtypes => '@', # Array of subtypes, only valid if isUnion or sequence87 });88 89 89 # Used to represent a map of 'variable name' <-> 'variable type' 90 90 struct( domSignature => { 91 91 direction => '$', # Variable direction (in or out) 92 92 name => '$', # Variable name 93 type => '$' , # Variable type 93 type => '$', # Variable type name (DEPRECATED - please use idlType) 94 idlType => '$', # Variable type 94 95 specials => '@', # Specials 95 96 extendedAttributes => '$', # Extended attributes … … 708 709 709 710 my $type = $self->parseType(); 711 $member->idlType($type); 710 712 $member->type($type->name); 711 713 $member->isNullable($type->isNullable); … … 1255 1257 1256 1258 my $type = $self->parseType(); 1259 $newDataNode->signature->idlType($type); 1257 1260 $newDataNode->signature->type($type->name); 1258 1261 $newDataNode->signature->isNullable($type->isNullable); … … 1547 1550 1548 1551 my $type = $self->parseType(); 1552 $paramDataNode->idlType($type); 1549 1553 $paramDataNode->type(identifierRemoveNullablePrefix($type->name)); 1550 1554 $paramDataNode->isNullable($type->isNullable); … … 1556 1560 if ($next->type() == IdentifierToken || $next->value() =~ /$nextExceptionField_1/) { 1557 1561 my $type = $self->parseType(); 1562 $paramDataNode->idlType($type); 1558 1563 $paramDataNode->type($type->name); 1559 1564 $paramDataNode->isNullable($type->isNullable); … … 1618 1623 1619 1624 my $type = $self->parseType(); 1625 $newDataNode->signature->idlType($type); 1620 1626 $newDataNode->signature->type($type->name); 1621 1627 $newDataNode->signature->isNullable($type->isNullable); -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r206953 r206956 72 72 #include <runtime/PropertyNameArray.h> 73 73 #include <wtf/GetPtr.h> 74 #include <wtf/Variant.h> 74 75 75 76 #if ENABLE(Condition1) … … 985 986 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVariadicDoubleMethod(JSC::ExecState*); 986 987 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVariadicNodeMethod(JSC::ExecState*); 988 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVariadicUnionMethod(JSC::ExecState*); 987 989 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionAny(JSC::ExecState*); 988 990 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionTestPromiseFunction(JSC::ExecState*); … … 1592 1594 { "variadicDoubleMethod", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVariadicDoubleMethod), (intptr_t) (1) } }, 1593 1595 { "variadicNodeMethod", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVariadicNodeMethod), (intptr_t) (1) } }, 1596 { "variadicUnionMethod", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVariadicUnionMethod), (intptr_t) (1) } }, 1594 1597 { "any", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionAny), (intptr_t) (2) } }, 1595 1598 { "testPromiseFunction", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionTestPromiseFunction), (intptr_t) (0) } }, … … 6564 6567 ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info()); 6565 6568 auto& impl = castedThis->wrapped(); 6566 auto blobArgs = toArguments<VariadicHelper<JSBlob, Blob>>(*state, 0); 6567 if (!blobArgs.arguments) 6568 return throwArgumentTypeError(*state, throwScope, blobArgs.argumentIndex, "blobArgs", "TestObject", "overloadedMethod", "Blob"); 6569 auto blobArgs = convertVariadicArguments<IDLInterface<Blob>>(*state, 0); 6570 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 6569 6571 impl.overloadedMethod(WTFMove(blobArgs.arguments.value())); 6570 6572 return JSValue::encode(jsUndefined()); … … 7082 7084 auto head = state->uncheckedArgument(0).toWTFString(state); 7083 7085 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 7084 auto tail = toArguments<VariadicHelper<JSC::JSValue, String>>(*state, 1);7086 auto tail = convertVariadicArguments<IDLDOMString>(*state, 1); 7085 7087 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 7086 7088 impl.variadicStringMethod(WTFMove(head), WTFMove(tail.arguments.value())); … … 7103 7105 auto head = convert<double>(*state, state->uncheckedArgument(0), ShouldAllowNonFinite::Yes); 7104 7106 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 7105 auto tail = toArguments<VariadicHelper<JSC::JSValue, double>>(*state, 1);7107 auto tail = convertVariadicArguments<IDLUnrestrictedDouble>(*state, 1); 7106 7108 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 7107 7109 impl.variadicDoubleMethod(WTFMove(head), WTFMove(tail.arguments.value())); … … 7125 7127 if (UNLIKELY(!head)) 7126 7128 return throwArgumentTypeError(*state, throwScope, 0, "head", "TestObject", "variadicNodeMethod", "Node"); 7127 auto tail = toArguments<VariadicHelper<JSNode, Node>>(*state, 1); 7128 if (!tail.arguments) 7129 return throwArgumentTypeError(*state, throwScope, tail.argumentIndex, "tail", "TestObject", "variadicNodeMethod", "Node"); 7129 auto tail = convertVariadicArguments<IDLInterface<Node>>(*state, 1); 7130 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 7130 7131 impl.variadicNodeMethod(*head, WTFMove(tail.arguments.value())); 7132 return JSValue::encode(jsUndefined()); 7133 } 7134 7135 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVariadicUnionMethod(ExecState* state) 7136 { 7137 VM& vm = state->vm(); 7138 auto throwScope = DECLARE_THROW_SCOPE(vm); 7139 UNUSED_PARAM(throwScope); 7140 JSValue thisValue = state->thisValue(); 7141 auto castedThis = jsDynamicCast<JSTestObj*>(thisValue); 7142 if (UNLIKELY(!castedThis)) 7143 return throwThisTypeError(*state, throwScope, "TestObject", "variadicUnionMethod"); 7144 ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info()); 7145 auto& impl = castedThis->wrapped(); 7146 if (UNLIKELY(state->argumentCount() < 1)) 7147 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); 7148 auto head = state->uncheckedArgument(0).toWTFString(state); 7149 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 7150 auto tail = convertVariadicArguments<IDLUnion<IDLInterface<Node>, IDLDOMString>>(*state, 1); 7151 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 7152 impl.variadicUnionMethod(WTFMove(head), WTFMove(tail.arguments.value())); 7131 7153 return JSValue::encode(jsUndefined()); 7132 7154 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp
r206723 r206956 26 26 #include "JSDOMBinding.h" 27 27 #include "JSDOMConstructor.h" 28 #include "JSDOMConvert.h" 28 29 #include <runtime/Error.h> 29 30 #include <runtime/FunctionPrototype.h> … … 138 139 auto* castedThis = jsCast<JSTestOverloadedConstructorsConstructor*>(state->callee()); 139 140 ASSERT(castedThis); 140 auto longArgs = toArguments<VariadicHelper<JSC::JSValue, int32_t>>(*state, 0);141 auto longArgs = convertVariadicArguments<IDLLong>(*state, 0); 141 142 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 142 143 auto object = TestOverloadedConstructors::create(WTFMove(longArgs)); -
trunk/Source/WebCore/bindings/scripts/test/TestObj.idl
r206877 r206956 360 360 void variadicDoubleMethod(unrestricted double head, unrestricted double... tail); 361 361 void variadicNodeMethod(Node head, Node... tail); 362 void variadicUnionMethod(DOMString head, (Node or DOMString)... tail); 362 363 363 364 // Nullable attributes. -
trunk/Source/WebCore/dom/ChildNode.idl
r206723 r206956 23 23 NoInterfaceObject, 24 24 ] interface ChildNode { 25 [Unscopable, MayThrowLegacyException , Custom] void before((Node or DOMString)... nodes);26 [Unscopable, MayThrowLegacyException , Custom] void after((Node or DOMString)... nodes);27 [Unscopable, MayThrowLegacyException , Custom] void replaceWith((Node or DOMString)... nodes);25 [Unscopable, MayThrowLegacyException] void before((Node or DOMString)... nodes); 26 [Unscopable, MayThrowLegacyException] void after((Node or DOMString)... nodes); 27 [Unscopable, MayThrowLegacyException] void replaceWith((Node or DOMString)... nodes); 28 28 [Unscopable, MayThrowLegacyException] void remove(); 29 29 }; -
trunk/Source/WebCore/dom/ContainerNode.cpp
r204493 r206956 878 878 } 879 879 880 void ContainerNode::append(Vector<std::experimental::variant< Ref<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec)880 void ContainerNode::append(Vector<std::experimental::variant<std::reference_wrapper<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec) 881 881 { 882 882 RefPtr<Node> node = convertNodesOrStringsIntoNode(WTFMove(nodeOrStringVector), ec); … … 887 887 } 888 888 889 void ContainerNode::prepend(Vector<std::experimental::variant< Ref<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec)889 void ContainerNode::prepend(Vector<std::experimental::variant<std::reference_wrapper<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec) 890 890 { 891 891 RefPtr<Node> node = convertNodesOrStringsIntoNode(WTFMove(nodeOrStringVector), ec); -
trunk/Source/WebCore/dom/ContainerNode.h
r204717 r206956 100 100 WEBCORE_EXPORT Element* lastElementChild() const; 101 101 WEBCORE_EXPORT unsigned childElementCount() const; 102 void append(Vector<std::experimental::variant< Ref<Node>, String>>&&, ExceptionCode&);103 void prepend(Vector<std::experimental::variant< Ref<Node>, String>>&&, ExceptionCode&);102 void append(Vector<std::experimental::variant<std::reference_wrapper<Node>, String>>&&, ExceptionCode&); 103 void prepend(Vector<std::experimental::variant<std::reference_wrapper<Node>, String>>&&, ExceptionCode&); 104 104 105 105 bool ensurePreInsertionValidity(Node& newChild, Node* refChild, ExceptionCode&); -
trunk/Source/WebCore/dom/Node.cpp
r206944 r206956 436 436 } 437 437 438 static HashSet<RefPtr<Node>> nodeSetPreTransformedFromNodeOrStringVector(const Vector<std::experimental::variant< Ref<Node>, String>>& vector)438 static HashSet<RefPtr<Node>> nodeSetPreTransformedFromNodeOrStringVector(const Vector<std::experimental::variant<std::reference_wrapper<Node>, String>>& vector) 439 439 { 440 440 HashSet<RefPtr<Node>> nodeSet; 441 441 442 442 auto visitor = WTF::makeVisitor( 443 [&](const Ref<Node>& node) { nodeSet.add(const_cast<Node*>(node.ptr())); },443 [&](const std::reference_wrapper<Node>& node) { nodeSet.add(const_cast<Node*>(&node.get())); }, 444 444 [](const String&) { } 445 445 ); … … 469 469 } 470 470 471 RefPtr<Node> Node::convertNodesOrStringsIntoNode(Vector<std::experimental::variant< Ref<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec)471 RefPtr<Node> Node::convertNodesOrStringsIntoNode(Vector<std::experimental::variant<std::reference_wrapper<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec) 472 472 { 473 473 if (nodeOrStringVector.isEmpty()) … … 478 478 479 479 auto visitor = WTF::makeVisitor( 480 [&]( Ref<Node>& node) { nodes.uncheckedAppend(node.copyRef()); },480 [&](std::reference_wrapper<Node>& node) { nodes.uncheckedAppend(node); }, 481 481 [&](String& string) { nodes.uncheckedAppend(Text::create(document(), string)); } 482 482 ); … … 496 496 } 497 497 498 void Node::before(Vector<std::experimental::variant< Ref<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec)498 void Node::before(Vector<std::experimental::variant<std::reference_wrapper<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec) 499 499 { 500 500 RefPtr<ContainerNode> parent = parentNode(); … … 517 517 } 518 518 519 void Node::after(Vector<std::experimental::variant< Ref<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec)519 void Node::after(Vector<std::experimental::variant<std::reference_wrapper<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec) 520 520 { 521 521 RefPtr<ContainerNode> parent = parentNode(); … … 533 533 } 534 534 535 void Node::replaceWith(Vector<std::experimental::variant< Ref<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec)535 void Node::replaceWith(Vector<std::experimental::variant<std::reference_wrapper<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec) 536 536 { 537 537 RefPtr<ContainerNode> parent = parentNode(); -
trunk/Source/WebCore/dom/Node.h
r206843 r206956 203 203 204 204 // From the ChildNode - https://dom.spec.whatwg.org/#childnode 205 void before(Vector<std::experimental::variant< Ref<Node>, String>>&&, ExceptionCode&);206 void after(Vector<std::experimental::variant< Ref<Node>, String>>&&, ExceptionCode&);207 void replaceWith(Vector<std::experimental::variant< Ref<Node>, String>>&&, ExceptionCode&);205 void before(Vector<std::experimental::variant<std::reference_wrapper<Node>, String>>&&, ExceptionCode&); 206 void after(Vector<std::experimental::variant<std::reference_wrapper<Node>, String>>&&, ExceptionCode&); 207 void replaceWith(Vector<std::experimental::variant<std::reference_wrapper<Node>, String>>&&, ExceptionCode&); 208 208 WEBCORE_EXPORT void remove(ExceptionCode&); 209 209 … … 660 660 void updateAncestorsForStyleRecalc(); 661 661 662 RefPtr<Node> convertNodesOrStringsIntoNode(Vector<std::experimental::variant< Ref<Node>, String>>&&, ExceptionCode&);662 RefPtr<Node> convertNodesOrStringsIntoNode(Vector<std::experimental::variant<std::reference_wrapper<Node>, String>>&&, ExceptionCode&); 663 663 664 664 private: -
trunk/Source/WebCore/dom/ParentNode.idl
r206723 r206956 34 34 readonly attribute unsigned long childElementCount; 35 35 36 [Unscopable, MayThrowLegacyException , Custom] void prepend((Node or DOMString)... nodes);37 [Unscopable, MayThrowLegacyException , Custom] void append((Node or DOMString)... nodes);36 [Unscopable, MayThrowLegacyException] void prepend((Node or DOMString)... nodes); 37 [Unscopable, MayThrowLegacyException] void append((Node or DOMString)... nodes); 38 38 39 39 // [Unscopable] Element? query(DOMString relativeSelectors);
Note: See TracChangeset
for help on using the changeset viewer.