diff options
author | Emilio Cobos Álvarez <ecoal95@gmail.com> | 2015-10-03 21:09:54 +0200 |
---|---|---|
committer | Emilio Cobos Álvarez <ecoal95@gmail.com> | 2015-10-08 00:29:31 +0200 |
commit | 7030f098231a98f492ad691700d0c79c82cfb372 (patch) | |
tree | 0f25b0ea260621d1952310198a2489b11265b410 /components/script/dom/webglrenderingcontext.rs | |
parent | 217c7da41304142ffaf7c02a3eb888b0f150c59d (diff) | |
download | servo-7030f098231a98f492ad691700d0c79c82cfb372.tar.gz servo-7030f098231a98f492ad691700d0c79c82cfb372.zip |
webgl: Implement WebGLContextEvent and use it on context creation error
spec: https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15
Diffstat (limited to 'components/script/dom/webglrenderingcontext.rs')
-rw-r--r-- | components/script/dom/webglrenderingcontext.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index cd71f64d077..2fd87cfd19d 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -8,16 +8,18 @@ use canvas_traits::{WebGLFramebufferBindingRequest, WebGLShaderParameter}; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::{WebGLRenderingContextMethods}; use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::{self, WebGLContextAttributes}; -use dom::bindings::codegen::InheritTypes::NodeCast; +use dom::bindings::codegen::InheritTypes::{EventCast, EventTargetCast, NodeCast}; use dom::bindings::codegen::UnionTypes::ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement; use dom::bindings::conversions::ToJSValConvertible; use dom::bindings::global::{GlobalField, GlobalRef}; use dom::bindings::js::{JS, LayoutJS, Root}; use dom::bindings::utils::{Reflector, reflect_dom_object}; +use dom::event::{EventBubbles, EventCancelable}; use dom::htmlcanvaselement::HTMLCanvasElement; use dom::htmlcanvaselement::utils as canvas_utils; use dom::node::{NodeDamage, window_from_node}; use dom::webglbuffer::WebGLBuffer; +use dom::webglcontextevent::WebGLContextEvent; use dom::webglframebuffer::WebGLFramebuffer; use dom::webglprogram::WebGLProgram; use dom::webglrenderbuffer::WebGLRenderbuffer; @@ -115,6 +117,15 @@ impl WebGLRenderingContext { WebGLRenderingContextBinding::Wrap)), Err(msg) => { error!("Couldn't create WebGLRenderingContext: {}", msg); + let event = WebGLContextEvent::new(global, "webglcontextcreationerror".to_owned(), + EventBubbles::DoesNotBubble, + EventCancelable::Cancelable, + msg); + + let event = EventCast::from_ref(event.r()); + let target = EventTargetCast::from_ref(canvas); + + event.fire(target); None } } |