Bug 1324543 - Fix inheritance in our webidl. - r=jgilbert,bz a=gchang
authorBoris Zbarsky <bz@mozilla.com>
Tue, 20 Dec 2016 15:47:13 -0800
changeset 374245 e58d9eef4c96901f243db1491282e4619d4bd980
parent 374244 72990bca82a937cb7128bb30ef7133139025f83c
child 374246 39582d06756a9ff47993d4097b4fb25f041be406
push id35
push userfmarier@mozilla.com
push dateThu, 09 Feb 2017 06:52:49 +0000
reviewersjgilbert, bz, gchang
bugs1324543
milestone52.0a2
Bug 1324543 - Fix inheritance in our webidl. - r=jgilbert,bz a=gchang MozReview-Commit-ID: 7W95FqqfBuE
dom/bindings/Bindings.conf
dom/canvas/WebGL2Context.h
dom/webidl/WebGL2RenderingContext.webidl
dom/webidl/WebGLRenderingContext.webidl
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -1250,17 +1250,16 @@ DOMInterfaces = {
 'WebGLRenderingContext': {
     'nativeType': 'mozilla::WebGLContext',
     'headerFile': 'WebGLContext.h',
 },
 
 'WebGL2RenderingContext': {
     'nativeType': 'mozilla::WebGL2Context',
     'headerFile': 'WebGL2Context.h',
-    'implicitJSContext': [ 'getSupportedExtensions' ],
 },
 
 'WebGLSampler': {
     'nativeType': 'mozilla::WebGLSampler',
     'headerFile': 'WebGLSampler.h'
 },
 
 'WebGLShader': {
--- a/dom/canvas/WebGL2Context.h
+++ b/dom/canvas/WebGL2Context.h
@@ -61,16 +61,18 @@ public:
     void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
                          GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
                          GLbitfield mask, GLenum filter);
     void FramebufferTextureLayer(GLenum target, GLenum attachment, WebGLTexture* texture, GLint level, GLint layer);
 
     virtual JS::Value GetFramebufferAttachmentParameter(JSContext* cx, GLenum target,
                                                         GLenum attachment, GLenum pname,
                                                         ErrorResult& rv) override;
+    // Make the inline version from the superclass visible here.
+    using WebGLContext::GetFramebufferAttachmentParameter;
 
     void InvalidateFramebuffer(GLenum target, const dom::Sequence<GLenum>& attachments,
                                ErrorResult& rv);
     void InvalidateSubFramebuffer (GLenum target, const dom::Sequence<GLenum>& attachments, GLint x, GLint y,
                                    GLsizei width, GLsizei height, ErrorResult& rv);
     void ReadBuffer(GLenum mode);
 
 
@@ -361,16 +363,18 @@ public:
     // -------------------------------------------------------------------------
     // Uniform Buffer Objects and Transform Feedback Buffers - WebGL2ContextUniforms.cpp
     // TODO(djg): Implemented in WebGLContext
 /*
     void BindBufferBase(GLenum target, GLuint index, WebGLBuffer* buffer);
     void BindBufferRange(GLenum target, GLuint index, WebGLBuffer* buffer, GLintptr offset, GLsizeiptr size);
 */
     virtual JS::Value GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv) override;
+    // Make the inline version from the superclass visible here.
+    using WebGLContext::GetParameter;
     void GetIndexedParameter(JSContext* cx, GLenum target, GLuint index,
                              JS::MutableHandleValue retval, ErrorResult& rv);
     void GetUniformIndices(const WebGLProgram& program,
                            const dom::Sequence<nsString>& uniformNames,
                            dom::Nullable< nsTArray<GLuint> >& retval);
     void GetActiveUniforms(JSContext* cx, const WebGLProgram& program,
                            const dom::Sequence<GLuint>& uniformIndices, GLenum pname,
                            JS::MutableHandleValue retval);
--- a/dom/webidl/WebGL2RenderingContext.webidl
+++ b/dom/webidl/WebGL2RenderingContext.webidl
@@ -19,18 +19,25 @@ interface WebGLSync {
 };
 
 [Pref="webgl.enable-webgl2"]
 interface WebGLTransformFeedback {
 };
 
 typedef (Uint32Array or sequence<GLuint>) Uint32List;
 
+// WebGL2 spec has this as an empty interface that pulls in everything
+// via WebGL2RenderingContextBase.
 [Pref="webgl.enable-webgl2"]
-interface WebGL2RenderingContext : WebGLRenderingContext
+interface WebGL2RenderingContext
+{
+};
+
+[NoInterfaceObject]
+interface WebGL2RenderingContextBase
 {
     const GLenum READ_BUFFER                                   = 0x0C02;
     const GLenum UNPACK_ROW_LENGTH                             = 0x0CF2;
     const GLenum UNPACK_SKIP_ROWS                              = 0x0CF3;
     const GLenum UNPACK_SKIP_PIXELS                            = 0x0CF4;
     const GLenum PACK_ROW_LENGTH                               = 0x0D02;
     const GLenum PACK_SKIP_ROWS                                = 0x0D03;
     const GLenum PACK_SKIP_PIXELS                              = 0x0D04;
@@ -169,18 +176,16 @@ interface WebGL2RenderingContext : WebGL
     const GLenum FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE         = 0x8211;
     const GLenum FRAMEBUFFER_ATTACHMENT_RED_SIZE               = 0x8212;
     const GLenum FRAMEBUFFER_ATTACHMENT_GREEN_SIZE             = 0x8213;
     const GLenum FRAMEBUFFER_ATTACHMENT_BLUE_SIZE              = 0x8214;
     const GLenum FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE             = 0x8215;
     const GLenum FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE             = 0x8216;
     const GLenum FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE           = 0x8217;
     const GLenum FRAMEBUFFER_DEFAULT                           = 0x8218;
-    const GLenum DEPTH_STENCIL_ATTACHMENT                      = 0x821A;
-    const GLenum DEPTH_STENCIL                                 = 0x84F9;
     const GLenum UNSIGNED_INT_24_8                             = 0x84FA;
     const GLenum DEPTH24_STENCIL8                              = 0x88F0;
     const GLenum UNSIGNED_NORMALIZED                           = 0x8C17;
     const GLenum DRAW_FRAMEBUFFER_BINDING                      = 0x8CA6; /* Same as FRAMEBUFFER_BINDING */
     const GLenum READ_FRAMEBUFFER                              = 0x8CA8;
     const GLenum DRAW_FRAMEBUFFER                              = 0x8CA9;
     const GLenum READ_FRAMEBUFFER_BINDING                      = 0x8CAA;
     const GLenum RENDERBUFFER_SAMPLES                          = 0x8CAB;
@@ -295,24 +300,24 @@ interface WebGL2RenderingContext : WebGL
 
     /* WebGL-specific enums */
     const GLenum MAX_CLIENT_WAIT_TIMEOUT_WEBGL                 = 0x9247;
 
     /* Buffer objects */
     // WebGL1:
     void bufferData(GLenum target, GLsizeiptr size, GLenum usage);
     void bufferData(GLenum target, ArrayBuffer? srcData, GLenum usage);
-    //void bufferData(GLenum target, ArrayBufferView srcData, GLenum usage);
+    void bufferData(GLenum target, ArrayBufferView srcData, GLenum usage);
     void bufferSubData(GLenum target, GLintptr offset, ArrayBuffer srcData);
-    //void bufferSubData(GLenum target, GLintptr offset, ArrayBufferView srcData);
+    void bufferSubData(GLenum target, GLintptr offset, ArrayBufferView srcData);
     // WebGL2:
     void bufferData(GLenum target, ArrayBufferView srcData, GLenum usage,
-                    optional GLuint srcOffset = 0, optional GLuint length = 0);
+                    GLuint srcOffset, optional GLuint length = 0);
     void bufferSubData(GLenum target, GLintptr dstByteOffset, ArrayBufferView srcData,
-                       optional GLuint srcOffset = 0, optional GLuint length = 0);
+                       GLuint srcOffset, optional GLuint length = 0);
 
     void copyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset,
                            GLintptr writeOffset, GLsizeiptr size);
     // MapBufferRange, in particular its read-only and write-only modes,
     // can not be exposed safely to JavaScript. GetBufferSubData
     // replaces it for the purpose of fetching data back from the GPU.
     void getBufferSubData(GLenum target, GLintptr srcByteOffset, ArrayBufferView dstData,
                           optional GLuint dstOffset = 0, optional GLuint length = 0);
@@ -661,11 +666,14 @@ interface WebGL2RenderingContext : WebGL
 
     /* Vertex Array Objects */
     WebGLVertexArrayObject? createVertexArray();
     void deleteVertexArray(WebGLVertexArrayObject? vertexArray);
     [WebGLHandlesContextLoss] GLboolean isVertexArray(WebGLVertexArrayObject? vertexArray);
     void bindVertexArray(WebGLVertexArrayObject? array);
 };
 
+WebGL2RenderingContextBase implements WebGLRenderingContextBase;
+WebGL2RenderingContext implements WebGL2RenderingContextBase;
+
 [NoInterfaceObject]
 interface EXT_color_buffer_float {
 };
--- a/dom/webidl/WebGLRenderingContext.webidl
+++ b/dom/webidl/WebGLRenderingContext.webidl
@@ -97,20 +97,22 @@ interface WebGLShaderPrecisionFormat {
     readonly attribute GLint rangeMin;
     readonly attribute GLint rangeMax;
     readonly attribute GLint precision;
 };
 
 typedef (Float32Array or sequence<GLfloat>) Float32List;
 typedef (Int32Array or sequence<GLint>) Int32List;
 
-[Exposed=(Window,Worker),
- Func="mozilla::dom::OffscreenCanvas::PrefEnabledOnWorkerThread"]
-interface WebGLRenderingContext {
-
+// Shared interface for the things that WebGLRenderingContext and
+// WebGL2RenderingContext have in common.  This doesn't have all the things they
+// have in common, because we don't support splitting multiple overloads of the
+// same method across separate interfaces and pulling them in with "implements".
+[Exposed=(Window, Worker), NoInterfaceObject]
+interface WebGLRenderingContextBase {
     /* ClearBufferMask */
     const GLenum DEPTH_BUFFER_BIT               = 0x00000100;
     const GLenum STENCIL_BUFFER_BIT             = 0x00000400;
     const GLenum COLOR_BUFFER_BIT               = 0x00004000;
 
     /* BeginMode */
     const GLenum POINTS                         = 0x0000;
     const GLenum LINES                          = 0x0001;
@@ -548,38 +550,24 @@ interface WebGLRenderingContext {
     void bindTexture(GLenum target, WebGLTexture? texture);
     void blendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
     void blendEquation(GLenum mode);
     void blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha);
     void blendFunc(GLenum sfactor, GLenum dfactor);
     void blendFuncSeparate(GLenum srcRGB, GLenum dstRGB,
                            GLenum srcAlpha, GLenum dstAlpha);
 
-    void bufferData(GLenum target, GLsizeiptr size, GLenum usage);
-    void bufferData(GLenum target, ArrayBuffer? data, GLenum usage);
-    void bufferData(GLenum target, ArrayBufferView data, GLenum usage);
-    void bufferSubData(GLenum target, GLintptr offset, ArrayBuffer data);
-    void bufferSubData(GLenum target, GLintptr offset, ArrayBufferView data);
-
     [WebGLHandlesContextLoss] GLenum checkFramebufferStatus(GLenum target);
     void clear(GLbitfield mask);
     void clearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
     void clearDepth(GLclampf depth);
     void clearStencil(GLint s);
     void colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
     void compileShader(WebGLShader shader);
 
-    void compressedTexImage2D(GLenum target, GLint level, GLenum internalformat,
-                              GLsizei width, GLsizei height, GLint border,
-                              ArrayBufferView data);
-    void compressedTexSubImage2D(GLenum target, GLint level,
-                                 GLint xoffset, GLint yoffset,
-                                 GLsizei width, GLsizei height, GLenum format,
-                                 ArrayBufferView data);
-
     void copyTexImage2D(GLenum target, GLint level, GLenum internalformat,
                         GLint x, GLint y, GLsizei width, GLsizei height,
                         GLint border);
     void copyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
                            GLint x, GLint y, GLsizei width, GLsizei height);
 
     WebGLBuffer? createBuffer();
     WebGLFramebuffer? createFramebuffer();
@@ -669,97 +657,43 @@ interface WebGLRenderingContext {
     [WebGLHandlesContextLoss] GLboolean isRenderbuffer(WebGLRenderbuffer? renderbuffer);
     [WebGLHandlesContextLoss] GLboolean isShader(WebGLShader? shader);
     [WebGLHandlesContextLoss] GLboolean isTexture(WebGLTexture? texture);
     void lineWidth(GLfloat width);
     void linkProgram(WebGLProgram program);
     void pixelStorei(GLenum pname, GLint param);
     void polygonOffset(GLfloat factor, GLfloat units);
 
-    [Throws]
-    void readPixels(GLint x, GLint y, GLsizei width, GLsizei height,
-                    GLenum format, GLenum type, ArrayBufferView? pixels);
-
     void renderbufferStorage(GLenum target, GLenum internalformat,
                              GLsizei width, GLsizei height);
     void sampleCoverage(GLclampf value, GLboolean invert);
     void scissor(GLint x, GLint y, GLsizei width, GLsizei height);
 
     void shaderSource(WebGLShader shader, DOMString source);
 
     void stencilFunc(GLenum func, GLint ref, GLuint mask);
     void stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask);
     void stencilMask(GLuint mask);
     void stencilMaskSeparate(GLenum face, GLuint mask);
     void stencilOp(GLenum fail, GLenum zfail, GLenum zpass);
     void stencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
 
-
-    // Overloads must share [Throws].
-    [Throws] // Can't actually throw.
-    void texImage2D(GLenum target, GLint level, GLint internalformat,
-                    GLsizei width, GLsizei height, GLint border, GLenum format,
-                    GLenum type, ArrayBufferView? pixels);
-    [Throws] // Can't actually throw.
-    void texImage2D(GLenum target, GLint level, GLint internalformat,
-                    GLenum format, GLenum type, ImageData pixels);
-    [Throws]
-    void texImage2D(GLenum target, GLint level, GLint internalformat,
-                    GLenum format, GLenum type, HTMLImageElement image); // May throw DOMException
-    [Throws]
-    void texImage2D(GLenum target, GLint level, GLint internalformat,
-                    GLenum format, GLenum type, HTMLCanvasElement canvas); // May throw DOMException
-    [Throws]
-    void texImage2D(GLenum target, GLint level, GLint internalformat,
-                    GLenum format, GLenum type, HTMLVideoElement video); // May throw DOMException
-
     void texParameterf(GLenum target, GLenum pname, GLfloat param);
     void texParameteri(GLenum target, GLenum pname, GLint param);
 
-    [Throws] // Can't actually throw.
-    void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
-                       GLsizei width, GLsizei height,
-                       GLenum format, GLenum type, ArrayBufferView? pixels);
-    [Throws] // Can't actually throw.
-    void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
-                       GLenum format, GLenum type, ImageData pixels);
-    [Throws]
-    void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
-                       GLenum format, GLenum type, HTMLImageElement image); // May throw DOMException
-    [Throws]
-    void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
-                       GLenum format, GLenum type, HTMLCanvasElement canvas); // May throw DOMException
-    [Throws]
-    void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
-                       GLenum format, GLenum type, HTMLVideoElement video); // May throw DOMException
-
     void uniform1f(WebGLUniformLocation? location, GLfloat x);
     void uniform2f(WebGLUniformLocation? location, GLfloat x, GLfloat y);
     void uniform3f(WebGLUniformLocation? location, GLfloat x, GLfloat y, GLfloat z);
     void uniform4f(WebGLUniformLocation? location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
 
     void uniform1i(WebGLUniformLocation? location, GLint x);
     void uniform2i(WebGLUniformLocation? location, GLint x, GLint y);
     void uniform3i(WebGLUniformLocation? location, GLint x, GLint y, GLint z);
     void uniform4i(WebGLUniformLocation? location, GLint x, GLint y, GLint z, GLint w);
 
-    void uniform1fv(WebGLUniformLocation? location, Float32List data);
-    void uniform2fv(WebGLUniformLocation? location, Float32List data);
-    void uniform3fv(WebGLUniformLocation? location, Float32List data);
-    void uniform4fv(WebGLUniformLocation? location, Float32List data);
-
-    void uniform1iv(WebGLUniformLocation? location, Int32List data);
-    void uniform2iv(WebGLUniformLocation? location, Int32List data);
-    void uniform3iv(WebGLUniformLocation? location, Int32List data);
-    void uniform4iv(WebGLUniformLocation? location, Int32List data);
-
-    void uniformMatrix2fv(WebGLUniformLocation? location, GLboolean transpose, Float32List data);
-    void uniformMatrix3fv(WebGLUniformLocation? location, GLboolean transpose, Float32List data);
-    void uniformMatrix4fv(WebGLUniformLocation? location, GLboolean transpose, Float32List data);
-
     void useProgram(WebGLProgram? program);
     void validateProgram(WebGLProgram program);
 
     void vertexAttrib1f(GLuint indx, GLfloat x);
     void vertexAttrib1fv(GLuint indx, Float32Array values);
     void vertexAttrib1fv(GLuint indx, sequence<GLfloat> values);
     void vertexAttrib2f(GLuint indx, GLfloat x, GLfloat y);
     void vertexAttrib2fv(GLuint indx, Float32Array values);
@@ -771,16 +705,103 @@ interface WebGLRenderingContext {
     void vertexAttrib4fv(GLuint indx, Float32Array values);
     void vertexAttrib4fv(GLuint indx, sequence<GLfloat> values);
     void vertexAttribPointer(GLuint indx, GLint size, GLenum type,
                              GLboolean normalized, GLsizei stride, GLintptr offset);
 
     void viewport(GLint x, GLint y, GLsizei width, GLsizei height);
 };
 
+[Exposed=(Window,Worker),
+ Func="mozilla::dom::OffscreenCanvas::PrefEnabledOnWorkerThread"]
+interface WebGLRenderingContext {
+    // bufferData has WebGL2 overloads.
+    void bufferData(GLenum target, GLsizeiptr size, GLenum usage);
+    void bufferData(GLenum target, ArrayBuffer? data, GLenum usage);
+    void bufferData(GLenum target, ArrayBufferView data, GLenum usage);
+    // bufferSubData has WebGL2 overloads.
+    void bufferSubData(GLenum target, GLintptr offset, ArrayBuffer data);
+    void bufferSubData(GLenum target, GLintptr offset, ArrayBufferView data);
+
+    // compressedTexImage2D has WebGL2 overloads.
+    void compressedTexImage2D(GLenum target, GLint level, GLenum internalformat,
+                              GLsizei width, GLsizei height, GLint border,
+                              ArrayBufferView data);
+    // compressedTexSubImage2D has WebGL2 overloads.
+    void compressedTexSubImage2D(GLenum target, GLint level,
+                                 GLint xoffset, GLint yoffset,
+                                 GLsizei width, GLsizei height, GLenum format,
+                                 ArrayBufferView data);
+
+    // readPixels has WebGL2 overloads.
+    [Throws]
+    void readPixels(GLint x, GLint y, GLsizei width, GLsizei height,
+                    GLenum format, GLenum type, ArrayBufferView? pixels);
+
+    // texImage2D has WebGL2 overloads.
+    // Overloads must share [Throws].
+    [Throws] // Can't actually throw.
+    void texImage2D(GLenum target, GLint level, GLint internalformat,
+                    GLsizei width, GLsizei height, GLint border, GLenum format,
+                    GLenum type, ArrayBufferView? pixels);
+    [Throws] // Can't actually throw.
+    void texImage2D(GLenum target, GLint level, GLint internalformat,
+                    GLenum format, GLenum type, ImageData pixels);
+    [Throws]
+    void texImage2D(GLenum target, GLint level, GLint internalformat,
+                    GLenum format, GLenum type, HTMLImageElement image); // May throw DOMException
+    [Throws]
+    void texImage2D(GLenum target, GLint level, GLint internalformat,
+                    GLenum format, GLenum type, HTMLCanvasElement canvas); // May throw DOMException
+    [Throws]
+    void texImage2D(GLenum target, GLint level, GLint internalformat,
+                    GLenum format, GLenum type, HTMLVideoElement video); // May throw DOMException
+
+    // texSubImage2D has WebGL2 overloads.
+    [Throws] // Can't actually throw.
+    void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
+                       GLsizei width, GLsizei height,
+                       GLenum format, GLenum type, ArrayBufferView? pixels);
+    [Throws] // Can't actually throw.
+    void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
+                       GLenum format, GLenum type, ImageData pixels);
+    [Throws]
+    void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
+                       GLenum format, GLenum type, HTMLImageElement image); // May throw DOMException
+    [Throws]
+    void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
+                       GLenum format, GLenum type, HTMLCanvasElement canvas); // May throw DOMException
+    [Throws]
+    void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
+                       GLenum format, GLenum type, HTMLVideoElement video); // May throw DOMException
+
+    // uniform*fv have WebGL2 overloads, or rather extensions, that are not
+    // distinguishable from the WebGL1 versions when called with two arguments.
+    void uniform1fv(WebGLUniformLocation? location, Float32List data);
+    void uniform2fv(WebGLUniformLocation? location, Float32List data);
+    void uniform3fv(WebGLUniformLocation? location, Float32List data);
+    void uniform4fv(WebGLUniformLocation? location, Float32List data);
+
+    // uniform*iv have WebGL2 overloads, or rather extensions, that are not
+    // distinguishable from the WebGL1 versions when called with two arguments.
+    void uniform1iv(WebGLUniformLocation? location, Int32List data);
+    void uniform2iv(WebGLUniformLocation? location, Int32List data);
+    void uniform3iv(WebGLUniformLocation? location, Int32List data);
+    void uniform4iv(WebGLUniformLocation? location, Int32List data);
+
+    // uniformMatrix*fv have WebGL2 overloads, or rather extensions, that are
+    // not distinguishable from the WebGL1 versions when called with two
+    // arguments.
+    void uniformMatrix2fv(WebGLUniformLocation? location, GLboolean transpose, Float32List data);
+    void uniformMatrix3fv(WebGLUniformLocation? location, GLboolean transpose, Float32List data);
+    void uniformMatrix4fv(WebGLUniformLocation? location, GLboolean transpose, Float32List data);
+};
+
+WebGLRenderingContext implements WebGLRenderingContextBase;
+
 // For OffscreenCanvas
 // Reference: https://wiki.whatwg.org/wiki/OffscreenCanvas
 [Exposed=(Window,Worker)]
 partial interface WebGLRenderingContext {
     [Func="mozilla::dom::OffscreenCanvas::PrefEnabled"]
     void commit();
 };