[WebIDL] Remove custom bindings for WebGL code dealing with WebGL extensions
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Jul 2017 01:16:06 +0000 (01:16 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Jul 2017 01:16:06 +0000 (01:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=174186

Patch by Sam Weinig <sam@webkit.org> on 2017-07-06
Reviewed by Alex Christensen.

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
Update files. Categorize some of the remaining custom bindings into groups.

* bindings/IDLTypes.h:
Add a IDLWebGLExtension type, to model the special WebGLExtension type. In
the future, WebGLExtension can probably be replaced by a Variant.

* bindings/js/JSDOMConvertWebGL.cpp: Added.
Move WebGLAny's convertToJSValue and add a convertToJSValue for WebGLExtension.

* bindings/js/JSDOMConvertWebGL.h:
(WebCore::convertToJSValue):
Since WebGLExtension is a wrapper type, we need both a pointer and reference variant
of the conversion.

(WebCore::JSConverter<IDLWebGLExtension>::convert):
Added.

* bindings/js/JSWebGL2RenderingContextCustom.cpp:
(WebCore::toJS): Deleted.
(WebCore::JSWebGL2RenderingContext::getExtension): Deleted.
Remove custom operation and converter.

* bindings/js/JSWebGLRenderingContextCustom.cpp:
(WebCore::toJS): Deleted.
(WebCore::JSWebGLRenderingContext::getExtension): Deleted.
Remove custom operation and converter.

* bindings/scripts/CodeGeneratorJS.pm:
(AddToIncludesForIDLType):
(NativeToJSValueDOMConvertNeedsState):
(NativeToJSValueDOMConvertNeedsGlobalObject):
Add support for IDLWebGLExtension.

* html/canvas/WebGLAny.cpp: Removed.
* html/canvas/WebGLAny.h:
Moved convertToJSValue to the bindings where it belongs.

* html/canvas/WebGLRenderingContextBase.idl:
Annotate getExtension with [OverrideIDLType=IDLWebGLExtension].

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

12 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/IDLTypes.h
Source/WebCore/bindings/js/JSDOMConvertWebGL.cpp [new file with mode: 0644]
Source/WebCore/bindings/js/JSDOMConvertWebGL.h
Source/WebCore/bindings/js/JSWebGL2RenderingContextCustom.cpp
Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/html/canvas/WebGLAny.cpp [deleted file]
Source/WebCore/html/canvas/WebGLAny.h
Source/WebCore/html/canvas/WebGLRenderingContextBase.idl

index e5ded22..1bcf89e 100644 (file)
@@ -1147,6 +1147,7 @@ set(WebCore_SOURCES
     bindings/js/JSDOMConvertDate.cpp
     bindings/js/JSDOMConvertNumbers.cpp
     bindings/js/JSDOMConvertStrings.cpp
+    bindings/js/JSDOMConvertWebGL.cpp
     bindings/js/JSDOMIterator.cpp
     bindings/js/JSFontFaceCustom.cpp
     bindings/js/JSFontFaceSetCustom.cpp
@@ -3174,7 +3175,6 @@ if (ENABLE_WEBGL)
         html/canvas/OESTextureHalfFloatLinear.cpp
         html/canvas/OESVertexArrayObject.cpp
         html/canvas/WebGL2RenderingContext.cpp
-        html/canvas/WebGLAny.cpp
         html/canvas/WebGLBuffer.cpp
         html/canvas/WebGLCompressedTextureATC.cpp
         html/canvas/WebGLCompressedTexturePVRTC.cpp
index 99a6971..4fecaed 100644 (file)
@@ -1,3 +1,52 @@
+2017-07-06  Sam Weinig  <sam@webkit.org>
+
+        [WebIDL] Remove custom bindings for WebGL code dealing with WebGL extensions
+        https://bugs.webkit.org/show_bug.cgi?id=174186
+
+        Reviewed by Alex Christensen.
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        Update files. Categorize some of the remaining custom bindings into groups.
+
+        * bindings/IDLTypes.h:
+        Add a IDLWebGLExtension type, to model the special WebGLExtension type. In
+        the future, WebGLExtension can probably be replaced by a Variant.
+        
+        * bindings/js/JSDOMConvertWebGL.cpp: Added.
+        Move WebGLAny's convertToJSValue and add a convertToJSValue for WebGLExtension.
+
+        * bindings/js/JSDOMConvertWebGL.h:
+        (WebCore::convertToJSValue):
+        Since WebGLExtension is a wrapper type, we need both a pointer and reference variant
+        of the conversion.
+
+        (WebCore::JSConverter<IDLWebGLExtension>::convert):
+        Added.
+
+        * bindings/js/JSWebGL2RenderingContextCustom.cpp:
+        (WebCore::toJS): Deleted.
+        (WebCore::JSWebGL2RenderingContext::getExtension): Deleted.
+        Remove custom operation and converter.
+
+        * bindings/js/JSWebGLRenderingContextCustom.cpp:
+        (WebCore::toJS): Deleted.
+        (WebCore::JSWebGLRenderingContext::getExtension): Deleted.
+        Remove custom operation and converter.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (AddToIncludesForIDLType):
+        (NativeToJSValueDOMConvertNeedsState):
+        (NativeToJSValueDOMConvertNeedsGlobalObject):
+        Add support for IDLWebGLExtension.
+
+        * html/canvas/WebGLAny.cpp: Removed.
+        * html/canvas/WebGLAny.h:
+        Moved convertToJSValue to the bindings where it belongs.
+
+        * html/canvas/WebGLRenderingContextBase.idl:
+        Annotate getExtension with [OverrideIDLType=IDLWebGLExtension].
+
 2017-07-06  Joseph Pecoraro  <pecoraro@apple.com>
 
         [Cocoa] CTParagraphStyle leak under WebCore::LinkImageLayout::LinkImageLayout
index 71cd819..16d459f 100644 (file)
                6E3FAE8E14733FDB00E42307 /* WebGLDepthTexture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E3FAE8C14733FDB00E42307 /* WebGLDepthTexture.cpp */; };
                6E3FAE8F14733FDB00E42306 /* WebGLCompressedTextureS3TC.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E3FAE8D14733FDB00E42306 /* WebGLCompressedTextureS3TC.h */; };
                6E3FAE8F14733FDB00E42307 /* WebGLDepthTexture.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E3FAE8D14733FDB00E42307 /* WebGLDepthTexture.h */; };
-               6E47E66010B7944B00B186C8 /* WebGLAny.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E47E65E10B7944B00B186C8 /* WebGLAny.cpp */; };
                6E47E66110B7944B00B186C8 /* WebGLAny.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E47E65F10B7944B00B186C8 /* WebGLAny.h */; settings = {ATTRIBUTES = (Private, ); }; };
                6E4ABCD4138EA0B70071D291 /* JSHTMLUnknownElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E4ABCD2138EA0B70071D291 /* JSHTMLUnknownElement.cpp */; };
                6E4ABCD5138EA0B70071D291 /* JSHTMLUnknownElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E4ABCD3138EA0B70071D291 /* JSHTMLUnknownElement.h */; };
                7C9DBFEE1A9C49B1000D6B25 /* JSHTMLAttachmentElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C9DBFEC1A9C49B1000D6B25 /* JSHTMLAttachmentElement.h */; };
                7CB5CA3F1E525C7100FAEF13 /* MediaQueryExpression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CB5CA3D1E525C6C00FAEF13 /* MediaQueryExpression.cpp */; };
                7CB5CA401E525C7300FAEF13 /* MediaQueryExpression.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CB5CA3E1E525C6C00FAEF13 /* MediaQueryExpression.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               7CBA5BA71F0B4BDE0034D745 /* JSDOMConvertWebGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CBA5BA61F0B4BDE0034D745 /* JSDOMConvertWebGL.cpp */; };
                7CC01D0A1E4A7B0400E529CC /* JSDOMBuiltinConstructorBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C0CEF2E1E4A5832008DEB80 /* JSDOMBuiltinConstructorBase.cpp */; };
                7CC01D0B1E4A7B0400E529CC /* JSDOMConstructorBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C0CEF2F1E4A58AD008DEB80 /* JSDOMConstructorBase.cpp */; };
                7CC01D0C1E4A7B0400E529CC /* JSDOMConstructorWithDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C0CEF301E4A58F1008DEB80 /* JSDOMConstructorWithDocument.cpp */; };
                6E3FAE8D14733FDB00E42307 /* WebGLDepthTexture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebGLDepthTexture.h; sourceTree = "<group>"; };
                6E3FAE9014733FEA00E42306 /* WebGLCompressedTextureS3TC.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebGLCompressedTextureS3TC.idl; sourceTree = "<group>"; };
                6E3FAE9014733FEA00E42307 /* WebGLDepthTexture.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebGLDepthTexture.idl; sourceTree = "<group>"; };
-               6E47E65E10B7944B00B186C8 /* WebGLAny.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebGLAny.cpp; sourceTree = "<group>"; };
                6E47E65F10B7944B00B186C8 /* WebGLAny.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebGLAny.h; sourceTree = "<group>"; };
                6E4ABCD2138EA0B70071D291 /* JSHTMLUnknownElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLUnknownElement.cpp; sourceTree = "<group>"; };
                6E4ABCD3138EA0B70071D291 /* JSHTMLUnknownElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLUnknownElement.h; sourceTree = "<group>"; };
                7C9DBFEC1A9C49B1000D6B25 /* JSHTMLAttachmentElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLAttachmentElement.h; sourceTree = "<group>"; };
                7CB5CA3D1E525C6C00FAEF13 /* MediaQueryExpression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaQueryExpression.cpp; sourceTree = "<group>"; };
                7CB5CA3E1E525C6C00FAEF13 /* MediaQueryExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaQueryExpression.h; sourceTree = "<group>"; };
+               7CBA5BA61F0B4BDE0034D745 /* JSDOMConvertWebGL.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMConvertWebGL.cpp; sourceTree = "<group>"; };
                7CC2DDF81EC9415A0027B774 /* NotificationPermission.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NotificationPermission.h; sourceTree = "<group>"; };
                7CC2DDFA1EC9415A0027B774 /* NotificationPermission.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = NotificationPermission.idl; sourceTree = "<group>"; };
                7CC2DDFE1EC95A440027B774 /* JSNotificationPermission.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSNotificationPermission.cpp; sourceTree = "<group>"; };
                                D3F3D35D1A69A5060059FC2B /* WebGL2RenderingContext.idl */,
                                A7D20F6B107F438B00A80392 /* WebGLActiveInfo.h */,
                                A7D20F3B107F373800A80392 /* WebGLActiveInfo.idl */,
-                               6E47E65E10B7944B00B186C8 /* WebGLAny.cpp */,
                                6E47E65F10B7944B00B186C8 /* WebGLAny.h */,
                                49C7B9A81042D32E0009D447 /* WebGLBuffer.cpp */,
                                49C7B9A91042D32E0009D447 /* WebGLBuffer.h */,
                                516BB7920CE91E6800512F79 /* JSTreeWalkerCustom.cpp */,
                                BE6DF708171CA2C500DD52B8 /* JSVideoTrackCustom.cpp */,
                                BE6DF70A171CA2C500DD52B8 /* JSVideoTrackListCustom.cpp */,
+                               D3F3D3591A69A3B00059FC2B /* JSWebGL2RenderingContextCustom.cpp */,
+                               49EED14C1051971A00099FAB /* JSWebGLRenderingContextCustom.cpp */,
                                31A088C41E737B2C003B6609 /* JSWebGPURenderingContextCustom.cpp */,
                                31A088C51E737B2C003B6609 /* JSWebGPURenderPassAttachmentDescriptorCustom.cpp */,
                                83A4A9F81CE7FD7E00709B00 /* JSXMLDocumentCustom.cpp */,
                                7C8E34A91E4A338E0054CE23 /* JSDOMConvertUnion.h */,
                                7C8E34AA1E4A338E0054CE23 /* JSDOMConvertVariadic.h */,
                                7C8E34AB1E4A338E0054CE23 /* JSDOMConvertWebGL.h */,
+                               7CBA5BA61F0B4BDE0034D745 /* JSDOMConvertWebGL.cpp */,
                                7C8E34AC1E4A338E0054CE23 /* JSDOMConvertXPathNSResolver.h */,
                        );
                        name = Conversions;
                        sourceTree = "<group>";
                };
+               7CBA5BA91F0B51480034D745 /* Promises Only */ = {
+                       isa = PBXGroup;
+                       children = (
+                               C28083411C6DC96A001451B6 /* JSFontFaceCustom.cpp */,
+                               1C24EEAA1C72AA0A0080F8FC /* JSFontFaceSetCustom.cpp */,
+                               2D9BF7481DBFDDF8007A7D99 /* JSMediaKeySessionCustom.cpp */,
+                               38850C521E964C1100C60753 /* JSWebGPUCommandBufferCustom.cpp */,
+                       );
+                       name = "Promises Only";
+                       sourceTree = "<group>";
+               };
                7E4DE10B198B10810051CB02 /* cocoa */ = {
                        isa = PBXGroup;
                        children = (
                        isa = PBXGroup;
                        children = (
                                7C3D8EE41E08BABE0023B084 /* GC / Wrapping Only */,
+                               7CBA5BA91F0B51480034D745 /* Promises Only */,
                                A584FE371864DAC100843B10 /* JSCommandLineAPIHostCustom.cpp */,
                                E157A8E618184C67009F821D /* JSCryptoKeyCustom.cpp */,
                                BC5825F20C0B89380053F1B5 /* JSCSSStyleDeclarationCustom.cpp */,
                                DEC2975D1B4DEB2A005F5945 /* JSCustomEventCustom.cpp */,
                                BCD9C25E0C17AA67005C90A2 /* JSDOMWindowCustom.cpp */,
                                652FBBBB0DE27CB60001D386 /* JSDOMWindowCustom.h */,
-                               C28083411C6DC96A001451B6 /* JSFontFaceCustom.cpp */,
-                               1C24EEAA1C72AA0A0080F8FC /* JSFontFaceSetCustom.cpp */,
                                BCE7B1920D4E86960075A539 /* JSHistoryCustom.cpp */,
                                BC4EDEF30C08F3FB007EDD49 /* JSHTMLAppletElementCustom.cpp */,
                                9392262C1032107B006E7D5D /* JSHTMLCanvasElementCustom.cpp */,
                                D6F7960C166FFECE0076DD18 /* JSHTMLTemplateElementCustom.cpp */,
                                7A74ECBC101839DA00BF939E /* JSInspectorFrontendHostCustom.cpp */,
                                BCE1C43F0D9830F4003B02F2 /* JSLocationCustom.cpp */,
-                               2D9BF7481DBFDDF8007A7D99 /* JSMediaKeySessionCustom.cpp */,
                                410B7E711045FAB000D8224F /* JSMessageEventCustom.cpp */,
                                A1E5B31D1AAD1DA4006EBEFB /* JSMockContentFilterSettingsCustom.cpp */,
                                C6F0917E143A2BB900685849 /* JSMutationObserverCustom.cpp */,
                                418C395D1C8F0AAB0051C8A3 /* JSReadableStreamSourceCustom.cpp */,
                                51D0C5150DAA90B7003B3831 /* JSStorageCustom.cpp */,
                                57A9C88D1DA70BF800BC7305 /* JSSubtleCryptoCustom.cpp */,
-                               D3F3D3591A69A3B00059FC2B /* JSWebGL2RenderingContextCustom.cpp */,
-                               49EED14C1051971A00099FAB /* JSWebGLRenderingContextCustom.cpp */,
-                               38850C521E964C1100C60753 /* JSWebGPUCommandBufferCustom.cpp */,
                                E1FF8F661807460800132674 /* JSWebKitSubtleCryptoCustom.cpp */,
                                E18258AB0EF3CD7000933242 /* JSWorkerGlobalScopeCustom.cpp */,
                                BC348BBD0DB7F531004ABAB9 /* JSXMLHttpRequestCustom.cpp */,
                                CD0EEE0E14743F39003EAFA2 /* AudioDestinationIOS.cpp in Sources */,
                                FD3160BC12B0272A00C1A359 /* AudioDestinationMac.cpp in Sources */,
                                FD31600712B0267600C1A359 /* AudioDestinationNode.cpp in Sources */,
+                               7CBA5BA71F0B4BDE0034D745 /* JSDOMConvertWebGL.cpp in Sources */,
                                FD31608112B026F700C1A359 /* AudioDSPKernelProcessor.cpp in Sources */,
                                CD5596911475B678001D0BD0 /* AudioFileReaderIOS.cpp in Sources */,
                                FD3160BE12B0272A00C1A359 /* AudioFileReaderMac.cpp in Sources */,
                                FE0D84EB1048436E001A179E /* WebEvent.mm in Sources */,
                                225A16B60D5C11E900090295 /* WebEventRegion.mm in Sources */,
                                D3F3D36D1A69B7DC0059FC2B /* WebGL2RenderingContext.cpp in Sources */,
-                               6E47E66010B7944B00B186C8 /* WebGLAny.cpp in Sources */,
                                1AFFC4531D5E81C400267A66 /* WebGLBlacklist.mm in Sources */,
                                49C7B9C81042D32F0009D447 /* WebGLBuffer.cpp in Sources */,
                                7E66E23316D6EB6C00F7E7FF /* WebGLCompressedTextureATC.cpp in Sources */,
index edde456..d0df9ef 100644 (file)
@@ -51,6 +51,10 @@ class IDBKeyData;
 class IDBValue;
 class DOMPromise;
 
+#if ENABLE(WEBGL)
+class WebGLExtension;
+#endif
+
 template<typename T>
 struct IDLType {
     using ImplementationType = T;
@@ -258,6 +262,7 @@ struct IDLIDBValue : IDLWrapper<IDBValue> { };
 
 #if ENABLE(WEBGL)
 struct IDLWebGLAny : IDLType<WebGLAny> { };
+struct IDLWebGLExtension : IDLWrapper<WebGLExtension> { };
 #endif
 
 // Helper predicates
diff --git a/Source/WebCore/bindings/js/JSDOMConvertWebGL.cpp b/Source/WebCore/bindings/js/JSDOMConvertWebGL.cpp
new file mode 100644 (file)
index 0000000..7226f91
--- /dev/null
@@ -0,0 +1,188 @@
+/*
+ * Copyright (C) 2017 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 "JSDOMConvertWebGL.h"
+
+#if ENABLE(WEBGL)
+
+#include "JSANGLEInstancedArrays.h"
+#include "JSDOMConvertBufferSource.h"
+#include "JSEXTBlendMinMax.h"
+#include "JSEXTFragDepth.h"
+#include "JSEXTShaderTextureLOD.h"
+#include "JSEXTTextureFilterAnisotropic.h"
+#include "JSEXTsRGB.h"
+#include "JSOESElementIndexUint.h"
+#include "JSOESStandardDerivatives.h"
+#include "JSOESTextureFloat.h"
+#include "JSOESTextureFloatLinear.h"
+#include "JSOESTextureHalfFloat.h"
+#include "JSOESTextureHalfFloatLinear.h"
+#include "JSOESVertexArrayObject.h"
+#include "JSWebGLBuffer.h"
+#include "JSWebGLCompressedTextureATC.h"
+#include "JSWebGLCompressedTexturePVRTC.h"
+#include "JSWebGLCompressedTextureS3TC.h"
+#include "JSWebGLDebugRendererInfo.h"
+#include "JSWebGLDebugShaders.h"
+#include "JSWebGLDepthTexture.h"
+#include "JSWebGLDrawBuffers.h"
+#include "JSWebGLFramebuffer.h"
+#include "JSWebGLLoseContext.h"
+#include "JSWebGLProgram.h"
+#include "JSWebGLRenderbuffer.h"
+#include "JSWebGLTexture.h"
+#include "JSWebGLVertexArrayObject.h"
+#include "JSWebGLVertexArrayObjectOES.h"
+
+using namespace JSC;
+
+namespace WebCore {
+
+// FIXME: This should use the IDLUnion JSConverter.
+JSValue convertToJSValue(ExecState& state, JSDOMGlobalObject& globalObject, const WebGLAny& any)
+{
+    return WTF::switchOn(any,
+        [] (std::nullptr_t) {
+            return jsNull();
+        },
+        [] (bool value) {
+            return jsBoolean(value);
+        },
+        [] (int value) {
+            return jsNumber(value);
+        },
+        [] (unsigned value) {
+            return jsNumber(value);
+        },
+        [] (long long value) {
+            return jsNumber(value);
+        },
+        [] (float value) {
+            return jsNumber(value);
+        },
+        [&] (const String& value) {
+            return jsStringWithCache(&state, value);
+        },
+        [&] (const Vector<bool>& values) {
+            MarkedArgumentBuffer list;
+            for (auto& value : values)
+                list.append(jsBoolean(value));
+            return constructArray(&state, 0, &globalObject, list);
+        },
+        [&] (const RefPtr<Float32Array>& array) {
+            return toJS(&state, &globalObject, array.get());
+        },
+        [&] (const RefPtr<Int32Array>& array) {
+            return toJS(&state, &globalObject, array.get());
+        },
+        [&] (const RefPtr<Uint8Array>& array) {
+            return toJS(&state, &globalObject, array.get());
+        },
+        [&] (const RefPtr<Uint32Array>& array) {
+            return toJS(&state, &globalObject, array.get());
+        },
+        [&] (const RefPtr<WebGLBuffer>& buffer) {
+            return toJS(&state, &globalObject, buffer.get());
+        },
+        [&] (const RefPtr<WebGLFramebuffer>& buffer) {
+            return toJS(&state, &globalObject, buffer.get());
+        },
+        [&] (const RefPtr<WebGLProgram>& program) {
+            return toJS(&state, &globalObject, program.get());
+        },
+        [&] (const RefPtr<WebGLRenderbuffer>& buffer) {
+            return toJS(&state, &globalObject, buffer.get());
+        },
+        [&] (const RefPtr<WebGLTexture>& texture) {
+            return toJS(&state, &globalObject, texture.get());
+        },
+        [&] (const RefPtr<WebGLVertexArrayObjectOES>& array) {
+            return toJS(&state, &globalObject, array.get());
+        }
+#if ENABLE(WEBGL2)
+        ,
+        [&] (const RefPtr<WebGLVertexArrayObject>& array) {
+            return toJS(&state, &globalObject, array.get());
+        }
+#endif
+    );
+}
+
+JSValue convertToJSValue(ExecState& state, JSDOMGlobalObject& globalObject, WebGLExtension& extension)
+{
+    switch (extension.getName()) {
+    case WebGLExtension::WebGLLoseContextName:
+        return toJS(&state, &globalObject, static_cast<WebGLLoseContext&>(extension));
+    case WebGLExtension::EXTShaderTextureLODName:
+        return toJS(&state, &globalObject, static_cast<EXTShaderTextureLOD&>(extension));
+    case WebGLExtension::EXTTextureFilterAnisotropicName:
+        return toJS(&state, &globalObject, static_cast<EXTTextureFilterAnisotropic&>(extension));
+    case WebGLExtension::EXTsRGBName:
+        return toJS(&state, &globalObject, static_cast<EXTsRGB&>(extension));
+    case WebGLExtension::EXTFragDepthName:
+        return toJS(&state, &globalObject, static_cast<EXTFragDepth&>(extension));
+    case WebGLExtension::EXTBlendMinMaxName:
+        return toJS(&state, &globalObject, static_cast<EXTBlendMinMax&>(extension));
+    case WebGLExtension::OESStandardDerivativesName:
+        return toJS(&state, &globalObject, static_cast<OESStandardDerivatives&>(extension));
+    case WebGLExtension::OESTextureFloatName:
+        return toJS(&state, &globalObject, static_cast<OESTextureFloat&>(extension));
+    case WebGLExtension::OESTextureFloatLinearName:
+        return toJS(&state, &globalObject, static_cast<OESTextureFloatLinear&>(extension));
+    case WebGLExtension::OESTextureHalfFloatName:
+        return toJS(&state, &globalObject, static_cast<OESTextureHalfFloat&>(extension));
+    case WebGLExtension::OESTextureHalfFloatLinearName:
+        return toJS(&state, &globalObject, static_cast<OESTextureHalfFloatLinear&>(extension));
+    case WebGLExtension::OESVertexArrayObjectName:
+        return toJS(&state, &globalObject, static_cast<OESVertexArrayObject&>(extension));
+    case WebGLExtension::OESElementIndexUintName:
+        return toJS(&state, &globalObject, static_cast<OESElementIndexUint&>(extension));
+    case WebGLExtension::WebGLDebugRendererInfoName:
+        return toJS(&state, &globalObject, static_cast<WebGLDebugRendererInfo&>(extension));
+    case WebGLExtension::WebGLDebugShadersName:
+        return toJS(&state, &globalObject, static_cast<WebGLDebugShaders&>(extension));
+    case WebGLExtension::WebGLCompressedTextureATCName:
+        return toJS(&state, &globalObject, static_cast<WebGLCompressedTextureATC&>(extension));
+    case WebGLExtension::WebGLCompressedTexturePVRTCName:
+        return toJS(&state, &globalObject, static_cast<WebGLCompressedTexturePVRTC&>(extension));
+    case WebGLExtension::WebGLCompressedTextureS3TCName:
+        return toJS(&state, &globalObject, static_cast<WebGLCompressedTextureS3TC&>(extension));
+    case WebGLExtension::WebGLDepthTextureName:
+        return toJS(&state, &globalObject, static_cast<WebGLDepthTexture&>(extension));
+    case WebGLExtension::WebGLDrawBuffersName:
+        return toJS(&state, &globalObject, static_cast<WebGLDrawBuffers&>(extension));
+    case WebGLExtension::ANGLEInstancedArraysName:
+        return toJS(&state, &globalObject, static_cast<ANGLEInstancedArrays&>(extension));
+    }
+    ASSERT_NOT_REACHED();
+    return jsNull();
+}
+
+}
+
+#endif
+
index 4adcef5..26f3ca8 100644 (file)
 #if ENABLE(WEBGL)
 
 #include "IDLTypes.h"
+#include "JSDOMConvertBase.h"
 
 namespace WebCore {
 
+JSC::JSValue convertToJSValue(JSC::ExecState&, JSDOMGlobalObject&, const WebGLAny&);
+JSC::JSValue convertToJSValue(JSC::ExecState&, JSDOMGlobalObject&, WebGLExtension&);
+
+inline JSC::JSValue convertToJSValue(JSC::ExecState& state, JSDOMGlobalObject& globalObject, WebGLExtension* extension)
+{
+    if (!extension)
+        return JSC::jsNull();
+    return convertToJSValue(state, globalObject, *extension);
+}
+
 template<> struct JSConverter<IDLWebGLAny> {
     static constexpr bool needsState = true;
     static constexpr bool needsGlobalObject = true;
@@ -41,6 +52,17 @@ template<> struct JSConverter<IDLWebGLAny> {
     }
 };
 
+template<> struct JSConverter<IDLWebGLExtension> {
+    static constexpr bool needsState = true;
+    static constexpr bool needsGlobalObject = true;
+
+    template <typename T>
+    static JSC::JSValue convert(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const T& value)
+    {
+        return convertToJSValue(state, globalObject, Detail::getPtrOrRef(value));
+    }
+};
+
 } // namespace WebCore
 
 #endif
index b22668b..9cefb0e 100644 (file)
@@ -39,25 +39,6 @@ void JSWebGL2RenderingContext::visitAdditionalChildren(SlotVisitor& visitor)
     visitor.addOpaqueRoot(&wrapped());
 }
 
-static JSValue toJS(ExecState&, JSDOMGlobalObject&, WebGLExtension*)
-{
-    // No extensions for WebGL2 at the moment.
-    return jsNull();
-}
-
-JSValue JSWebGL2RenderingContext::getExtension(ExecState& state)
-{
-    VM& vm = state.vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    if (state.argumentCount() < 1)
-        return throwException(&state, scope, createNotEnoughArgumentsError(&state));
-
-    auto name = state.uncheckedArgument(0).toWTFString(&state);
-    RETURN_IF_EXCEPTION(scope, { });
-    return toJS(state, *globalObject(), wrapped().getExtension(name));
-}
-
 } // namespace WebCore
 
 #endif // ENABLE(WEBGL)
index 3e3906b..ebe9014 100644 (file)
 #include "config.h"
 
 #if ENABLE(WEBGL)
+
 #include "JSWebGLRenderingContext.h"
-#include "DOMWrapperWorld.h"
-#include "EXTBlendMinMax.h"
-#include "EXTFragDepth.h"
-#include "EXTShaderTextureLOD.h"
-#include "EXTTextureFilterAnisotropic.h"
-#include "EXTsRGB.h"
-#include "JSANGLEInstancedArrays.h"
-#include "JSEXTBlendMinMax.h"
-#include "JSEXTFragDepth.h"
-#include "JSEXTShaderTextureLOD.h"
-#include "JSEXTTextureFilterAnisotropic.h"
-#include "JSEXTsRGB.h"
-#include "JSOESElementIndexUint.h"
-#include "JSOESStandardDerivatives.h"
-#include "JSOESTextureFloat.h"
-#include "JSOESTextureFloatLinear.h"
-#include "JSOESTextureHalfFloat.h"
-#include "JSOESTextureHalfFloatLinear.h"
-#include "JSOESVertexArrayObject.h"
-#include "JSWebGLCompressedTextureATC.h"
-#include "JSWebGLCompressedTexturePVRTC.h"
-#include "JSWebGLCompressedTextureS3TC.h"
-#include "JSWebGLDebugRendererInfo.h"
-#include "JSWebGLDebugShaders.h"
-#include "JSWebGLDepthTexture.h"
-#include "JSWebGLDrawBuffers.h"
-#include "JSWebGLLoseContext.h"
-#include "JSWebGLVertexArrayObject.h"
-#include "JSWebGLVertexArrayObjectOES.h"
-#include "OESElementIndexUint.h"
-#include "OESStandardDerivatives.h"
-#include "OESTextureFloat.h"
-#include "OESTextureFloatLinear.h"
-#include "OESTextureHalfFloat.h"
-#include "OESTextureHalfFloatLinear.h"
-#include "OESVertexArrayObject.h"
-#include "WebGLCompressedTextureATC.h"
-#include "WebGLCompressedTexturePVRTC.h"
-#include "WebGLCompressedTextureS3TC.h"
-#include "WebGLDebugRendererInfo.h"
-#include "WebGLDebugShaders.h"
-#include "WebGLDepthTexture.h"
-#include "WebGLDrawBuffers.h"
-#include "WebGLExtension.h"
-#include "WebGLLoseContext.h"
-#include "WebGLVertexArrayObject.h"
-#include "WebGLVertexArrayObjectOES.h"
 
 using namespace JSC;
 
@@ -84,71 +38,6 @@ void JSWebGLRenderingContext::visitAdditionalChildren(SlotVisitor& visitor)
     visitor.addOpaqueRoot(&wrapped());
 }
 
-static JSValue toJS(ExecState& state, JSDOMGlobalObject& globalObject, WebGLExtension* extension)
-{
-    if (!extension)
-        return jsNull();
-    switch (extension->getName()) {
-    case WebGLExtension::WebGLLoseContextName:
-        return toJS(&state, &globalObject, static_cast<WebGLLoseContext*>(extension));
-    case WebGLExtension::EXTShaderTextureLODName:
-        return toJS(&state, &globalObject, static_cast<EXTShaderTextureLOD*>(extension));
-    case WebGLExtension::EXTTextureFilterAnisotropicName:
-        return toJS(&state, &globalObject, static_cast<EXTTextureFilterAnisotropic*>(extension));
-    case WebGLExtension::EXTsRGBName:
-        return toJS(&state, &globalObject, static_cast<EXTsRGB*>(extension));
-    case WebGLExtension::EXTFragDepthName:
-        return toJS(&state, &globalObject, static_cast<EXTFragDepth*>(extension));
-    case WebGLExtension::EXTBlendMinMaxName:
-        return toJS(&state, &globalObject, static_cast<EXTBlendMinMax*>(extension));
-    case WebGLExtension::OESStandardDerivativesName:
-        return toJS(&state, &globalObject, static_cast<OESStandardDerivatives*>(extension));
-    case WebGLExtension::OESTextureFloatName:
-        return toJS(&state, &globalObject, static_cast<OESTextureFloat*>(extension));
-    case WebGLExtension::OESTextureFloatLinearName:
-        return toJS(&state, &globalObject, static_cast<OESTextureFloatLinear*>(extension));
-    case WebGLExtension::OESTextureHalfFloatName:
-        return toJS(&state, &globalObject, static_cast<OESTextureHalfFloat*>(extension));
-    case WebGLExtension::OESTextureHalfFloatLinearName:
-        return toJS(&state, &globalObject, static_cast<OESTextureHalfFloatLinear*>(extension));
-    case WebGLExtension::OESVertexArrayObjectName:
-        return toJS(&state, &globalObject, static_cast<OESVertexArrayObject*>(extension));
-    case WebGLExtension::OESElementIndexUintName:
-        return toJS(&state, &globalObject, static_cast<OESElementIndexUint*>(extension));
-    case WebGLExtension::WebGLDebugRendererInfoName:
-        return toJS(&state, &globalObject, static_cast<WebGLDebugRendererInfo*>(extension));
-    case WebGLExtension::WebGLDebugShadersName:
-        return toJS(&state, &globalObject, static_cast<WebGLDebugShaders*>(extension));
-    case WebGLExtension::WebGLCompressedTextureATCName:
-        return toJS(&state, &globalObject, static_cast<WebGLCompressedTextureATC*>(extension));
-    case WebGLExtension::WebGLCompressedTexturePVRTCName:
-        return toJS(&state, &globalObject, static_cast<WebGLCompressedTexturePVRTC*>(extension));
-    case WebGLExtension::WebGLCompressedTextureS3TCName:
-        return toJS(&state, &globalObject, static_cast<WebGLCompressedTextureS3TC*>(extension));
-    case WebGLExtension::WebGLDepthTextureName:
-        return toJS(&state, &globalObject, static_cast<WebGLDepthTexture*>(extension));
-    case WebGLExtension::WebGLDrawBuffersName:
-        return toJS(&state, &globalObject, static_cast<WebGLDrawBuffers*>(extension));
-    case WebGLExtension::ANGLEInstancedArraysName:
-        return toJS(&state, &globalObject, static_cast<ANGLEInstancedArrays*>(extension));
-    }
-    ASSERT_NOT_REACHED();
-    return jsNull();
-}
-
-JSValue JSWebGLRenderingContext::getExtension(ExecState& state)
-{
-    VM& vm = state.vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    if (state.argumentCount() < 1)
-        return throwException(&state, scope, createNotEnoughArgumentsError(&state));
-
-    auto name = state.uncheckedArgument(0).toWTFString(&state);
-    RETURN_IF_EXCEPTION(scope, { });
-    return toJS(state, *globalObject(), wrapped().getExtension(name));
-}
-
 } // namespace WebCore
 
 #endif // ENABLE(WEBGL)
index c5519fa..7059c55 100644 (file)
@@ -321,7 +321,7 @@ sub AddToIncludesForIDLType
             return;
         }
 
-        if ($overrideTypeName eq "IDLWebGLAny") {
+        if ($overrideTypeName eq "IDLWebGLAny" || $overrideTypeName eq "IDLWebGLExtension") {
             AddToIncludes("JSDOMConvertWebGL.h", $includesRef, $conditional);
             return;
         }
@@ -6381,6 +6381,7 @@ sub NativeToJSValueDOMConvertNeedsState
         my $overrideTypeName = $type->extendedAttributes->{OverrideIDLType};
         return 1 if $overrideTypeName eq "IDLIDBKey";
         return 1 if $overrideTypeName eq "IDLWebGLAny";
+        return 1 if $overrideTypeName eq "IDLWebGLExtension";
 
         return 0;
     }
@@ -6413,6 +6414,7 @@ sub NativeToJSValueDOMConvertNeedsGlobalObject
         my $overrideTypeName = $type->extendedAttributes->{OverrideIDLType};
         return 1 if $overrideTypeName eq "IDLIDBKey";
         return 1 if $overrideTypeName eq "IDLWebGLAny";
+        return 1 if $overrideTypeName eq "IDLWebGLExtension";
 
         return 0;
     }
diff --git a/Source/WebCore/html/canvas/WebGLAny.cpp b/Source/WebCore/html/canvas/WebGLAny.cpp
deleted file mode 100644 (file)
index 75ce051..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2017 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. ``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
- * 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 "WebGLAny.h"
-
-#if ENABLE(WEBGL)
-
-#include "JSDOMConvert.h"
-#include "JSWebGLBuffer.h"
-#include "JSWebGLFramebuffer.h"
-#include "JSWebGLProgram.h"
-#include "JSWebGLRenderbuffer.h"
-#include "JSWebGLTexture.h"
-#include "JSWebGLVertexArrayObjectOES.h"
-#include <wtf/Variant.h>
-
-#if ENABLE(WEBGL2)
-#include "JSWebGLVertexArrayObject.h"
-#endif
-
-namespace WebCore {
-
-using namespace JSC;
-
-// FIXME: This should use the IDLUnion JSConverter.
-JSValue convertToJSValue(ExecState& state, JSDOMGlobalObject& globalObject, const WebGLAny& any)
-{
-    return WTF::switchOn(any,
-        [] (std::nullptr_t) {
-            return jsNull();
-        },
-        [] (bool value) {
-            return jsBoolean(value);
-        },
-        [] (int value) {
-            return jsNumber(value);
-        },
-        [] (unsigned value) {
-            return jsNumber(value);
-        },
-        [] (long long value) {
-            return jsNumber(value);
-        },
-        [] (float value) {
-            return jsNumber(value);
-        },
-        [&] (const String& value) {
-            return jsStringWithCache(&state, value);
-        },
-        [&] (const Vector<bool>& values) {
-            MarkedArgumentBuffer list;
-            for (auto& value : values)
-                list.append(jsBoolean(value));
-            return constructArray(&state, 0, &globalObject, list);
-        },
-        [&] (const RefPtr<Float32Array>& array) {
-            return toJS(&state, &globalObject, array.get());
-        },
-        [&] (const RefPtr<Int32Array>& array) {
-            return toJS(&state, &globalObject, array.get());
-        },
-        [&] (const RefPtr<Uint8Array>& array) {
-            return toJS(&state, &globalObject, array.get());
-        },
-        [&] (const RefPtr<Uint32Array>& array) {
-            return toJS(&state, &globalObject, array.get());
-        },
-        [&] (const RefPtr<WebGLBuffer>& buffer) {
-            return toJS(&state, &globalObject, buffer.get());
-        },
-        [&] (const RefPtr<WebGLFramebuffer>& buffer) {
-            return toJS(&state, &globalObject, buffer.get());
-        },
-        [&] (const RefPtr<WebGLProgram>& program) {
-            return toJS(&state, &globalObject, program.get());
-        },
-        [&] (const RefPtr<WebGLRenderbuffer>& buffer) {
-            return toJS(&state, &globalObject, buffer.get());
-        },
-        [&] (const RefPtr<WebGLTexture>& texture) {
-            return toJS(&state, &globalObject, texture.get());
-        },
-        [&] (const RefPtr<WebGLVertexArrayObjectOES>& array) {
-            return toJS(&state, &globalObject, array.get());
-        }
-#if ENABLE(WEBGL2)
-        ,
-        [&] (const RefPtr<WebGLVertexArrayObject>& array) {
-            return toJS(&state, &globalObject, array.get());
-        }
-#endif
-    );
-}
-
-}
-
-#endif
index c773b08..f04fd62 100644 (file)
@@ -72,8 +72,6 @@ using WebGLAny = Variant<
 #endif
 >;
 
-JSC::JSValue convertToJSValue(JSC::ExecState&, JSDOMGlobalObject&, const WebGLAny&);
-
 } // namespace WebCore
 
 #endif
index 11698be..5e77bc4 100644 (file)
@@ -560,7 +560,7 @@ typedef (ImageData or HTMLImageElement or HTMLCanvasElement or HTMLVideoElement)
     GLenum getError();
 
     sequence<DOMString>? getSupportedExtensions();
-    [Custom] object? getExtension(DOMString name);
+    [OverrideIDLType=IDLWebGLExtension] object? getExtension(DOMString name);
 
     [OverrideIDLType=IDLWebGLAny] any getFramebufferAttachmentParameter(GLenum target, GLenum attachment, GLenum pname);
     [OverrideIDLType=IDLWebGLAny] any getParameter(GLenum pname);