author | Boris Zbarsky <bzbarsky@mit.edu> |
Wed, 16 Nov 2016 14:10:22 -0500 | |
changeset 322815 | f9f88713123dd3486daa5e71559f64e5131050f8 |
parent 322814 | 482ed3f75e5b92aaeffd4471a28e4be8399e7084 |
child 322816 | 3ea1cc45978327e18bdda60eb47e4a96f51ba1af |
push id | 83978 |
push user | bzbarsky@mozilla.com |
push date | Wed, 16 Nov 2016 19:10:39 +0000 |
treeherder | mozilla-inbound@3ea1cc459783 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jgilbert |
bugs | 1317625 |
milestone | 53.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -1239,17 +1239,16 @@ DOMInterfaces = { 'WebGLRenderbuffer': { 'nativeType': 'mozilla::WebGLRenderbuffer', 'headerFile': 'WebGLRenderbuffer.h' }, 'WebGLRenderingContext': { 'nativeType': 'mozilla::WebGLContext', 'headerFile': 'WebGLContext.h', - 'implicitJSContext': [ 'getSupportedExtensions' ], }, 'WebGL2RenderingContext': { 'nativeType': 'mozilla::WebGL2Context', 'headerFile': 'WebGL2Context.h', 'implicitJSContext': [ 'getSupportedExtensions' ], },
--- a/dom/canvas/WebGLContext.h +++ b/dom/canvas/WebGLContext.h @@ -7,16 +7,17 @@ #define WEBGLCONTEXT_H_ #include <stdarg.h> #include "GLContextTypes.h" #include "GLDefs.h" #include "mozilla/Attributes.h" #include "mozilla/CheckedInt.h" +#include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/HTMLCanvasElement.h" #include "mozilla/dom/TypedArray.h" #include "mozilla/EnumeratedArray.h" #include "mozilla/ErrorResult.h" #include "mozilla/gfx/2D.h" #include "mozilla/LinkedList.h" #include "mozilla/UniquePtr.h" #include "nsCycleCollectionNoteChild.h" @@ -479,20 +480,21 @@ public: } layers::LayersBackend GetCompositorBackendType() const; void GetContextAttributes(dom::Nullable<dom::WebGLContextAttributes>& retval); bool IsContextLost() const { return mContextStatus != ContextNotLost; } - void GetSupportedExtensions(JSContext* cx, - dom::Nullable< nsTArray<nsString> >& retval); + void GetSupportedExtensions(dom::Nullable< nsTArray<nsString> >& retval, + dom::CallerType callerType); void GetExtension(JSContext* cx, const nsAString& name, - JS::MutableHandle<JSObject*> retval, ErrorResult& rv); + JS::MutableHandle<JSObject*> retval, + dom::CallerType callerType, ErrorResult& rv); void AttachShader(WebGLProgram* prog, WebGLShader* shader); void BindAttribLocation(WebGLProgram* prog, GLuint location, const nsAString& name); void BindFramebuffer(GLenum target, WebGLFramebuffer* fb); void BindRenderbuffer(GLenum target, WebGLRenderbuffer* fb); void BindVertexArray(WebGLVertexArray* vao); void BlendColor(GLclampf r, GLclampf g, GLclampf b, GLclampf a); void BlendEquation(GLenum mode); @@ -1446,26 +1448,27 @@ protected: RefPtr<WebGLExtensionBase>> ExtensionsArrayType; ExtensionsArrayType mExtensions; // enable an extension. the extension should not be enabled before. void EnableExtension(WebGLExtensionID ext); // Enable an extension if it's supported. Return the extension on success. - WebGLExtensionBase* EnableSupportedExtension(JSContext* js, + WebGLExtensionBase* EnableSupportedExtension(dom::CallerType callerType, WebGLExtensionID ext); public: // returns true if the extension has been enabled by calling getExtension. bool IsExtensionEnabled(WebGLExtensionID ext) const; protected: - // returns true if the extension is supported for this JSContext (this decides what getSupportedExtensions exposes) - bool IsExtensionSupported(JSContext* cx, WebGLExtensionID ext) const; + // returns true if the extension is supported for this caller type (this decides what getSupportedExtensions exposes) + bool IsExtensionSupported(dom::CallerType callerType, + WebGLExtensionID ext) const; bool IsExtensionSupported(WebGLExtensionID ext) const; static const char* GetExtensionString(WebGLExtensionID ext); nsTArray<GLenum> mCompressedTextureFormats; // ------------------------------------------------------------------------- // WebGL 2 specifics (implemented in WebGL2Context.cpp)
--- a/dom/canvas/WebGLContextExtensions.cpp +++ b/dom/canvas/WebGLContextExtensions.cpp @@ -6,16 +6,17 @@ #include "WebGLContext.h" #include "WebGLContextUtils.h" #include "WebGLExtensions.h" #include "gfxPrefs.h" #include "GLContext.h" #include "nsString.h" #include "mozilla/Preferences.h" +#include "mozilla/dom/BindingDeclarations.h" #include "AccessCheck.h" namespace mozilla { /*static*/ const char* WebGLContext::GetExtensionString(WebGLExtensionID ext) { typedef EnumeratedArray<WebGLExtensionID, WebGLExtensionID::Max, @@ -65,26 +66,25 @@ WebGLContext::GetExtensionString(WebGLEx } bool WebGLContext::IsExtensionEnabled(WebGLExtensionID ext) const { return mExtensions[ext]; } -bool WebGLContext::IsExtensionSupported(JSContext* cx, +bool WebGLContext::IsExtensionSupported(dom::CallerType callerType, WebGLExtensionID ext) const { bool allowPrivilegedExts = false; // Chrome contexts need access to debug information even when // webgl.disable-extensions is set. This is used in the graphics // section of about:support - if (NS_IsMainThread() && - xpc::AccessCheck::isChrome(js::GetContextCompartment(cx))) { + if (callerType == dom::CallerType::System) { allowPrivilegedExts = true; } if (gfxPrefs::WebGLPrivilegedExtensionsEnabled()) { allowPrivilegedExts = true; } if (allowPrivilegedExts) { @@ -228,31 +228,35 @@ WebGLContext::IsExtensionSupported(WebGL static bool CompareWebGLExtensionName(const nsACString& name, const char* other) { return name.Equals(other, nsCaseInsensitiveCStringComparator()); } WebGLExtensionBase* -WebGLContext::EnableSupportedExtension(JSContext* js, WebGLExtensionID ext) +WebGLContext::EnableSupportedExtension(dom::CallerType callerType, + WebGLExtensionID ext) { if (!IsExtensionEnabled(ext)) { - if (!IsExtensionSupported(js, ext)) + if (!IsExtensionSupported(callerType, ext)) return nullptr; EnableExtension(ext); } return mExtensions[ext]; } void -WebGLContext::GetExtension(JSContext* cx, const nsAString& wideName, - JS::MutableHandle<JSObject*> retval, ErrorResult& rv) +WebGLContext::GetExtension(JSContext* cx, + const nsAString& wideName, + JS::MutableHandle<JSObject*> retval, + dom::CallerType callerType, + ErrorResult& rv) { retval.set(nullptr); if (IsContextLost()) return; NS_LossyConvertUTF16toASCII name(wideName); @@ -298,32 +302,34 @@ WebGLContext::GetExtension(JSContext* cx name.get()); } } if (ext == WebGLExtensionID::Unknown) return; // step 2: check if the extension is supported - if (!IsExtensionSupported(cx, ext)) + if (!IsExtensionSupported(callerType, ext)) return; // step 3: if the extension hadn't been previously been created, create it now, thus enabling it - WebGLExtensionBase* extObj = EnableSupportedExtension(cx, ext); + WebGLExtensionBase* extObj = EnableSupportedExtension(callerType, ext); if (!extObj) return; // Step 4: Enable any implied extensions. switch (ext) { case WebGLExtensionID::OES_texture_float: - EnableSupportedExtension(cx, WebGLExtensionID::WEBGL_color_buffer_float); + EnableSupportedExtension(callerType, + WebGLExtensionID::WEBGL_color_buffer_float); break; case WebGLExtensionID::OES_texture_half_float: - EnableSupportedExtension(cx, WebGLExtensionID::EXT_color_buffer_half_float); + EnableSupportedExtension(callerType, + WebGLExtensionID::EXT_color_buffer_half_float); break; default: break; } retval.set(WebGLObjectAsJSObject(cx, extObj, rv)); } @@ -427,44 +433,48 @@ WebGLContext::EnableExtension(WebGLExten default: MOZ_ASSERT(false, "should not get there."); } mExtensions[ext] = obj; } void -WebGLContext::GetSupportedExtensions(JSContext* cx, - dom::Nullable< nsTArray<nsString> >& retval) +WebGLContext::GetSupportedExtensions(dom::Nullable< nsTArray<nsString> >& retval, + dom::CallerType callerType) { retval.SetNull(); if (IsContextLost()) return; nsTArray<nsString>& arr = retval.SetValue(); for (size_t i = 0; i < size_t(WebGLExtensionID::Max); i++) { WebGLExtensionID extension = WebGLExtensionID(i); - if (IsExtensionSupported(cx, extension)) { + if (IsExtensionSupported(callerType, extension)) { const char* extStr = GetExtensionString(extension); arr.AppendElement(NS_ConvertUTF8toUTF16(extStr)); } } /** * We keep backward compatibility for these deprecated vendor-prefixed * alias. Do not add new ones anymore. Hide it behind the * webgl.enable-draft-extensions flag instead. */ - if (IsExtensionSupported(cx, WebGLExtensionID::WEBGL_lose_context)) + if (IsExtensionSupported(callerType, WebGLExtensionID::WEBGL_lose_context)) arr.AppendElement(NS_LITERAL_STRING("MOZ_WEBGL_lose_context")); - if (IsExtensionSupported(cx, WebGLExtensionID::WEBGL_compressed_texture_s3tc)) + if (IsExtensionSupported(callerType, + WebGLExtensionID::WEBGL_compressed_texture_s3tc)) arr.AppendElement(NS_LITERAL_STRING("MOZ_WEBGL_compressed_texture_s3tc")); - if (IsExtensionSupported(cx, WebGLExtensionID::WEBGL_compressed_texture_atc)) + if (IsExtensionSupported(callerType, + WebGLExtensionID::WEBGL_compressed_texture_atc)) arr.AppendElement(NS_LITERAL_STRING("MOZ_WEBGL_compressed_texture_atc")); - if (IsExtensionSupported(cx, WebGLExtensionID::WEBGL_compressed_texture_pvrtc)) + if (IsExtensionSupported(callerType, + WebGLExtensionID::WEBGL_compressed_texture_pvrtc)) arr.AppendElement(NS_LITERAL_STRING("MOZ_WEBGL_compressed_texture_pvrtc")); - if (IsExtensionSupported(cx, WebGLExtensionID::WEBGL_depth_texture)) + if (IsExtensionSupported(callerType, + WebGLExtensionID::WEBGL_depth_texture)) arr.AppendElement(NS_LITERAL_STRING("MOZ_WEBGL_depth_texture")); } } // namespace mozilla
--- a/dom/webidl/WebGLRenderingContext.webidl +++ b/dom/webidl/WebGLRenderingContext.webidl @@ -528,19 +528,20 @@ interface WebGLRenderingContext { // The canvas might actually be null in some cases, apparently. readonly attribute (HTMLCanvasElement or OffscreenCanvas)? canvas; readonly attribute GLsizei drawingBufferWidth; readonly attribute GLsizei drawingBufferHeight; [WebGLHandlesContextLoss] WebGLContextAttributes? getContextAttributes(); [WebGLHandlesContextLoss] boolean isContextLost(); + [NeedsCallerType] sequence<DOMString>? getSupportedExtensions(); - [Throws] + [Throws, NeedsCallerType] object? getExtension(DOMString name); void activeTexture(GLenum texture); void attachShader(WebGLProgram? program, WebGLShader? shader); void bindAttribLocation(WebGLProgram? program, GLuint index, DOMString name); void bindBuffer(GLenum target, WebGLBuffer? buffer); void bindFramebuffer(GLenum target, WebGLFramebuffer? framebuffer); void bindRenderbuffer(GLenum target, WebGLRenderbuffer? renderbuffer);