JSDOMBinding is too big. Split it up!
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Jan 2017 03:37:34 +0000 (03:37 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Jan 2017 03:37:34 +0000 (03:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=167601

Reviewed by Darin Adler.

Source/WebCore:

Splits JSDOMBinding.h/cpp up a bit by splitting out:
- JSDOMBindingCaller.h
- JSDOMBindingSecurity.h/cpp
- JSDOMExceptionHandling.h/cpp
- JSDOMWrapperCache.h/cpp

Also:
- Moves all constructor objects to JSDOMConstructor.h/cpp,
- Moves special DOMWindow accessors to JSDOMWindowBase.
- Deletes unused CallbackFunction.h/cpp

* CMakeLists.txt:
* Modules/webdatabase/Database.cpp:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/CallbackFunction.cpp: Removed.
* bindings/js/CallbackFunction.h: Removed.
* bindings/js/DOMConstructorWithDocument.h: Removed.
* bindings/js/JSCryptoCustom.cpp:
* bindings/js/JSCustomXPathNSResolver.cpp:
* bindings/js/JSDOMBinding.cpp:
* bindings/js/JSDOMBinding.h:
* bindings/js/JSDOMBindingCaller.h: Copied from Source/WebCore/bindings/js/JSDOMBinding.h.
* bindings/js/JSDOMBindingSecurity.cpp: Copied from Source/WebCore/bindings/js/JSDOMBinding.cpp.
* bindings/js/JSDOMBindingSecurity.h: Copied from Source/WebCore/bindings/js/JSDOMBinding.h.
* bindings/js/JSDOMConstructor.cpp: Copied from Source/WebCore/bindings/js/JSDOMBinding.cpp.
* bindings/js/JSDOMConstructor.h:
* bindings/js/JSDOMConvert.h:
* bindings/js/JSDOMExceptionHandling.cpp: Copied from Source/WebCore/bindings/js/JSDOMBinding.cpp.
* bindings/js/JSDOMExceptionHandling.h: Copied from Source/WebCore/bindings/js/JSDOMBinding.h.
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::callerDOMWindow): Moved from JSDOMBinding.h
(WebCore::activeDOMWindow): Moved from JSDOMBinding.h
(WebCore::firstDOMWindow): Moved from JSDOMBinding.h
* bindings/js/JSDOMWindowBase.h:
* bindings/js/JSDOMWindowCustom.cpp:
* bindings/js/JSDOMWindowProperties.cpp:
* bindings/js/JSDOMWrapperCache.cpp: Copied from Source/WebCore/bindings/js/JSDOMBinding.cpp.
* bindings/js/JSDOMWrapperCache.h: Copied from Source/WebCore/bindings/js/JSDOMBinding.h.
* bindings/js/JSEventTargetCustom.h:
* bindings/js/JSHTMLElementCustom.cpp:
* bindings/js/JSLocationCustom.cpp:
* bindings/js/JSMutationObserverCustom.cpp:
* bindings/js/JSSQLStatementErrorCallbackCustom.cpp:
* bindings/js/JSStorageCustom.cpp:
* bindings/js/JSWorkerCustom.cpp:
* bindings/js/JSXPathNSResolverCustom.cpp:
* bindings/js/ScheduledAction.cpp:
* bindings/js/ScriptController.cpp:
* bindings/js/ScriptController.h:
* bindings/js/ScriptGlobalObject.cpp:
(WebCore::ScriptGlobalObject::set):
* bindings/js/StructuredClone.cpp:
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateImplementation):
(GenerateCallWith):
(GenerateParametersCheck):
(GenerateCallbackImplementationContent):
(NativeToJSValue):
* bridge/objc/WebScriptObject.mm:
* html/HTMLFrameElementBase.cpp:
* html/HTMLVideoElement.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorDOMAgent.cpp:
* inspector/PageScriptDebugServer.cpp:
* inspector/WorkerScriptDebugServer.cpp:

Source/WebKit2:

* Shared/WebCoreArgumentCoders.cpp:
Replace include of JSDOMBinding with JSDOMExceptionHandling.

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

83 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/webdatabase/Database.cpp
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/CallbackFunction.cpp [deleted file]
Source/WebCore/bindings/js/CallbackFunction.h [deleted file]
Source/WebCore/bindings/js/DOMConstructorWithDocument.h [deleted file]
Source/WebCore/bindings/js/JSBindingsAllInOne.cpp
Source/WebCore/bindings/js/JSCryptoCustom.cpp
Source/WebCore/bindings/js/JSCustomXPathNSResolver.cpp
Source/WebCore/bindings/js/JSDOMBinding.cpp
Source/WebCore/bindings/js/JSDOMBinding.h
Source/WebCore/bindings/js/JSDOMBindingCaller.h [new file with mode: 0644]
Source/WebCore/bindings/js/JSDOMBindingSecurity.cpp [new file with mode: 0644]
Source/WebCore/bindings/js/JSDOMBindingSecurity.h [new file with mode: 0644]
Source/WebCore/bindings/js/JSDOMConstructor.cpp [new file with mode: 0644]
Source/WebCore/bindings/js/JSDOMConstructor.h
Source/WebCore/bindings/js/JSDOMConvert.h
Source/WebCore/bindings/js/JSDOMExceptionHandling.cpp [new file with mode: 0644]
Source/WebCore/bindings/js/JSDOMExceptionHandling.h [new file with mode: 0644]
Source/WebCore/bindings/js/JSDOMWindowBase.cpp
Source/WebCore/bindings/js/JSDOMWindowBase.h
Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
Source/WebCore/bindings/js/JSDOMWindowProperties.cpp
Source/WebCore/bindings/js/JSDOMWrapperCache.cpp [new file with mode: 0644]
Source/WebCore/bindings/js/JSDOMWrapperCache.h [new file with mode: 0644]
Source/WebCore/bindings/js/JSEventTargetCustom.h
Source/WebCore/bindings/js/JSHTMLElementCustom.cpp
Source/WebCore/bindings/js/JSLocationCustom.cpp
Source/WebCore/bindings/js/JSMutationObserverCustom.cpp
Source/WebCore/bindings/js/JSSQLStatementErrorCallbackCustom.cpp
Source/WebCore/bindings/js/JSStorageCustom.cpp
Source/WebCore/bindings/js/JSWorkerCustom.cpp
Source/WebCore/bindings/js/JSXPathNSResolverCustom.cpp
Source/WebCore/bindings/js/ScheduledAction.cpp
Source/WebCore/bindings/js/ScriptController.cpp
Source/WebCore/bindings/js/ScriptController.h
Source/WebCore/bindings/js/ScriptGlobalObject.cpp
Source/WebCore/bindings/js/StructuredClone.cpp
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/test/JS/JSInterfaceName.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestCEReactions.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestCEReactionsStringifier.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunction.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestCallbackInterface.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestClassWithJSBuiltinConstructor.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestCustomConstructorWithNoInterfaceObject.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestDOMJIT.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestException.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestInterfaceLeadingUnderscore.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestIterable.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestJSBuiltinConstructor.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestOverrideBuiltins.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestSerialization.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp
Source/WebCore/bridge/objc/WebScriptObject.mm
Source/WebCore/html/HTMLFrameElementBase.cpp
Source/WebCore/html/HTMLVideoElement.cpp
Source/WebCore/inspector/InspectorController.cpp
Source/WebCore/inspector/InspectorDOMAgent.cpp
Source/WebCore/inspector/PageScriptDebugServer.cpp
Source/WebCore/inspector/WorkerScriptDebugServer.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Scripts/webkit/messages.py
Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index 44316de..3ea503c 100644 (file)
@@ -1069,7 +1069,6 @@ set(WebCore_SOURCES
 
     bindings/js/CachedModuleScriptLoader.cpp
     bindings/js/CachedScriptFetcher.cpp
-    bindings/js/CallbackFunction.cpp
     bindings/js/CommonVM.cpp
     bindings/js/DOMWrapperWorld.cpp
     bindings/js/GCController.cpp
@@ -1100,6 +1099,9 @@ set(WebCore_SOURCES
     bindings/js/JSCustomEventCustom.cpp
     bindings/js/JSCustomXPathNSResolver.cpp
     bindings/js/JSDOMBinding.cpp
+    bindings/js/JSDOMBindingSecurity.cpp
+    bindings/js/JSDOMConstructor.cpp
+    bindings/js/JSDOMExceptionHandling.cpp
     bindings/js/JSDOMGlobalObject.cpp
     bindings/js/JSDOMGlobalObjectTask.cpp
     bindings/js/JSDOMPromise.cpp
@@ -1109,6 +1111,7 @@ set(WebCore_SOURCES
     bindings/js/JSDOMWindowProperties.cpp
     bindings/js/JSDOMWindowShell.cpp
     bindings/js/JSDOMWrapper.cpp
+    bindings/js/JSDOMWrapperCache.cpp
     bindings/js/JSDocumentCustom.cpp
     bindings/js/JSDocumentFragmentCustom.cpp
     bindings/js/JSElementCustom.cpp
index df916b0..705efca 100644 (file)
@@ -1,3 +1,76 @@
+2017-01-30  Sam Weinig  <sam@webkit.org>
+
+        JSDOMBinding is too big. Split it up!
+        https://bugs.webkit.org/show_bug.cgi?id=167601
+
+        Reviewed by Darin Adler.
+
+        Splits JSDOMBinding.h/cpp up a bit by splitting out:
+        - JSDOMBindingCaller.h
+        - JSDOMBindingSecurity.h/cpp
+        - JSDOMExceptionHandling.h/cpp
+        - JSDOMWrapperCache.h/cpp
+
+        Also:
+        - Moves all constructor objects to JSDOMConstructor.h/cpp,  
+        - Moves special DOMWindow accessors to JSDOMWindowBase.
+        - Deletes unused CallbackFunction.h/cpp
+
+        * CMakeLists.txt:
+        * Modules/webdatabase/Database.cpp:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/CallbackFunction.cpp: Removed.
+        * bindings/js/CallbackFunction.h: Removed.
+        * bindings/js/DOMConstructorWithDocument.h: Removed.
+        * bindings/js/JSCryptoCustom.cpp:
+        * bindings/js/JSCustomXPathNSResolver.cpp:
+        * bindings/js/JSDOMBinding.cpp:
+        * bindings/js/JSDOMBinding.h:
+        * bindings/js/JSDOMBindingCaller.h: Copied from Source/WebCore/bindings/js/JSDOMBinding.h.
+        * bindings/js/JSDOMBindingSecurity.cpp: Copied from Source/WebCore/bindings/js/JSDOMBinding.cpp.
+        * bindings/js/JSDOMBindingSecurity.h: Copied from Source/WebCore/bindings/js/JSDOMBinding.h.
+        * bindings/js/JSDOMConstructor.cpp: Copied from Source/WebCore/bindings/js/JSDOMBinding.cpp.
+        * bindings/js/JSDOMConstructor.h:
+        * bindings/js/JSDOMConvert.h:
+        * bindings/js/JSDOMExceptionHandling.cpp: Copied from Source/WebCore/bindings/js/JSDOMBinding.cpp.
+        * bindings/js/JSDOMExceptionHandling.h: Copied from Source/WebCore/bindings/js/JSDOMBinding.h.
+        * bindings/js/JSDOMWindowBase.cpp:
+        (WebCore::callerDOMWindow): Moved from JSDOMBinding.h
+        (WebCore::activeDOMWindow): Moved from JSDOMBinding.h
+        (WebCore::firstDOMWindow): Moved from JSDOMBinding.h
+        * bindings/js/JSDOMWindowBase.h:
+        * bindings/js/JSDOMWindowCustom.cpp:
+        * bindings/js/JSDOMWindowProperties.cpp:
+        * bindings/js/JSDOMWrapperCache.cpp: Copied from Source/WebCore/bindings/js/JSDOMBinding.cpp.
+        * bindings/js/JSDOMWrapperCache.h: Copied from Source/WebCore/bindings/js/JSDOMBinding.h.
+        * bindings/js/JSEventTargetCustom.h:
+        * bindings/js/JSHTMLElementCustom.cpp:
+        * bindings/js/JSLocationCustom.cpp:
+        * bindings/js/JSMutationObserverCustom.cpp:
+        * bindings/js/JSSQLStatementErrorCallbackCustom.cpp:
+        * bindings/js/JSStorageCustom.cpp:
+        * bindings/js/JSWorkerCustom.cpp:
+        * bindings/js/JSXPathNSResolverCustom.cpp:
+        * bindings/js/ScheduledAction.cpp:
+        * bindings/js/ScriptController.cpp:
+        * bindings/js/ScriptController.h:
+        * bindings/js/ScriptGlobalObject.cpp:
+        (WebCore::ScriptGlobalObject::set):
+        * bindings/js/StructuredClone.cpp:
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateImplementation):
+        (GenerateCallWith):
+        (GenerateParametersCheck):
+        (GenerateCallbackImplementationContent):
+        (NativeToJSValue):
+        * bridge/objc/WebScriptObject.mm:
+        * html/HTMLFrameElementBase.cpp:
+        * html/HTMLVideoElement.cpp:
+        * inspector/InspectorController.cpp:
+        * inspector/InspectorDOMAgent.cpp:
+        * inspector/PageScriptDebugServer.cpp:
+        * inspector/WorkerScriptDebugServer.cpp:
+
 2017-01-30  Andy Estes  <aestes@apple.com>
 
         [QuickLook] FrameLoaderClient should return the new QuickLookHandleClient it creates
index c3d0896..8869f6b 100644 (file)
@@ -40,6 +40,7 @@
 #include "DatabaseThread.h"
 #include "DatabaseTracker.h"
 #include "Document.h"
+#include "ExceptionCode.h"
 #include "JSDOMWindow.h"
 #include "Logging.h"
 #include "SQLError.h"
index 3d9557a..2c98d48 100644 (file)
                7C3E510B18DF8F3500C112F7 /* HTMLConverter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7C3E510918DF8F3500C112F7 /* HTMLConverter.mm */; };
                7C3F01C11C8E5ABA00ADD962 /* UserContentProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C3F01C01C8E5AB100ADD962 /* UserContentProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7C3F01C21C8E5AC200ADD962 /* UserContentProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C3F01BF1C8E5AB100ADD962 /* UserContentProvider.cpp */; };
+               7C45C9CF1E3EFDF700AAB558 /* JSDOMBindingSecurity.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C45C9CA1E3E8D2E00AAB558 /* JSDOMBindingSecurity.cpp */; };
+               7C45C9D01E3EFDFB00AAB558 /* JSDOMWrapperCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C45C9CB1E3E8E4900AAB558 /* JSDOMWrapperCache.cpp */; };
+               7C45C9D11E3EFE0500AAB558 /* JSDOMConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C45C9CD1E3E900B00AAB558 /* JSDOMConstructor.cpp */; };
+               7C45C9D21E3EFE0800AAB558 /* JSDOMExceptionHandling.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C45C9CC1E3E8F0800AAB558 /* JSDOMExceptionHandling.cpp */; };
+               7C45C9D31E3FCBD700AAB558 /* JSDOMWrapperCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C45C9C81E3E8B5100AAB558 /* JSDOMWrapperCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               7C45C9D41E3FCBDF00AAB558 /* JSDOMBindingSecurity.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C45C9C91E3E8CD700AAB558 /* JSDOMBindingSecurity.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               7C45C9D51E3FCBE400AAB558 /* JSDOMBindingCaller.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C45C9C61E3E8ABA00AAB558 /* JSDOMBindingCaller.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               7C45C9D61E3FCBF800AAB558 /* JSDOMExceptionHandling.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C45C9C71E3E8AFF00AAB558 /* JSDOMExceptionHandling.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7C48A6D0191C9D6500026674 /* WebKitNamespace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C48A6CE191C9D6500026674 /* WebKitNamespace.cpp */; };
                7C48A6D1191C9D6500026674 /* WebKitNamespace.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C48A6CF191C9D6500026674 /* WebKitNamespace.h */; };
                7C4C96DC1AD4483500365A50 /* JSReadableStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C4C96D81AD4483500365A50 /* JSReadableStream.cpp */; };
                B10B6980140C174000BC1C26 /* WebVTTToken.h in Headers */ = {isa = PBXBuildFile; fileRef = B10B697D140C174000BC1C26 /* WebVTTToken.h */; };
                B10B6981140C174000BC1C26 /* WebVTTTokenizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B10B697E140C174000BC1C26 /* WebVTTTokenizer.cpp */; };
                B10B6982140C174000BC1C26 /* WebVTTTokenizer.h in Headers */ = {isa = PBXBuildFile; fileRef = B10B697F140C174000BC1C26 /* WebVTTTokenizer.h */; };
-               B1827493134CA4C100B98C2D /* CallbackFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1827492134CA4C100B98C2D /* CallbackFunction.cpp */; };
                B1AD4E7313A12A4600846B27 /* TextTrackLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1AD4E7113A12A4600846B27 /* TextTrackLoader.cpp */; };
                B1AD4E7413A12A4600846B27 /* TextTrackLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = B1AD4E7213A12A4600846B27 /* TextTrackLoader.h */; };
-               B1D5ECB5134B58DA0087C78F /* CallbackFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = B1D5ECB4134B58DA0087C78F /* CallbackFunction.h */; };
                B20111070AB7740500DB0E68 /* JSSVGAElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B20111050AB7740500DB0E68 /* JSSVGAElement.cpp */; };
                B20111080AB7740500DB0E68 /* JSSVGAElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B20111060AB7740500DB0E68 /* JSSVGAElement.h */; };
                B22279640D00BF220071B782 /* GradientAttributes.h in Headers */ = {isa = PBXBuildFile; fileRef = B22277CD0D00BF1F0071B782 /* GradientAttributes.h */; };
                B543B85717EB758F003BE93A /* SVGPropertyInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B543B85617EB758F003BE93A /* SVGPropertyInfo.cpp */; };
                B562DB6017D3CD630010AF96 /* HTMLElementTypeHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = B562DB5E17D3CD560010AF96 /* HTMLElementTypeHelpers.h */; settings = {ATTRIBUTES = (Private, ); }; };
                B562DB6117D3CD660010AF96 /* SVGElementTypeHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = B562DB5F17D3CD560010AF96 /* SVGElementTypeHelpers.h */; };
-               B56576E817DA94E200A56BDC /* DOMConstructorWithDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = B56576E717DA94E200A56BDC /* DOMConstructorWithDocument.h */; };
                B56579B51824D12A00E79F23 /* RenderChildIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = B56579B41824D12A00E79F23 /* RenderChildIterator.h */; };
                B57CB52D182A3EED0079A647 /* InlineElementBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B57CB52C182A3EED0079A647 /* InlineElementBox.cpp */; };
                B57CB52E182A3EFC0079A647 /* InlineElementBox.h in Headers */ = {isa = PBXBuildFile; fileRef = B57CB52B182A37F60079A647 /* InlineElementBox.h */; };
                7C3F01C01C8E5AB100ADD962 /* UserContentProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserContentProvider.h; sourceTree = "<group>"; };
                7C4189AB1B07C170000FA757 /* GlobalEventHandlers.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = GlobalEventHandlers.idl; sourceTree = "<group>"; };
                7C4189AC1B07CBF2000FA757 /* WindowEventHandlers.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WindowEventHandlers.idl; sourceTree = "<group>"; };
+               7C45C9C61E3E8ABA00AAB558 /* JSDOMBindingCaller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMBindingCaller.h; sourceTree = "<group>"; };
+               7C45C9C71E3E8AFF00AAB558 /* JSDOMExceptionHandling.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMExceptionHandling.h; sourceTree = "<group>"; };
+               7C45C9C81E3E8B5100AAB558 /* JSDOMWrapperCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMWrapperCache.h; sourceTree = "<group>"; };
+               7C45C9C91E3E8CD700AAB558 /* JSDOMBindingSecurity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMBindingSecurity.h; sourceTree = "<group>"; };
+               7C45C9CA1E3E8D2E00AAB558 /* JSDOMBindingSecurity.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMBindingSecurity.cpp; sourceTree = "<group>"; };
+               7C45C9CB1E3E8E4900AAB558 /* JSDOMWrapperCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMWrapperCache.cpp; sourceTree = "<group>"; };
+               7C45C9CC1E3E8F0800AAB558 /* JSDOMExceptionHandling.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMExceptionHandling.cpp; sourceTree = "<group>"; };
+               7C45C9CD1E3E900B00AAB558 /* JSDOMConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMConstructor.cpp; sourceTree = "<group>"; };
                7C48A6CE191C9D6500026674 /* WebKitNamespace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitNamespace.cpp; sourceTree = "<group>"; };
                7C48A6CF191C9D6500026674 /* WebKitNamespace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitNamespace.h; sourceTree = "<group>"; };
                7C48A6D2191C9D8E00026674 /* WebKitNamespace.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebKitNamespace.idl; sourceTree = "<group>"; };
                B10B697D140C174000BC1C26 /* WebVTTToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebVTTToken.h; sourceTree = "<group>"; };
                B10B697E140C174000BC1C26 /* WebVTTTokenizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebVTTTokenizer.cpp; sourceTree = "<group>"; };
                B10B697F140C174000BC1C26 /* WebVTTTokenizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebVTTTokenizer.h; sourceTree = "<group>"; };
-               B1827492134CA4C100B98C2D /* CallbackFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CallbackFunction.cpp; sourceTree = "<group>"; };
                B1A942E115B5CE2200D525D1 /* MediaSourceRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaSourceRegistry.cpp; sourceTree = "<group>"; };
                B1A942E215B5CE2200D525D1 /* MediaSourceRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSourceRegistry.h; sourceTree = "<group>"; };
                B1AD4E7113A12A4600846B27 /* TextTrackLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextTrackLoader.cpp; sourceTree = "<group>"; };
                B1AD4E7213A12A4600846B27 /* TextTrackLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextTrackLoader.h; sourceTree = "<group>"; };
-               B1D5ECB4134B58DA0087C78F /* CallbackFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CallbackFunction.h; sourceTree = "<group>"; };
                B20111050AB7740500DB0E68 /* JSSVGAElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGAElement.cpp; sourceTree = "<group>"; };
                B20111060AB7740500DB0E68 /* JSSVGAElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSSVGAElement.h; sourceTree = "<group>"; };
                B22277CD0D00BF1F0071B782 /* GradientAttributes.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = GradientAttributes.h; sourceTree = "<group>"; };
                B562DB5E17D3CD560010AF96 /* HTMLElementTypeHelpers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HTMLElementTypeHelpers.h; sourceTree = "<group>"; };
                B562DB5F17D3CD560010AF96 /* SVGElementTypeHelpers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGElementTypeHelpers.h; sourceTree = "<group>"; };
                B56576E417DA599F00A56BDC /* JSMainThreadExecStateInstrumentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMainThreadExecStateInstrumentation.h; sourceTree = "<group>"; };
-               B56576E717DA94E200A56BDC /* DOMConstructorWithDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMConstructorWithDocument.h; sourceTree = "<group>"; };
                B56579B41824D12A00E79F23 /* RenderChildIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderChildIterator.h; sourceTree = "<group>"; };
                B57CB52B182A37F60079A647 /* InlineElementBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineElementBox.h; sourceTree = "<group>"; };
                B57CB52C182A3EED0079A647 /* InlineElementBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InlineElementBox.cpp; sourceTree = "<group>"; };
                                BCD533630ED6848900887468 /* CachedScriptSourceProvider.h */,
                                0F60F3291DFBB10400416D6C /* CommonVM.cpp */,
                                0F60F32A1DFBB10400416D6C /* CommonVM.h */,
-                               B56576E717DA94E200A56BDC /* DOMConstructorWithDocument.h */,
                                BC53DA471143134D000D817E /* DOMWrapperWorld.cpp */,
                                BC53DA2D1143121E000D817E /* DOMWrapperWorld.h */,
                                1432E8480C51493F00B1500F /* GCController.cpp */,
                                9BD4E9151C462872005065BC /* JSCustomElementInterface.h */,
                                93B70D4709EB0C7C009D8468 /* JSDOMBinding.cpp */,
                                93B70D4809EB0C7C009D8468 /* JSDOMBinding.h */,
+                               7C45C9C61E3E8ABA00AAB558 /* JSDOMBindingCaller.h */,
+                               7C45C9CA1E3E8D2E00AAB558 /* JSDOMBindingSecurity.cpp */,
+                               7C45C9C91E3E8CD700AAB558 /* JSDOMBindingSecurity.h */,
+                               7C45C9CD1E3E900B00AAB558 /* JSDOMConstructor.cpp */,
                                413C2C331BC29A7B0075204C /* JSDOMConstructor.h */,
                                930841331CDDB15500B0958C /* JSDOMConvert.h */,
+                               7C45C9CC1E3E8F0800AAB558 /* JSDOMExceptionHandling.cpp */,
+                               7C45C9C71E3E8AFF00AAB558 /* JSDOMExceptionHandling.h */,
                                E1C36CBC0EB08062007410BC /* JSDOMGlobalObject.cpp */,
                                E1C36C020EB076D6007410BC /* JSDOMGlobalObject.h */,
                                7C2BDD3B17C7F98B0038FF15 /* JSDOMGlobalObjectTask.cpp */,
                                BCBFB53B0DCD29CF0019B3E5 /* JSDOMWindowShell.h */,
                                4170A2E91D8C0CC000318452 /* JSDOMWrapper.cpp */,
                                65E0E9431133C89F00B4CB10 /* JSDOMWrapper.h */,
+                               7C45C9CB1E3E8E4900AAB558 /* JSDOMWrapperCache.cpp */,
+                               7C45C9C81E3E8B5100AAB558 /* JSDOMWrapperCache.h */,
                                E3A5872E1DC3F52600F607A6 /* JSDynamicDowncast.h */,
                                BC60901E0E91B8EC000C68B5 /* JSEventTargetCustom.cpp */,
                                46B63F6B1C6E8CDF002E914B /* JSEventTargetCustom.h */,
                BCCE58A71061E82F008FB35A /* Callback Objects */ = {
                        isa = PBXGroup;
                        children = (
-                               B1827492134CA4C100B98C2D /* CallbackFunction.cpp */,
-                               B1D5ECB4134B58DA0087C78F /* CallbackFunction.h */,
                                1449E286107D4DB400B5793F /* JSCallbackData.cpp */,
                                1449E24A107D4A8400B5793F /* JSCallbackData.h */,
                                E10B93C20B73C291003ED890 /* JSCustomXPathNSResolver.cpp */,
                                93F1995008245E59001E9ABC /* CachePolicy.h in Headers */,
                                E43AF8E71AC5B7EC00CA717E /* CacheValidation.h in Headers */,
                                49AE2D97134EE5F90072920A /* CalculationValue.h in Headers */,
-                               B1D5ECB5134B58DA0087C78F /* CallbackFunction.h in Headers */,
                                49484FC2102CF23C00187DD3 /* CanvasGradient.h in Headers */,
                                4671E0661D67A59600C6B497 /* CanvasPath.h in Headers */,
                                49484FC5102CF23C00187DD3 /* CanvasPattern.h in Headers */,
                                E125F8361822F18A00D84CD9 /* CryptoKeyHMAC.h in Headers */,
                                E1F80B8818317252007885C3 /* CryptoKeyPair.h in Headers */,
                                E164FAA318315BF400DB4E61 /* CryptoKeyRSA.h in Headers */,
+                               7C45C9D51E3FCBE400AAB558 /* JSDOMBindingCaller.h in Headers */,
                                E125F856182C0F8300D84CD9 /* CryptoKeySerialization.h in Headers */,
                                E125F85A182C1AA600D84CD9 /* CryptoKeySerializationRaw.h in Headers */,
                                E19727161820549E00592D51 /* CryptoKeyType.h in Headers */,
                                A8185F3909765766005826D9 /* DocumentType.h in Headers */,
                                973889A1116EA9DC00ADF313 /* DocumentWriter.h in Headers */,
                                1A8F6BC30DB55CDC001DB794 /* DOMApplicationCache.h in Headers */,
-                               B56576E817DA94E200A56BDC /* DOMConstructorWithDocument.h in Headers */,
                                BC60D6E90D28D83400B9918F /* DOMCoreException.h in Headers */,
                                FC9A0F75164094CF003D6B8D /* DOMCSSNamespace.h in Headers */,
                                9B3A8872145632F9003AE8F5 /* DOMDOMSettableTokenList.h in Headers */,
                                4496E3A0139813A5003EE32A /* JSSVGMPathElement.h in Headers */,
                                8542A7970AE5C94300DF58DF /* JSSVGNumber.h in Headers */,
                                B2FA3DB10AB75A6F000E5AC4 /* JSSVGNumberList.h in Headers */,
+                               7C45C9D31E3FCBD700AAB558 /* JSDOMWrapperCache.h in Headers */,
                                B2FA3DB50AB75A6F000E5AC4 /* JSSVGPathElement.h in Headers */,
                                B2FA3DB70AB75A6F000E5AC4 /* JSSVGPathSeg.h in Headers */,
                                B2FA3DB90AB75A6F000E5AC4 /* JSSVGPathSegArcAbs.h in Headers */,
                                97BC6A521505F081001B74AC /* SQLTransactionCallback.h in Headers */,
                                97BC6A571505F081001B74AC /* SQLTransactionCoordinator.h in Headers */,
                                97BC6A581505F081001B74AC /* SQLTransactionErrorCallback.h in Headers */,
+                               7C45C9D41E3FCBDF00AAB558 /* JSDOMBindingSecurity.h in Headers */,
                                FE36FD1816C7826500F887C1 /* SQLTransactionState.h in Headers */,
                                FE36FD1716C7826500F887C1 /* SQLTransactionStateMachine.h in Headers */,
                                1A2E6E5A0CC55213004A2062 /* SQLValue.h in Headers */,
                                0FF50272102BA96A0066F39A /* StyleMedia.h in Headers */,
                                BC5EB74E0E81E06700B25965 /* StyleMultiColData.h in Headers */,
                                E4DACE6A1D12E10B0075980F /* StylePendingResources.h in Headers */,
+                               7C45C9D61E3FCBF800AAB558 /* JSDOMExceptionHandling.h in Headers */,
                                A80E6DFC0A199067007FB8C5 /* StyleProperties.h in Headers */,
                                E1B25107152A0BB00069B779 /* StylePropertyShorthand.h in Headers */,
                                83C05A5B1A686212007E5DEA /* StylePropertyShorthandFunctions.h in Headers */,
                                BCB16C270979C3BD00467741 /* CachedXSLStyleSheet.cpp in Sources */,
                                E43AF8E61AC5B7E800CA717E /* CacheValidation.cpp in Sources */,
                                49AE2D96134EE5F90072920A /* CalculationValue.cpp in Sources */,
-                               B1827493134CA4C100B98C2D /* CallbackFunction.cpp in Sources */,
                                49484FC1102CF23C00187DD3 /* CanvasGradient.cpp in Sources */,
                                4671E0651D67A59600C6B497 /* CanvasPath.cpp in Sources */,
                                49484FC4102CF23C00187DD3 /* CanvasPattern.cpp in Sources */,
                                FBB0C5B717BBD626003D3677 /* CSSFilterImageValue.cpp in Sources */,
                                BC64B4D50CB4298A005F2B62 /* CSSFontFace.cpp in Sources */,
                                409EBDB216B7EE7400CBA3FC /* CSSFontFaceLoadEvent.cpp in Sources */,
+                               7C45C9D11E3EFE0500AAB558 /* JSDOMConstructor.cpp in Sources */,
                                A80E6CE70A1989CA007FB8C5 /* CSSFontFaceRule.cpp in Sources */,
                                C26017A31C72DC9900F74A16 /* CSSFontFaceSet.cpp in Sources */,
                                BC64B4D70CB4298A005F2B62 /* CSSFontFaceSource.cpp in Sources */,
                                B2AFFC7C0D00A5C10030074D /* FontCacheMac.mm in Sources */,
                                B2C3DA600D006CD600EF6F26 /* FontCascade.cpp in Sources */,
                                B2AFFC800D00A5C10030074D /* FontCascadeCocoa.mm in Sources */,
+                               7C45C9D01E3EFDFB00AAB558 /* JSDOMWrapperCache.cpp in Sources */,
                                B2C3DA670D006CD600EF6F26 /* FontCascadeFonts.cpp in Sources */,
                                7C4EDD741A7B607800198C4D /* FontCocoa.mm in Sources */,
                                B2AFFC7D0D00A5C10030074D /* FontCustomPlatformData.cpp in Sources */,
                                B22279A40D00BF220071B782 /* SVGComponentTransferFunctionElement.cpp in Sources */,
                                B2227B050D00BFF10071B782 /* SVGCSSComputedStyleDeclaration.cpp in Sources */,
                                B22279A70D00BF220071B782 /* SVGCursorElement.cpp in Sources */,
+                               7C45C9D21E3EFE0800AAB558 /* JSDOMExceptionHandling.cpp in Sources */,
                                B22279AD0D00BF220071B782 /* SVGDefsElement.cpp in Sources */,
                                B22279B00D00BF220071B782 /* SVGDescElement.cpp in Sources */,
                                B22279B30D00BF220071B782 /* SVGDocument.cpp in Sources */,
                                B22279CD0D00BF220071B782 /* SVGFEComponentTransferElement.cpp in Sources */,
                                B22279D00D00BF220071B782 /* SVGFECompositeElement.cpp in Sources */,
                                1921327411C0E6BB00456238 /* SVGFEConvolveMatrixElement.cpp in Sources */,
+                               7C45C9CF1E3EFDF700AAB558 /* JSDOMBindingSecurity.cpp in Sources */,
                                B22279D30D00BF220071B782 /* SVGFEDiffuseLightingElement.cpp in Sources */,
                                B22279D60D00BF220071B782 /* SVGFEDisplacementMapElement.cpp in Sources */,
                                B22279D90D00BF220071B782 /* SVGFEDistantLightElement.cpp in Sources */,
diff --git a/Source/WebCore/bindings/js/CallbackFunction.cpp b/Source/WebCore/bindings/js/CallbackFunction.cpp
deleted file mode 100644 (file)
index 3ad8e27..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2011 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 "CallbackFunction.h"
-
-#include "ExceptionCode.h"
-#include "JSDOMBinding.h"
-#include <runtime/CallData.h>
-
-namespace WebCore {
-
-bool checkFunctionOnlyCallback(JSC::ExecState* state, JSC::JSValue value, CallbackAllowedValueFlags acceptedValues)
-{
-    if (value.isUndefined() && (acceptedValues & CallbackAllowUndefined))
-        return false;
-
-    if (value.isNull() && (acceptedValues & CallbackAllowNull))
-        return false;
-
-    JSC::CallData callData;
-    if (getCallData(value, callData) == JSC::CallType::None) {
-        auto scope = DECLARE_THROW_SCOPE(state->vm());
-        throwTypeMismatchError(*state, scope);
-        return false;
-    }
-
-    return true;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/bindings/js/CallbackFunction.h b/Source/WebCore/bindings/js/CallbackFunction.h
deleted file mode 100644 (file)
index 9728997..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-
-#pragma once
-
-#include <runtime/JSObject.h>
-
-namespace JSC {
-class ExecState;
-}
-
-namespace WebCore {
-
-class JSDOMGlobalObject;
-
-enum CallbackAllowedValueFlag {
-    CallbackAllowUndefined = 1,
-    CallbackAllowNull = 1 << 1
-};
-
-typedef unsigned CallbackAllowedValueFlags;
-
-bool checkFunctionOnlyCallback(JSC::ExecState*, JSC::JSValue, CallbackAllowedValueFlags);
-
-// Creates callback objects for callbacks marked as FunctionOnly in WebIDL.
-template <typename JSCallbackType>
-RefPtr<JSCallbackType> createFunctionOnlyCallback(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, JSC::JSValue value, CallbackAllowedValueFlags acceptedValues = 0)
-{
-    if (checkFunctionOnlyCallback(exec, value, acceptedValues))
-        return JSCallbackType::create(asObject(value), globalObject);
-    return nullptr;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/bindings/js/DOMConstructorWithDocument.h b/Source/WebCore/bindings/js/DOMConstructorWithDocument.h
deleted file mode 100644 (file)
index d2adfac..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- *  Copyright (C) 2009 Google, Inc. All rights reserved.
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this library; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#pragma once
-
-#include "Document.h"
-#include "JSDOMBinding.h"
-
-namespace WebCore {
-
-// Constructors using this base class depend on being in a Document and
-// can never be used from a WorkerGlobalScope.
-class DOMConstructorWithDocument : public DOMConstructorObject {
-    typedef DOMConstructorObject Base;
-public:
-    Document* document() const
-    {
-        return downcast<Document>(scriptExecutionContext());
-    }
-
-protected:
-    DOMConstructorWithDocument(JSC::Structure* structure, JSDOMGlobalObject& globalObject)
-        : DOMConstructorObject(structure, globalObject)
-    {
-    }
-
-    void finishCreation(JSDOMGlobalObject& globalObject)
-    {
-        Base::finishCreation(globalObject.vm());
-        ASSERT(globalObject.scriptExecutionContext()->isDocument());
-    }
-};
-
-} // namespace WebCore
index 5e5b334..9e7c40e 100644 (file)
@@ -26,7 +26,6 @@
 // This all-in-one cpp file cuts down on template bloat to allow us to build our Windows release build.
 
 #include "CachedModuleScriptLoader.cpp"
-#include "CallbackFunction.cpp"
 #include "DOMWrapperWorld.cpp"
 #include "GCController.cpp"
 #include "JSAnimationTimelineCustom.cpp"
@@ -46,6 +45,9 @@
 #include "JSSQLStatementErrorCallbackCustom.cpp"
 #include "JSCustomXPathNSResolver.cpp"
 #include "JSDOMBinding.cpp"
+#include "JSDOMBindingSecurity.cpp"
+#include "JSDOMConstructor.cpp"
+#include "JSDOMExceptionHandling.cpp"
 #include "JSDOMGlobalObject.cpp"
 #include "JSDOMGlobalObjectTask.cpp"
 #include "JSDOMPromise.cpp"
@@ -55,6 +57,7 @@
 #include "JSDOMWindowProperties.cpp"
 #include "JSDOMWindowShell.cpp"
 #include "JSDOMWrapper.cpp"
+#include "JSDOMWrapperCache.cpp"
 #include "JSDocumentCustom.cpp"
 #include "JSDocumentFragmentCustom.cpp"
 #include "JSElementCustom.cpp"
index b6f419a..4b1e971 100644 (file)
@@ -26,8 +26,8 @@
 #include "config.h"
 #include "JSCrypto.h"
 
-#include "ExceptionCode.h"
 #include "JSDOMBinding.h"
+#include "JSDOMExceptionHandling.h"
 #include <runtime/ArrayBufferView.h>
 #include <runtime/Error.h>
 #include <runtime/JSArrayBufferView.h>
index 21d0bc3..2f14dff 100644 (file)
@@ -28,8 +28,8 @@
 
 #include "CommonVM.h"
 #include "Document.h"
-#include "ExceptionCode.h"
 #include "Frame.h"
+#include "JSDOMExceptionHandling.h"
 #include "JSDOMWindowCustom.h"
 #include "JSMainThreadExecState.h"
 #include "Page.h"
index be51846..12a2b95 100644 (file)
 
 #include "CachedScript.h"
 #include "CommonVM.h"
-#include "DOMConstructorWithDocument.h"
-#include "ExceptionCode.h"
-#include "ExceptionCodeDescription.h"
-#include "ExceptionHeaders.h"
-#include "ExceptionInterfaces.h"
 #include "Frame.h"
 #include "HTMLParserIdioms.h"
-#include "IDBDatabaseException.h"
 #include "JSDOMConvert.h"
-#include "JSDOMPromise.h"
-#include "JSDOMWindowCustom.h"
-#include "JSExceptionBase.h"
-#include "SecurityOrigin.h"
-#include <bytecode/CodeBlock.h>
-#include <inspector/ScriptCallStack.h>
-#include <inspector/ScriptCallStackFactory.h>
 #include <runtime/DateInstance.h>
-#include <runtime/Error.h>
-#include <runtime/ErrorHandlingScope.h>
-#include <runtime/ErrorInstance.h>
-#include <runtime/Exception.h>
-#include <runtime/ExceptionHelpers.h>
-#include <runtime/JSFunction.h>
 #include <stdarg.h>
 #include <wtf/MathExtras.h>
-#include <wtf/unicode/CharacterNames.h>
 #include <wtf/text/StringBuilder.h>
+#include <wtf/unicode/CharacterNames.h>
 
 using namespace JSC;
-using namespace Inspector;
 
 namespace WebCore {
 
-STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(DOMConstructorObject);
-STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(DOMConstructorWithDocument);
-
 void addImpureProperty(const AtomicString& propertyName)
 {
     commonVM().addImpureProperty(propertyName);
@@ -184,170 +161,6 @@ double valueToDate(ExecState* exec, JSValue value)
     return static_cast<DateInstance*>(value.toObject(exec))->internalNumber();
 }
 
-void reportException(ExecState* exec, JSValue exceptionValue, CachedScript* cachedScript)
-{
-    VM& vm = exec->vm();
-    RELEASE_ASSERT(vm.currentThreadIsHoldingAPILock());
-    auto* exception = jsDynamicDowncast<JSC::Exception*>(vm, exceptionValue);
-    if (!exception) {
-        exception = vm.lastException();
-        if (!exception)
-            exception = JSC::Exception::create(exec->vm(), exceptionValue, JSC::Exception::DoNotCaptureStack);
-    }
-
-    reportException(exec, exception, cachedScript);
-}
-
-String retrieveErrorMessage(ExecState& state, VM& vm, JSValue exception, CatchScope& catchScope)
-{
-    if (auto* exceptionBase = toExceptionBase(vm, exception))
-        return exceptionBase->toString();
-
-    // FIXME: <http://webkit.org/b/115087> Web Inspector: WebCore::reportException should not evaluate JavaScript handling exceptions
-    // If this is a custom exception object, call toString on it to try and get a nice string representation for the exception.
-    String errorMessage;
-    if (auto* error = jsDynamicDowncast<ErrorInstance*>(vm, exception))
-        errorMessage = error->sanitizedToString(&state);
-    else
-        errorMessage = exception.toWTFString(&state);
-
-    // We need to clear any new exception that may be thrown in the toString() call above.
-    // reportException() is not supposed to be making new exceptions.
-    catchScope.clearException();
-    vm.clearLastException();
-    return errorMessage;
-}
-
-void reportException(ExecState* exec, JSC::Exception* exception, CachedScript* cachedScript, ExceptionDetails* exceptionDetails)
-{
-    VM& vm = exec->vm();
-    auto scope = DECLARE_CATCH_SCOPE(vm);
-
-    RELEASE_ASSERT(vm.currentThreadIsHoldingAPILock());
-    if (isTerminatedExecutionException(vm, exception))
-        return;
-
-    ErrorHandlingScope errorScope(exec->vm());
-
-    RefPtr<ScriptCallStack> callStack(createScriptCallStackFromException(exec, exception, ScriptCallStack::maxCallStackSizeToCapture));
-    scope.clearException();
-    vm.clearLastException();
-
-    JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject());
-    if (JSDOMWindow* window = jsDynamicDowncast<JSDOMWindow*>(vm, globalObject)) {
-        if (!window->wrapped().isCurrentlyDisplayedInFrame())
-            return;
-    }
-
-    int lineNumber = 0;
-    int columnNumber = 0;
-    String exceptionSourceURL;
-    if (const ScriptCallFrame* callFrame = callStack->firstNonNativeCallFrame()) {
-        lineNumber = callFrame->lineNumber();
-        columnNumber = callFrame->columnNumber();
-        exceptionSourceURL = callFrame->sourceURL();
-    }
-
-    String errorMessage = retrieveErrorMessage(*exec, vm, exception->value(), scope);
-    ScriptExecutionContext* scriptExecutionContext = globalObject->scriptExecutionContext();
-    scriptExecutionContext->reportException(errorMessage, lineNumber, columnNumber, exceptionSourceURL, exception, callStack->size() ? callStack : nullptr, cachedScript);
-
-    if (exceptionDetails) {
-        exceptionDetails->message = errorMessage;
-        exceptionDetails->lineNumber = lineNumber;
-        exceptionDetails->columnNumber = columnNumber;
-        exceptionDetails->sourceURL = exceptionSourceURL;
-    }
-}
-
-void reportCurrentException(ExecState* exec)
-{
-    VM& vm = exec->vm();
-    auto scope = DECLARE_CATCH_SCOPE(vm);
-    auto* exception = scope.exception();
-    scope.clearException();
-    reportException(exec, exception);
-}
-
-static JSValue createDOMException(ExecState* exec, ExceptionCode ec, const String* message = nullptr)
-{
-    if (!ec || ec == ExistingExceptionError)
-        return jsUndefined();
-
-    // FIXME: Handle other WebIDL exception types.
-    if (ec == TypeError) {
-        if (!message || message->isEmpty())
-            return createTypeError(exec);
-        return createTypeError(exec, *message);
-    }
-
-    if (ec == RangeError) {
-        if (!message || message->isEmpty())
-            return createRangeError(exec, ASCIILiteral("Bad value"));
-        return createRangeError(exec, *message);
-    }
-
-    if (ec == StackOverflowError)
-        return createStackOverflowError(exec);
-
-    // FIXME: All callers to createDOMException need to pass in the correct global object.
-    // For now, we're going to assume the lexicalGlobalObject. Which is wrong in cases like this:
-    // frames[0].document.createElement(null, null); // throws an exception which should have the subframe's prototypes.
-    JSDOMGlobalObject* globalObject = deprecatedGlobalObjectForPrototype(exec);
-
-    ExceptionCodeDescription description(ec);
-
-    CString messageCString;
-    if (message)
-        messageCString = message->utf8();
-    if (message && !message->isEmpty()) {
-        // It is safe to do this because the char* contents of the CString are copied into a new WTF::String before the CString is destroyed.
-        description.description = messageCString.data();
-    }
-
-    JSValue errorObject;
-    switch (description.type) {
-    case DOMCoreExceptionType:
-#if ENABLE(INDEXED_DATABASE)
-    case IDBDatabaseExceptionType:
-#endif
-        errorObject = toJS(exec, globalObject, DOMCoreException::create(description));
-        break;
-    case FileExceptionType:
-        errorObject = toJS(exec, globalObject, FileException::create(description));
-        break;
-    case SQLExceptionType:
-        errorObject = toJS(exec, globalObject, SQLException::create(description));
-        break;
-    case SVGExceptionType:
-        errorObject = toJS(exec, globalObject, SVGException::create(description));
-        break;
-    case XPathExceptionType:
-        errorObject = toJS(exec, globalObject, XPathException::create(description));
-        break;
-    }
-    
-    ASSERT(errorObject);
-    addErrorInfo(exec, asObject(errorObject), true);
-    return errorObject;
-}
-
-JSValue createDOMException(ExecState* exec, ExceptionCode ec, const String& message)
-{
-    return createDOMException(exec, ec, &message);
-}
-
-JSValue createDOMException(ExecState& state, Exception&& exception)
-{
-    return createDOMException(&state, exception.code(), exception.releaseMessage());
-}
-
-void propagateExceptionSlowPath(JSC::ExecState& state, JSC::ThrowScope& throwScope, Exception&& exception)
-{
-    ASSERT(!throwScope.exception());
-    throwException(&state, throwScope, createDOMException(state, WTFMove(exception)));
-}
-
 bool hasIteratorMethod(JSC::ExecState& state, JSC::JSValue value)
 {
     auto& vm = state.vm();
@@ -365,43 +178,6 @@ bool hasIteratorMethod(JSC::ExecState& state, JSC::JSValue value)
     return !applyMethod.isUndefined();
 }
 
-bool BindingSecurity::shouldAllowAccessToFrame(ExecState& state, Frame& frame, String& message)
-{
-    if (BindingSecurity::shouldAllowAccessToFrame(&state, &frame, DoNotReportSecurityError))
-        return true;
-    message = frame.document()->domWindow()->crossDomainAccessErrorMessage(activeDOMWindow(&state));
-    return false;
-}
-
-bool BindingSecurity::shouldAllowAccessToDOMWindow(ExecState& state, DOMWindow& globalObject, String& message)
-{
-    if (BindingSecurity::shouldAllowAccessToDOMWindow(&state, globalObject, DoNotReportSecurityError))
-        return true;
-    message = globalObject.crossDomainAccessErrorMessage(activeDOMWindow(&state));
-    return false;
-}
-
-void printErrorMessageForFrame(Frame* frame, const String& message)
-{
-    if (!frame)
-        return;
-    frame->document()->domWindow()->printErrorMessage(message);
-}
-
-Structure* getCachedDOMStructure(JSDOMGlobalObject& globalObject, const ClassInfo* classInfo)
-{
-    JSDOMStructureMap& structures = globalObject.structures(NoLockingNecessary);
-    return structures.get(classInfo).get();
-}
-
-Structure* cacheDOMStructure(JSDOMGlobalObject& globalObject, Structure* structure, const ClassInfo* classInfo)
-{
-    auto locker = lockDuringMarking(globalObject.vm().heap, globalObject.gcLock());
-    JSDOMStructureMap& structures = globalObject.structures(locker);
-    ASSERT(!structures.contains(classInfo));
-    return structures.set(classInfo, WriteBarrier<Structure>(globalObject.vm(), &globalObject, structure)).iterator->value.get();
-}
-
 static const int32_t kMaxInt32 = 0x7fffffff;
 static const int32_t kMinInt32 = -kMaxInt32 - 1;
 static const uint32_t kMaxUInt32 = 0xffffffffU;
@@ -715,320 +491,4 @@ uint64_t toUInt64(ExecState& state, JSValue value)
     return n;
 }
 
-class GetCallerGlobalObjectFunctor {
-public:
-    GetCallerGlobalObjectFunctor() = default;
-
-    StackVisitor::Status operator()(StackVisitor& visitor) const
-    {
-        if (!m_hasSkippedFirstFrame) {
-            m_hasSkippedFirstFrame = true;
-            return StackVisitor::Continue;
-        }
-
-        if (auto* codeBlock = visitor->codeBlock())
-            m_globalObject = codeBlock->globalObject();
-        else {
-            ASSERT(visitor->callee());
-            // FIXME: Callee is not an object if the caller is Web Assembly.
-            // Figure out what to do here. We can probably get the global object
-            // from the top-most Wasm Instance. https://bugs.webkit.org/show_bug.cgi?id=165721
-            if (visitor->callee()->isObject())
-                m_globalObject = jsCast<JSObject*>(visitor->callee())->globalObject();
-        }
-        return StackVisitor::Done;
-    }
-
-    JSGlobalObject* globalObject() const { return m_globalObject; }
-
-private:
-    mutable bool m_hasSkippedFirstFrame { false };
-    mutable JSGlobalObject* m_globalObject { nullptr };
-};
-
-DOMWindow& callerDOMWindow(ExecState* exec)
-{
-    GetCallerGlobalObjectFunctor iter;
-    exec->iterate(iter);
-    return iter.globalObject() ? asJSDOMWindow(iter.globalObject())->wrapped() : firstDOMWindow(exec);
-}
-
-DOMWindow& activeDOMWindow(ExecState* exec)
-{
-    return asJSDOMWindow(exec->lexicalGlobalObject())->wrapped();
-}
-
-DOMWindow& firstDOMWindow(ExecState* exec)
-{
-    return asJSDOMWindow(exec->vmEntryGlobalObject())->wrapped();
-}
-
-static inline bool canAccessDocument(JSC::ExecState* state, Document* targetDocument, SecurityReportingOption reportingOption)
-{
-    VM& vm = state->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    if (!targetDocument)
-        return false;
-
-    DOMWindow& active = activeDOMWindow(state);
-
-    if (active.document()->securityOrigin().canAccess(targetDocument->securityOrigin()))
-        return true;
-
-    switch (reportingOption) {
-    case ThrowSecurityError:
-        throwSecurityError(*state, scope, targetDocument->domWindow()->crossDomainAccessErrorMessage(active));
-        break;
-    case LogSecurityError:
-        printErrorMessageForFrame(targetDocument->frame(), targetDocument->domWindow()->crossDomainAccessErrorMessage(active));
-        break;
-    case DoNotReportSecurityError:
-        break;
-    }
-
-    return false;
-}
-
-bool BindingSecurity::shouldAllowAccessToDOMWindow(JSC::ExecState* state, DOMWindow& target, SecurityReportingOption reportingOption)
-{
-    return canAccessDocument(state, target.document(), reportingOption);
-}
-
-bool BindingSecurity::shouldAllowAccessToFrame(JSC::ExecState* state, Frame* target, SecurityReportingOption reportingOption)
-{
-    return target && canAccessDocument(state, target->document(), reportingOption);
-}
-
-bool BindingSecurity::shouldAllowAccessToNode(JSC::ExecState& state, Node* target)
-{
-    return !target || canAccessDocument(&state, &target->document(), LogSecurityError);
-}
-    
-static EncodedJSValue throwTypeError(JSC::ExecState& state, JSC::ThrowScope& scope, const String& errorMessage)
-{
-    return throwVMTypeError(&state, scope, errorMessage);
-}
-
-static void appendArgumentMustBe(StringBuilder& builder, unsigned argumentIndex, const char* argumentName, const char* interfaceName, const char* functionName)
-{
-    builder.appendLiteral("Argument ");
-    builder.appendNumber(argumentIndex + 1);
-    builder.appendLiteral(" ('");
-    builder.append(argumentName);
-    builder.appendLiteral("') to ");
-    if (!functionName) {
-        builder.appendLiteral("the ");
-        builder.append(interfaceName);
-        builder.appendLiteral(" constructor");
-    } else {
-        builder.append(interfaceName);
-        builder.append('.');
-        builder.append(functionName);
-    }
-    builder.appendLiteral(" must be ");
-}
-
-JSC::EncodedJSValue reportDeprecatedGetterError(JSC::ExecState& state, const char* interfaceName, const char* attributeName)
-{
-    auto& context = *jsCast<JSDOMGlobalObject*>(state.lexicalGlobalObject())->scriptExecutionContext();
-    context.addConsoleMessage(MessageSource::JS, MessageLevel::Error, makeString("Deprecated attempt to access property '", attributeName, "' on a non-", interfaceName, " object."));
-    return JSValue::encode(jsUndefined());
-}
-    
-void reportDeprecatedSetterError(JSC::ExecState& state, const char* interfaceName, const char* attributeName)
-{
-    auto& context = *jsCast<JSDOMGlobalObject*>(state.lexicalGlobalObject())->scriptExecutionContext();
-    context.addConsoleMessage(MessageSource::JS, MessageLevel::Error, makeString("Deprecated attempt to set property '", attributeName, "' on a non-", interfaceName, " object."));
-}
-
-void throwNotSupportedError(JSC::ExecState& state, JSC::ThrowScope& scope)
-{
-    ASSERT(!scope.exception());
-    throwException(&state, scope, createDOMException(&state, NOT_SUPPORTED_ERR));
-}
-
-void throwNotSupportedError(JSC::ExecState& state, JSC::ThrowScope& scope, const char* message)
-{
-    ASSERT(!scope.exception());
-    String messageString(message);
-    throwException(&state, scope, createDOMException(&state, NOT_SUPPORTED_ERR, &messageString));
-}
-
-void throwInvalidStateError(JSC::ExecState& state, JSC::ThrowScope& scope, const char* message)
-{
-    ASSERT(!scope.exception());
-    String messageString(message);
-    throwException(&state, scope, createDOMException(&state, INVALID_STATE_ERR, &messageString));
-}
-
-void throwSecurityError(JSC::ExecState& state, JSC::ThrowScope& scope, const String& message)
-{
-    ASSERT(!scope.exception());
-    throwException(&state, scope, createDOMException(&state, SECURITY_ERR, message));
-}
-
-JSC::EncodedJSValue throwArgumentMustBeEnumError(JSC::ExecState& state, JSC::ThrowScope& scope, unsigned argumentIndex, const char* argumentName, const char* functionInterfaceName, const char* functionName, const char* expectedValues)
-{
-    StringBuilder builder;
-    appendArgumentMustBe(builder, argumentIndex, argumentName, functionInterfaceName, functionName);
-    builder.appendLiteral("one of: ");
-    builder.append(expectedValues);
-    return throwVMTypeError(&state, scope, builder.toString());
-}
-
-JSC::EncodedJSValue throwArgumentMustBeFunctionError(JSC::ExecState& state, JSC::ThrowScope& scope, unsigned argumentIndex, const char* argumentName, const char* interfaceName, const char* functionName)
-{
-    StringBuilder builder;
-    appendArgumentMustBe(builder, argumentIndex, argumentName, interfaceName, functionName);
-    builder.appendLiteral("a function");
-    return throwVMTypeError(&state, scope, builder.toString());
-}
-
-JSC::EncodedJSValue throwArgumentTypeError(JSC::ExecState& state, JSC::ThrowScope& scope, unsigned argumentIndex, const char* argumentName, const char* functionInterfaceName, const char* functionName, const char* expectedType)
-{
-    StringBuilder builder;
-    appendArgumentMustBe(builder, argumentIndex, argumentName, functionInterfaceName, functionName);
-    builder.appendLiteral("an instance of ");
-    builder.append(expectedType);
-    return throwVMTypeError(&state, scope, builder.toString());
-}
-
-void throwArrayElementTypeError(JSC::ExecState& state, JSC::ThrowScope& scope)
-{
-    throwTypeError(state, scope, ASCIILiteral("Invalid Array element type"));
-}
-
-void throwAttributeTypeError(JSC::ExecState& state, JSC::ThrowScope& scope, const char* interfaceName, const char* attributeName, const char* expectedType)
-{
-    throwTypeError(state, scope, makeString("The ", interfaceName, '.', attributeName, " attribute must be an instance of ", expectedType));
-}
-
-JSC::EncodedJSValue throwRequiredMemberTypeError(JSC::ExecState& state, JSC::ThrowScope& scope, const char* memberName, const char* dictionaryName, const char* expectedType)
-{
-    StringBuilder builder;
-    builder.appendLiteral("Member ");
-    builder.append(dictionaryName);
-    builder.append('.');
-    builder.append(memberName);
-    builder.appendLiteral(" is required and must be an instance of ");
-    builder.append(expectedType);
-    return throwVMTypeError(&state, scope, builder.toString());
-}
-
-JSC::EncodedJSValue throwConstructorScriptExecutionContextUnavailableError(JSC::ExecState& state, JSC::ThrowScope& scope, const char* interfaceName)
-{
-    return throwVMError(&state, scope, createReferenceError(&state, makeString(interfaceName, " constructor associated execution context is unavailable")));
-}
-
-void throwSequenceTypeError(JSC::ExecState& state, JSC::ThrowScope& scope)
-{
-    throwTypeError(state, scope, ASCIILiteral("Value is not a sequence"));
-}
-
-void throwNonFiniteTypeError(ExecState& state, JSC::ThrowScope& scope)
-{
-    throwTypeError(&state, scope, ASCIILiteral("The provided value is non-finite"));
-}
-
-String makeGetterTypeErrorMessage(const char* interfaceName, const char* attributeName)
-{
-    return makeString("The ", interfaceName, '.', attributeName, " getter can only be used on instances of ", interfaceName);
-}
-
-JSC::EncodedJSValue throwGetterTypeError(JSC::ExecState& state, JSC::ThrowScope& scope, const char* interfaceName, const char* attributeName)
-{
-    return throwVMTypeError(&state, scope, makeGetterTypeErrorMessage(interfaceName, attributeName));
-}
-
-JSC::EncodedJSValue rejectPromiseWithGetterTypeError(JSC::ExecState& state, const char* interfaceName, const char* attributeName)
-{
-    return createRejectedPromiseWithTypeError(state, makeGetterTypeErrorMessage(interfaceName, attributeName));
-}
-
-bool throwSetterTypeError(JSC::ExecState& state, JSC::ThrowScope& scope, const char* interfaceName, const char* attributeName)
-{
-    throwTypeError(state, scope, makeString("The ", interfaceName, '.', attributeName, " setter can only be used on instances of ", interfaceName));
-    return false;
-}
-
-String makeThisTypeErrorMessage(const char* interfaceName, const char* functionName)
-{
-    return makeString("Can only call ", interfaceName, '.', functionName, " on instances of ", interfaceName);
-}
-
-EncodedJSValue throwThisTypeError(JSC::ExecState& state, JSC::ThrowScope& scope, const char* interfaceName, const char* functionName)
-{
-    return throwTypeError(state, scope, makeThisTypeErrorMessage(interfaceName, functionName));
-}
-
-JSC::EncodedJSValue rejectPromiseWithThisTypeError(DeferredPromise& promise, const char* interfaceName, const char* methodName)
-{
-    promise.reject(TypeError, makeThisTypeErrorMessage(interfaceName, methodName));
-    return JSValue::encode(jsUndefined());
-}
-
-JSC::EncodedJSValue rejectPromiseWithThisTypeError(JSC::ExecState& state, const char* interfaceName, const char* methodName)
-{
-    return createRejectedPromiseWithTypeError(state, makeThisTypeErrorMessage(interfaceName, methodName));
-}
-
-void callFunctionWithCurrentArguments(JSC::ExecState& state, JSC::JSObject& thisObject, JSC::JSFunction& function)
-{
-    JSC::CallData callData;
-    JSC::CallType callType = JSC::getCallData(&function, callData);
-    ASSERT(callType != CallType::None);
-
-    JSC::MarkedArgumentBuffer arguments;
-    for (unsigned i = 0; i < state.argumentCount(); ++i)
-        arguments.append(state.uncheckedArgument(i));
-    JSC::call(&state, &function, callType, callData, &thisObject, arguments);
-}
-
-void DOMConstructorJSBuiltinObject::visitChildren(JSC::JSCell* cell, JSC::SlotVisitor& visitor)
-{
-    auto* thisObject = jsCast<DOMConstructorJSBuiltinObject*>(cell);
-    ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-    Base::visitChildren(thisObject, visitor);
-    visitor.append(thisObject->m_initializeFunction);
-}
-
-static EncodedJSValue JSC_HOST_CALL callThrowTypeError(ExecState* exec)
-{
-    VM& vm = exec->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-    throwTypeError(exec, scope, ASCIILiteral("Constructor requires 'new' operator"));
-    return JSValue::encode(jsNull());
-}
-
-CallType DOMConstructorObject::getCallData(JSCell*, CallData& callData)
-{
-    callData.native.function = callThrowTypeError;
-    return CallType::Host;
-}
-
-void throwDOMSyntaxError(JSC::ExecState& state, JSC::ThrowScope& scope)
-{
-    ASSERT(!scope.exception());
-    throwException(&state, scope, createDOMException(&state, SYNTAX_ERR));
-}
-
-void throwDataCloneError(JSC::ExecState& state, JSC::ThrowScope& scope)
-{
-    ASSERT(!scope.exception());
-    throwException(&state, scope, createDOMException(&state, DATA_CLONE_ERR));
-}
-
-void throwIndexSizeError(JSC::ExecState& state, JSC::ThrowScope& scope)
-{
-    ASSERT(!scope.exception());
-    throwException(&state, scope, createDOMException(&state, INDEX_SIZE_ERR));
-}
-
-void throwTypeMismatchError(JSC::ExecState& state, JSC::ThrowScope& scope)
-{
-    ASSERT(!scope.exception());
-    throwException(&state, scope, createDOMException(&state, TYPE_MISMATCH_ERR));
-}
-
 } // namespace WebCore
index 813d14f..6d5d520 100644 (file)
 
 #pragma once
 
-#include "DOMWrapperWorld.h"
-#include "ExceptionCode.h"
 #include "ExceptionOr.h"
-#include "JSDOMGlobalObject.h"
-#include "JSDOMWrapper.h"
-#include "JSDynamicDowncast.h"
-#include "ScriptWrappable.h"
-#include "ScriptWrappableInlines.h"
-#include "WebCoreTypedArrayController.h"
+#include "JSDOMWrapperCache.h"
 #include <cstddef>
 #include <heap/HeapInlines.h>
 #include <heap/SlotVisitorInlines.h>
-#include <heap/Weak.h>
-#include <heap/WeakInlines.h>
 #include <runtime/AuxiliaryBarrierInlines.h>
-#include <runtime/Error.h>
 #include <runtime/IteratorOperations.h>
 #include <runtime/JSArray.h>
-#include <runtime/JSArrayBuffer.h>
 #include <runtime/JSCJSValueInlines.h>
 #include <runtime/JSCellInlines.h>
 #include <runtime/JSObjectInlines.h>
@@ -49,8 +38,6 @@
 #include <runtime/Lookup.h>
 #include <runtime/ObjectConstructor.h>
 #include <runtime/StructureInlines.h>
-#include <runtime/TypedArrayInlines.h>
-#include <runtime/TypedArrays.h>
 #include <runtime/WriteBarrier.h>
 #include <wtf/Forward.h>
 #include <wtf/GetPtr.h>
@@ -66,140 +53,10 @@ class JSFunction;
 
 namespace WebCore {
 
-class CachedScript;
-class DeferredPromise;
-class DOMWindow;
-class Frame;
 class URL;
-class Node;
-
-struct ExceptionDetails {
-    String message;
-    int lineNumber { 0 };
-    int columnNumber { 0 };
-    String sourceURL;
-};
-
-// Base class for all constructor objects in the JSC bindings.
-class DOMConstructorObject : public JSDOMObject {
-public:
-    typedef JSDOMObject Base;
-    static const unsigned StructureFlags = Base::StructureFlags | JSC::ImplementsHasInstance | JSC::ImplementsDefaultHasInstance | JSC::TypeOfShouldCallGetCallData;
-    static JSC::Structure* createStructure(JSC::VM&, JSC::JSGlobalObject*, JSC::JSValue);
-
-protected:
-    DOMConstructorObject(JSC::Structure*, JSDOMGlobalObject&);
-
-    static String className(const JSObject*);
-    static JSC::CallType getCallData(JSCell*, JSC::CallData&);
-};
-
-class DOMConstructorJSBuiltinObject : public DOMConstructorObject {
-public:
-    typedef DOMConstructorObject Base;
-
-protected:
-    DOMConstructorJSBuiltinObject(JSC::Structure*, JSDOMGlobalObject&);
-    static void visitChildren(JSC::JSCell*, JSC::SlotVisitor&);
-
-    JSC::JSFunction* initializeFunction();
-    void setInitializeFunction(JSC::VM&, JSC::JSFunction&);
-
-private:
-    JSC::WriteBarrier<JSC::JSFunction> m_initializeFunction;
-};
-
-DOMWindow& callerDOMWindow(JSC::ExecState*);
-DOMWindow& activeDOMWindow(JSC::ExecState*);
-DOMWindow& firstDOMWindow(JSC::ExecState*);
-
-WEBCORE_EXPORT JSC::EncodedJSValue reportDeprecatedGetterError(JSC::ExecState&, const char* interfaceName, const char* attributeName);
-WEBCORE_EXPORT void reportDeprecatedSetterError(JSC::ExecState&, const char* interfaceName, const char* attributeName);
-
-void throwAttributeTypeError(JSC::ExecState&, JSC::ThrowScope&, const char* interfaceName, const char* attributeName, const char* expectedType);
-WEBCORE_EXPORT bool throwSetterTypeError(JSC::ExecState&, JSC::ThrowScope&, const char* interfaceName, const char* attributeName);
-
-void throwArrayElementTypeError(JSC::ExecState&, JSC::ThrowScope&);
-void throwDataCloneError(JSC::ExecState&, JSC::ThrowScope&);
-void throwDOMSyntaxError(JSC::ExecState&, JSC::ThrowScope&); // Not the same as a JavaScript syntax error.
-void throwIndexSizeError(JSC::ExecState&, JSC::ThrowScope&);
-void throwInvalidStateError(JSC::ExecState&, JSC::ThrowScope&, const char* message);
-WEBCORE_EXPORT void throwNonFiniteTypeError(JSC::ExecState&, JSC::ThrowScope&);
-void throwNotSupportedError(JSC::ExecState&, JSC::ThrowScope&);
-void throwNotSupportedError(JSC::ExecState&, JSC::ThrowScope&, const char* message);
-void throwSecurityError(JSC::ExecState&, JSC::ThrowScope&, const String& message);
-WEBCORE_EXPORT void throwSequenceTypeError(JSC::ExecState&, JSC::ThrowScope&);
-void throwTypeMismatchError(JSC::ExecState&, JSC::ThrowScope&);
-
-WEBCORE_EXPORT JSC::EncodedJSValue throwArgumentMustBeEnumError(JSC::ExecState&, JSC::ThrowScope&, unsigned argumentIndex, const char* argumentName, const char* functionInterfaceName, const char* functionName, const char* expectedValues);
-JSC::EncodedJSValue throwArgumentMustBeFunctionError(JSC::ExecState&, JSC::ThrowScope&, unsigned argumentIndex, const char* argumentName, const char* functionInterfaceName, const char* functionName);
-WEBCORE_EXPORT JSC::EncodedJSValue throwArgumentTypeError(JSC::ExecState&, JSC::ThrowScope&, unsigned argumentIndex, const char* argumentName, const char* functionInterfaceName, const char* functionName, const char* expectedType);
-WEBCORE_EXPORT JSC::EncodedJSValue throwRequiredMemberTypeError(JSC::ExecState&, JSC::ThrowScope&, const char* memberName, const char* dictionaryName, const char* expectedType);
-JSC::EncodedJSValue throwConstructorScriptExecutionContextUnavailableError(JSC::ExecState&, JSC::ThrowScope&, const char* interfaceName);
-
-String makeGetterTypeErrorMessage(const char* interfaceName, const char* attributeName);
-String makeThisTypeErrorMessage(const char* interfaceName, const char* attributeName);
-
-WEBCORE_EXPORT JSC::EncodedJSValue throwGetterTypeError(JSC::ExecState&, JSC::ThrowScope&, const char* interfaceName, const char* attributeName);
-WEBCORE_EXPORT JSC::EncodedJSValue throwThisTypeError(JSC::ExecState&, JSC::ThrowScope&, const char* interfaceName, const char* functionName);
-
-WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithGetterTypeError(JSC::ExecState&, const char* interfaceName, const char* attributeName);
-WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithThisTypeError(DeferredPromise&, const char* interfaceName, const char* operationName);
-WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithThisTypeError(JSC::ExecState&, const char* interfaceName, const char* operationName);
-
-WEBCORE_EXPORT JSC::Structure* getCachedDOMStructure(JSDOMGlobalObject&, const JSC::ClassInfo*);
-WEBCORE_EXPORT JSC::Structure* cacheDOMStructure(JSDOMGlobalObject&, JSC::Structure*, const JSC::ClassInfo*);
-
-template<typename WrapperClass> JSC::Structure* getDOMStructure(JSC::VM&, JSDOMGlobalObject&);
-template<typename WrapperClass> JSC::Structure* deprecatedGetDOMStructure(JSC::ExecState*);
-template<typename WrapperClass> JSC::JSObject* getDOMPrototype(JSC::VM&, JSC::JSGlobalObject*);
-
-void callFunctionWithCurrentArguments(JSC::ExecState&, JSC::JSObject& thisObject, JSC::JSFunction&);
-
-template<typename JSClass> JSC::EncodedJSValue createJSBuiltin(JSC::ExecState&, JSC::JSFunction& initializeFunction, JSDOMGlobalObject&);
-
-JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld&, JSC::ArrayBuffer*);
-void* wrapperKey(JSC::ArrayBuffer*);
-
-JSDOMObject* getInlineCachedWrapper(DOMWrapperWorld&, void*);
-JSDOMObject* getInlineCachedWrapper(DOMWrapperWorld&, ScriptWrappable*);
-JSC::JSArrayBuffer* getInlineCachedWrapper(DOMWrapperWorld&, JSC::ArrayBuffer*);
-
-bool setInlineCachedWrapper(DOMWrapperWorld&, void*, JSDOMObject*, JSC::WeakHandleOwner*);
-bool setInlineCachedWrapper(DOMWrapperWorld&, ScriptWrappable*, JSDOMObject* wrapper, JSC::WeakHandleOwner* wrapperOwner);
-bool setInlineCachedWrapper(DOMWrapperWorld&, JSC::ArrayBuffer*, JSC::JSArrayBuffer* wrapper, JSC::WeakHandleOwner* wrapperOwner);
-
-bool clearInlineCachedWrapper(DOMWrapperWorld&, void*, JSDOMObject*);
-bool clearInlineCachedWrapper(DOMWrapperWorld&, ScriptWrappable*, JSDOMObject* wrapper);
-bool clearInlineCachedWrapper(DOMWrapperWorld&, JSC::ArrayBuffer*, JSC::JSArrayBuffer* wrapper);
-
-template<typename DOMClass> JSC::JSObject* getCachedWrapper(DOMWrapperWorld&, DOMClass&);
-template<typename DOMClass> inline JSC::JSObject* getCachedWrapper(DOMWrapperWorld& world, Ref<DOMClass>& object) { return getCachedWrapper(world, object.get()); }
-template<typename DOMClass, typename WrapperClass> void cacheWrapper(DOMWrapperWorld&, DOMClass*, WrapperClass*);
-template<typename DOMClass, typename WrapperClass> void uncacheWrapper(DOMWrapperWorld&, DOMClass*, WrapperClass*);
-template<typename DOMClass, typename T> auto createWrapper(JSDOMGlobalObject*, Ref<T>&&) -> typename std::enable_if<std::is_same<DOMClass, T>::value, typename JSDOMWrapperConverterTraits<DOMClass>::WrapperClass*>::type;
-template<typename DOMClass, typename T> auto createWrapper(JSDOMGlobalObject*, Ref<T>&&) -> typename std::enable_if<!std::is_same<DOMClass, T>::value, typename JSDOMWrapperConverterTraits<DOMClass>::WrapperClass*>::type;
-
-template<typename DOMClass> JSC::JSValue wrap(JSC::ExecState*, JSDOMGlobalObject*, DOMClass&);
-
-template<typename JSClass> JSClass& castThisValue(JSC::ExecState&);
 
 void addImpureProperty(const AtomicString&);
 
-const JSC::HashTable& getHashTableForGlobalData(JSC::VM&, const JSC::HashTable& staticTable);
-
-String retrieveErrorMessage(JSC::ExecState&, JSC::VM&, JSC::JSValue exception, JSC::CatchScope&);
-WEBCORE_EXPORT void reportException(JSC::ExecState*, JSC::JSValue exception, CachedScript* = nullptr);
-WEBCORE_EXPORT void reportException(JSC::ExecState*, JSC::Exception*, CachedScript* = nullptr, ExceptionDetails* = nullptr);
-void reportCurrentException(JSC::ExecState*);
-
-JSC::JSValue createDOMException(JSC::ExecState&, Exception&&);
-JSC::JSValue createDOMException(JSC::ExecState*, ExceptionCode, const String&);
-
-// Convert a DOM implementation exception into a JavaScript exception in the execution state.
-void propagateException(JSC::ExecState&, JSC::ThrowScope&, Exception&&);
-WEBCORE_EXPORT void propagateExceptionSlowPath(JSC::ExecState&, JSC::ThrowScope&, Exception&&);
-
 JSC::JSValue jsString(JSC::ExecState*, const URL&); // empty if the URL is null
 
 JSC::JSValue jsStringOrUndefined(JSC::ExecState*, const String&); // undefined if the string is null
@@ -210,7 +67,6 @@ JSC::JSValue jsStringOrUndefined(JSC::ExecState*, const URL&); // undefined if t
 JSC::JSValue jsOwnedStringOrNull(JSC::ExecState*, const String&);
 
 String propertyNameToString(JSC::PropertyName);
-
 AtomicString propertyNameToAtomicString(JSC::PropertyName);
 
 WEBCORE_EXPORT String identifierToByteString(JSC::ExecState&, const JSC::Identifier&);
@@ -254,9 +110,6 @@ JSC::JSValue jsDate(JSC::ExecState*, double value);
 // NaN if the value can't be converted to a date.
 double valueToDate(JSC::ExecState*, JSC::JSValue);
 
-// Validates that the passed object is a sequence type per section 4.1.13 of the WebIDL spec.
-JSC::JSObject* toJSSequence(JSC::ExecState&, JSC::JSValue, unsigned& length);
-
 JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, JSC::ArrayBuffer&);
 JSC::JSValue toJS(JSC::ExecState*, JSC::JSGlobalObject*, JSC::ArrayBufferView&);
 JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, JSC::ArrayBuffer*);
@@ -267,10 +120,6 @@ template<typename T> JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, cons
 template<typename T> JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, const Vector<RefPtr<T>>&);
 JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, const JSC::PrivateName&);
 
-JSC::JSValue toJSIterator(JSC::ExecState&, JSDOMGlobalObject&, JSC::JSValue);
-template<typename T> JSC::JSValue toJSIterator(JSC::ExecState&, JSDOMGlobalObject&, const T&);
-JSC::JSValue toJSIteratorEnd(JSC::ExecState&);
-
 RefPtr<JSC::ArrayBufferView> toPossiblySharedArrayBufferView(JSC::VM&, JSC::JSValue);
 RefPtr<JSC::Int8Array> toPossiblySharedInt8Array(JSC::VM&, JSC::JSValue);
 RefPtr<JSC::Int16Array> toPossiblySharedInt16Array(JSC::VM&, JSC::JSValue);
@@ -293,285 +142,16 @@ RefPtr<JSC::Uint32Array> toUnsharedUint32Array(JSC::VM&, JSC::JSValue);
 RefPtr<JSC::Float32Array> toUnsharedFloat32Array(JSC::VM&, JSC::JSValue);
 RefPtr<JSC::Float64Array> toUnsharedFloat64Array(JSC::VM&, JSC::JSValue);
 
-template<typename T, typename JSType> Vector<Ref<T>> toRefNativeArray(JSC::ExecState&, JSC::JSValue);
-WEBCORE_EXPORT bool hasIteratorMethod(JSC::ExecState&, JSC::JSValue);
-
-enum SecurityReportingOption { DoNotReportSecurityError, LogSecurityError, ThrowSecurityError };
-namespace BindingSecurity {
-    template<typename T> T* checkSecurityForNode(JSC::ExecState&, T&);
-    template<typename T> T* checkSecurityForNode(JSC::ExecState&, T*);
-    template<typename T> ExceptionOr<T*> checkSecurityForNode(JSC::ExecState&, ExceptionOr<T*>&&);
-    template<typename T> ExceptionOr<T*> checkSecurityForNode(JSC::ExecState&, ExceptionOr<T&>&&);
-    bool shouldAllowAccessToDOMWindow(JSC::ExecState*, DOMWindow&, SecurityReportingOption = LogSecurityError);
-    bool shouldAllowAccessToDOMWindow(JSC::ExecState&, DOMWindow&, String& message);
-    bool shouldAllowAccessToFrame(JSC::ExecState*, Frame*, SecurityReportingOption = LogSecurityError);
-    bool shouldAllowAccessToFrame(JSC::ExecState&, Frame&, String& message);
-    bool shouldAllowAccessToNode(JSC::ExecState&, Node*);
-};
-
-void printErrorMessageForFrame(Frame*, const String& message);
-
 String propertyNameToString(JSC::PropertyName);
 AtomicString propertyNameToAtomicString(JSC::PropertyName);
 
-template<JSC::NativeFunction, int length> JSC::EncodedJSValue nonCachingStaticFunctionGetter(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
-
-
-enum class CastedThisErrorBehavior { Throw, ReturnEarly, RejectPromise, Assert };
-
-template<typename JSClass>
-struct BindingCaller {
-    using AttributeSetterFunction = bool(JSC::ExecState&, JSClass&, JSC::JSValue, JSC::ThrowScope&);
-    using AttributeGetterFunction = JSC::JSValue(JSC::ExecState&, JSClass&, JSC::ThrowScope&);
-    using OperationCallerFunction = JSC::EncodedJSValue(JSC::ExecState*, JSClass*, JSC::ThrowScope&);
-    using PromiseOperationCallerFunction = JSC::EncodedJSValue(JSC::ExecState*, JSClass*, Ref<DeferredPromise>&&, JSC::ThrowScope&);
-
-    static JSClass* castForAttribute(JSC::ExecState&, JSC::EncodedJSValue);
-    static JSClass* castForOperation(JSC::ExecState&);
-
-    template<PromiseOperationCallerFunction operationCaller, CastedThisErrorBehavior shouldThrow = CastedThisErrorBehavior::RejectPromise>
-    static JSC::EncodedJSValue callPromiseOperation(JSC::ExecState* state, Ref<DeferredPromise>&& promise, const char* operationName)
-    {
-        ASSERT(state);
-        auto throwScope = DECLARE_THROW_SCOPE(state->vm());
-        auto* thisObject = castForOperation(*state);
-        if (shouldThrow != CastedThisErrorBehavior::Assert && UNLIKELY(!thisObject))
-            return rejectPromiseWithThisTypeError(promise.get(), JSClass::info()->className, operationName);
-        ASSERT(thisObject);
-        ASSERT_GC_OBJECT_INHERITS(thisObject, JSClass::info());
-        // FIXME: We should refactor the binding generated code to use references for state and thisObject.
-        return operationCaller(state, thisObject, WTFMove(promise), throwScope);
-    }
-
-    template<OperationCallerFunction operationCaller, CastedThisErrorBehavior shouldThrow = CastedThisErrorBehavior::Throw>
-    static JSC::EncodedJSValue callOperation(JSC::ExecState* state, const char* operationName)
-    {
-        ASSERT(state);
-        auto throwScope = DECLARE_THROW_SCOPE(state->vm());
-        auto* thisObject = castForOperation(*state);
-        if (shouldThrow != CastedThisErrorBehavior::Assert && UNLIKELY(!thisObject)) {
-            if (shouldThrow == CastedThisErrorBehavior::Throw)
-                return throwThisTypeError(*state, throwScope, JSClass::info()->className, operationName);
-            // For custom promise-returning operations
-            return rejectPromiseWithThisTypeError(*state, JSClass::info()->className, operationName);
-        }
-        ASSERT(thisObject);
-        ASSERT_GC_OBJECT_INHERITS(thisObject, JSClass::info());
-        // FIXME: We should refactor the binding generated code to use references for state and thisObject.
-        return operationCaller(state, thisObject, throwScope);
-    }
-
-    template<AttributeSetterFunction setter, CastedThisErrorBehavior shouldThrow = CastedThisErrorBehavior::Throw>
-    static bool setAttribute(JSC::ExecState* state, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue encodedValue, const char* attributeName)
-    {
-        ASSERT(state);
-        auto throwScope = DECLARE_THROW_SCOPE(state->vm());
-        auto* thisObject = castForAttribute(*state, thisValue);
-        if (UNLIKELY(!thisObject))
-            return (shouldThrow == CastedThisErrorBehavior::Throw) ? throwSetterTypeError(*state, throwScope, JSClass::info()->className, attributeName) : false;
-        return setter(*state, *thisObject, JSC::JSValue::decode(encodedValue), throwScope);
-    }
+WEBCORE_EXPORT bool hasIteratorMethod(JSC::ExecState&, JSC::JSValue);
 
-    template<AttributeGetterFunction getter, CastedThisErrorBehavior shouldThrow = CastedThisErrorBehavior::Throw>
-    static JSC::EncodedJSValue attribute(JSC::ExecState* state, JSC::EncodedJSValue thisValue, const char* attributeName)
-    {
-        ASSERT(state);
-        auto throwScope = DECLARE_THROW_SCOPE(state->vm());
-        auto* thisObject = castForAttribute(*state, thisValue);
-        if (UNLIKELY(!thisObject)) {
-            if (shouldThrow == CastedThisErrorBehavior::Throw)
-                return throwGetterTypeError(*state, throwScope, JSClass::info()->className, attributeName);
-            if (shouldThrow == CastedThisErrorBehavior::RejectPromise)
-                return rejectPromiseWithGetterTypeError(*state, JSClass::info()->className, attributeName);
-            return JSC::JSValue::encode(JSC::jsUndefined());
-        }
-        return JSC::JSValue::encode(getter(*state, *thisObject, throwScope));
-    }
-};
+template<JSC::NativeFunction, int length> JSC::EncodedJSValue nonCachingStaticFunctionGetter(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
 
-// ExceptionOr handling.
-void propagateException(JSC::ExecState&, JSC::ThrowScope&, ExceptionOr<void>&&);
-template<typename T> JSC::JSValue toJS(JSC::ExecState&, JSDOMGlobalObject&, JSC::ThrowScope&, ExceptionOr<T>&&);
-template<typename T> JSC::JSValue toJSNewlyCreated(JSC::ExecState&, JSDOMGlobalObject&, JSC::ThrowScope&, ExceptionOr<T>&& value);
 
 // Inline functions and template definitions.
 
-inline JSC::Structure* DOMConstructorObject::createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
-{
-    return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
-}
-
-inline DOMConstructorObject::DOMConstructorObject(JSC::Structure* structure, JSDOMGlobalObject& globalObject)
-    : JSDOMObject(structure, globalObject)
-{
-}
-
-inline String DOMConstructorObject::className(const JSObject*)
-{
-    return ASCIILiteral("Function");
-}
-
-inline DOMConstructorJSBuiltinObject::DOMConstructorJSBuiltinObject(JSC::Structure* structure, JSDOMGlobalObject& globalObject)
-    : DOMConstructorObject(structure, globalObject)
-{
-}
-
-inline JSC::JSFunction* DOMConstructorJSBuiltinObject::initializeFunction()
-{
-    return m_initializeFunction.get();
-}
-
-inline void DOMConstructorJSBuiltinObject::setInitializeFunction(JSC::VM& vm, JSC::JSFunction& function)
-{
-    m_initializeFunction.set(vm, this, &function);
-}
-
-inline JSDOMGlobalObject* deprecatedGlobalObjectForPrototype(JSC::ExecState* exec)
-{
-    // FIXME: Callers to this function should be using the global object
-    // from which the object is being created, instead of assuming the lexical one.
-    // e.g. subframe.document.body should use the subframe's global object, not the lexical one.
-    return JSC::jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject());
-}
-
-template<typename WrapperClass> inline JSC::Structure* getDOMStructure(JSC::VM& vm, JSDOMGlobalObject& globalObject)
-{
-    if (JSC::Structure* structure = getCachedDOMStructure(globalObject, WrapperClass::info()))
-        return structure;
-    return cacheDOMStructure(globalObject, WrapperClass::createStructure(vm, &globalObject, WrapperClass::createPrototype(vm, &globalObject)), WrapperClass::info());
-}
-
-template<typename WrapperClass> inline JSC::Structure* deprecatedGetDOMStructure(JSC::ExecState* exec)
-{
-    // FIXME: This function is wrong. It uses the wrong global object for creating the prototype structure.
-    return getDOMStructure<WrapperClass>(exec->vm(), *deprecatedGlobalObjectForPrototype(exec));
-}
-
-template<typename WrapperClass> inline JSC::JSObject* getDOMPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
-{
-    return JSC::jsCast<JSC::JSObject*>(asObject(getDOMStructure<WrapperClass>(vm, *JSC::jsCast<JSDOMGlobalObject*>(globalObject))->storedPrototype()));
-}
-
-template<typename JSClass> inline JSC::EncodedJSValue createJSBuiltin(JSC::ExecState& state, JSC::JSFunction& initializeFunction, JSDOMGlobalObject& globalObject)
-{
-    JSC::JSObject* object = JSClass::create(getDOMStructure<JSClass>(globalObject.vm(), globalObject), &globalObject);
-    callFunctionWithCurrentArguments(state, *object, initializeFunction);
-    return JSC::JSValue::encode(object);
-}
-
-inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld& world, JSC::ArrayBuffer*)
-{
-    return static_cast<WebCoreTypedArrayController*>(world.vm().m_typedArrayController.get())->wrapperOwner();
-}
-
-inline void* wrapperKey(JSC::ArrayBuffer* domObject)
-{
-    return domObject;
-}
-
-inline JSDOMObject* getInlineCachedWrapper(DOMWrapperWorld&, void*) { return nullptr; }
-inline bool setInlineCachedWrapper(DOMWrapperWorld&, void*, JSDOMObject*, JSC::WeakHandleOwner*) { return false; }
-inline bool clearInlineCachedWrapper(DOMWrapperWorld&, void*, JSDOMObject*) { return false; }
-
-inline JSDOMObject* getInlineCachedWrapper(DOMWrapperWorld& world, ScriptWrappable* domObject)
-{
-    if (!world.isNormal())
-        return nullptr;
-    return domObject->wrapper();
-}
-
-inline JSC::JSArrayBuffer* getInlineCachedWrapper(DOMWrapperWorld& world, JSC::ArrayBuffer* buffer)
-{
-    if (!world.isNormal())
-        return nullptr;
-    return buffer->m_wrapper.get();
-}
-
-inline bool setInlineCachedWrapper(DOMWrapperWorld& world, ScriptWrappable* domObject, JSDOMObject* wrapper, JSC::WeakHandleOwner* wrapperOwner)
-{
-    if (!world.isNormal())
-        return false;
-    domObject->setWrapper(wrapper, wrapperOwner, &world);
-    return true;
-}
-
-inline bool setInlineCachedWrapper(DOMWrapperWorld& world, JSC::ArrayBuffer* domObject, JSC::JSArrayBuffer* wrapper, JSC::WeakHandleOwner* wrapperOwner)
-{
-    if (!world.isNormal())
-        return false;
-    domObject->m_wrapper = JSC::Weak<JSC::JSArrayBuffer>(wrapper, wrapperOwner, &world);
-    return true;
-}
-
-inline bool clearInlineCachedWrapper(DOMWrapperWorld& world, ScriptWrappable* domObject, JSDOMObject* wrapper)
-{
-    if (!world.isNormal())
-        return false;
-    domObject->clearWrapper(wrapper);
-    return true;
-}
-
-inline bool clearInlineCachedWrapper(DOMWrapperWorld& world, JSC::ArrayBuffer* domObject, JSC::JSArrayBuffer* wrapper)
-{
-    if (!world.isNormal())
-        return false;
-    weakClear(domObject->m_wrapper, wrapper);
-    return true;
-}
-
-template<typename DOMClass> inline JSC::JSObject* getCachedWrapper(DOMWrapperWorld& world, DOMClass& domObject)
-{
-    if (auto* wrapper = getInlineCachedWrapper(world, &domObject))
-        return wrapper;
-    return world.m_wrappers.get(wrapperKey(&domObject));
-}
-
-template<typename DOMClass, typename WrapperClass> inline void cacheWrapper(DOMWrapperWorld& world, DOMClass* domObject, WrapperClass* wrapper)
-{
-    JSC::WeakHandleOwner* owner = wrapperOwner(world, domObject);
-    if (setInlineCachedWrapper(world, domObject, wrapper, owner))
-        return;
-    weakAdd(world.m_wrappers, wrapperKey(domObject), JSC::Weak<JSC::JSObject>(wrapper, owner, &world));
-}
-
-template<typename DOMClass, typename WrapperClass> inline void uncacheWrapper(DOMWrapperWorld& world, DOMClass* domObject, WrapperClass* wrapper)
-{
-    if (clearInlineCachedWrapper(world, domObject, wrapper))
-        return;
-    weakRemove(world.m_wrappers, wrapperKey(domObject), wrapper);
-}
-
-template<typename DOMClass, typename T> inline auto createWrapper(JSDOMGlobalObject* globalObject, Ref<T>&& domObject) -> typename std::enable_if<std::is_same<DOMClass, T>::value, typename JSDOMWrapperConverterTraits<DOMClass>::WrapperClass*>::type
-{
-    using WrapperClass = typename JSDOMWrapperConverterTraits<DOMClass>::WrapperClass;
-
-    ASSERT(!getCachedWrapper(globalObject->world(), domObject));
-    auto* domObjectPtr = domObject.ptr();
-    auto* wrapper = WrapperClass::create(getDOMStructure<WrapperClass>(globalObject->vm(), *globalObject), globalObject, WTFMove(domObject));
-    cacheWrapper(globalObject->world(), domObjectPtr, wrapper);
-    return wrapper;
-}
-
-template<typename DOMClass, typename T> inline auto createWrapper(JSDOMGlobalObject* globalObject, Ref<T>&& domObject) -> typename std::enable_if<!std::is_same<DOMClass, T>::value, typename JSDOMWrapperConverterTraits<DOMClass>::WrapperClass*>::type
-{
-    return createWrapper<DOMClass>(globalObject, static_reference_cast<DOMClass>(WTFMove(domObject)));
-}
-
-template<typename DOMClass> inline JSC::JSValue wrap(JSC::ExecState* state, JSDOMGlobalObject* globalObject, DOMClass& domObject)
-{
-    if (auto* wrapper = getCachedWrapper(globalObject->world(), domObject))
-        return wrapper;
-    return toJSNewlyCreated(state, globalObject, Ref<DOMClass>(domObject));
-}
-
-template<typename JSClass> inline JSClass& castThisValue(JSC::ExecState& state)
-{
-    auto thisValue = state.thisValue();
-    auto castedThis = jsDynamicDowncast<JSClass*>(state.vm(), thisValue);
-    ASSERT(castedThis);
-    return *castedThis;
-}
-
 inline int32_t finiteInt32Value(JSC::JSValue value, JSC::ExecState* exec, bool& okay)
 {
     double number = value.toNumber(exec);
@@ -579,32 +159,6 @@ inline int32_t finiteInt32Value(JSC::JSValue value, JSC::ExecState* exec, bool&
     return JSC::toInt32(number);
 }
 
-// Validates that the passed object is a sequence type per section 4.1.13 of the WebIDL spec.
-inline JSC::JSObject* toJSSequence(JSC::ExecState& exec, JSC::JSValue value, unsigned& length)
-{
-    JSC::VM& vm = exec.vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    JSC::JSObject* object = value.getObject();
-    if (!object) {
-        throwSequenceTypeError(exec, scope);
-        return nullptr;
-    }
-
-    JSC::JSValue lengthValue = object->get(&exec, exec.propertyNames().length);
-    RETURN_IF_EXCEPTION(scope, nullptr);
-
-    if (lengthValue.isUndefinedOrNull()) {
-        throwSequenceTypeError(exec, scope);
-        return nullptr;
-    }
-
-    length = lengthValue.toUInt32(&exec);
-    RETURN_IF_EXCEPTION(scope, nullptr);
-
-    return object;
-}
-
 inline JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, JSC::ArrayBuffer& buffer)
 {
     if (auto result = getCachedWrapper(globalObject->world(), buffer))
@@ -676,21 +230,6 @@ inline JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject*, const JSC::Pr
     return JSC::Symbol::create(exec->vm(), privateName.uid());
 }
 
-inline JSC::JSValue toJSIterator(JSC::ExecState& state, JSDOMGlobalObject&, JSC::JSValue value)
-{
-    return createIteratorResultObject(&state, value, false);
-}
-
-template<typename T> inline JSC::JSValue toJSIterator(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const T& value)
-{
-    return createIteratorResultObject(&state, toJS(&state, &globalObject, value), false);
-}
-
-inline JSC::JSValue toJSIteratorEnd(JSC::ExecState& state)
-{
-    return createIteratorResultObject(&state, JSC::jsUndefined(), true);
-}
-
 inline RefPtr<JSC::ArrayBufferView> toPossiblySharedArrayBufferView(JSC::VM& vm, JSC::JSValue value)
 {
     auto* wrapper = jsDynamicDowncast<JSC::JSArrayBufferView*>(vm, value);
@@ -727,30 +266,6 @@ inline RefPtr<JSC::Uint32Array> toUnsharedUint32Array(JSC::VM& vm, JSC::JSValue
 inline RefPtr<JSC::Float32Array> toUnsharedFloat32Array(JSC::VM& vm, JSC::JSValue value) { return JSC::toUnsharedNativeTypedView<JSC::Float32Adaptor>(vm, value); }
 inline RefPtr<JSC::Float64Array> toUnsharedFloat64Array(JSC::VM& vm, JSC::JSValue value) { return JSC::toUnsharedNativeTypedView<JSC::Float64Adaptor>(vm, value); }
 
-template<typename T, typename JST> inline Vector<Ref<T>> toRefNativeArray(JSC::ExecState& state, JSC::JSValue value)
-{
-    JSC::VM& vm = state.vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    if (!value.isObject()) {
-        throwSequenceTypeError(state, scope);
-        return { };
-    }
-
-    Vector<Ref<T>> result;
-    forEachInIterable(&state, value, [&result](JSC::VM& vm, JSC::ExecState* state, JSC::JSValue jsValue) {
-        auto scope = DECLARE_THROW_SCOPE(vm);
-
-        if (jsValue.inherits(vm, JST::info())) {
-            auto* object = JST::toWrapped(vm, jsValue);
-            ASSERT(object);
-            result.append(*object);
-        } else
-            throwArrayElementTypeError(*state, scope);
-    });
-    return result;
-}
-
 inline String propertyNameToString(JSC::PropertyName propertyName)
 {
     ASSERT(!propertyName.isSymbol());
@@ -767,59 +282,4 @@ template<JSC::NativeFunction nativeFunction, int length> JSC::EncodedJSValue non
     return JSC::JSValue::encode(JSC::JSFunction::create(exec->vm(), exec->lexicalGlobalObject(), length, propertyName.publicName(), nativeFunction));
 }
 
-ALWAYS_INLINE void propagateException(JSC::ExecState& state, JSC::ThrowScope& throwScope, Exception&& exception)
-{
-    if (throwScope.exception())
-        return;
-    propagateExceptionSlowPath(state, throwScope, WTFMove(exception));
-}
-
-inline void propagateException(JSC::ExecState& state, JSC::ThrowScope& throwScope, ExceptionOr<void>&& value)
-{
-    if (UNLIKELY(value.hasException()))
-        propagateException(state, throwScope, value.releaseException());
-}
-
-template<typename T> inline JSC::JSValue toJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, JSC::ThrowScope& throwScope, ExceptionOr<T>&& value)
-{
-    if (UNLIKELY(value.hasException())) {
-        propagateException(state, throwScope, value.releaseException());
-        return { };
-    }
-    return toJS(&state, &globalObject, value.releaseReturnValue());
-}
-
-template<typename T> inline JSC::JSValue toJSNewlyCreated(JSC::ExecState& state, JSDOMGlobalObject& globalObject, JSC::ThrowScope& throwScope, ExceptionOr<T>&& value)
-{
-    if (UNLIKELY(value.hasException())) {
-        propagateException(state, throwScope, value.releaseException());
-        return { };
-    }
-    return toJSNewlyCreated(&state, &globalObject, value.releaseReturnValue());
-}
-
-template<typename T> inline T* BindingSecurity::checkSecurityForNode(JSC::ExecState& state, T& node)
-{
-    return shouldAllowAccessToNode(state, &node) ? &node : nullptr;
-}
-
-template<typename T> inline T* BindingSecurity::checkSecurityForNode(JSC::ExecState& state, T* node)
-{
-    return shouldAllowAccessToNode(state, node) ? node : nullptr;
-}
-
-template<typename T> inline ExceptionOr<T*> BindingSecurity::checkSecurityForNode(JSC::ExecState& state, ExceptionOr<T*>&& value)
-{
-    if (value.hasException())
-        return value.releaseException();
-    return checkSecurityForNode(state, value.releaseReturnValue());
-}
-
-template<typename T> inline ExceptionOr<T*> BindingSecurity::checkSecurityForNode(JSC::ExecState& state, ExceptionOr<T&>&& value)
-{
-    if (value.hasException())
-        return value.releaseException();
-    return checkSecurityForNode(state, value.releaseReturnValue());
-}
-
 } // namespace WebCore
diff --git a/Source/WebCore/bindings/js/JSDOMBindingCaller.h b/Source/WebCore/bindings/js/JSDOMBindingCaller.h
new file mode 100644 (file)
index 0000000..715c671
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ *  Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
+ *  Copyright (C) 2003-2006, 2008-2009, 2013, 2016 Apple Inc. All rights reserved.
+ *  Copyright (C) 2007 Samuel Weinig <sam@webkit.org>
+ *  Copyright (C) 2009 Google, Inc. All rights reserved.
+ *  Copyright (C) 2012 Ericsson AB. All rights reserved.
+ *  Copyright (C) 2013 Michael Pruett <michael@68k.org>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#pragma once
+
+#include "JSDOMExceptionHandling.h"
+
+namespace WebCore {
+
+enum class CastedThisErrorBehavior { Throw, ReturnEarly, RejectPromise, Assert };
+
+template<typename JSClass>
+struct BindingCaller {
+    using AttributeSetterFunction = bool(JSC::ExecState&, JSClass&, JSC::JSValue, JSC::ThrowScope&);
+    using AttributeGetterFunction = JSC::JSValue(JSC::ExecState&, JSClass&, JSC::ThrowScope&);
+    using OperationCallerFunction = JSC::EncodedJSValue(JSC::ExecState*, JSClass*, JSC::ThrowScope&);
+    using PromiseOperationCallerFunction = JSC::EncodedJSValue(JSC::ExecState*, JSClass*, Ref<DeferredPromise>&&, JSC::ThrowScope&);
+
+    static JSClass* castForAttribute(JSC::ExecState&, JSC::EncodedJSValue);
+    static JSClass* castForOperation(JSC::ExecState&);
+
+    template<PromiseOperationCallerFunction operationCaller, CastedThisErrorBehavior shouldThrow = CastedThisErrorBehavior::RejectPromise>
+    static JSC::EncodedJSValue callPromiseOperation(JSC::ExecState* state, Ref<DeferredPromise>&& promise, const char* operationName)
+    {
+        ASSERT(state);
+        auto throwScope = DECLARE_THROW_SCOPE(state->vm());
+        auto* thisObject = castForOperation(*state);
+        if (shouldThrow != CastedThisErrorBehavior::Assert && UNLIKELY(!thisObject))
+            return rejectPromiseWithThisTypeError(promise.get(), JSClass::info()->className, operationName);
+        ASSERT(thisObject);
+        ASSERT_GC_OBJECT_INHERITS(thisObject, JSClass::info());
+        // FIXME: We should refactor the binding generated code to use references for state and thisObject.
+        return operationCaller(state, thisObject, WTFMove(promise), throwScope);
+    }
+
+    template<OperationCallerFunction operationCaller, CastedThisErrorBehavior shouldThrow = CastedThisErrorBehavior::Throw>
+    static JSC::EncodedJSValue callOperation(JSC::ExecState* state, const char* operationName)
+    {
+        ASSERT(state);
+        auto throwScope = DECLARE_THROW_SCOPE(state->vm());
+        auto* thisObject = castForOperation(*state);
+        if (shouldThrow != CastedThisErrorBehavior::Assert && UNLIKELY(!thisObject)) {
+            if (shouldThrow == CastedThisErrorBehavior::Throw)
+                return throwThisTypeError(*state, throwScope, JSClass::info()->className, operationName);
+            // For custom promise-returning operations
+            return rejectPromiseWithThisTypeError(*state, JSClass::info()->className, operationName);
+        }
+        ASSERT(thisObject);
+        ASSERT_GC_OBJECT_INHERITS(thisObject, JSClass::info());
+        // FIXME: We should refactor the binding generated code to use references for state and thisObject.
+        return operationCaller(state, thisObject, throwScope);
+    }
+
+    template<AttributeSetterFunction setter, CastedThisErrorBehavior shouldThrow = CastedThisErrorBehavior::Throw>
+    static bool setAttribute(JSC::ExecState* state, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue encodedValue, const char* attributeName)
+    {
+        ASSERT(state);
+        auto throwScope = DECLARE_THROW_SCOPE(state->vm());
+        auto* thisObject = castForAttribute(*state, thisValue);
+        if (UNLIKELY(!thisObject))
+            return (shouldThrow == CastedThisErrorBehavior::Throw) ? throwSetterTypeError(*state, throwScope, JSClass::info()->className, attributeName) : false;
+        return setter(*state, *thisObject, JSC::JSValue::decode(encodedValue), throwScope);
+    }
+
+    template<AttributeGetterFunction getter, CastedThisErrorBehavior shouldThrow = CastedThisErrorBehavior::Throw>
+    static JSC::EncodedJSValue attribute(JSC::ExecState* state, JSC::EncodedJSValue thisValue, const char* attributeName)
+    {
+        ASSERT(state);
+        auto throwScope = DECLARE_THROW_SCOPE(state->vm());
+        auto* thisObject = castForAttribute(*state, thisValue);
+        if (UNLIKELY(!thisObject)) {
+            if (shouldThrow == CastedThisErrorBehavior::Throw)
+                return throwGetterTypeError(*state, throwScope, JSClass::info()->className, attributeName);
+            if (shouldThrow == CastedThisErrorBehavior::RejectPromise)
+                return rejectPromiseWithGetterTypeError(*state, JSClass::info()->className, attributeName);
+            return JSC::JSValue::encode(JSC::jsUndefined());
+        }
+        return JSC::JSValue::encode(getter(*state, *thisObject, throwScope));
+    }
+};
+
+} // namespace WebCore
diff --git a/Source/WebCore/bindings/js/JSDOMBindingSecurity.cpp b/Source/WebCore/bindings/js/JSDOMBindingSecurity.cpp
new file mode 100644 (file)
index 0000000..4eefc86
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ *  Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
+ *  Copyright (C) 2004-2011, 2013, 2016 Apple Inc. All rights reserved.
+ *  Copyright (C) 2007 Samuel Weinig <sam@webkit.org>
+ *  Copyright (C) 2013 Michael Pruett <michael@68k.org>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#include "JSDOMBindingSecurity.h"
+
+#include "DOMWindow.h"
+#include "Document.h"
+#include "Frame.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWindowBase.h"
+#include "SecurityOrigin.h"
+#include <wtf/text/WTFString.h>
+
+using namespace JSC;
+
+namespace WebCore {
+
+void printErrorMessageForFrame(Frame* frame, const String& message)
+{
+    if (!frame)
+        return;
+    frame->document()->domWindow()->printErrorMessage(message);
+}
+
+static inline bool canAccessDocument(JSC::ExecState* state, Document* targetDocument, SecurityReportingOption reportingOption)
+{
+    VM& vm = state->vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+
+    if (!targetDocument)
+        return false;
+
+    DOMWindow& active = activeDOMWindow(state);
+
+    if (active.document()->securityOrigin().canAccess(targetDocument->securityOrigin()))
+        return true;
+
+    switch (reportingOption) {
+    case ThrowSecurityError:
+        throwSecurityError(*state, scope, targetDocument->domWindow()->crossDomainAccessErrorMessage(active));
+        break;
+    case LogSecurityError:
+        printErrorMessageForFrame(targetDocument->frame(), targetDocument->domWindow()->crossDomainAccessErrorMessage(active));
+        break;
+    case DoNotReportSecurityError:
+        break;
+    }
+
+    return false;
+}
+
+bool BindingSecurity::shouldAllowAccessToFrame(ExecState& state, Frame& frame, String& message)
+{
+    if (BindingSecurity::shouldAllowAccessToFrame(&state, &frame, DoNotReportSecurityError))
+        return true;
+    message = frame.document()->domWindow()->crossDomainAccessErrorMessage(activeDOMWindow(&state));
+    return false;
+}
+
+bool BindingSecurity::shouldAllowAccessToDOMWindow(ExecState& state, DOMWindow& globalObject, String& message)
+{
+    if (BindingSecurity::shouldAllowAccessToDOMWindow(&state, globalObject, DoNotReportSecurityError))
+        return true;
+    message = globalObject.crossDomainAccessErrorMessage(activeDOMWindow(&state));
+    return false;
+}
+
+bool BindingSecurity::shouldAllowAccessToDOMWindow(JSC::ExecState* state, DOMWindow& target, SecurityReportingOption reportingOption)
+{
+    return canAccessDocument(state, target.document(), reportingOption);
+}
+
+bool BindingSecurity::shouldAllowAccessToFrame(JSC::ExecState* state, Frame* target, SecurityReportingOption reportingOption)
+{
+    return target && canAccessDocument(state, target->document(), reportingOption);
+}
+
+bool BindingSecurity::shouldAllowAccessToNode(JSC::ExecState& state, Node* target)
+{
+    return !target || canAccessDocument(&state, &target->document(), LogSecurityError);
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/bindings/js/JSDOMBindingSecurity.h b/Source/WebCore/bindings/js/JSDOMBindingSecurity.h
new file mode 100644 (file)
index 0000000..7b4085a
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ *  Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
+ *  Copyright (C) 2003-2006, 2008-2009, 2013, 2016 Apple Inc. All rights reserved.
+ *  Copyright (C) 2007 Samuel Weinig <sam@webkit.org>
+ *  Copyright (C) 2009 Google, Inc. All rights reserved.
+ *  Copyright (C) 2012 Ericsson AB. All rights reserved.
+ *  Copyright (C) 2013 Michael Pruett <michael@68k.org>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#pragma once
+
+#include "ExceptionOr.h"
+#include <wtf/Forward.h>
+
+namespace JSC {
+class ExecState;
+}
+
+namespace WebCore {
+
+class DOMWindow;
+class Frame;
+class Node;
+
+void printErrorMessageForFrame(Frame*, const String& message);
+
+enum SecurityReportingOption { DoNotReportSecurityError, LogSecurityError, ThrowSecurityError };
+
+namespace BindingSecurity {
+
+template<typename T> T* checkSecurityForNode(JSC::ExecState&, T&);
+template<typename T> T* checkSecurityForNode(JSC::ExecState&, T*);
+template<typename T> ExceptionOr<T*> checkSecurityForNode(JSC::ExecState&, ExceptionOr<T*>&&);
+template<typename T> ExceptionOr<T*> checkSecurityForNode(JSC::ExecState&, ExceptionOr<T&>&&);
+
+bool shouldAllowAccessToDOMWindow(JSC::ExecState*, DOMWindow&, SecurityReportingOption = LogSecurityError);
+bool shouldAllowAccessToDOMWindow(JSC::ExecState&, DOMWindow&, String& message);
+bool shouldAllowAccessToFrame(JSC::ExecState*, Frame*, SecurityReportingOption = LogSecurityError);
+bool shouldAllowAccessToFrame(JSC::ExecState&, Frame&, String& message);
+bool shouldAllowAccessToNode(JSC::ExecState&, Node*);
+
+};
+
+template<typename T> inline T* BindingSecurity::checkSecurityForNode(JSC::ExecState& state, T& node)
+{
+    return shouldAllowAccessToNode(state, &node) ? &node : nullptr;
+}
+
+template<typename T> inline T* BindingSecurity::checkSecurityForNode(JSC::ExecState& state, T* node)
+{
+    return shouldAllowAccessToNode(state, node) ? node : nullptr;
+}
+
+template<typename T> inline ExceptionOr<T*> BindingSecurity::checkSecurityForNode(JSC::ExecState& state, ExceptionOr<T*>&& value)
+{
+    if (value.hasException())
+        return value.releaseException();
+    return checkSecurityForNode(state, value.releaseReturnValue());
+}
+
+template<typename T> inline ExceptionOr<T*> BindingSecurity::checkSecurityForNode(JSC::ExecState& state, ExceptionOr<T&>&& value)
+{
+    if (value.hasException())
+        return value.releaseException();
+    return checkSecurityForNode(state, value.releaseReturnValue());
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/bindings/js/JSDOMConstructor.cpp b/Source/WebCore/bindings/js/JSDOMConstructor.cpp
new file mode 100644 (file)
index 0000000..e530741
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ *  Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
+ *  Copyright (C) 2004-2011, 2013, 2016 Apple Inc. All rights reserved.
+ *  Copyright (C) 2007 Samuel Weinig <sam@webkit.org>
+ *  Copyright (C) 2013 Michael Pruett <michael@68k.org>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#include "JSDOMConstructor.h"
+
+#include <runtime/JSCInlines.h>
+
+using namespace JSC;
+
+namespace WebCore {
+
+STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(DOMConstructorObject);
+STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(DOMConstructorWithDocument);
+    
+void callFunctionWithCurrentArguments(JSC::ExecState& state, JSC::JSObject& thisObject, JSC::JSFunction& function)
+{
+    JSC::CallData callData;
+    JSC::CallType callType = JSC::getCallData(&function, callData);
+    ASSERT(callType != CallType::None);
+
+    JSC::MarkedArgumentBuffer arguments;
+    for (unsigned i = 0; i < state.argumentCount(); ++i)
+        arguments.append(state.uncheckedArgument(i));
+    JSC::call(&state, &function, callType, callData, &thisObject, arguments);
+}
+
+void DOMConstructorJSBuiltinObject::visitChildren(JSC::JSCell* cell, JSC::SlotVisitor& visitor)
+{
+    auto* thisObject = jsCast<DOMConstructorJSBuiltinObject*>(cell);
+    ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+    Base::visitChildren(thisObject, visitor);
+    visitor.append(thisObject->m_initializeFunction);
+}
+
+static EncodedJSValue JSC_HOST_CALL callThrowTypeError(ExecState* exec)
+{
+    VM& vm = exec->vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+    throwTypeError(exec, scope, ASCIILiteral("Constructor requires 'new' operator"));
+    return JSValue::encode(jsNull());
+}
+
+CallType DOMConstructorObject::getCallData(JSCell*, CallData& callData)
+{
+    callData.native.function = callThrowTypeError;
+    return CallType::Host;
+}
+
+} // namespace WebCore
index 883c2fd..6d4d480 100644 (file)
 
 #pragma once
 
-#include "DOMConstructorWithDocument.h"
-#include "JSDOMBinding.h"
+#include "Document.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWrapperCache.h"
 
 namespace WebCore {
 
+// Base class for all constructor objects in the JSC bindings.
+class DOMConstructorObject : public JSDOMObject {
+public:
+    typedef JSDOMObject Base;
+    static const unsigned StructureFlags = Base::StructureFlags | JSC::ImplementsHasInstance | JSC::ImplementsDefaultHasInstance | JSC::TypeOfShouldCallGetCallData;
+    static JSC::Structure* createStructure(JSC::VM&, JSC::JSGlobalObject*, JSC::JSValue);
+
+protected:
+    DOMConstructorObject(JSC::Structure*, JSDOMGlobalObject&);
+
+    static String className(const JSObject*);
+    static JSC::CallType getCallData(JSCell*, JSC::CallData&);
+};
+
+// Constructors using this base class depend on being in a Document and
+// can never be used from a WorkerGlobalScope.
+class DOMConstructorWithDocument : public DOMConstructorObject {
+    typedef DOMConstructorObject Base;
+public:
+    Document* document() const
+    {
+        return downcast<Document>(scriptExecutionContext());
+    }
+
+protected:
+    DOMConstructorWithDocument(JSC::Structure* structure, JSDOMGlobalObject& globalObject)
+        : DOMConstructorObject(structure, globalObject)
+    {
+    }
+
+    void finishCreation(JSDOMGlobalObject& globalObject)
+    {
+        Base::finishCreation(globalObject.vm());
+        ASSERT(globalObject.scriptExecutionContext()->isDocument());
+    }
+};
+
+class DOMConstructorJSBuiltinObject : public DOMConstructorObject {
+public:
+    typedef DOMConstructorObject Base;
+
+protected:
+    DOMConstructorJSBuiltinObject(JSC::Structure*, JSDOMGlobalObject&);
+    static void visitChildren(JSC::JSCell*, JSC::SlotVisitor&);
+
+    JSC::JSFunction* initializeFunction();
+    void setInitializeFunction(JSC::VM&, JSC::JSFunction&);
+
+private:
+    JSC::WriteBarrier<JSC::JSFunction> m_initializeFunction;
+};
+
 template<typename JSClass> class JSDOMConstructorNotConstructable : public DOMConstructorObject {
 public:
     typedef DOMConstructorObject Base;
@@ -131,6 +184,37 @@ private:
     JSC::FunctionExecutable* initializeExecutable(JSC::VM&);
 };
 
+inline JSC::Structure* DOMConstructorObject::createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+{
+    return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+}
+
+inline DOMConstructorObject::DOMConstructorObject(JSC::Structure* structure, JSDOMGlobalObject& globalObject)
+    : JSDOMObject(structure, globalObject)
+{
+}
+
+inline String DOMConstructorObject::className(const JSObject*)
+{
+    return ASCIILiteral("Function");
+}
+
+inline DOMConstructorJSBuiltinObject::DOMConstructorJSBuiltinObject(JSC::Structure* structure, JSDOMGlobalObject& globalObject)
+    : DOMConstructorObject(structure, globalObject)
+{
+}
+
+inline JSC::JSFunction* DOMConstructorJSBuiltinObject::initializeFunction()
+{
+    return m_initializeFunction.get();
+}
+
+inline void DOMConstructorJSBuiltinObject::setInitializeFunction(JSC::VM& vm, JSC::JSFunction& function)
+{
+    m_initializeFunction.set(vm, this, &function);
+}
+
+
 template<typename JSClass> inline JSDOMConstructorNotConstructable<JSClass>* JSDOMConstructorNotConstructable<JSClass>::create(JSC::VM& vm, JSC::Structure* structure, JSDOMGlobalObject& globalObject)
 {
     JSDOMConstructorNotConstructable* constructor = new (NotNull, JSC::allocateCell<JSDOMConstructorNotConstructable>(vm.heap)) JSDOMConstructorNotConstructable(structure, globalObject);
@@ -220,6 +304,8 @@ template<typename JSClass> inline void JSBuiltinConstructor<JSClass>::finishCrea
     initializeProperties(vm, globalObject);
 }
 
+void callFunctionWithCurrentArguments(JSC::ExecState&, JSC::JSObject& thisObject, JSC::JSFunction&);
+
 template<typename JSClass> inline JSC::EncodedJSValue JSBuiltinConstructor<JSClass>::callConstructor(JSC::ExecState& state, JSC::JSObject& object)
 {
     callFunctionWithCurrentArguments(state, object, *initializeFunction());
index 39ef288..7dafbff 100644 (file)
@@ -29,6 +29,7 @@
 #include "IDBBindingUtilities.h"
 #include "IDLTypes.h"
 #include "JSDOMBinding.h"
+#include "JSDOMExceptionHandling.h"
 #include <runtime/JSGlobalObjectInlines.h>
 #include <runtime/JSONObject.h>
 
diff --git a/Source/WebCore/bindings/js/JSDOMExceptionHandling.cpp b/Source/WebCore/bindings/js/JSDOMExceptionHandling.cpp
new file mode 100644 (file)
index 0000000..585553d
--- /dev/null
@@ -0,0 +1,404 @@
+/*
+ *  Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
+ *  Copyright (C) 2004-2011, 2013, 2016 Apple Inc. All rights reserved.
+ *  Copyright (C) 2007 Samuel Weinig <sam@webkit.org>
+ *  Copyright (C) 2013 Michael Pruett <michael@68k.org>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#include "JSDOMExceptionHandling.h"
+
+#include "CachedScript.h"
+#include "DOMWindow.h"
+#include "ExceptionCodeDescription.h"
+#include "ExceptionHeaders.h"
+#include "ExceptionInterfaces.h"
+#include "JSDOMPromise.h"
+#include "JSDOMWindow.h"
+#include "JSDynamicDowncast.h"
+#include "JSExceptionBase.h"
+#include <inspector/ScriptCallStack.h>
+#include <inspector/ScriptCallStackFactory.h>
+#include <runtime/ErrorHandlingScope.h>
+#include <runtime/Exception.h>
+#include <runtime/ExceptionHelpers.h>
+#include <wtf/text/StringBuilder.h>
+
+#if ENABLE(INDEXED_DATABASE)
+#include "IDBDatabaseException.h"
+#endif
+
+using namespace JSC;
+
+namespace WebCore {
+
+void reportException(ExecState* exec, JSValue exceptionValue, CachedScript* cachedScript)
+{
+    VM& vm = exec->vm();
+    RELEASE_ASSERT(vm.currentThreadIsHoldingAPILock());
+    auto* exception = jsDynamicDowncast<JSC::Exception*>(vm, exceptionValue);
+    if (!exception) {
+        exception = vm.lastException();
+        if (!exception)
+            exception = JSC::Exception::create(exec->vm(), exceptionValue, JSC::Exception::DoNotCaptureStack);
+    }
+
+    reportException(exec, exception, cachedScript);
+}
+
+String retrieveErrorMessage(ExecState& state, VM& vm, JSValue exception, CatchScope& catchScope)
+{
+    if (auto* exceptionBase = toExceptionBase(vm, exception))
+        return exceptionBase->toString();
+
+    // FIXME: <http://webkit.org/b/115087> Web Inspector: WebCore::reportException should not evaluate JavaScript handling exceptions
+    // If this is a custom exception object, call toString on it to try and get a nice string representation for the exception.
+    String errorMessage;
+    if (auto* error = jsDynamicDowncast<ErrorInstance*>(vm, exception))
+        errorMessage = error->sanitizedToString(&state);
+    else
+        errorMessage = exception.toWTFString(&state);
+
+    // We need to clear any new exception that may be thrown in the toString() call above.
+    // reportException() is not supposed to be making new exceptions.
+    catchScope.clearException();
+    vm.clearLastException();
+    return errorMessage;
+}
+
+void reportException(ExecState* exec, JSC::Exception* exception, CachedScript* cachedScript, ExceptionDetails* exceptionDetails)
+{
+    VM& vm = exec->vm();
+    auto scope = DECLARE_CATCH_SCOPE(vm);
+
+    RELEASE_ASSERT(vm.currentThreadIsHoldingAPILock());
+    if (isTerminatedExecutionException(vm, exception))
+        return;
+
+    ErrorHandlingScope errorScope(exec->vm());
+
+    auto callStack = Inspector::createScriptCallStackFromException(exec, exception, Inspector::ScriptCallStack::maxCallStackSizeToCapture);
+    scope.clearException();
+    vm.clearLastException();
+
+    auto* globalObject = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject());
+    if (auto* window = jsDynamicDowncast<JSDOMWindow*>(vm, globalObject)) {
+        if (!window->wrapped().isCurrentlyDisplayedInFrame())
+            return;
+    }
+
+    int lineNumber = 0;
+    int columnNumber = 0;
+    String exceptionSourceURL;
+    if (auto* callFrame = callStack->firstNonNativeCallFrame()) {
+        lineNumber = callFrame->lineNumber();
+        columnNumber = callFrame->columnNumber();
+        exceptionSourceURL = callFrame->sourceURL();
+    }
+
+    auto errorMessage = retrieveErrorMessage(*exec, vm, exception->value(), scope);
+    globalObject->scriptExecutionContext()->reportException(errorMessage, lineNumber, columnNumber, exceptionSourceURL, exception, callStack->size() ? callStack.ptr() : nullptr, cachedScript);
+
+    if (exceptionDetails) {
+        exceptionDetails->message = errorMessage;
+        exceptionDetails->lineNumber = lineNumber;
+        exceptionDetails->columnNumber = columnNumber;
+        exceptionDetails->sourceURL = exceptionSourceURL;
+    }
+}
+
+void reportCurrentException(ExecState* exec)
+{
+    VM& vm = exec->vm();
+    auto scope = DECLARE_CATCH_SCOPE(vm);
+    auto* exception = scope.exception();
+    scope.clearException();
+    reportException(exec, exception);
+}
+
+static JSValue createDOMException(ExecState* exec, ExceptionCode ec, const String* message = nullptr)
+{
+    if (!ec || ec == ExistingExceptionError)
+        return jsUndefined();
+
+    // FIXME: Handle other WebIDL exception types.
+    if (ec == TypeError) {
+        if (!message || message->isEmpty())
+            return createTypeError(exec);
+        return createTypeError(exec, *message);
+    }
+
+    if (ec == RangeError) {
+        if (!message || message->isEmpty())
+            return createRangeError(exec, ASCIILiteral("Bad value"));
+        return createRangeError(exec, *message);
+    }
+
+    if (ec == StackOverflowError)
+        return createStackOverflowError(exec);
+
+    // FIXME: All callers to createDOMException need to pass in the correct global object.
+    // For now, we're going to assume the lexicalGlobalObject. Which is wrong in cases like this:
+    // frames[0].document.createElement(null, null); // throws an exception which should have the subframe's prototypes.
+    JSDOMGlobalObject* globalObject = deprecatedGlobalObjectForPrototype(exec);
+
+    ExceptionCodeDescription description(ec);
+
+    CString messageCString;
+    if (message)
+        messageCString = message->utf8();
+    if (message && !message->isEmpty()) {
+        // It is safe to do this because the char* contents of the CString are copied into a new WTF::String before the CString is destroyed.
+        description.description = messageCString.data();
+    }
+
+    JSValue errorObject;
+    switch (description.type) {
+    case DOMCoreExceptionType:
+#if ENABLE(INDEXED_DATABASE)
+    case IDBDatabaseExceptionType:
+#endif
+        errorObject = toJS(exec, globalObject, DOMCoreException::create(description));
+        break;
+    case FileExceptionType:
+        errorObject = toJS(exec, globalObject, FileException::create(description));
+        break;
+    case SQLExceptionType:
+        errorObject = toJS(exec, globalObject, SQLException::create(description));
+        break;
+    case SVGExceptionType:
+        errorObject = toJS(exec, globalObject, SVGException::create(description));
+        break;
+    case XPathExceptionType:
+        errorObject = toJS(exec, globalObject, XPathException::create(description));
+        break;
+    }
+    
+    ASSERT(errorObject);
+    addErrorInfo(exec, asObject(errorObject), true);
+    return errorObject;
+}
+
+JSValue createDOMException(ExecState* exec, ExceptionCode ec, const String& message)
+{
+    return createDOMException(exec, ec, &message);
+}
+
+JSValue createDOMException(ExecState& state, Exception&& exception)
+{
+    return createDOMException(&state, exception.code(), exception.releaseMessage());
+}
+
+void propagateExceptionSlowPath(JSC::ExecState& state, JSC::ThrowScope& throwScope, Exception&& exception)
+{
+    ASSERT(!throwScope.exception());
+    throwException(&state, throwScope, createDOMException(state, WTFMove(exception)));
+}
+    
+static EncodedJSValue throwTypeError(JSC::ExecState& state, JSC::ThrowScope& scope, const String& errorMessage)
+{
+    return throwVMTypeError(&state, scope, errorMessage);
+}
+
+static void appendArgumentMustBe(StringBuilder& builder, unsigned argumentIndex, const char* argumentName, const char* interfaceName, const char* functionName)
+{
+    builder.appendLiteral("Argument ");
+    builder.appendNumber(argumentIndex + 1);
+    builder.appendLiteral(" ('");
+    builder.append(argumentName);
+    builder.appendLiteral("') to ");
+    if (!functionName) {
+        builder.appendLiteral("the ");
+        builder.append(interfaceName);
+        builder.appendLiteral(" constructor");
+    } else {
+        builder.append(interfaceName);
+        builder.append('.');
+        builder.append(functionName);
+    }
+    builder.appendLiteral(" must be ");
+}
+
+JSC::EncodedJSValue reportDeprecatedGetterError(JSC::ExecState& state, const char* interfaceName, const char* attributeName)
+{
+    auto& context = *jsCast<JSDOMGlobalObject*>(state.lexicalGlobalObject())->scriptExecutionContext();
+    context.addConsoleMessage(MessageSource::JS, MessageLevel::Error, makeString("Deprecated attempt to access property '", attributeName, "' on a non-", interfaceName, " object."));
+    return JSValue::encode(jsUndefined());
+}
+    
+void reportDeprecatedSetterError(JSC::ExecState& state, const char* interfaceName, const char* attributeName)
+{
+    auto& context = *jsCast<JSDOMGlobalObject*>(state.lexicalGlobalObject())->scriptExecutionContext();
+    context.addConsoleMessage(MessageSource::JS, MessageLevel::Error, makeString("Deprecated attempt to set property '", attributeName, "' on a non-", interfaceName, " object."));
+}
+
+void throwNotSupportedError(JSC::ExecState& state, JSC::ThrowScope& scope)
+{
+    ASSERT(!scope.exception());
+    throwException(&state, scope, createDOMException(&state, NOT_SUPPORTED_ERR));
+}
+
+void throwNotSupportedError(JSC::ExecState& state, JSC::ThrowScope& scope, const char* message)
+{
+    ASSERT(!scope.exception());
+    String messageString(message);
+    throwException(&state, scope, createDOMException(&state, NOT_SUPPORTED_ERR, &messageString));
+}
+
+void throwInvalidStateError(JSC::ExecState& state, JSC::ThrowScope& scope, const char* message)
+{
+    ASSERT(!scope.exception());
+    String messageString(message);
+    throwException(&state, scope, createDOMException(&state, INVALID_STATE_ERR, &messageString));
+}
+
+void throwSecurityError(JSC::ExecState& state, JSC::ThrowScope& scope, const String& message)
+{
+    ASSERT(!scope.exception());
+    throwException(&state, scope, createDOMException(&state, SECURITY_ERR, message));
+}
+
+JSC::EncodedJSValue throwArgumentMustBeEnumError(JSC::ExecState& state, JSC::ThrowScope& scope, unsigned argumentIndex, const char* argumentName, const char* functionInterfaceName, const char* functionName, const char* expectedValues)
+{
+    StringBuilder builder;
+    appendArgumentMustBe(builder, argumentIndex, argumentName, functionInterfaceName, functionName);
+    builder.appendLiteral("one of: ");
+    builder.append(expectedValues);
+    return throwVMTypeError(&state, scope, builder.toString());
+}
+
+JSC::EncodedJSValue throwArgumentMustBeFunctionError(JSC::ExecState& state, JSC::ThrowScope& scope, unsigned argumentIndex, const char* argumentName, const char* interfaceName, const char* functionName)
+{
+    StringBuilder builder;
+    appendArgumentMustBe(builder, argumentIndex, argumentName, interfaceName, functionName);
+    builder.appendLiteral("a function");
+    return throwVMTypeError(&state, scope, builder.toString());
+}
+
+JSC::EncodedJSValue throwArgumentTypeError(JSC::ExecState& state, JSC::ThrowScope& scope, unsigned argumentIndex, const char* argumentName, const char* functionInterfaceName, const char* functionName, const char* expectedType)
+{
+    StringBuilder builder;
+    appendArgumentMustBe(builder, argumentIndex, argumentName, functionInterfaceName, functionName);
+    builder.appendLiteral("an instance of ");
+    builder.append(expectedType);
+    return throwVMTypeError(&state, scope, builder.toString());
+}
+
+void throwArrayElementTypeError(JSC::ExecState& state, JSC::ThrowScope& scope)
+{
+    throwTypeError(state, scope, ASCIILiteral("Invalid Array element type"));
+}
+
+void throwAttributeTypeError(JSC::ExecState& state, JSC::ThrowScope& scope, const char* interfaceName, const char* attributeName, const char* expectedType)
+{
+    throwTypeError(state, scope, makeString("The ", interfaceName, '.', attributeName, " attribute must be an instance of ", expectedType));
+}
+
+JSC::EncodedJSValue throwRequiredMemberTypeError(JSC::ExecState& state, JSC::ThrowScope& scope, const char* memberName, const char* dictionaryName, const char* expectedType)
+{
+    StringBuilder builder;
+    builder.appendLiteral("Member ");
+    builder.append(dictionaryName);
+    builder.append('.');
+    builder.append(memberName);
+    builder.appendLiteral(" is required and must be an instance of ");
+    builder.append(expectedType);
+    return throwVMTypeError(&state, scope, builder.toString());
+}
+
+JSC::EncodedJSValue throwConstructorScriptExecutionContextUnavailableError(JSC::ExecState& state, JSC::ThrowScope& scope, const char* interfaceName)
+{
+    return throwVMError(&state, scope, createReferenceError(&state, makeString(interfaceName, " constructor associated execution context is unavailable")));
+}
+
+void throwSequenceTypeError(JSC::ExecState& state, JSC::ThrowScope& scope)
+{
+    throwTypeError(state, scope, ASCIILiteral("Value is not a sequence"));
+}
+
+void throwNonFiniteTypeError(ExecState& state, JSC::ThrowScope& scope)
+{
+    throwTypeError(&state, scope, ASCIILiteral("The provided value is non-finite"));
+}
+
+String makeGetterTypeErrorMessage(const char* interfaceName, const char* attributeName)
+{
+    return makeString("The ", interfaceName, '.', attributeName, " getter can only be used on instances of ", interfaceName);
+}
+
+JSC::EncodedJSValue throwGetterTypeError(JSC::ExecState& state, JSC::ThrowScope& scope, const char* interfaceName, const char* attributeName)
+{
+    return throwVMTypeError(&state, scope, makeGetterTypeErrorMessage(interfaceName, attributeName));
+}
+
+JSC::EncodedJSValue rejectPromiseWithGetterTypeError(JSC::ExecState& state, const char* interfaceName, const char* attributeName)
+{
+    return createRejectedPromiseWithTypeError(state, makeGetterTypeErrorMessage(interfaceName, attributeName));
+}
+
+bool throwSetterTypeError(JSC::ExecState& state, JSC::ThrowScope& scope, const char* interfaceName, const char* attributeName)
+{
+    throwTypeError(state, scope, makeString("The ", interfaceName, '.', attributeName, " setter can only be used on instances of ", interfaceName));
+    return false;
+}
+
+String makeThisTypeErrorMessage(const char* interfaceName, const char* functionName)
+{
+    return makeString("Can only call ", interfaceName, '.', functionName, " on instances of ", interfaceName);
+}
+
+EncodedJSValue throwThisTypeError(JSC::ExecState& state, JSC::ThrowScope& scope, const char* interfaceName, const char* functionName)
+{
+    return throwTypeError(state, scope, makeThisTypeErrorMessage(interfaceName, functionName));
+}
+
+JSC::EncodedJSValue rejectPromiseWithThisTypeError(DeferredPromise& promise, const char* interfaceName, const char* methodName)
+{
+    promise.reject(TypeError, makeThisTypeErrorMessage(interfaceName, methodName));
+    return JSValue::encode(jsUndefined());
+}
+
+JSC::EncodedJSValue rejectPromiseWithThisTypeError(JSC::ExecState& state, const char* interfaceName, const char* methodName)
+{
+    return createRejectedPromiseWithTypeError(state, makeThisTypeErrorMessage(interfaceName, methodName));
+}
+
+void throwDOMSyntaxError(JSC::ExecState& state, JSC::ThrowScope& scope)
+{
+    ASSERT(!scope.exception());
+    throwException(&state, scope, createDOMException(&state, SYNTAX_ERR));
+}
+
+void throwDataCloneError(JSC::ExecState& state, JSC::ThrowScope& scope)
+{
+    ASSERT(!scope.exception());
+    throwException(&state, scope, createDOMException(&state, DATA_CLONE_ERR));
+}
+
+void throwIndexSizeError(JSC::ExecState& state, JSC::ThrowScope& scope)
+{
+    ASSERT(!scope.exception());
+    throwException(&state, scope, createDOMException(&state, INDEX_SIZE_ERR));
+}
+
+void throwTypeMismatchError(JSC::ExecState& state, JSC::ThrowScope& scope)
+{
+    ASSERT(!scope.exception());
+    throwException(&state, scope, createDOMException(&state, TYPE_MISMATCH_ERR));
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/bindings/js/JSDOMExceptionHandling.h b/Source/WebCore/bindings/js/JSDOMExceptionHandling.h
new file mode 100644 (file)
index 0000000..459450f
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ *  Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
+ *  Copyright (C) 2003-2006, 2008-2009, 2013, 2016 Apple Inc. All rights reserved.
+ *  Copyright (C) 2007 Samuel Weinig <sam@webkit.org>
+ *  Copyright (C) 2009 Google, Inc. All rights reserved.
+ *  Copyright (C) 2012 Ericsson AB. All rights reserved.
+ *  Copyright (C) 2013 Michael Pruett <michael@68k.org>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#pragma once
+
+#include "ExceptionCode.h"
+#include "ExceptionOr.h"
+#include <runtime/Error.h>
+
+namespace JSC {
+class CatchScope;
+}
+
+namespace WebCore {
+
+class CachedScript;
+class DeferredPromise;
+class JSDOMGlobalObject;
+
+struct ExceptionDetails {
+    String message;
+    int lineNumber { 0 };
+    int columnNumber { 0 };
+    String sourceURL;
+};
+
+WEBCORE_EXPORT JSC::EncodedJSValue reportDeprecatedGetterError(JSC::ExecState&, const char* interfaceName, const char* attributeName);
+WEBCORE_EXPORT void reportDeprecatedSetterError(JSC::ExecState&, const char* interfaceName, const char* attributeName);
+
+void throwAttributeTypeError(JSC::ExecState&, JSC::ThrowScope&, const char* interfaceName, const char* attributeName, const char* expectedType);
+WEBCORE_EXPORT bool throwSetterTypeError(JSC::ExecState&, JSC::ThrowScope&, const char* interfaceName, const char* attributeName);
+
+void throwArrayElementTypeError(JSC::ExecState&, JSC::ThrowScope&);
+void throwDataCloneError(JSC::ExecState&, JSC::ThrowScope&);
+void throwDOMSyntaxError(JSC::ExecState&, JSC::ThrowScope&); // Not the same as a JavaScript syntax error.
+void throwIndexSizeError(JSC::ExecState&, JSC::ThrowScope&);
+void throwInvalidStateError(JSC::ExecState&, JSC::ThrowScope&, const char* message);
+WEBCORE_EXPORT void throwNonFiniteTypeError(JSC::ExecState&, JSC::ThrowScope&);
+void throwNotSupportedError(JSC::ExecState&, JSC::ThrowScope&);
+void throwNotSupportedError(JSC::ExecState&, JSC::ThrowScope&, const char* message);
+void throwSecurityError(JSC::ExecState&, JSC::ThrowScope&, const String& message);
+WEBCORE_EXPORT void throwSequenceTypeError(JSC::ExecState&, JSC::ThrowScope&);
+void throwTypeMismatchError(JSC::ExecState&, JSC::ThrowScope&);
+
+WEBCORE_EXPORT JSC::EncodedJSValue throwArgumentMustBeEnumError(JSC::ExecState&, JSC::ThrowScope&, unsigned argumentIndex, const char* argumentName, const char* functionInterfaceName, const char* functionName, const char* expectedValues);
+JSC::EncodedJSValue throwArgumentMustBeFunctionError(JSC::ExecState&, JSC::ThrowScope&, unsigned argumentIndex, const char* argumentName, const char* functionInterfaceName, const char* functionName);
+WEBCORE_EXPORT JSC::EncodedJSValue throwArgumentTypeError(JSC::ExecState&, JSC::ThrowScope&, unsigned argumentIndex, const char* argumentName, const char* functionInterfaceName, const char* functionName, const char* expectedType);
+WEBCORE_EXPORT JSC::EncodedJSValue throwRequiredMemberTypeError(JSC::ExecState&, JSC::ThrowScope&, const char* memberName, const char* dictionaryName, const char* expectedType);
+JSC::EncodedJSValue throwConstructorScriptExecutionContextUnavailableError(JSC::ExecState&, JSC::ThrowScope&, const char* interfaceName);
+
+String makeGetterTypeErrorMessage(const char* interfaceName, const char* attributeName);
+String makeThisTypeErrorMessage(const char* interfaceName, const char* attributeName);
+
+WEBCORE_EXPORT JSC::EncodedJSValue throwGetterTypeError(JSC::ExecState&, JSC::ThrowScope&, const char* interfaceName, const char* attributeName);
+WEBCORE_EXPORT JSC::EncodedJSValue throwThisTypeError(JSC::ExecState&, JSC::ThrowScope&, const char* interfaceName, const char* functionName);
+
+WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithGetterTypeError(JSC::ExecState&, const char* interfaceName, const char* attributeName);
+WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithThisTypeError(DeferredPromise&, const char* interfaceName, const char* operationName);
+WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithThisTypeError(JSC::ExecState&, const char* interfaceName, const char* operationName);
+
+String retrieveErrorMessage(JSC::ExecState&, JSC::VM&, JSC::JSValue exception, JSC::CatchScope&);
+WEBCORE_EXPORT void reportException(JSC::ExecState*, JSC::JSValue exception, CachedScript* = nullptr);
+WEBCORE_EXPORT void reportException(JSC::ExecState*, JSC::Exception*, CachedScript* = nullptr, ExceptionDetails* = nullptr);
+void reportCurrentException(JSC::ExecState*);
+
+JSC::JSValue createDOMException(JSC::ExecState&, Exception&&);
+JSC::JSValue createDOMException(JSC::ExecState*, ExceptionCode, const String&);
+
+// Convert a DOM implementation exception into a JavaScript exception in the execution state.
+void propagateException(JSC::ExecState&, JSC::ThrowScope&, Exception&&);
+WEBCORE_EXPORT void propagateExceptionSlowPath(JSC::ExecState&, JSC::ThrowScope&, Exception&&);
+
+// ExceptionOr handling.
+void propagateException(JSC::ExecState&, JSC::ThrowScope&, ExceptionOr<void>&&);
+template<typename T> JSC::JSValue toJS(JSC::ExecState&, JSDOMGlobalObject&, JSC::ThrowScope&, ExceptionOr<T>&&);
+template<typename T> JSC::JSValue toJSNewlyCreated(JSC::ExecState&, JSDOMGlobalObject&, JSC::ThrowScope&, ExceptionOr<T>&& value);
+
+
+ALWAYS_INLINE void propagateException(JSC::ExecState& state, JSC::ThrowScope& throwScope, Exception&& exception)
+{
+    if (throwScope.exception())
+        return;
+    propagateExceptionSlowPath(state, throwScope, WTFMove(exception));
+}
+
+inline void propagateException(JSC::ExecState& state, JSC::ThrowScope& throwScope, ExceptionOr<void>&& value)
+{
+    if (UNLIKELY(value.hasException()))
+        propagateException(state, throwScope, value.releaseException());
+}
+
+template<typename T> inline JSC::JSValue toJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, JSC::ThrowScope& throwScope, ExceptionOr<T>&& value)
+{
+    if (UNLIKELY(value.hasException())) {
+        propagateException(state, throwScope, value.releaseException());
+        return { };
+    }
+    return toJS(&state, &globalObject, value.releaseReturnValue());
+}
+
+template<typename T> inline JSC::JSValue toJSNewlyCreated(JSC::ExecState& state, JSDOMGlobalObject& globalObject, JSC::ThrowScope& throwScope, ExceptionOr<T>&& value)
+{
+    if (UNLIKELY(value.hasException())) {
+        propagateException(state, throwScope, value.releaseException());
+        return { };
+    }
+    return toJSNewlyCreated(&state, &globalObject, value.releaseReturnValue());
+}
+
+} // namespace WebCore
index 80f5f23..20228b9 100644 (file)
@@ -30,6 +30,7 @@
 #include "DOMWindow.h"
 #include "Frame.h"
 #include "InspectorController.h"
+#include "JSDOMBindingSecurity.h"
 #include "JSDOMGlobalObjectTask.h"
 #include "JSDOMWindowCustom.h"
 #include "JSMainThreadExecState.h"
@@ -286,6 +287,54 @@ JSDOMWindow* toJSDOMWindow(JSC::VM& vm, JSValue value)
     return 0;
 }
 
+DOMWindow& callerDOMWindow(ExecState* exec)
+{
+    class GetCallerGlobalObjectFunctor {
+    public:
+        GetCallerGlobalObjectFunctor() = default;
+
+        StackVisitor::Status operator()(StackVisitor& visitor) const
+        {
+            if (!m_hasSkippedFirstFrame) {
+                m_hasSkippedFirstFrame = true;
+                return StackVisitor::Continue;
+            }
+
+            if (auto* codeBlock = visitor->codeBlock())
+                m_globalObject = codeBlock->globalObject();
+            else {
+                ASSERT(visitor->callee());
+                // FIXME: Callee is not an object if the caller is Web Assembly.
+                // Figure out what to do here. We can probably get the global object
+                // from the top-most Wasm Instance. https://bugs.webkit.org/show_bug.cgi?id=165721
+                if (visitor->callee()->isObject())
+                    m_globalObject = jsCast<JSObject*>(visitor->callee())->globalObject();
+            }
+            return StackVisitor::Done;
+        }
+
+        JSGlobalObject* globalObject() const { return m_globalObject; }
+
+    private:
+        mutable bool m_hasSkippedFirstFrame { false };
+        mutable JSGlobalObject* m_globalObject { nullptr };
+    };
+
+    GetCallerGlobalObjectFunctor iter;
+    exec->iterate(iter);
+    return iter.globalObject() ? asJSDOMWindow(iter.globalObject())->wrapped() : firstDOMWindow(exec);
+}
+
+DOMWindow& activeDOMWindow(ExecState* exec)
+{
+    return asJSDOMWindow(exec->lexicalGlobalObject())->wrapped();
+}
+
+DOMWindow& firstDOMWindow(ExecState* exec)
+{
+    return asJSDOMWindow(exec->vmEntryGlobalObject())->wrapped();
+}
+
 void JSDOMWindowBase::fireFrameClearedWatchpointsForWindow(DOMWindow* window)
 {
     JSC::VM& vm = commonVM();
index 9073837..19c3da4 100644 (file)
@@ -97,4 +97,8 @@ namespace WebCore {
     JSDOMWindow* toJSDOMWindow(Frame*, DOMWrapperWorld&);
     WEBCORE_EXPORT JSDOMWindow* toJSDOMWindow(JSC::VM&, JSC::JSValue);
 
+    DOMWindow& callerDOMWindow(JSC::ExecState*);
+    DOMWindow& activeDOMWindow(JSC::ExecState*);
+    DOMWindow& firstDOMWindow(JSC::ExecState*);
+
 } // namespace WebCore
index 281dcdd..66dfe6d 100644 (file)
@@ -25,6 +25,7 @@
 #include "Frame.h"
 #include "HTMLCollection.h"
 #include "HTMLDocument.h"
+#include "JSDOMBindingSecurity.h"
 #include "JSEvent.h"
 #include "JSEventListener.h"
 #include "JSHTMLAudioElement.h"
index 412bb0f..c364f2f 100644 (file)
@@ -29,6 +29,7 @@
 #include "Frame.h"
 #include "HTMLDocument.h"
 #include "JSDOMBinding.h"
+#include "JSDOMBindingSecurity.h"
 #include "JSDOMWindowBase.h"
 #include "JSElement.h"
 #include "JSHTMLCollection.h"
diff --git a/Source/WebCore/bindings/js/JSDOMWrapperCache.cpp b/Source/WebCore/bindings/js/JSDOMWrapperCache.cpp
new file mode 100644 (file)
index 0000000..6d875d5
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ *  Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
+ *  Copyright (C) 2004-2011, 2013, 2016 Apple Inc. All rights reserved.
+ *  Copyright (C) 2007 Samuel Weinig <sam@webkit.org>
+ *  Copyright (C) 2013 Michael Pruett <michael@68k.org>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#include "JSDOMWrapperCache.h"
+
+#include <runtime/JSCInlines.h>
+
+using namespace JSC;
+
+namespace WebCore {
+
+Structure* getCachedDOMStructure(JSDOMGlobalObject& globalObject, const ClassInfo* classInfo)
+{
+    JSDOMStructureMap& structures = globalObject.structures(NoLockingNecessary);
+    return structures.get(classInfo).get();
+}
+
+Structure* cacheDOMStructure(JSDOMGlobalObject& globalObject, Structure* structure, const ClassInfo* classInfo)
+{
+    auto locker = lockDuringMarking(globalObject.vm().heap, globalObject.gcLock());
+    JSDOMStructureMap& structures = globalObject.structures(locker);
+    ASSERT(!structures.contains(classInfo));
+    return structures.set(classInfo, WriteBarrier<Structure>(globalObject.vm(), &globalObject, structure)).iterator->value.get();
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/bindings/js/JSDOMWrapperCache.h b/Source/WebCore/bindings/js/JSDOMWrapperCache.h
new file mode 100644 (file)
index 0000000..dd8c4b2
--- /dev/null
@@ -0,0 +1,206 @@
+/*
+ *  Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
+ *  Copyright (C) 2003-2006, 2008-2009, 2013, 2016 Apple Inc. All rights reserved.
+ *  Copyright (C) 2007 Samuel Weinig <sam@webkit.org>
+ *  Copyright (C) 2009 Google, Inc. All rights reserved.
+ *  Copyright (C) 2012 Ericsson AB. All rights reserved.
+ *  Copyright (C) 2013 Michael Pruett <michael@68k.org>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#pragma once
+
+#include "DOMWrapperWorld.h"
+#include "JSDOMGlobalObject.h"
+#include "JSDOMWrapper.h"
+#include "JSDynamicDowncast.h"
+#include "ScriptWrappable.h"
+#include "ScriptWrappableInlines.h"
+#include "WebCoreTypedArrayController.h"
+#include <heap/Weak.h>
+#include <heap/WeakInlines.h>
+#include <runtime/JSArrayBuffer.h>
+#include <runtime/TypedArrayInlines.h>
+#include <runtime/TypedArrays.h>
+
+namespace WebCore {
+
+WEBCORE_EXPORT JSC::Structure* getCachedDOMStructure(JSDOMGlobalObject&, const JSC::ClassInfo*);
+WEBCORE_EXPORT JSC::Structure* cacheDOMStructure(JSDOMGlobalObject&, JSC::Structure*, const JSC::ClassInfo*);
+
+template<typename WrapperClass> JSC::Structure* getDOMStructure(JSC::VM&, JSDOMGlobalObject&);
+template<typename WrapperClass> JSC::Structure* deprecatedGetDOMStructure(JSC::ExecState*);
+template<typename WrapperClass> JSC::JSObject* getDOMPrototype(JSC::VM&, JSC::JSGlobalObject*);
+
+JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld&, JSC::ArrayBuffer*);
+void* wrapperKey(JSC::ArrayBuffer*);
+
+JSDOMObject* getInlineCachedWrapper(DOMWrapperWorld&, void*);
+JSDOMObject* getInlineCachedWrapper(DOMWrapperWorld&, ScriptWrappable*);
+JSC::JSArrayBuffer* getInlineCachedWrapper(DOMWrapperWorld&, JSC::ArrayBuffer*);
+
+bool setInlineCachedWrapper(DOMWrapperWorld&, void*, JSDOMObject*, JSC::WeakHandleOwner*);
+bool setInlineCachedWrapper(DOMWrapperWorld&, ScriptWrappable*, JSDOMObject* wrapper, JSC::WeakHandleOwner* wrapperOwner);
+bool setInlineCachedWrapper(DOMWrapperWorld&, JSC::ArrayBuffer*, JSC::JSArrayBuffer* wrapper, JSC::WeakHandleOwner* wrapperOwner);
+
+bool clearInlineCachedWrapper(DOMWrapperWorld&, void*, JSDOMObject*);
+bool clearInlineCachedWrapper(DOMWrapperWorld&, ScriptWrappable*, JSDOMObject* wrapper);
+bool clearInlineCachedWrapper(DOMWrapperWorld&, JSC::ArrayBuffer*, JSC::JSArrayBuffer* wrapper);
+
+template<typename DOMClass> JSC::JSObject* getCachedWrapper(DOMWrapperWorld&, DOMClass&);
+template<typename DOMClass> inline JSC::JSObject* getCachedWrapper(DOMWrapperWorld& world, Ref<DOMClass>& object) { return getCachedWrapper(world, object.get()); }
+template<typename DOMClass, typename WrapperClass> void cacheWrapper(DOMWrapperWorld&, DOMClass*, WrapperClass*);
+template<typename DOMClass, typename WrapperClass> void uncacheWrapper(DOMWrapperWorld&, DOMClass*, WrapperClass*);
+template<typename DOMClass, typename T> auto createWrapper(JSDOMGlobalObject*, Ref<T>&&) -> typename std::enable_if<std::is_same<DOMClass, T>::value, typename JSDOMWrapperConverterTraits<DOMClass>::WrapperClass*>::type;
+template<typename DOMClass, typename T> auto createWrapper(JSDOMGlobalObject*, Ref<T>&&) -> typename std::enable_if<!std::is_same<DOMClass, T>::value, typename JSDOMWrapperConverterTraits<DOMClass>::WrapperClass*>::type;
+
+template<typename DOMClass> JSC::JSValue wrap(JSC::ExecState*, JSDOMGlobalObject*, DOMClass&);
+
+
+// Inline functions and template definitions.
+
+inline JSDOMGlobalObject* deprecatedGlobalObjectForPrototype(JSC::ExecState* exec)
+{
+    // FIXME: Callers to this function should be using the global object
+    // from which the object is being created, instead of assuming the lexical one.
+    // e.g. subframe.document.body should use the subframe's global object, not the lexical one.
+    return JSC::jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject());
+}
+
+template<typename WrapperClass> inline JSC::Structure* getDOMStructure(JSC::VM& vm, JSDOMGlobalObject& globalObject)
+{
+    if (JSC::Structure* structure = getCachedDOMStructure(globalObject, WrapperClass::info()))
+        return structure;
+    return cacheDOMStructure(globalObject, WrapperClass::createStructure(vm, &globalObject, WrapperClass::createPrototype(vm, &globalObject)), WrapperClass::info());
+}
+
+template<typename WrapperClass> inline JSC::Structure* deprecatedGetDOMStructure(JSC::ExecState* exec)
+{
+    // FIXME: This function is wrong. It uses the wrong global object for creating the prototype structure.
+    return getDOMStructure<WrapperClass>(exec->vm(), *deprecatedGlobalObjectForPrototype(exec));
+}
+
+template<typename WrapperClass> inline JSC::JSObject* getDOMPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
+{
+    return JSC::jsCast<JSC::JSObject*>(asObject(getDOMStructure<WrapperClass>(vm, *JSC::jsCast<JSDOMGlobalObject*>(globalObject))->storedPrototype()));
+}
+
+inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld& world, JSC::ArrayBuffer*)
+{
+    return static_cast<WebCoreTypedArrayController*>(world.vm().m_typedArrayController.get())->wrapperOwner();
+}
+
+inline void* wrapperKey(JSC::ArrayBuffer* domObject)
+{
+    return domObject;
+}
+
+inline JSDOMObject* getInlineCachedWrapper(DOMWrapperWorld&, void*) { return nullptr; }
+inline bool setInlineCachedWrapper(DOMWrapperWorld&, void*, JSDOMObject*, JSC::WeakHandleOwner*) { return false; }
+inline bool clearInlineCachedWrapper(DOMWrapperWorld&, void*, JSDOMObject*) { return false; }
+
+inline JSDOMObject* getInlineCachedWrapper(DOMWrapperWorld& world, ScriptWrappable* domObject)
+{
+    if (!world.isNormal())
+        return nullptr;
+    return domObject->wrapper();
+}
+
+inline JSC::JSArrayBuffer* getInlineCachedWrapper(DOMWrapperWorld& world, JSC::ArrayBuffer* buffer)
+{
+    if (!world.isNormal())
+        return nullptr;
+    return buffer->m_wrapper.get();
+}
+
+inline bool setInlineCachedWrapper(DOMWrapperWorld& world, ScriptWrappable* domObject, JSDOMObject* wrapper, JSC::WeakHandleOwner* wrapperOwner)
+{
+    if (!world.isNormal())
+        return false;
+    domObject->setWrapper(wrapper, wrapperOwner, &world);
+    return true;
+}
+
+inline bool setInlineCachedWrapper(DOMWrapperWorld& world, JSC::ArrayBuffer* domObject, JSC::JSArrayBuffer* wrapper, JSC::WeakHandleOwner* wrapperOwner)
+{
+    if (!world.isNormal())
+        return false;
+    domObject->m_wrapper = JSC::Weak<JSC::JSArrayBuffer>(wrapper, wrapperOwner, &world);
+    return true;
+}
+
+inline bool clearInlineCachedWrapper(DOMWrapperWorld& world, ScriptWrappable* domObject, JSDOMObject* wrapper)
+{
+    if (!world.isNormal())
+        return false;
+    domObject->clearWrapper(wrapper);
+    return true;
+}
+
+inline bool clearInlineCachedWrapper(DOMWrapperWorld& world, JSC::ArrayBuffer* domObject, JSC::JSArrayBuffer* wrapper)
+{
+    if (!world.isNormal())
+        return false;
+    weakClear(domObject->m_wrapper, wrapper);
+    return true;
+}
+
+template<typename DOMClass> inline JSC::JSObject* getCachedWrapper(DOMWrapperWorld& world, DOMClass& domObject)
+{
+    if (auto* wrapper = getInlineCachedWrapper(world, &domObject))
+        return wrapper;
+    return world.m_wrappers.get(wrapperKey(&domObject));
+}
+
+template<typename DOMClass, typename WrapperClass> inline void cacheWrapper(DOMWrapperWorld& world, DOMClass* domObject, WrapperClass* wrapper)
+{
+    JSC::WeakHandleOwner* owner = wrapperOwner(world, domObject);
+    if (setInlineCachedWrapper(world, domObject, wrapper, owner))
+        return;
+    weakAdd(world.m_wrappers, wrapperKey(domObject), JSC::Weak<JSC::JSObject>(wrapper, owner, &world));
+}
+
+template<typename DOMClass, typename WrapperClass> inline void uncacheWrapper(DOMWrapperWorld& world, DOMClass* domObject, WrapperClass* wrapper)
+{
+    if (clearInlineCachedWrapper(world, domObject, wrapper))
+        return;
+    weakRemove(world.m_wrappers, wrapperKey(domObject), wrapper);
+}
+
+template<typename DOMClass, typename T> inline auto createWrapper(JSDOMGlobalObject* globalObject, Ref<T>&& domObject) -> typename std::enable_if<std::is_same<DOMClass, T>::value, typename JSDOMWrapperConverterTraits<DOMClass>::WrapperClass*>::type
+{
+    using WrapperClass = typename JSDOMWrapperConverterTraits<DOMClass>::WrapperClass;
+
+    ASSERT(!getCachedWrapper(globalObject->world(), domObject));
+    auto* domObjectPtr = domObject.ptr();
+    auto* wrapper = WrapperClass::create(getDOMStructure<WrapperClass>(globalObject->vm(), *globalObject), globalObject, WTFMove(domObject));
+    cacheWrapper(globalObject->world(), domObjectPtr, wrapper);
+    return wrapper;
+}
+
+template<typename DOMClass, typename T> inline auto createWrapper(JSDOMGlobalObject* globalObject, Ref<T>&& domObject) -> typename std::enable_if<!std::is_same<DOMClass, T>::value, typename JSDOMWrapperConverterTraits<DOMClass>::WrapperClass*>::type
+{
+    return createWrapper<DOMClass>(globalObject, static_reference_cast<DOMClass>(WTFMove(domObject)));
+}
+
+template<typename DOMClass> inline JSC::JSValue wrap(JSC::ExecState* state, JSDOMGlobalObject* globalObject, DOMClass& domObject)
+{
+    if (auto* wrapper = getCachedWrapper(globalObject->world(), domObject))
+        return wrapper;
+    return toJSNewlyCreated(state, globalObject, Ref<DOMClass>(domObject));
+}
+
+} // namespace WebCore
index 9d8d718..7f55358 100644 (file)
@@ -27,6 +27,8 @@
 
 #include "DOMWindow.h"
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
+#include "JSDOMBindingSecurity.h"
 
 namespace WebCore {
 
index 0026ce1..b88a9ca 100644 (file)
@@ -31,6 +31,7 @@
 #include "Document.h"
 #include "HTMLFormElement.h"
 #include "JSCustomElementInterface.h"
+#include "JSDOMConstructor.h"
 #include "JSNodeCustom.h"
 #include "ScriptExecutionContext.h"
 #include <runtime/InternalFunction.h>
index a342584..cbb4e75 100644 (file)
@@ -24,6 +24,8 @@
 #include "JSLocation.h"
 
 #include "JSDOMBinding.h"
+#include "JSDOMBindingSecurity.h"
+#include "JSDOMExceptionHandling.h"
 #include "RuntimeApplicationChecks.h"
 #include <runtime/JSFunction.h>
 
index 3f34df3..cce61c1 100644 (file)
@@ -33,6 +33,7 @@
 #include "JSMutationObserver.h"
 
 #include "ExceptionCode.h"
+#include "JSDOMConstructor.h"
 #include "JSMutationCallback.h"
 #include "JSNodeCustom.h"
 #include "MutationObserver.h"
index 3c95d42..0030f01 100644 (file)
@@ -29,6 +29,7 @@
 #include "config.h"
 #include "JSSQLStatementErrorCallback.h"
 
+#include "JSDOMExceptionHandling.h"
 #include "JSSQLError.h"
 #include "JSSQLTransaction.h"
 #include "ScriptExecutionContext.h"
index 6a2c46c..ed28913 100644 (file)
@@ -27,6 +27,7 @@
 #include "JSStorage.h"
 
 #include "JSDOMBinding.h"
+#include "JSDOMExceptionHandling.h"
 #include <runtime/IdentifierInlines.h>
 #include <runtime/PropertyNameArray.h>
 #include <wtf/text/WTFString.h>
index 867313b..e25b35e 100644 (file)
@@ -28,7 +28,8 @@
 #include "JSWorker.h"
 
 #include "Document.h"
-#include "JSDOMBinding.h"
+#include "JSDOMConstructor.h"
+#include "JSDOMExceptionHandling.h"
 #include "JSDOMGlobalObject.h"
 #include "JSDOMWindowCustom.h"
 #include "Worker.h"
index c7929d1..8c1761c 100644 (file)
@@ -27,7 +27,7 @@
 #include "JSXPathNSResolver.h"
 
 #include "JSCustomXPathNSResolver.h"
-#include "JSDOMBinding.h"
+#include "JSDOMExceptionHandling.h"
 
 using namespace JSC;
 
index 908f4dc..9333266 100644 (file)
@@ -29,7 +29,7 @@
 #include "Document.h"
 #include "Frame.h"
 #include "FrameLoader.h"
-#include "JSDOMBinding.h"
+#include "JSDOMExceptionHandling.h"
 #include "JSDOMWindow.h"
 #include "JSMainThreadExecState.h"
 #include "JSMainThreadExecStateInstrumentation.h"
index adbeaff..d092780 100644 (file)
@@ -32,6 +32,8 @@
 #include "GCController.h"
 #include "HTMLPlugInElement.h"
 #include "InspectorInstrumentation.h"
+#include "JSDOMBindingSecurity.h"
+#include "JSDOMExceptionHandling.h"
 #include "JSDOMWindow.h"
 #include "JSDocument.h"
 #include "JSMainThreadExecState.h"
index da423e7..93abeee 100644 (file)
@@ -56,11 +56,12 @@ class Frame;
 class HTMLDocument;
 class HTMLPlugInElement;
 class LoadableModuleScript;
-class SecurityOrigin;
 class ScriptSourceCode;
+class SecurityOrigin;
 class Widget;
+struct ExceptionDetails;
 
-typedef HashMap<void*, RefPtr<JSC::Bindings::RootObject>> RootObjectMap;
+using RootObjectMap = HashMap<void*, RefPtr<JSC::Bindings::RootObject>>;
 
 enum ReasonForCallingCanExecuteScripts {
     AboutToExecuteScript,
index 6f226c0..2275ff9 100644 (file)
@@ -31,7 +31,8 @@
 #include "config.h"
 #include "ScriptGlobalObject.h"
 
-#include "JSDOMBinding.h"
+#include "JSDOMConvert.h"
+#include "JSDOMExceptionHandling.h"
 #include "JSInspectorFrontendHost.h"
 #include <runtime/IdentifierInlines.h>
 
@@ -45,7 +46,7 @@ bool ScriptGlobalObject::set(ExecState& scriptState, const char* name, Inspector
     JSLockHolder lock(vm);
     auto scope = DECLARE_CATCH_SCOPE(vm);
     auto& globalObject = *jsCast<JSDOMGlobalObject*>(scriptState.lexicalGlobalObject());
-    globalObject.putDirect(vm, Identifier::fromString(&vm, name), toJS(&scriptState, &globalObject, value));
+    globalObject.putDirect(vm, Identifier::fromString(&vm, name), toJS<IDLInterface<InspectorFrontendHost>>(scriptState, globalObject, value));
     if (UNLIKELY(scope.exception())) {
         reportException(&scriptState, scope.exception());
         return false;
index 1d231c2..4869ac0 100644 (file)
@@ -28,6 +28,7 @@
 #include "StructuredClone.h"
 
 #include "JSDOMBinding.h"
+#include "JSDOMExceptionHandling.h"
 #include <runtime/JSTypedArrays.h>
 
 using namespace JSC;
index 7121bdc..e2ab7ed 100644 (file)
@@ -3013,6 +3013,9 @@ sub GenerateImplementation
     push(@implContentHeader, GenerateImplementationContentHeader($interface));
 
     $implIncludes{"JSDOMBinding.h"} = 1;
+    $implIncludes{"JSDOMBindingCaller.h"} = 1;
+    $implIncludes{"JSDOMExceptionHandling.h"} = 1;
+    $implIncludes{"JSDOMWrapperCache.h"} = 1;
     $implIncludes{"<wtf/GetPtr.h>"} = 1;
     $implIncludes{"<runtime/PropertyNameArray.h>"} = 1 if $indexedGetterFunction;
 
@@ -3633,6 +3636,7 @@ sub GenerateImplementation
             if ($interface->extendedAttributes->{CheckSecurity} &&
                 !$attribute->extendedAttributes->{DoNotCheckSecurity} &&
                 !$attribute->extendedAttributes->{DoNotCheckSecurityOnGetter}) {
+                AddToImplIncludes("JSDOMBindingSecurity.h");
                 if ($interfaceName eq "DOMWindow") {
                     push(@implContent, "    if (!BindingSecurity::shouldAllowAccessToDOMWindow(&state, thisObject.wrapped(), ThrowSecurityError))\n");
                 } else {
@@ -3803,6 +3807,7 @@ sub GenerateImplementation
             }
 
             if ($interface->extendedAttributes->{CheckSecurity} && !$attribute->extendedAttributes->{DoNotCheckSecurity} && !$attribute->extendedAttributes->{DoNotCheckSecurityOnSetter}) {
+                AddToImplIncludes("JSDOMBindingSecurity.h");
                 if ($interfaceName eq "DOMWindow") {
                     push(@implContent, "    if (!BindingSecurity::shouldAllowAccessToDOMWindow(&state, thisObject.wrapped(), ThrowSecurityError))\n");
                 } else {
@@ -4051,6 +4056,7 @@ END
                 push(@implContent, "    UNUSED_PARAM(throwScope);\n");
 
                 if ($interface->extendedAttributes->{CheckSecurity} and !$function->extendedAttributes->{DoNotCheckSecurity}) {
+                    AddToImplIncludes("JSDOMBindingSecurity.h");
                     if ($interfaceName eq "DOMWindow") {
                         push(@implContent, "    if (!BindingSecurity::shouldAllowAccessToDOMWindow(state, castedThis->wrapped(), ThrowSecurityError))\n");
                     } else {
@@ -4477,6 +4483,7 @@ sub GenerateCallWith
     }
     if ($codeGenerator->ExtendedAttributeContains($callWith, "CallerDocument")) {
         $implIncludes{"Document.h"} = 1;
+        $implIncludes{"JSDOMWindowBase.h"} = 1;
         push(@$outputArray, "    auto* document = callerDOMWindow($statePointer).document();\n");
         push(@$outputArray, "    if (!document)\n");
         push(@$outputArray, "        return" . ($returnValue ? " " . $returnValue : "") . ";\n");
@@ -4488,9 +4495,21 @@ sub GenerateCallWith
         $implIncludes{"<inspector/ScriptCallStackFactory.h>"} = 1;
         push(@callWithArgs, "WTFMove(scriptArguments)");
     }
-    push(@callWithArgs, "activeDOMWindow($statePointer)") if $codeGenerator->ExtendedAttributeContains($callWith, "ActiveWindow");
-    push(@callWithArgs, "firstDOMWindow($statePointer)") if $codeGenerator->ExtendedAttributeContains($callWith, "FirstWindow");
-    push(@callWithArgs, "callerDOMWindow($statePointer)") if $codeGenerator->ExtendedAttributeContains($callWith, "CallerWindow");
+    if ($codeGenerator->ExtendedAttributeContains($callWith, "ActiveWindow")) {
+        $implIncludes{"JSDOMWindowBase.h"} = 1;
+        push(@callWithArgs, "activeDOMWindow($statePointer)");
+        
+    }
+    if ($codeGenerator->ExtendedAttributeContains($callWith, "FirstWindow")) {
+        $implIncludes{"JSDOMWindowBase.h"} = 1;
+        push(@callWithArgs, "firstDOMWindow($statePointer)");
+        
+    }
+    if ($codeGenerator->ExtendedAttributeContains($callWith, "CallerWindow")) {
+        $implIncludes{"JSDOMWindowBase.h"} = 1;
+        push(@callWithArgs, "callerDOMWindow($statePointer)");
+        
+    }
 
     return @callWithArgs;
 }
@@ -4599,8 +4618,6 @@ sub GenerateParametersCheck
         $quotedFunctionName = "nullptr";
     }
 
-    AddToImplIncludes("JSDOMBinding.h", $conditional);
-
     my $argumentIndex = 0;
     foreach my $argument (@{$function->arguments}) {
         my $type = $argument->type;
@@ -5064,6 +5081,7 @@ sub GenerateCallbackImplementationContent
 
             # FIXME: We currently just report the exception. We should probably add an extended attribute to indicate when
             # we want the exception to be rethrown instead.
+            $includesRef->{"JSDOMExceptionHandling.h"} = 1;
             push(@$contentRef, "    if (returnedException)\n");
             push(@$contentRef, "        reportException(state, returnedException);\n");
             push(@$contentRef, "    return !returnedException;\n");
@@ -5612,7 +5630,10 @@ sub NativeToJSValue
     AddToImplIncludesForIDLType($type, $conditional);
     AddToImplIncludes("JSDOMConvert.h", $conditional);
 
-    $value = "BindingSecurity::checkSecurityForNode($stateReference, $value)" if $context->extendedAttributes->{CheckSecurityForNode};
+    if ($context->extendedAttributes->{CheckSecurityForNode}) {
+        AddToImplIncludes("JSDOMBindingSecurity.h", $conditional);
+        $value = "BindingSecurity::checkSecurityForNode($stateReference, $value)";
+    }
 
     my $IDLType = GetIDLType($interface, $type, $context);
 
index 06bbd86..2307cbc 100644 (file)
 #include "JSInterfaceName.h"
 
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
 #include "JSDOMConstructor.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWrapperCache.h"
 #include <runtime/FunctionPrototype.h>
 #include <wtf/GetPtr.h>
 
index 388c3d3..2d1a43a 100644 (file)
 #include "JSTestActiveDOMObject.h"
 
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
+#include "JSDOMBindingSecurity.h"
 #include "JSDOMConstructor.h"
 #include "JSDOMConvert.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWrapperCache.h"
 #include "JSNode.h"
 #include <runtime/Error.h>
 #include <runtime/FunctionPrototype.h>
index 1a24548..9ebc30e 100644 (file)
 #include "CustomElementReactionQueue.h"
 #include "HTMLNames.h"
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
 #include "JSDOMConstructor.h"
 #include "JSDOMConvert.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWrapperCache.h"
 #include "JSTestCEReactionsStringifier.h"
 #include <runtime/Error.h>
 #include <runtime/FunctionPrototype.h>
index 40b15e7..4a4f9ce 100644 (file)
 
 #include "CustomElementReactionQueue.h"
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
 #include "JSDOMConstructor.h"
 #include "JSDOMConvert.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWrapperCache.h"
 #include <runtime/Error.h>
 #include <runtime/FunctionPrototype.h>
 #include <wtf/GetPtr.h>
index 34fc203..1ea108f 100644 (file)
@@ -25,6 +25,7 @@
 #include "JSTestCallbackFunction.h"
 
 #include "JSDOMConvert.h"
+#include "JSDOMExceptionHandling.h"
 #include "JSTestNode.h"
 #include "ScriptExecutionContext.h"
 #include "SerializedScriptValue.h"
index 5b3bd57..a89ac0d 100644 (file)
@@ -22,6 +22,7 @@
 #include "JSTestCallbackFunctionWithTypedefs.h"
 
 #include "JSDOMConvert.h"
+#include "JSDOMExceptionHandling.h"
 #include "ScriptExecutionContext.h"
 #include <runtime/JSArray.h>
 #include <runtime/JSLock.h>
index 7e15084..ac59482 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "JSDOMConstructor.h"
 #include "JSDOMConvert.h"
+#include "JSDOMExceptionHandling.h"
 #include "JSDOMStringList.h"
 #include "JSTestNode.h"
 #include "ScriptExecutionContext.h"
index 5e0d7c1..8cb92eb 100644 (file)
 #include "JSTestClassWithJSBuiltinConstructor.h"
 
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
 #include "JSDOMConstructor.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWrapperCache.h"
 #include "TestClassWithJSBuiltinConstructorBuiltins.h"
 #include <runtime/FunctionPrototype.h>
 #include <wtf/GetPtr.h>
index 3f61013..ab6bfe9 100644 (file)
 #include "JSTestCustomConstructorWithNoInterfaceObject.h"
 
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
 #include "JSDOMConstructor.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWrapperCache.h"
 #include <runtime/FunctionPrototype.h>
 #include <wtf/GetPtr.h>
 
index 6280605..0bbe107 100644 (file)
 #include "JSTestCustomNamedGetter.h"
 
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
 #include "JSDOMConstructor.h"
 #include "JSDOMConvert.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWrapperCache.h"
 #include <runtime/Error.h>
 #include <runtime/FunctionPrototype.h>
 #include <wtf/GetPtr.h>
index f933e66..f5aad29 100644 (file)
 #include "DOMJITIDLType.h"
 #include "DOMJITIDLTypeFilter.h"
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
 #include "JSDOMConstructor.h"
 #include "JSDOMConvert.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWrapperCache.h"
 #include "JSElement.h"
 #include "JSNodeList.h"
 #include <interpreter/FrameTracers.h>
index 3218c0e..51c10fe 100644 (file)
 #include "JSTestEventConstructor.h"
 
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
 #include "JSDOMConstructor.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWrapperCache.h"
 #include <runtime/Error.h>
 #include <wtf/GetPtr.h>
 
index 6e0ef7f..bb36d65 100644 (file)
 #include "JSTestEventTarget.h"
 
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
 #include "JSDOMConstructor.h"
 #include "JSDOMConvert.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWrapperCache.h"
 #include "JSNode.h"
 #include <runtime/Error.h>
 #include <runtime/PropertyNameArray.h>
index 4db499d..6fe5c7f 100644 (file)
 #include "JSTestException.h"
 
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
 #include "JSDOMConstructor.h"
 #include "JSDOMConvert.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWrapperCache.h"
 #include <runtime/FunctionPrototype.h>
 #include <wtf/GetPtr.h>
 
index 8749caf..0285ec0 100644 (file)
 #include "JSTestGenerateIsReachable.h"
 
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
 #include "JSDOMConstructor.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWrapperCache.h"
 #include <runtime/FunctionPrototype.h>
 #include <wtf/GetPtr.h>
 
index 0abd310..9a6ae32 100644 (file)
 #include "JSTestGlobalObject.h"
 
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
 #include "JSDOMConstructor.h"
 #include "JSDOMConvert.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWrapperCache.h"
 #include "RuntimeEnabledFeatures.h"
 #include "WebCoreJSClientData.h"
 #include <runtime/Error.h>
index b0f31fa..033a61e 100644 (file)
 #include "JSTestInterface.h"
 
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
 #include "JSDOMConstructor.h"
 #include "JSDOMConvert.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWrapperCache.h"
 #include "JSTestObj.h"
 #include "TestSupplemental.h"
 #include <runtime/Error.h>
index b2f7652..a205670 100644 (file)
 #include "JSTestInterfaceLeadingUnderscore.h"
 
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
 #include "JSDOMConstructor.h"
 #include "JSDOMConvert.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWrapperCache.h"
 #include <runtime/FunctionPrototype.h>
 #include <wtf/GetPtr.h>
 
index 4daf1a6..29dd36e 100644 (file)
 #include "JSTestIterable.h"
 
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
 #include "JSDOMConstructor.h"
+#include "JSDOMExceptionHandling.h"
 #include "JSDOMIterator.h"
+#include "JSDOMWrapperCache.h"
 #include <runtime/FunctionPrototype.h>
 #include <wtf/GetPtr.h>
 
index aeb607e..1c1ddb8 100644 (file)
 #include "JSTestJSBuiltinConstructor.h"
 
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
 #include "JSDOMConstructor.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWrapperCache.h"
 #include "TestJSBuiltinConstructorBuiltins.h"
 #include <runtime/Error.h>
 #include <runtime/FunctionPrototype.h>
index 4bd6410..34f8708 100644 (file)
 #include "JSTestMediaQueryListListener.h"
 
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
 #include "JSDOMConstructor.h"
 #include "JSDOMConvert.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWrapperCache.h"
 #include "JSMediaQueryListListener.h"
 #include <runtime/Error.h>
 #include <runtime/FunctionPrototype.h>
index 487bfcb..1db99bb 100644 (file)
 #include "JSTestNamedConstructor.h"
 
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
 #include "JSDOMConstructor.h"
 #include "JSDOMConvert.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWrapperCache.h"
 #include <runtime/Error.h>
 #include <runtime/FunctionPrototype.h>
 #include <wtf/GetPtr.h>
index da28d7f..cd1bb16 100644 (file)
 #include "JSTestNode.h"
 
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
 #include "JSDOMConstructor.h"
 #include "JSDOMConvert.h"
+#include "JSDOMExceptionHandling.h"
 #include "JSDOMIterator.h"
 #include "JSDOMPromise.h"
+#include "JSDOMWrapperCache.h"
 #include "RuntimeEnabledFeatures.h"
 #include <runtime/Error.h>
 #include <runtime/ObjectConstructor.h>
index 0c67a66..bd8861d 100644 (file)
 #include "HTMLNames.h"
 #include "JSBlob.h"
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
+#include "JSDOMBindingSecurity.h"
 #include "JSDOMConstructor.h"
+#include "JSDOMExceptionHandling.h"
 #include "JSDOMIterator.h"
 #include "JSDOMPromise.h"
 #include "JSDOMStringList.h"
 #include "JSDOMWindow.h"
+#include "JSDOMWindowBase.h"
 #include "JSDOMWindowShell.h"
+#include "JSDOMWrapperCache.h"
 #include "JSDocument.h"
 #include "JSElement.h"
 #include "JSEventListener.h"
index dfa1edb..1ac8383 100644 (file)
 
 #include "JSBlob.h"
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
 #include "JSDOMConstructor.h"
 #include "JSDOMConvert.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWrapperCache.h"
 #include <runtime/Error.h>
 #include <runtime/FunctionPrototype.h>
 #include <wtf/GetPtr.h>
index fecd8fa..1f85b5f 100644 (file)
 #include "JSTestOverloadedConstructorsWithSequence.h"
 
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
 #include "JSDOMConstructor.h"
 #include "JSDOMConvert.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWrapperCache.h"
 #include <runtime/Error.h>
 #include <runtime/FunctionPrototype.h>
 #include <runtime/JSArray.h>
index ec5687c..cb0d1a8 100644 (file)
 #include "JSTestOverrideBuiltins.h"
 
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
 #include "JSDOMConstructor.h"
 #include "JSDOMConvert.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWrapperCache.h"
 #include "JSNode.h"
 #include <runtime/Error.h>
 #include <runtime/FunctionPrototype.h>
index b93d9bf..b3247fd 100644 (file)
 #include "JSTestSerialization.h"
 
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
 #include "JSDOMConstructor.h"
 #include "JSDOMConvert.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWrapperCache.h"
 #include "JSTestNode.h"
 #include <runtime/FunctionPrototype.h>
 #include <runtime/ObjectConstructor.h>
index 08d9463..4b67f8f 100644 (file)
 #include "JSTestSerializedScriptValueInterface.h"
 
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
 #include "JSDOMConstructor.h"
 #include "JSDOMConvert.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWrapperCache.h"
 #include "JSMessagePort.h"
 #include "SerializedScriptValue.h"
 #include <runtime/Error.h>
index 2624fc4..58483a8 100644 (file)
 #include "JSTestTypedefs.h"
 
 #include "JSDOMBinding.h"
+#include "JSDOMBindingCaller.h"
 #include "JSDOMConstructor.h"
 #include "JSDOMConvert.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWrapperCache.h"
 #include "JSSVGPoint.h"
 #include "JSTestCallbackFunction.h"
 #include "JSTestCallbackInterface.h"
index b213b3a..1058c51 100644 (file)
@@ -28,6 +28,7 @@
 
 #import "BridgeJSC.h"
 #import "Frame.h"
+#import "JSDOMBindingSecurity.h"
 #import "JSDOMWindow.h"
 #import "JSDOMWindowCustom.h"
 #import "JSHTMLElement.h"
index 7322992..1e902a3 100644 (file)
@@ -31,7 +31,7 @@
 #include "FrameView.h"
 #include "HTMLNames.h"
 #include "HTMLParserIdioms.h"
-#include "JSDOMBinding.h"
+#include "JSDOMBindingSecurity.h"
 #include "Page.h"
 #include "RenderWidget.h"
 #include "ScriptController.h"
index a9db905..076dcc2 100644 (file)
@@ -33,6 +33,7 @@
 #include "ChromeClient.h"
 #include "Document.h"
 #include "EventNames.h"
+#include "ExceptionCode.h"
 #include "Frame.h"
 #include "HTMLImageLoader.h"
 #include "HTMLNames.h"
index 8986d60..2d05e51 100644 (file)
@@ -54,6 +54,7 @@
 #include "InspectorTimelineAgent.h"
 #include "InspectorWorkerAgent.h"
 #include "InstrumentingAgents.h"
+#include "JSDOMBindingSecurity.h"
 #include "JSDOMWindow.h"
 #include "JSDOMWindowCustom.h"
 #include "JSMainThreadExecState.h"
index d3052a9..69331f4 100644 (file)
@@ -70,6 +70,7 @@
 #include "InspectorPageAgent.h"
 #include "InstrumentingAgents.h"
 #include "IntRect.h"
+#include "JSDOMBindingSecurity.h"
 #include "JSEventListener.h"
 #include "JSNode.h"
 #include "MainFrame.h"
index 728741f..b3ae44b 100644 (file)
@@ -33,6 +33,7 @@
 #include "FrameView.h"
 #include "InspectorController.h"
 #include "InspectorFrontendClient.h"
+#include "JSDOMExceptionHandling.h"
 #include "JSDOMWindowCustom.h"
 #include "MainFrame.h"
 #include "Page.h"
@@ -45,7 +46,6 @@
 #include <wtf/StdLibExtras.h>
 
 #if PLATFORM(IOS)
-#include "JSDOMWindowBase.h"
 #include "WebCoreThreadInternal.h"
 #endif
 
index 014dde3..53d85a3 100644 (file)
@@ -32,7 +32,7 @@
 #include "config.h"
 #include "WorkerScriptDebugServer.h"
 
-#include "JSDOMBinding.h"
+#include "JSDOMExceptionHandling.h"
 #include "Timer.h"
 #include "WorkerGlobalScope.h"
 #include "WorkerRunLoop.h"
index 6796564..25e885d 100644 (file)
@@ -1,3 +1,13 @@
+2017-01-30  Sam Weinig  <sam@webkit.org>
+
+        JSDOMBinding is too big. Split it up!
+        https://bugs.webkit.org/show_bug.cgi?id=167601
+
+        Reviewed by Darin Adler.
+
+        * Shared/WebCoreArgumentCoders.cpp:
+        Replace include of JSDOMBinding with JSDOMExceptionHandling.
+
 2017-01-30  Andy Estes  <aestes@apple.com>
 
         [QuickLook] FrameLoaderClient should return the new QuickLookHandleClient it creates
index 6bc3e15..228731f 100644 (file)
@@ -348,7 +348,7 @@ def headers_for_type(type):
     special_cases = {
         'String': ['<wtf/text/WTFString.h>'],
         'WebCore::CompositionUnderline': ['<WebCore/Editor.h>'],
-        'WebCore::ExceptionDetails': ['<WebCore/JSDOMBinding.h>'],
+        'WebCore::ExceptionDetails': ['<WebCore/JSDOMExceptionHandling.h>'],
         'WebCore::FileChooserSettings': ['<WebCore/FileChooser.h>'],
         'WebCore::GrammarDetail': ['<WebCore/TextCheckerClient.h>'],
         'WebCore::HasInsecureContent': ['<WebCore/FrameLoaderTypes.h>'],
index bf06c0c..be84c9d 100644 (file)
@@ -47,7 +47,7 @@
 #include <WebCore/GraphicsLayer.h>
 #include <WebCore/IDBGetResult.h>
 #include <WebCore/Image.h>
-#include <WebCore/JSDOMBinding.h>
+#include <WebCore/JSDOMExceptionHandling.h>
 #include <WebCore/Length.h>
 #include <WebCore/Path.h>
 #include <WebCore/PluginData.h>
index 5425502..0c764d9 100644 (file)
 #include <WebCore/FloatRect.h>
 #include <WebCore/FocusDirection.h>
 #include <WebCore/JSDOMBinding.h>
+#include <WebCore/JSDOMExceptionHandling.h>
 #include <WebCore/MIMETypeRegistry.h>
 #include <WebCore/RenderEmbeddedObject.h>
 #include <WebCore/SerializedCryptoKeyWrap.h>
index 7bdd10a..9b540c6 100644 (file)
@@ -60,6 +60,7 @@
 #include <WebCore/GeolocationClient.h>
 #include <WebCore/GeolocationController.h>
 #include <WebCore/GeolocationPosition.h>
+#include <WebCore/JSDOMExceptionHandling.h>
 #include <WebCore/JSDOMWindow.h>
 #include <WebCore/JSNotification.h>
 #include <WebCore/MainFrame.h>
index f55b64a..02a9c8b 100644 (file)
 #include <WebCore/HistoryItem.h>
 #include <WebCore/HitTestResult.h>
 #include <WebCore/InspectorController.h>
+#include <WebCore/JSDOMExceptionHandling.h>
 #include <WebCore/JSDOMWindow.h>
 #include <WebCore/KeyboardEvent.h>
 #include <WebCore/LibWebRTCProvider.h>