Autogenerate passing union types as part of a functions variadic arguments
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 8 Oct 2016 19:07:14 +0000 (19:07 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 8 Oct 2016 19:07:14 +0000 (19:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=162919

Reviewed by Darin Adler.

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSBindingsAllInOne.cpp:
Remove deleted files.

* bindings/generic/IDLTypes.h:
Switch to use std::reference_wrapper as it's implementation type. We may need more
granularity here in the future, but this will work for now.

* bindings/js/JSCharacterDataCustom.cpp: Removed.
* bindings/js/JSDocumentTypeCustom.cpp: Removed.
* bindings/js/JSNodeOrString.cpp: Removed.
* bindings/js/JSNodeOrString.h: Removed.

* bindings/js/JSDOMBinding.h:
(WebCore::VariadicHelperBase::convert): Deleted.
(WebCore::toArguments): Deleted.
Moved to JSDOMConvert.h and renamed to convertVariadicArguments and make
it work in terms of IDLTypes.

* bindings/js/JSDOMConvert.h:
(WebCore::Converter<IDLInterface<T>>::convert):
(WebCore::VariadicConverterBase::convert):
(WebCore::VariadicConverterBase<IDLInterface<T>>::convert):
(WebCore::convertVariadicArguments):

* bindings/js/JSDocumentCustom.cpp:
(WebCore::JSDocument::prepend): Deleted.
(WebCore::JSDocument::append): Deleted.
* bindings/js/JSDocumentFragmentCustom.cpp:
(WebCore::JSDocumentFragment::prepend): Deleted.
(WebCore::JSDocumentFragment::append): Deleted.
* bindings/js/JSElementCustom.cpp:
(WebCore::JSElement::before): Deleted.
(WebCore::JSElement::after): Deleted.
(WebCore::JSElement::replaceWith): Deleted.
(WebCore::JSElement::prepend): Deleted.
(WebCore::JSElement::append): Deleted.
Remove now generated functions.

* bindings/scripts/CodeGenerator.pm:
(assert):
Add assert to help debugging.

(ParseInterface):
Don't treat union types as interfaces.

(GetFlattenedMemberTypes):
(GetNumberOfNullableMemberTypes):
(GetIDLUnionMemberTypes):
Implement WebIDL algorithms for getting the flattened member list of union, and use it
to construct the c++ IDLType.

(GetBaseIDLType):
(GetIDLType):
Add helper to convert an parsed idlType to a c++ IDLType.

(IsWrapperType):
Don't treat union types as wrappers.

* bindings/scripts/CodeGeneratorJS.pm:
(AddToImplIncludesForIDLType):
Add helper for adding #includes based on a parsed idlType. It recursively handles union types.

(GenerateParametersCheck):
Use the new convertVariadicArguments function to handle all variadic arguments, including
union types.

* bindings/scripts/IDLParser.pm:
(parseDictionaryMember):
(parseAttributeRest):
(parseOptionalOrRequiredArgument):
(parseExceptionField):
Add an idlType to domSignature and populate it.

* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::jsTestObjPrototypeFunctionOverloadedMethod13):
(WebCore::jsTestObjPrototypeFunctionVariadicStringMethod):
(WebCore::jsTestObjPrototypeFunctionVariadicDoubleMethod):
(WebCore::jsTestObjPrototypeFunctionVariadicNodeMethod):
(WebCore::jsTestObjPrototypeFunctionVariadicUnionMethod):
* bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
(WebCore::constructJSTestOverloadedConstructors5):
* bindings/scripts/test/TestObj.idl:
Add and update tests.

* dom/ChildNode.idl:
* dom/ParentNode.idl:
Remove Custom extended attribute.

* dom/ContainerNode.cpp:
* dom/ContainerNode.h:
* dom/Node.cpp:
* dom/Node.h:
Switch to using std::reference_wrapper instead of Ref<> for passed in parameters.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206956 268f45cc-cd09-0410-ab3c-d52691b4dbfc

26 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/generic/IDLTypes.h
Source/WebCore/bindings/js/JSBindingsAllInOne.cpp
Source/WebCore/bindings/js/JSCharacterDataCustom.cpp [deleted file]
Source/WebCore/bindings/js/JSDOMBinding.h
Source/WebCore/bindings/js/JSDOMConvert.h
Source/WebCore/bindings/js/JSDocumentCustom.cpp
Source/WebCore/bindings/js/JSDocumentFragmentCustom.cpp
Source/WebCore/bindings/js/JSDocumentTypeCustom.cpp [deleted file]
Source/WebCore/bindings/js/JSElementCustom.cpp
Source/WebCore/bindings/js/JSNodeOrString.cpp [deleted file]
Source/WebCore/bindings/js/JSNodeOrString.h [deleted file]
Source/WebCore/bindings/scripts/CodeGenerator.pm
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/IDLParser.pm
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp
Source/WebCore/bindings/scripts/test/TestObj.idl
Source/WebCore/dom/ChildNode.idl
Source/WebCore/dom/ContainerNode.cpp
Source/WebCore/dom/ContainerNode.h
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/Node.h
Source/WebCore/dom/ParentNode.idl

index cc40387..ed49d7a 100644 (file)
@@ -1068,7 +1068,6 @@ set(WebCore_SOURCES
     bindings/js/JSCSSValueCustom.cpp
     bindings/js/JSCallbackData.cpp
     bindings/js/JSCanvasRenderingContext2DCustom.cpp
-    bindings/js/JSCharacterDataCustom.cpp
     bindings/js/JSClientRectCustom.cpp
     bindings/js/JSCommandLineAPIHostCustom.cpp
     bindings/js/JSCryptoAlgorithmBuilder.cpp
@@ -1105,7 +1104,6 @@ set(WebCore_SOURCES
     bindings/js/JSDictionary.cpp
     bindings/js/JSDocumentCustom.cpp
     bindings/js/JSDocumentFragmentCustom.cpp
-    bindings/js/JSDocumentTypeCustom.cpp
     bindings/js/JSElementCustom.cpp
     bindings/js/JSErrorEventCustom.cpp
     bindings/js/JSErrorHandler.cpp
@@ -1158,7 +1156,6 @@ set(WebCore_SOURCES
     bindings/js/JSNodeCustom.cpp
     bindings/js/JSNodeFilterCustom.cpp
     bindings/js/JSNodeIteratorCustom.cpp
-    bindings/js/JSNodeOrString.cpp
     bindings/js/JSNodeListCustom.cpp
     bindings/js/JSPerformanceEntryCustom.cpp
     bindings/js/JSPerformanceTimingCustom.cpp
index cc0bb33..0103caa 100644 (file)
@@ -1,3 +1,106 @@
+2016-10-06  Sam Weinig  <sam@webkit.org>
+
+        Autogenerate passing union types as part of a functions variadic arguments
+        https://bugs.webkit.org/show_bug.cgi?id=162919
+
+        Reviewed by Darin Adler.
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSBindingsAllInOne.cpp:
+        Remove deleted files.
+
+        * bindings/generic/IDLTypes.h:
+        Switch to use std::reference_wrapper as it's implementation type. We may need more
+        granularity here in the future, but this will work for now.
+
+        * bindings/js/JSCharacterDataCustom.cpp: Removed.
+        * bindings/js/JSDocumentTypeCustom.cpp: Removed.
+        * bindings/js/JSNodeOrString.cpp: Removed.
+        * bindings/js/JSNodeOrString.h: Removed.
+
+        * bindings/js/JSDOMBinding.h:
+        (WebCore::VariadicHelperBase::convert): Deleted.
+        (WebCore::toArguments): Deleted.
+        Moved to JSDOMConvert.h and renamed to convertVariadicArguments and make
+        it work in terms of IDLTypes.
+
+        * bindings/js/JSDOMConvert.h:
+        (WebCore::Converter<IDLInterface<T>>::convert):
+        (WebCore::VariadicConverterBase::convert):
+        (WebCore::VariadicConverterBase<IDLInterface<T>>::convert):
+        (WebCore::convertVariadicArguments):
+
+        * bindings/js/JSDocumentCustom.cpp:
+        (WebCore::JSDocument::prepend): Deleted.
+        (WebCore::JSDocument::append): Deleted.
+        * bindings/js/JSDocumentFragmentCustom.cpp:
+        (WebCore::JSDocumentFragment::prepend): Deleted.
+        (WebCore::JSDocumentFragment::append): Deleted.
+        * bindings/js/JSElementCustom.cpp:
+        (WebCore::JSElement::before): Deleted.
+        (WebCore::JSElement::after): Deleted.
+        (WebCore::JSElement::replaceWith): Deleted.
+        (WebCore::JSElement::prepend): Deleted.
+        (WebCore::JSElement::append): Deleted.
+        Remove now generated functions.
+
+        * bindings/scripts/CodeGenerator.pm:
+        (assert):
+        Add assert to help debugging.
+
+        (ParseInterface):
+        Don't treat union types as interfaces.
+
+        (GetFlattenedMemberTypes):
+        (GetNumberOfNullableMemberTypes):
+        (GetIDLUnionMemberTypes):
+        Implement WebIDL algorithms for getting the flattened member list of union, and use it
+        to construct the c++ IDLType.
+
+        (GetBaseIDLType):
+        (GetIDLType):
+        Add helper to convert an parsed idlType to a c++ IDLType.
+
+        (IsWrapperType):
+        Don't treat union types as wrappers.
+        
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (AddToImplIncludesForIDLType):
+        Add helper for adding #includes based on a parsed idlType. It recursively handles union types.
+
+        (GenerateParametersCheck):
+        Use the new convertVariadicArguments function to handle all variadic arguments, including
+        union types.
+
+        * bindings/scripts/IDLParser.pm:
+        (parseDictionaryMember):
+        (parseAttributeRest):
+        (parseOptionalOrRequiredArgument):
+        (parseExceptionField):
+        Add an idlType to domSignature and populate it.
+
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore::jsTestObjPrototypeFunctionOverloadedMethod13):
+        (WebCore::jsTestObjPrototypeFunctionVariadicStringMethod):
+        (WebCore::jsTestObjPrototypeFunctionVariadicDoubleMethod):
+        (WebCore::jsTestObjPrototypeFunctionVariadicNodeMethod):
+        (WebCore::jsTestObjPrototypeFunctionVariadicUnionMethod):
+        * bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
+        (WebCore::constructJSTestOverloadedConstructors5):
+        * bindings/scripts/test/TestObj.idl:
+        Add and update tests.
+
+        * dom/ChildNode.idl:
+        * dom/ParentNode.idl:
+        Remove Custom extended attribute.
+
+        * dom/ContainerNode.cpp:
+        * dom/ContainerNode.h:
+        * dom/Node.cpp:
+        * dom/Node.h:
+        Switch to using std::reference_wrapper instead of Ref<> for passed in parameters.
+
 2016-10-08  Youenn Fablet  <youenn@apple.com>
 
         [Fetch API] Request constructor should provide exception messages
index 75d29ad..790acfa 100644 (file)
                7C1E97281A9F9834007BF0FB /* AutoFillButtonElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C1E97261A9F9834007BF0FB /* AutoFillButtonElement.h */; };
                7C2BDD3D17C7F98C0038FF15 /* JSDOMGlobalObjectTask.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C2BDD3B17C7F98B0038FF15 /* JSDOMGlobalObjectTask.cpp */; };
                7C2BDD3E17C7F98C0038FF15 /* JSDOMGlobalObjectTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C2BDD3C17C7F98B0038FF15 /* JSDOMGlobalObjectTask.h */; };
-               7C33F35A1B4A044800502CAF /* JSCharacterDataCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C33F3581B4A044800502CAF /* JSCharacterDataCustom.cpp */; };
-               7C33F35E1B4A04CE00502CAF /* JSDocumentTypeCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C33F35C1B4A04CE00502CAF /* JSDocumentTypeCustom.cpp */; };
                7C33F3621B4A050400502CAF /* JSDocumentFragmentCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C33F3601B4A050400502CAF /* JSDocumentFragmentCustom.cpp */; };
                7C3A91E61C963B8800D1A7E3 /* ClipboardAccessPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C3A91E51C963B8800D1A7E3 /* ClipboardAccessPolicy.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7C3B79711908757B00B47A2D /* UserMessageHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C3B796F1908757B00B47A2D /* UserMessageHandler.cpp */; };
                7C7941E41C56C29300A4C58E /* DataDetectorsCoreSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7C7941E21C56C29300A4C58E /* DataDetectorsCoreSoftLink.mm */; };
                7C7941E51C56C29300A4C58E /* DataDetectorsCoreSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C7941E31C56C29300A4C58E /* DataDetectorsCoreSoftLink.h */; };
                7C83DE861D04CC5D00FEBCF3 /* SpringSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C83DE851D04CBD400FEBCF3 /* SpringSolver.h */; };
-               7C91A38F1B498ABE003F9EFA /* JSNodeOrString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C91A38D1B498ABE003F9EFA /* JSNodeOrString.cpp */; };
-               7C91A3901B498ABE003F9EFA /* JSNodeOrString.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C91A38E1B498ABE003F9EFA /* JSNodeOrString.h */; };
                7C93F3491AA6BA5E00A98BAB /* CompiledContentExtension.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C93F3471AA6BA5E00A98BAB /* CompiledContentExtension.cpp */; };
                7C93F34A1AA6BA5E00A98BAB /* CompiledContentExtension.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C93F3481AA6BA5E00A98BAB /* CompiledContentExtension.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7C93F34D1AA6BF0700A98BAB /* ContentExtensionCompiler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C93F34B1AA6BF0700A98BAB /* ContentExtensionCompiler.cpp */; };
                7C1E97261A9F9834007BF0FB /* AutoFillButtonElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AutoFillButtonElement.h; sourceTree = "<group>"; };
                7C2BDD3B17C7F98B0038FF15 /* JSDOMGlobalObjectTask.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMGlobalObjectTask.cpp; sourceTree = "<group>"; };
                7C2BDD3C17C7F98B0038FF15 /* JSDOMGlobalObjectTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMGlobalObjectTask.h; sourceTree = "<group>"; };
-               7C33F3581B4A044800502CAF /* JSCharacterDataCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCharacterDataCustom.cpp; sourceTree = "<group>"; };
-               7C33F35C1B4A04CE00502CAF /* JSDocumentTypeCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDocumentTypeCustom.cpp; sourceTree = "<group>"; };
                7C33F3601B4A050400502CAF /* JSDocumentFragmentCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDocumentFragmentCustom.cpp; sourceTree = "<group>"; };
                7C3A91E51C963B8800D1A7E3 /* ClipboardAccessPolicy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClipboardAccessPolicy.h; sourceTree = "<group>"; };
                7C3B796F1908757B00B47A2D /* UserMessageHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserMessageHandler.cpp; sourceTree = "<group>"; };
                7C7941E21C56C29300A4C58E /* DataDetectorsCoreSoftLink.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DataDetectorsCoreSoftLink.mm; sourceTree = "<group>"; };
                7C7941E31C56C29300A4C58E /* DataDetectorsCoreSoftLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataDetectorsCoreSoftLink.h; sourceTree = "<group>"; };
                7C83DE851D04CBD400FEBCF3 /* SpringSolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpringSolver.h; sourceTree = "<group>"; };
-               7C91A38D1B498ABE003F9EFA /* JSNodeOrString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSNodeOrString.cpp; sourceTree = "<group>"; };
-               7C91A38E1B498ABE003F9EFA /* JSNodeOrString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSNodeOrString.h; sourceTree = "<group>"; };
                7C93F3471AA6BA5E00A98BAB /* CompiledContentExtension.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CompiledContentExtension.cpp; sourceTree = "<group>"; };
                7C93F3481AA6BA5E00A98BAB /* CompiledContentExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CompiledContentExtension.h; sourceTree = "<group>"; };
                7C93F34B1AA6BF0700A98BAB /* ContentExtensionCompiler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentExtensionCompiler.cpp; sourceTree = "<group>"; };
                                E38838951BAD145F00D62EE3 /* ScriptModuleLoader.h */,
                                C6F420A016B7164E0052A9F2 /* JSMutationCallback.cpp */,
                                C6F420A116B7164E0052A9F2 /* JSMutationCallback.h */,
-                               7C91A38D1B498ABE003F9EFA /* JSNodeOrString.cpp */,
-                               7C91A38E1B498ABE003F9EFA /* JSNodeOrString.h */,
                                CB38FD551CD21D5B00592A3F /* JSPerformanceEntryCustom.cpp */,
                                93B70D4F09EB0C7C009D8468 /* JSPluginElementFunctions.cpp */,
                                93B70D5009EB0C7C009D8468 /* JSPluginElementFunctions.h */,
                                BE6DF710171CA2DA00DD52B8 /* JSAudioTrackListCustom.cpp */,
                                8931DE5A14C44C44000DC9D2 /* JSBlobCustom.cpp */,
                                49EED14B1051971900099FAB /* JSCanvasRenderingContext2DCustom.cpp */,
-                               7C33F3581B4A044800502CAF /* JSCharacterDataCustom.cpp */,
                                46A58AC41D46B3FA00432036 /* JSClientRectCustom.cpp */,
                                A584FE371864DAC100843B10 /* JSCommandLineAPIHostCustom.cpp */,
                                7CEF26181D6A92E300BE905D /* JSCryptoCustom.cpp */,
                                49C7BA8C1042F5B10009D447 /* JSDocumentCustom.cpp */,
                                ADDA94BF19686F8000453029 /* JSDocumentCustom.h */,
                                7C33F3601B4A050400502CAF /* JSDocumentFragmentCustom.cpp */,
-                               7C33F35C1B4A04CE00502CAF /* JSDocumentTypeCustom.cpp */,
                                A9C6E6460D7465CA006442E9 /* JSDOMMimeTypeArrayCustom.cpp */,
                                A9C6E64A0D7465E7006442E9 /* JSDOMPluginArrayCustom.cpp */,
                                A9C6E64B0D7465E7006442E9 /* JSDOMPluginCustom.cpp */,
                                1A750D8E0A90E521000FF215 /* JSNodeIterator.h in Headers */,
                                BCD9C2C30C17B69E005C90A2 /* JSNodeList.h in Headers */,
                                AD20B18D18E9D237005A8083 /* JSNodeListCustom.h in Headers */,
-                               7C91A3901B498ABE003F9EFA /* JSNodeOrString.h in Headers */,
                                33503CA410179AD7003B47E1 /* JSNotification.h in Headers */,
                                33503CA610179AD7003B47E1 /* JSNotificationCenter.h in Headers */,
                                31EC1E2914FF60EE00C94662 /* JSNotificationPermissionCallback.h in Headers */,
                                FDA15EA112B03EE1003A583A /* JSChannelMergerNode.cpp in Sources */,
                                FDA15EA312B03EE1003A583A /* JSChannelSplitterNode.cpp in Sources */,
                                65DF31F309D1CC60000BE325 /* JSCharacterData.cpp in Sources */,
-                               7C33F35A1B4A044800502CAF /* JSCharacterDataCustom.cpp in Sources */,
                                BCC065870F3CE2A700CD2D87 /* JSClientRect.cpp in Sources */,
                                46A58AC51D46B3FA00432036 /* JSClientRectCustom.cpp in Sources */,
                                BCC065890F3CE2A700CD2D87 /* JSClientRectList.cpp in Sources */,
                                7C33F3621B4A050400502CAF /* JSDocumentFragmentCustom.cpp in Sources */,
                                1221E05F1C02B444006A1A00 /* JSDocumentTimeline.cpp in Sources */,
                                65DF31F509D1CC60000BE325 /* JSDocumentType.cpp in Sources */,
-                               7C33F35E1B4A04CE00502CAF /* JSDocumentTypeCustom.cpp in Sources */,
                                1AC2260C0DB69F190089B669 /* JSDOMApplicationCache.cpp in Sources */,
                                93B70D6309EB0C7C009D8468 /* JSDOMBinding.cpp in Sources */,
                                BC60D7C00D29A46300B9918F /* JSDOMCoreException.cpp in Sources */,
                                1A750DD40A90E729000FF215 /* JSNodeIteratorCustom.cpp in Sources */,
                                BCD9C2C20C17B69E005C90A2 /* JSNodeList.cpp in Sources */,
                                BCD9C2650C17AA67005C90A2 /* JSNodeListCustom.cpp in Sources */,
-                               7C91A38F1B498ABE003F9EFA /* JSNodeOrString.cpp in Sources */,
                                33503CA310179AD7003B47E1 /* JSNotification.cpp in Sources */,
                                33503CA510179AD7003B47E1 /* JSNotificationCenter.cpp in Sources */,
                                31EC1E2814FF60EE00C94662 /* JSNotificationPermissionCallback.cpp in Sources */,
index 887c1e6..8811f77 100644 (file)
@@ -84,9 +84,9 @@ struct IDLUSVString : IDLString { };
 
 struct IDLObject : IDLUnsupportedType { };
 
-template<typename T> struct IDLInterface : IDLType<Ref<T>> {
+template<typename T> struct IDLInterface : IDLType<std::reference_wrapper<T>> {
     using RawType = T;
-    using NullableType = RefPtr<T>;
+    using NullableType = T*;
 };
 
 template<typename T> struct IDLDictionary : IDLType<T> { };
index 55e61cd..f3adc05 100644 (file)
@@ -41,7 +41,6 @@
 #include "JSCSSValueCustom.cpp"
 #include "JSCallbackData.cpp"
 #include "JSCanvasRenderingContext2DCustom.cpp"
-#include "JSCharacterDataCustom.cpp"
 #include "JSClientRectCustom.cpp"
 #include "JSCommandLineAPIHostCustom.cpp"
 #include "JSCryptoCustom.cpp"
@@ -69,7 +68,6 @@
 #include "JSDictionary.cpp"
 #include "JSDocumentCustom.cpp"
 #include "JSDocumentFragmentCustom.cpp"
-#include "JSDocumentTypeCustom.cpp"
 #include "JSElementCustom.cpp"
 #include "JSErrorEventCustom.cpp"
 #include "JSErrorHandler.cpp"
 #include "JSNodeFilterCustom.cpp"
 #include "JSNodeIteratorCustom.cpp"
 #include "JSNodeListCustom.cpp"
-#include "JSNodeOrString.cpp"
 #include "JSPluginElementFunctions.cpp"
 #include "JSPopStateEventCustom.cpp"
 #include "JSReadableStreamPrivateConstructors.cpp"
diff --git a/Source/WebCore/bindings/js/JSCharacterDataCustom.cpp b/Source/WebCore/bindings/js/JSCharacterDataCustom.cpp
deleted file mode 100644 (file)
index 6017f1f..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "JSCharacterData.h"
-
-#include "ExceptionCode.h"
-#include "JSNodeOrString.h"
-
-using namespace JSC;
-
-namespace WebCore {
-
-JSValue JSCharacterData::before(ExecState& state)
-{
-    ExceptionCode ec = 0;
-    wrapped().before(toNodeOrStringVector(state), ec);
-    setDOMException(&state, ec);
-
-    return jsUndefined();
-}
-
-JSValue JSCharacterData::after(ExecState& state)
-{
-    ExceptionCode ec = 0;
-    wrapped().after(toNodeOrStringVector(state), ec);
-    setDOMException(&state, ec);
-
-    return jsUndefined();
-}
-
-JSValue JSCharacterData::replaceWith(ExecState& state)
-{
-    ExceptionCode ec = 0;
-    wrapped().replaceWith(toNodeOrStringVector(state), ec);
-    setDOMException(&state, ec);
-
-    return jsUndefined();
-}
-
-} // namespace WebCore
index c3b9025..86be703 100644 (file)
@@ -342,46 +342,6 @@ template<JSC::NativeFunction, int length> JSC::EncodedJSValue nonCachingStaticFu
 
 template<typename T> struct NativeValueTraits;
 
-template<typename JSClass, typename DOMClass, typename Enable = void>
-struct VariadicHelperBase {
-    using Item = DOMClass;
-
-    static Optional<Item> convert(JSC::ExecState& state, JSC::JSValue jsValue)
-    {
-        typedef NativeValueTraits<DOMClass> TraitsType;
-        DOMClass indexValue;
-        if (!TraitsType::nativeValue(state, jsValue, indexValue))
-            return Nullopt;
-        return indexValue;
-    }
-};
-
-template<typename JSClass, typename DOMClass>
-struct VariadicHelperBase<JSClass, DOMClass, typename std::enable_if<!JSDOMObjectInspector<JSClass>::isBuiltin>::type> {
-    using Class = typename std::remove_reference<decltype(std::declval<JSClass>().wrapped())>::type;
-    using Item = std::reference_wrapper<Class>;
-
-    static Optional<Item> convert(JSC::ExecState&, JSC::JSValue jsValue)
-    {
-        auto* value = JSClass::toWrapped(jsValue);
-        if (!value)
-            return Nullopt;
-        return Optional<Item>(*value);
-    }
-};
-
-template<typename JSClass, typename DOMClass>
-struct VariadicHelper : public VariadicHelperBase<JSClass, DOMClass> {
-    using Item = typename VariadicHelperBase<JSClass, DOMClass>::Item;
-    using Container = Vector<Item>;
-
-    struct Result {
-        size_t argumentIndex;
-        Optional<Container> arguments;
-    };
-};
-
-template<typename VariadicHelper> typename VariadicHelper::Result toArguments(JSC::ExecState&, size_t startIndex = 0);
 
 enum class CastedThisErrorBehavior { Throw, ReturnEarly };
 
@@ -916,24 +876,6 @@ inline AtomicString propertyNameToAtomicString(JSC::PropertyName propertyName)
     return AtomicString(propertyName.uid() ? propertyName.uid() : propertyName.publicName());
 }
 
-template<typename VariadicHelper> typename VariadicHelper::Result toArguments(JSC::ExecState& state, size_t startIndex)
-{
-    size_t length = state.argumentCount();
-    if (startIndex > length)
-        return { 0, Nullopt };
-
-    typename VariadicHelper::Container result;
-    result.reserveInitialCapacity(length - startIndex);
-
-    for (size_t i = startIndex; i < length; ++i) {
-        auto value = VariadicHelper::convert(state, state.uncheckedArgument(i));
-        if (!value)
-            return { i, Nullopt };
-        result.uncheckedAppend(WTFMove(value.value()));
-    }
-    return { length, WTFMove(result) };
-}
-
 template<JSC::NativeFunction nativeFunction, int length> JSC::EncodedJSValue nonCachingStaticFunctionGetter(JSC::ExecState* exec, JSC::EncodedJSValue, JSC::PropertyName propertyName)
 {
     return JSC::JSValue::encode(JSC::JSFunction::create(exec->vm(), exec->lexicalGlobalObject(), length, propertyName.publicName(), nativeFunction));
index 54be2fb..ae30065 100644 (file)
@@ -43,6 +43,10 @@ template<typename T> EnableIfFloatingPointType<T> convert(JSC::ExecState&, JSC::
 
 template<typename T> Optional<T> convertDictionary(JSC::ExecState&, JSC::JSValue);
 
+// Used for IDL enumerations.
+template<typename T> Optional<T> parse(JSC::ExecState&, JSC::JSValue);
+template<typename T> const char* expectedEnumerationValues();
+
 enum class IsNullable { No, Yes };
 template<typename T, typename JST> T* convertWrapperType(JSC::ExecState&, JSC::JSValue, IsNullable);
 
@@ -111,6 +115,13 @@ template<> struct Converter<IDLUSVString> : DefaultConverter<String> {
     }
 };
 
+template<typename T> struct Converter<IDLInterface<T>> : DefaultConverter<T*> {
+    static T* convert(JSC::ExecState& state, JSC::JSValue value)
+    {
+        return convertWrapperType<T, typename JSDOMWrapperConverterTraits<T>::WrapperClass>(state, value, IsNullable::No);
+    }
+};
+
 template<> struct Converter<JSC::JSValue> : DefaultConverter<JSC::JSValue> {
     using OptionalValue = JSC::JSValue; // Use jsUndefined() to mean an optional value was not present.
     static JSC::JSValue convert(JSC::ExecState&, JSC::JSValue value)
@@ -408,8 +419,66 @@ struct Converter<IDLUnion<T...>> : DefaultConverter<typename IDLUnion<T...>::Imp
     }
 };
 
-// Used for IDL enumerations.
-template<typename T> Optional<T> parse(JSC::ExecState&, JSC::JSValue);
-template<typename T> const char* expectedEnumerationValues();
+template<typename IDLType> 
+struct VariadicConverterBase;
+
+template<typename IDLType> 
+struct VariadicConverterBase {
+    using Item = typename IDLType::ImplementationType;
+
+    static Optional<Item> convert(JSC::ExecState& state, JSC::JSValue value)
+    {
+        auto& vm = state.vm();
+        auto scope = DECLARE_THROW_SCOPE(vm);
+
+        auto result = Converter<IDLType>::convert(state, value);
+        RETURN_IF_EXCEPTION(scope, Nullopt);
+
+        return result;
+    }
+};
+
+template<typename T>
+struct VariadicConverterBase<IDLInterface<T>> {
+    using Item = typename IDLInterface<T>::ImplementationType;
+
+    static Optional<Item> convert(JSC::ExecState& state, JSC::JSValue value)
+    {
+        auto* result = Converter<IDLInterface<T>>::convert(state, value);
+        if (!result)
+            return Nullopt;
+        return Optional<Item>(*result);
+    }
+};
+
+template<typename IDLType>
+struct VariadicConverter : VariadicConverterBase<IDLType> {
+    using Item = typename VariadicConverterBase<IDLType>::Item;
+    using Container = Vector<Item>;
+
+    struct Result {
+        size_t argumentIndex;
+        Optional<Container> arguments;
+    };
+};
+
+template<typename IDLType> typename VariadicConverter<IDLType>::Result convertVariadicArguments(JSC::ExecState& state, size_t startIndex)
+{
+    size_t length = state.argumentCount();
+    if (startIndex > length)
+        return { 0, Nullopt };
+
+    typename VariadicConverter<IDLType>::Container result;
+    result.reserveInitialCapacity(length - startIndex);
+
+    for (size_t i = startIndex; i < length; ++i) {
+        auto value = VariadicConverter<IDLType>::convert(state, state.uncheckedArgument(i));
+        if (!value)
+            return { i, Nullopt };
+        result.uncheckedAppend(WTFMove(*value));
+    }
+
+    return { length, WTFMove(result) };
+}
 
 } // namespace WebCore
index 022c17c..f021f19 100644 (file)
@@ -29,7 +29,6 @@
 #include "JSDOMWindowCustom.h"
 #include "JSHTMLDocument.h"
 #include "JSLocation.h"
-#include "JSNodeOrString.h"
 #include "JSXMLDocument.h"
 #include "Location.h"
 #include "NodeTraversal.h"
@@ -108,24 +107,6 @@ JSValue toJS(ExecState* state, JSDOMGlobalObject* globalObject, Document& docume
     return toJSNewlyCreated(state, globalObject, Ref<Document>(document));
 }
 
-JSValue JSDocument::prepend(ExecState& state)
-{
-    ExceptionCode ec = 0;
-    wrapped().prepend(toNodeOrStringVector(state), ec);
-    setDOMException(&state, ec);
-
-    return jsUndefined();
-}
-
-JSValue JSDocument::append(ExecState& state)
-{
-    ExceptionCode ec = 0;
-    wrapped().append(toNodeOrStringVector(state), ec);
-    setDOMException(&state, ec);
-
-    return jsUndefined();
-}
-
 #if ENABLE(TOUCH_EVENTS)
 JSValue JSDocument::createTouchList(ExecState& state)
 {
index 8df8ee7..1155716 100644 (file)
 #include "JSDocumentFragment.h"
 
 #include "ExceptionCode.h"
-#include "JSNodeOrString.h"
 #include "JSShadowRoot.h"
 
 using namespace JSC;
 
 namespace WebCore {
 
-JSValue JSDocumentFragment::prepend(ExecState& state)
-{
-    ExceptionCode ec = 0;
-    wrapped().prepend(toNodeOrStringVector(state), ec);
-    setDOMException(&state, ec);
-
-    return jsUndefined();
-}
-
-JSValue JSDocumentFragment::append(ExecState& state)
-{
-    ExceptionCode ec = 0;
-    wrapped().append(toNodeOrStringVector(state), ec);
-    setDOMException(&state, ec);
-
-    return jsUndefined();
-}
-
 JSValue toJSNewlyCreated(ExecState*, JSDOMGlobalObject* globalObject, Ref<DocumentFragment>&& impl)
 {
     if (impl->isShadowRoot())
diff --git a/Source/WebCore/bindings/js/JSDocumentTypeCustom.cpp b/Source/WebCore/bindings/js/JSDocumentTypeCustom.cpp
deleted file mode 100644 (file)
index a93d671..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "JSDocumentType.h"
-
-#include "ExceptionCode.h"
-#include "JSNodeOrString.h"
-
-using namespace JSC;
-
-namespace WebCore {
-
-JSValue JSDocumentType::before(ExecState& state)
-{
-    ExceptionCode ec = 0;
-    wrapped().before(toNodeOrStringVector(state), ec);
-    setDOMException(&state, ec);
-
-    return jsUndefined();
-}
-
-JSValue JSDocumentType::after(ExecState& state)
-{
-    ExceptionCode ec = 0;
-    wrapped().after(toNodeOrStringVector(state), ec);
-    setDOMException(&state, ec);
-
-    return jsUndefined();
-}
-
-JSValue JSDocumentType::replaceWith(ExecState& state)
-{
-    ExceptionCode ec = 0;
-    wrapped().replaceWith(toNodeOrStringVector(state), ec);
-    setDOMException(&state, ec);
-
-    return jsUndefined();
-}
-
-} // namespace WebCore
index 62e5392..542fc34 100644 (file)
@@ -38,7 +38,6 @@
 #include "JSDOMBinding.h"
 #include "JSHTMLElementWrapperFactory.h"
 #include "JSNodeList.h"
-#include "JSNodeOrString.h"
 #include "JSSVGElementWrapperFactory.h"
 #include "NodeList.h"
 #include "SVGElement.h"
@@ -75,49 +74,4 @@ JSValue toJSNewlyCreated(ExecState*, JSDOMGlobalObject* globalObject, Ref<Elemen
     return createNewElementWrapper(globalObject, WTFMove(element));
 }
 
-JSValue JSElement::before(ExecState& state)
-{
-    ExceptionCode ec = 0;
-    wrapped().before(toNodeOrStringVector(state), ec);
-    setDOMException(&state, ec);
-
-    return jsUndefined();
-}
-
-JSValue JSElement::after(ExecState& state)
-{
-    ExceptionCode ec = 0;
-    wrapped().after(toNodeOrStringVector(state), ec);
-    setDOMException(&state, ec);
-
-    return jsUndefined();
-}
-
-JSValue JSElement::replaceWith(ExecState& state)
-{
-    ExceptionCode ec = 0;
-    wrapped().replaceWith(toNodeOrStringVector(state), ec);
-    setDOMException(&state, ec);
-
-    return jsUndefined();
-}
-
-JSValue JSElement::prepend(ExecState& state)
-{
-    ExceptionCode ec = 0;
-    wrapped().prepend(toNodeOrStringVector(state), ec);
-    setDOMException(&state, ec);
-
-    return jsUndefined();
-}
-
-JSValue JSElement::append(ExecState& state)
-{
-    ExceptionCode ec = 0;
-    wrapped().append(toNodeOrStringVector(state), ec);
-    setDOMException(&state, ec);
-
-    return jsUndefined();
-}
-
 } // namespace WebCore
diff --git a/Source/WebCore/bindings/js/JSNodeOrString.cpp b/Source/WebCore/bindings/js/JSNodeOrString.cpp
deleted file mode 100644 (file)
index 693d9b4..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "JSNodeOrString.h"
-
-#include "IDLTypes.h"
-#include "JSDOMConvert.h"
-#include "JSNode.h"
-#include <JavaScriptCore/JSString.h>
-#include <JavaScriptCore/ThrowScope.h>
-
-using namespace JSC;
-
-namespace WebCore {
-
-Vector<std::experimental::variant<Ref<Node>, String>> toNodeOrStringVector(ExecState& state)
-{
-    using NodeOrStringType = IDLUnion<IDLInterface<Node>, IDLDOMString>;
-    using ConverterType = Converter<NodeOrStringType>;
-
-    using InterfaceTypeList = typename ConverterType::InterfaceTypeList;
-    using InterfaceType = brigand::front<InterfaceTypeList>;
-    static_assert(std::is_same<InterfaceType, IDLInterface<Node>>::value, "");
-    static_assert(brigand::size<InterfaceTypeList>::value == 1, "");
-
-    using StringTypeList = typename ConverterType::StringTypeList;
-    using StringType = typename ConverterType::StringType;
-    static_assert(std::is_same<StringType, IDLDOMString>::value, "");
-    static_assert(brigand::size<StringTypeList>::value == 1, "");
-
-    VM& vm = state.vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    size_t argumentCount = state.argumentCount();
-
-    Vector<typename NodeOrStringType::ImplementationType> result;
-    result.reserveInitialCapacity(argumentCount);
-
-    for (size_t i = 0; i < argumentCount; ++i) {
-         auto item = ConverterType::convert(state, state.uncheckedArgument(i));
-         RETURN_IF_EXCEPTION(scope, { });
-         result.uncheckedAppend(WTFMove(item));
-    }
-
-    return result;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/bindings/js/JSNodeOrString.h b/Source/WebCore/bindings/js/JSNodeOrString.h
deleted file mode 100644 (file)
index e5eea65..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef JSNodeOrString_h
-#define JSNodeOrString_h
-
-#include <wtf/Forward.h>
-#include <wtf/Variant.h>
-#include <wtf/Vector.h>
-
-namespace JSC {
-class ExecState;
-}
-
-namespace WebCore {
-
-class Node;
-
-Vector<std::experimental::variant<Ref<Node>, String>> toNodeOrStringVector(JSC::ExecState&);
-
-} // namespace WebCore
-
-#endif // JSNodeOrStringVector_h
index 6dd8d74..0d56666 100644 (file)
@@ -29,6 +29,8 @@ package CodeGenerator;
 use strict;
 
 use File::Find;
+use Carp qw<longmess>;
+use Data::Dumper;
 
 my $useDocument = "";
 my $useGenerator = "";
@@ -140,6 +142,16 @@ my $idlFiles;
 my $cachedInterfaces = {};
 my $cachedExternalDictionaries = {};
 
+sub assert
+{
+    my $message = shift;
+    
+    my $mess = longmess();
+    print Dumper($mess);
+
+    die $message;
+}
+
 # Default constructor
 sub new
 {
@@ -321,6 +333,7 @@ sub ParseInterface
     my $interfaceName = shift;
 
     return undef if $interfaceName eq 'Object';
+    return undef if $interfaceName eq 'UNION';
 
     if (exists $cachedInterfaces->{$interfaceName}) {
         return $cachedInterfaces->{$interfaceName};
@@ -328,7 +341,7 @@ sub ParseInterface
 
     # Step #1: Find the IDL file associated with 'interface'
     my $filename = $object->IDLFileForInterface($interfaceName)
-        or die("Could NOT find IDL file for interface \"$interfaceName\", reachable from \"" . $outerInterface->name . "\"!\n");
+        or assert("Could NOT find IDL file for interface \"$interfaceName\", reachable from \"" . $outerInterface->name . "\"!\n");
 
     print "  |  |>  Parsing parent IDL \"$filename\" for interface \"$interfaceName\"\n" if $verbose;
 
@@ -664,6 +677,99 @@ sub GetSequenceOrFrozenArrayInnerType
     return "";
 }
 
+# http://heycam.github.io/webidl/#dfn-flattened-union-member-types
+sub GetFlattenedMemberTypes
+{
+    my ($object, $idlUnionType) = @_;
+
+    my @flattenedMemberTypes = ();
+
+    foreach my $memberType (@{$idlUnionType->subtypes}) {
+        if ($memberType->isUnion) {
+            push(@flattenedMemberTypes, $object->GetFlattenedMemberTypes($memberType));
+        } else {
+            push(@flattenedMemberTypes, $memberType);
+        }
+    }
+
+    return @flattenedMemberTypes;
+}
+
+# http://heycam.github.io/webidl/#dfn-number-of-nullable-member-types
+sub GetNumberOfNullableMemberTypes
+{
+    my ($object, $idlUnionType) = @_;
+
+    my $count = 0;
+
+    foreach my $memberType (@{$idlUnionType->subtypes}) {
+        $count++ if $memberType->isNullable;
+        $count += $object->GetNumberOfNullableMemberTypes($memberType) if $memberType->isUnion;
+    }
+
+    return $count;
+}
+
+sub GetIDLUnionMemberTypes
+{
+    my ($object, $interface, $idlUnionType) = @_;
+
+    my $numberOfNullableMembers = $object->GetNumberOfNullableMemberTypes($idlUnionType);
+    assert("Union types must only have 0 or 1 nullable types.") if $numberOfNullableMembers > 1;
+
+    my @idlUnionMemberTypes = ();
+
+    push(@idlUnionMemberTypes, "IDLNull") if $numberOfNullableMembers == 1;
+
+    foreach my $memberType ($object->GetFlattenedMemberTypes($idlUnionType)) {
+        push(@idlUnionMemberTypes, $object->GetBaseIDLType($interface, $memberType));
+    }
+
+    return @idlUnionMemberTypes;
+}
+
+sub GetBaseIDLType
+{
+    my ($object, $interface, $idlType) = @_;
+
+    my %IDLTypes = (
+        "any" => "IDLAny",
+        "boolean" => "IDLBoolean",
+        "byte" => "IDLByte",
+        "octet" => "IDLOctet",
+        "short" => "IDLShort",
+        "unsigned short" => "IDLUnsignedShort",
+        "long" => "IDLLong",
+        "unsigned long" => "IDLUnsignedLong",
+        "long long" => "IDLLongLong",
+        "unsigned long long" => "IDLUnsignedLongLong",
+        "float" => "IDLFloat",
+        "unrestricted float" => "IDLUnrestrictedFloat",
+        "double" => "IDLDouble",
+        "unrestricted double" => "IDLUnrestrictedDouble",
+        "DOMString" => "IDLDOMString",
+        "ByteString" => "IDLByteString",
+        "USVString" => "IDLUSVString",
+    );
+
+    return $IDLTypes{$idlType->name} if exists $IDLTypes{$idlType->name};
+    return "IDLEnumeration<" . $object->GetEnumerationClassName($interface, $idlType->name) . ">" if $object->IsEnumType($idlType->name);
+    return "IDLDictionary<" . $object->GetDictionaryClassName($interface, $idlType->name) . ">" if $object->IsDictionaryType($idlType->name);
+    return "IDLSequence<" . $object->GetIDLType($interface, @{$idlType->subtypes}[0]) . ">" if $object->IsSequenceType($idlType->name);
+    return "IDLFrozenArray<" . $object->GetIDLType($interface, @{$idlType->subtypes}[0]) . ">" if $object->IsFrozenArrayType($idlType->name);
+    return "IDLUnion<" . join(", ", $object->GetIDLUnionMemberTypes($interface, $idlType)) . ">" if $idlType->isUnion;
+    return "IDLInterface<" . $idlType->name . ">";
+}
+
+sub GetIDLType
+{
+    my ($object, $interface, $idlType) = @_;
+
+    my $baseIDLType = $object->GetBaseIDLType($interface, $idlType);
+    return "IDLNullable<" . $baseIDLType . ">" if $idlType->isNullable;
+    return $baseIDLType;
+}
+
 # These match WK_lcfirst and WK_ucfirst defined in builtins_generator.py.
 # Uppercase the first letter while respecting WebKit style guidelines.
 # E.g., xmlEncoding becomes XMLEncoding, but xmlllang becomes Xmllang.
@@ -853,6 +959,7 @@ sub IsWrapperType
 
     return 0 if !$object->IsRefPtrType($type);
     return 0 if $object->IsTypedArrayType($type);
+    return 0 if $type eq "UNION";
     return 0 if $webCoreTypeHash{$type};
 
     return 1;
@@ -866,7 +973,7 @@ sub getInterfaceExtendedAttributesFromName
     my $object = shift;
     my $interfaceName = shift;
 
-    my $idlFile = $object->IDLFileForInterface($interfaceName) or die("Could NOT find IDL file for interface \"$interfaceName\"!\n");
+    my $idlFile = $object->IDLFileForInterface($interfaceName) or assert("Could NOT find IDL file for interface \"$interfaceName\"!\n");
 
     open FILE, "<", $idlFile or die;
     my @lines = <FILE>;
@@ -898,7 +1005,7 @@ sub ComputeIsCallbackInterface
 
   return 0 unless $object->IsWrapperType($type);
 
-  my $idlFile = $object->IDLFileForInterface($type) or die("Could NOT find IDL file for interface \"$type\"!\n");
+  my $idlFile = $object->IDLFileForInterface($type) or assert("Could NOT find IDL file for interface \"$type\"!\n");
 
   open FILE, "<", $idlFile or die;
   my @lines = <FILE>;
@@ -934,7 +1041,7 @@ sub ComputeIsFunctionOnlyCallbackInterface
 
   return 0 unless $object->IsCallbackInterface($type);
 
-  my $idlFile = $object->IDLFileForInterface($type) or die("Could NOT find IDL file for interface \"$type\"!\n");
+  my $idlFile = $object->IDLFileForInterface($type) or assert("Could NOT find IDL file for interface \"$type\"!\n");
 
   open FILE, "<", $idlFile or die;
   my @lines = <FILE>;
index 1e1ab5c..31125f2 100644 (file)
@@ -248,6 +248,28 @@ sub AddIncludesForType
     }
 }
 
+sub AddToImplIncludesForIDLType
+{
+    my ($idlType, $conditional) = @_;
+
+    return if $codeGenerator->SkipIncludeHeader($idlType->name);
+
+    if ($idlType->isUnion) {
+        AddToImplIncludes("<wtf/Variant.h>", $conditional);
+
+        foreach my $memberType (@{$idlType->subtypes}) {
+            AddToImplIncludesForIDLType($memberType, $conditional);
+        }
+
+        return;
+    }
+
+    if ($codeGenerator->IsWrapperType($idlType->name)) {
+        AddToImplIncludes("JS" . $idlType->name . ".h");
+        return;
+    }
+}
+
 sub AddToImplIncludes
 {
     my $header = shift;
@@ -4010,6 +4032,7 @@ sub GenerateParametersCheck
     my $argumentIndex = 0;
     foreach my $parameter (@{$function->parameters}) {
         my $type = $parameter->type;
+        my $idlType = $parameter->idlType;
 
         die "Optional parameters of non-nullable wrapper types are not supported" if $parameter->isOptional && !$parameter->isNullable && $codeGenerator->IsWrapperType($type);
         die "Optional parameters preceding variadic parameters are not supported" if ($parameter->isOptional &&  @{$function->parameters}[$numParameters - 1]->isVariadic);
@@ -4071,17 +4094,13 @@ sub GenerateParametersCheck
             }
             $value = "WTFMove($name)";
         } elsif ($parameter->isVariadic) {
-            AddToImplIncludes("JS${type}.h", $function->signature->extendedAttributes->{Conditional}) unless $codeGenerator->SkipIncludeHeader($type) or !$codeGenerator->IsWrapperType($type);
-            my ($wrapperType, $wrappedType) = GetVariadicType($interface, $type);
-            push(@$outputArray, "    auto $name = toArguments<VariadicHelper<$wrapperType, $wrappedType>>(*state, $argumentIndex);\n");
+            $implIncludes{"JSDOMConvert.h"} = 1;
+            AddToImplIncludesForIDLType($idlType, $function->signature->extendedAttributes->{Conditional});
+        
+            my $metaType = $codeGenerator->GetIDLType($interface, $idlType);
+            push(@$outputArray, "    auto $name = convertVariadicArguments<$metaType>(*state, $argumentIndex);\n");
+            push(@$outputArray, "    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());\n");
 
-            if (IsNativeType($type)) {
-                push(@$outputArray, "    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());\n");
-            }
-            else {
-                push(@$outputArray, "    if (!$name.arguments)\n");
-                push(@$outputArray, "        return throwArgumentTypeError(*state, throwScope, $name.argumentIndex, \"$name\", \"$visibleInterfaceName\", $quotedFunctionName, \"$type\");\n");
-            }
             $value = "WTFMove($name.arguments.value())";
 
         } elsif ($codeGenerator->IsEnumType($type)) {
index 78d53f7..e1ce760 100644 (file)
@@ -44,6 +44,13 @@ struct( idlDocument => {
     fileName => '$',
 });
 
+struct( domType => {
+    name =>         '$', # Type identifier
+    isNullable =>   '$', # Is the type Nullable (T?)
+    isUnion =>      '$', # Is the type a union (T or U)
+    subtypes =>     '@', # Array of subtypes, only valid if isUnion or sequence
+});
+
 # Used to represent 'interface' blocks
 struct( domInterface => {
     name => '$',      # Class identifier
@@ -79,18 +86,12 @@ struct( domAttribute => {
     signature => '$',         # Attribute signature
 });
 
-struct( domType => {
-    name =>         '$', # Type identifier
-    isNullable =>   '$', # Is the type Nullable (T?)
-    isUnion =>      '$', # Is the type a union (T or U)
-    subtypes =>     '@', # Array of subtypes, only valid if isUnion or sequence
-});
-
 # Used to represent a map of 'variable name' <-> 'variable type'
 struct( domSignature => {
     direction => '$',   # Variable direction (in or out)
     name => '$',        # Variable name
-    type => '$'      ,  # Variable type
+    type => '$',        # Variable type name (DEPRECATED - please use idlType)
+    idlType => '$',     # Variable type
     specials => '@',    # Specials
     extendedAttributes => '$', # Extended attributes
     isNullable => '$',  # Is variable type Nullable (T?)
@@ -707,6 +708,7 @@ sub parseDictionaryMember
         $member->extendedAttributes($extendedAttributeList);
 
         my $type = $self->parseType();
+        $member->idlType($type);
         $member->type($type->name);
         $member->isNullable($type->isNullable);
 
@@ -1254,6 +1256,7 @@ sub parseAttributeRest
         $newDataNode->signature(domSignature->new());
         
         my $type = $self->parseType();
+        $newDataNode->signature->idlType($type);
         $newDataNode->signature->type($type->name);
         $newDataNode->signature->isNullable($type->isNullable);
 
@@ -1546,6 +1549,7 @@ sub parseOptionalOrRequiredArgument
         $self->assertTokenValue($self->getToken(), "optional", __LINE__);
 
         my $type = $self->parseType();
+        $paramDataNode->idlType($type);
         $paramDataNode->type(identifierRemoveNullablePrefix($type->name));
         $paramDataNode->isNullable($type->isNullable);
         $paramDataNode->isOptional(1);
@@ -1555,6 +1559,7 @@ sub parseOptionalOrRequiredArgument
     }
     if ($next->type() == IdentifierToken || $next->value() =~ /$nextExceptionField_1/) {
         my $type = $self->parseType();
+        $paramDataNode->idlType($type);
         $paramDataNode->type($type->name);
         $paramDataNode->isNullable($type->isNullable);
         $paramDataNode->isOptional(0);
@@ -1617,6 +1622,7 @@ sub parseExceptionField
         $newDataNode->signature(domSignature->new());
 
         my $type = $self->parseType();
+        $newDataNode->signature->idlType($type);
         $newDataNode->signature->type($type->name);
         $newDataNode->signature->isNullable($type->isNullable);
         
index 4e5627e..fbc7607 100644 (file)
@@ -71,6 +71,7 @@
 #include <runtime/ObjectConstructor.h>
 #include <runtime/PropertyNameArray.h>
 #include <wtf/GetPtr.h>
+#include <wtf/Variant.h>
 
 #if ENABLE(Condition1)
 #include "JSTestObjectA.h"
@@ -984,6 +985,7 @@ JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOrange(JSC::ExecStat
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVariadicStringMethod(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVariadicDoubleMethod(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVariadicNodeMethod(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVariadicUnionMethod(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionAny(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionTestPromiseFunction(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionTestPromiseFunctionWithFloatArgument(JSC::ExecState*);
@@ -1591,6 +1593,7 @@ static const HashTableValue JSTestObjPrototypeTableValues[] =
     { "variadicStringMethod", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVariadicStringMethod), (intptr_t) (1) } },
     { "variadicDoubleMethod", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVariadicDoubleMethod), (intptr_t) (1) } },
     { "variadicNodeMethod", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVariadicNodeMethod), (intptr_t) (1) } },
+    { "variadicUnionMethod", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVariadicUnionMethod), (intptr_t) (1) } },
     { "any", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionAny), (intptr_t) (2) } },
     { "testPromiseFunction", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionTestPromiseFunction), (intptr_t) (0) } },
     { "testPromiseFunctionWithFloatArgument", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionTestPromiseFunctionWithFloatArgument), (intptr_t) (1) } },
@@ -6563,9 +6566,8 @@ static inline EncodedJSValue jsTestObjPrototypeFunctionOverloadedMethod13(ExecSt
         return throwThisTypeError(*state, throwScope, "TestObject", "overloadedMethod");
     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
     auto& impl = castedThis->wrapped();
-    auto blobArgs = toArguments<VariadicHelper<JSBlob, Blob>>(*state, 0);
-    if (!blobArgs.arguments)
-        return throwArgumentTypeError(*state, throwScope, blobArgs.argumentIndex, "blobArgs", "TestObject", "overloadedMethod", "Blob");
+    auto blobArgs = convertVariadicArguments<IDLInterface<Blob>>(*state, 0);
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     impl.overloadedMethod(WTFMove(blobArgs.arguments.value()));
     return JSValue::encode(jsUndefined());
 }
@@ -7081,7 +7083,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVariadicStringMethod(Exec
         return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
     auto head = state->uncheckedArgument(0).toWTFString(state);
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
-    auto tail = toArguments<VariadicHelper<JSC::JSValue, String>>(*state, 1);
+    auto tail = convertVariadicArguments<IDLDOMString>(*state, 1);
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     impl.variadicStringMethod(WTFMove(head), WTFMove(tail.arguments.value()));
     return JSValue::encode(jsUndefined());
@@ -7102,7 +7104,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVariadicDoubleMethod(Exec
         return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
     auto head = convert<double>(*state, state->uncheckedArgument(0), ShouldAllowNonFinite::Yes);
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
-    auto tail = toArguments<VariadicHelper<JSC::JSValue, double>>(*state, 1);
+    auto tail = convertVariadicArguments<IDLUnrestrictedDouble>(*state, 1);
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     impl.variadicDoubleMethod(WTFMove(head), WTFMove(tail.arguments.value()));
     return JSValue::encode(jsUndefined());
@@ -7124,13 +7126,33 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVariadicNodeMethod(ExecSt
     auto head = JSNode::toWrapped(state->uncheckedArgument(0));
     if (UNLIKELY(!head))
         return throwArgumentTypeError(*state, throwScope, 0, "head", "TestObject", "variadicNodeMethod", "Node");
-    auto tail = toArguments<VariadicHelper<JSNode, Node>>(*state, 1);
-    if (!tail.arguments)
-        return throwArgumentTypeError(*state, throwScope, tail.argumentIndex, "tail", "TestObject", "variadicNodeMethod", "Node");
+    auto tail = convertVariadicArguments<IDLInterface<Node>>(*state, 1);
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     impl.variadicNodeMethod(*head, WTFMove(tail.arguments.value()));
     return JSValue::encode(jsUndefined());
 }
 
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVariadicUnionMethod(ExecState* state)
+{
+    VM& vm = state->vm();
+    auto throwScope = DECLARE_THROW_SCOPE(vm);
+    UNUSED_PARAM(throwScope);
+    JSValue thisValue = state->thisValue();
+    auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
+    if (UNLIKELY(!castedThis))
+        return throwThisTypeError(*state, throwScope, "TestObject", "variadicUnionMethod");
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+    auto& impl = castedThis->wrapped();
+    if (UNLIKELY(state->argumentCount() < 1))
+        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
+    auto head = state->uncheckedArgument(0).toWTFString(state);
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+    auto tail = convertVariadicArguments<IDLUnion<IDLInterface<Node>, IDLDOMString>>(*state, 1);
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+    impl.variadicUnionMethod(WTFMove(head), WTFMove(tail.arguments.value()));
+    return JSValue::encode(jsUndefined());
+}
+
 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionAny(ExecState* state)
 {
     VM& vm = state->vm();
index 6bc71b2..de8cacf 100644 (file)
@@ -25,6 +25,7 @@
 #include "JSBlob.h"
 #include "JSDOMBinding.h"
 #include "JSDOMConstructor.h"
+#include "JSDOMConvert.h"
 #include <runtime/Error.h>
 #include <runtime/FunctionPrototype.h>
 #include <wtf/GetPtr.h>
@@ -137,7 +138,7 @@ static inline EncodedJSValue constructJSTestOverloadedConstructors5(ExecState* s
     UNUSED_PARAM(throwScope);
     auto* castedThis = jsCast<JSTestOverloadedConstructorsConstructor*>(state->callee());
     ASSERT(castedThis);
-    auto longArgs = toArguments<VariadicHelper<JSC::JSValue, int32_t>>(*state, 0);
+    auto longArgs = convertVariadicArguments<IDLLong>(*state, 0);
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     auto object = TestOverloadedConstructors::create(WTFMove(longArgs));
     return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
index 1b5b13e..a69f6ac 100644 (file)
@@ -359,6 +359,7 @@ enum TestConfidence { "high", "kinda-low" };
     void variadicStringMethod(DOMString head, DOMString... tail);
     void variadicDoubleMethod(unrestricted double head, unrestricted double... tail);
     void variadicNodeMethod(Node head, Node... tail);
+    void variadicUnionMethod(DOMString head, (Node or DOMString)... tail);
 
     // Nullable attributes.
     readonly attribute unrestricted double? nullableDoubleAttribute;
index 097f49a..370f838 100644 (file)
@@ -22,8 +22,8 @@
 [
     NoInterfaceObject,
 ] interface ChildNode {
-    [Unscopable, MayThrowLegacyException, Custom] void before((Node or DOMString)... nodes);
-    [Unscopable, MayThrowLegacyException, Custom] void after((Node or DOMString)... nodes);
-    [Unscopable, MayThrowLegacyException, Custom] void replaceWith((Node or DOMString)... nodes);
+    [Unscopable, MayThrowLegacyException] void before((Node or DOMString)... nodes);
+    [Unscopable, MayThrowLegacyException] void after((Node or DOMString)... nodes);
+    [Unscopable, MayThrowLegacyException] void replaceWith((Node or DOMString)... nodes);
     [Unscopable, MayThrowLegacyException] void remove();
 };
index 622bf89..653b50f 100644 (file)
@@ -877,7 +877,7 @@ unsigned ContainerNode::childElementCount() const
     return std::distance(children.begin(), children.end());
 }
 
-void ContainerNode::append(Vector<std::experimental::variant<Ref<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec)
+void ContainerNode::append(Vector<std::experimental::variant<std::reference_wrapper<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec)
 {
     RefPtr<Node> node = convertNodesOrStringsIntoNode(WTFMove(nodeOrStringVector), ec);
     if (ec || !node)
@@ -886,7 +886,7 @@ void ContainerNode::append(Vector<std::experimental::variant<Ref<Node>, String>>
     appendChild(*node, ec);
 }
 
-void ContainerNode::prepend(Vector<std::experimental::variant<Ref<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec)
+void ContainerNode::prepend(Vector<std::experimental::variant<std::reference_wrapper<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec)
 {
     RefPtr<Node> node = convertNodesOrStringsIntoNode(WTFMove(nodeOrStringVector), ec);
     if (ec || !node)
index 9ca7a18..ba93b7f 100644 (file)
@@ -99,8 +99,8 @@ public:
     WEBCORE_EXPORT Element* firstElementChild() const;
     WEBCORE_EXPORT Element* lastElementChild() const;
     WEBCORE_EXPORT unsigned childElementCount() const;
-    void append(Vector<std::experimental::variant<Ref<Node>, String>>&&, ExceptionCode&);
-    void prepend(Vector<std::experimental::variant<Ref<Node>, String>>&&, ExceptionCode&);
+    void append(Vector<std::experimental::variant<std::reference_wrapper<Node>, String>>&&, ExceptionCode&);
+    void prepend(Vector<std::experimental::variant<std::reference_wrapper<Node>, String>>&&, ExceptionCode&);
 
     bool ensurePreInsertionValidity(Node& newChild, Node* refChild, ExceptionCode&);
 
index 24c4091..b52983c 100644 (file)
@@ -435,12 +435,12 @@ bool Node::appendChild(Node& newChild, ExceptionCode& ec)
     return downcast<ContainerNode>(*this).appendChild(newChild, ec);
 }
 
-static HashSet<RefPtr<Node>> nodeSetPreTransformedFromNodeOrStringVector(const Vector<std::experimental::variant<Ref<Node>, String>>& vector)
+static HashSet<RefPtr<Node>> nodeSetPreTransformedFromNodeOrStringVector(const Vector<std::experimental::variant<std::reference_wrapper<Node>, String>>& vector)
 {
     HashSet<RefPtr<Node>> nodeSet;
 
     auto visitor = WTF::makeVisitor(
-        [&](const Ref<Node>& node) { nodeSet.add(const_cast<Node*>(node.ptr())); },
+        [&](const std::reference_wrapper<Node>& node) { nodeSet.add(const_cast<Node*>(&node.get())); },
         [](const String&) { }
     );
 
@@ -468,7 +468,7 @@ static RefPtr<Node> firstFollowingSiblingNotInNodeSet(Node& context, const HashS
     return nullptr;
 }
 
-RefPtr<Node> Node::convertNodesOrStringsIntoNode(Vector<std::experimental::variant<Ref<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec)
+RefPtr<Node> Node::convertNodesOrStringsIntoNode(Vector<std::experimental::variant<std::reference_wrapper<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec)
 {
     if (nodeOrStringVector.isEmpty())
         return nullptr;
@@ -477,7 +477,7 @@ RefPtr<Node> Node::convertNodesOrStringsIntoNode(Vector<std::experimental::varia
     nodes.reserveInitialCapacity(nodeOrStringVector.size());
 
     auto visitor = WTF::makeVisitor(
-        [&](Ref<Node>& node) { nodes.uncheckedAppend(node.copyRef()); },
+        [&](std::reference_wrapper<Node>& node) { nodes.uncheckedAppend(node); },
         [&](String& string) { nodes.uncheckedAppend(Text::create(document(), string)); }
     );
 
@@ -495,7 +495,7 @@ RefPtr<Node> Node::convertNodesOrStringsIntoNode(Vector<std::experimental::varia
     return WTFMove(nodeToReturn);
 }
 
-void Node::before(Vector<std::experimental::variant<Ref<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec)
+void Node::before(Vector<std::experimental::variant<std::reference_wrapper<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec)
 {
     RefPtr<ContainerNode> parent = parentNode();
     if (!parent)
@@ -516,7 +516,7 @@ void Node::before(Vector<std::experimental::variant<Ref<Node>, String>>&& nodeOr
     parent->insertBefore(*node, viablePreviousSibling.get(), ec);
 }
 
-void Node::after(Vector<std::experimental::variant<Ref<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec)
+void Node::after(Vector<std::experimental::variant<std::reference_wrapper<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec)
 {
     RefPtr<ContainerNode> parent = parentNode();
     if (!parent)
@@ -532,7 +532,7 @@ void Node::after(Vector<std::experimental::variant<Ref<Node>, String>>&& nodeOrS
     parent->insertBefore(*node, viableNextSibling.get(), ec);
 }
 
-void Node::replaceWith(Vector<std::experimental::variant<Ref<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec)
+void Node::replaceWith(Vector<std::experimental::variant<std::reference_wrapper<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec)
 {
     RefPtr<ContainerNode> parent = parentNode();
     if (!parent)
index 9664df7..ace7437 100644 (file)
@@ -202,9 +202,9 @@ public:
     WEBCORE_EXPORT Element* nextElementSibling() const;
 
     // From the ChildNode - https://dom.spec.whatwg.org/#childnode
-    void before(Vector<std::experimental::variant<Ref<Node>, String>>&&, ExceptionCode&);
-    void after(Vector<std::experimental::variant<Ref<Node>, String>>&&, ExceptionCode&);
-    void replaceWith(Vector<std::experimental::variant<Ref<Node>, String>>&&, ExceptionCode&);
+    void before(Vector<std::experimental::variant<std::reference_wrapper<Node>, String>>&&, ExceptionCode&);
+    void after(Vector<std::experimental::variant<std::reference_wrapper<Node>, String>>&&, ExceptionCode&);
+    void replaceWith(Vector<std::experimental::variant<std::reference_wrapper<Node>, String>>&&, ExceptionCode&);
     WEBCORE_EXPORT void remove(ExceptionCode&);
 
     // Other methods (not part of DOM)
@@ -659,7 +659,7 @@ protected:
     void setStyleChange(StyleChangeType changeType) { m_nodeFlags = (m_nodeFlags & ~StyleChangeMask) | changeType; }
     void updateAncestorsForStyleRecalc();
 
-    RefPtr<Node> convertNodesOrStringsIntoNode(Vector<std::experimental::variant<Ref<Node>, String>>&&, ExceptionCode&);
+    RefPtr<Node> convertNodesOrStringsIntoNode(Vector<std::experimental::variant<std::reference_wrapper<Node>, String>>&&, ExceptionCode&);
 
 private:
     virtual PseudoId customPseudoId() const
index 1e49c9d..1434ede 100644 (file)
@@ -33,8 +33,8 @@
     readonly attribute Element lastElementChild;
     readonly attribute unsigned long childElementCount;
 
-    [Unscopable, MayThrowLegacyException, Custom] void prepend((Node or DOMString)... nodes);
-    [Unscopable, MayThrowLegacyException, Custom] void append((Node or DOMString)... nodes);
+    [Unscopable, MayThrowLegacyException] void prepend((Node or DOMString)... nodes);
+    [Unscopable, MayThrowLegacyException] void append((Node or DOMString)... nodes);
 
     // [Unscopable] Element? query(DOMString relativeSelectors);
     // [NewObject, Unscopable] Elements queryAll(DOMString relativeSelectors);