From aa0a72df0f5017c71572af38ec912e8b011bb34d Mon Sep 17 00:00:00 2001 From: Alan Jeffrey Date: Wed, 17 Jul 2019 18:09:15 -0500 Subject: [PATCH 1/4] Added framebuffer and related attributes to XRWebGLLayer --- Cargo.lock | 4 +- components/script/dom/bindings/error.rs | 3 + components/script/dom/bindings/trace.rs | 11 +- components/script/dom/domexception.rs | 5 + components/script/dom/fakexrdevice.rs | 12 ++ .../script/dom/webidls/DOMException.webidl | 3 + .../script/dom/webidls/XRWebGLLayer.webidl | 6 +- components/script/dom/xrsession.rs | 2 +- components/script/dom/xrviewport.rs | 32 ++--- components/script/dom/xrwebgllayer.rs | 126 +++++++++++++++--- 10 files changed, 158 insertions(+), 46 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 896c9a697ab..4bb685728f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5485,7 +5485,7 @@ dependencies = [ [[package]] name = "webxr" version = "0.0.1" -source = "git+https://github.com/servo/webxr#abc779798259d287539347a5d2048ae745f1f2ac" +source = "git+https://github.com/servo/webxr#5c0eb61f8f38429fde45673d0884f947d14e9c79" dependencies = [ "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5497,7 +5497,7 @@ dependencies = [ [[package]] name = "webxr-api" version = "0.0.1" -source = "git+https://github.com/servo/webxr#abc779798259d287539347a5d2048ae745f1f2ac" +source = "git+https://github.com/servo/webxr#5c0eb61f8f38429fde45673d0884f947d14e9c79" dependencies = [ "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/components/script/dom/bindings/error.rs b/components/script/dom/bindings/error.rs index 5953a013d6d..40d690ff8d0 100644 --- a/components/script/dom/bindings/error.rs +++ b/components/script/dom/bindings/error.rs @@ -84,6 +84,8 @@ pub enum Error { InvalidModification, /// NotReadableError DOMException NotReadable, + /// OperationError DOMException + Operation, /// TypeError JavaScript Error Type(String), @@ -136,6 +138,7 @@ pub unsafe fn throw_dom_exception(cx: *mut JSContext, global: &GlobalScope, resu Error::TypeMismatch => DOMErrorName::TypeMismatchError, Error::InvalidModification => DOMErrorName::InvalidModificationError, Error::NotReadable => DOMErrorName::NotReadableError, + Error::Operation => DOMErrorName::OperationError, Error::Type(message) => { assert!(!JS_IsExceptionPending(cx)); throw_type_error(cx, &message); diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index a0307413719..7f4fad813e5 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -57,8 +57,8 @@ use devtools_traits::{CSSError, TimelineMarkerType, WorkerId}; use encoding_rs::{Decoder, Encoding}; use euclid::Length as EuclidLength; use euclid::{ - Point2D, Rect, RigidTransform3D, Rotation3D, Transform2D, Transform3D, TypedRigidTransform3D, - TypedScale, TypedSize2D, Vector2D, + Point2D, Rect, RigidTransform3D, Rotation3D, Transform2D, Transform3D, TypedRect, + TypedRigidTransform3D, TypedScale, TypedSize2D, Vector2D, }; use html5ever::buffer_queue::BufferQueue; use html5ever::{LocalName, Namespace, Prefix, QualName}; @@ -647,6 +647,13 @@ unsafe impl JSTraceable for TypedSize2D { } } +unsafe impl JSTraceable for TypedRect { + #[inline] + unsafe fn trace(&self, _trc: *mut JSTracer) { + // Do nothing + } +} + unsafe impl JSTraceable for StyleLocked { unsafe fn trace(&self, _trc: *mut JSTracer) { // Do nothing. diff --git a/components/script/dom/domexception.rs b/components/script/dom/domexception.rs index b5b0ca5a8c4..0df528edb87 100644 --- a/components/script/dom/domexception.rs +++ b/components/script/dom/domexception.rs @@ -37,6 +37,7 @@ pub enum DOMErrorName { InvalidNodeTypeError = DOMExceptionConstants::INVALID_NODE_TYPE_ERR, DataCloneError = DOMExceptionConstants::DATA_CLONE_ERR, NotReadableError = DOMExceptionConstants::NOT_READABLE_ERR, + OperationError = DOMExceptionConstants::OPERATION_ERR, } impl DOMErrorName { @@ -64,6 +65,7 @@ impl DOMErrorName { "InvalidNodeTypeError" => Some(DOMErrorName::InvalidNodeTypeError), "DataCloneError" => Some(DOMErrorName::DataCloneError), "NotReadableError" => Some(DOMErrorName::NotReadableError), + "OperationError" => Some(DOMErrorName::OperationError), _ => None, } } @@ -107,6 +109,9 @@ impl DOMException { }, DOMErrorName::DataCloneError => "The object can not be cloned.", DOMErrorName::NotReadableError => "The I/O read operation failed.", + DOMErrorName::OperationError => { + "The operation failed for an operation-specific reason." + }, }; ( diff --git a/components/script/dom/fakexrdevice.rs b/components/script/dom/fakexrdevice.rs index e8aa3e26dff..c1268d743d9 100644 --- a/components/script/dom/fakexrdevice.rs +++ b/components/script/dom/fakexrdevice.rs @@ -11,6 +11,7 @@ use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::globalscope::GlobalScope; use dom_struct::dom_struct; +use euclid::{TypedPoint2D, TypedRect, TypedSize2D}; use euclid::{TypedRigidTransform3D, TypedRotation3D, TypedTransform3D, TypedVector3D}; use ipc_channel::ipc::IpcSender; use webxr_api::{MockDeviceMsg, View, Views}; @@ -71,13 +72,24 @@ pub fn get_views(views: &[FakeXRViewInit]) -> Fallible { let offset_l = get_origin(&left.viewOffset)?.inverse(); let offset_r = get_origin(&right.viewOffset)?.inverse(); + let size_l = TypedSize2D::new(views[0].resolution.width, views[0].resolution.height); + let size_r = TypedSize2D::new(views[1].resolution.width, views[1].resolution.height); + + let origin_l = TypedPoint2D::new(0, 0); + let origin_r = TypedPoint2D::new(size_l.width, 0); + + let viewport_l = TypedRect::new(origin_l, size_l); + let viewport_r = TypedRect::new(origin_r, size_r); + let left = View { projection: proj_l, transform: offset_l, + viewport: viewport_l, }; let right = View { projection: proj_r, transform: offset_r, + viewport: viewport_r, }; Ok(Views::Stereo(left, right)) } diff --git a/components/script/dom/webidls/DOMException.webidl b/components/script/dom/webidls/DOMException.webidl index a686e5b7023..80bf319fdd5 100644 --- a/components/script/dom/webidls/DOMException.webidl +++ b/components/script/dom/webidls/DOMException.webidl @@ -38,7 +38,10 @@ interface DOMException { const unsigned short TIMEOUT_ERR = 23; const unsigned short INVALID_NODE_TYPE_ERR = 24; const unsigned short DATA_CLONE_ERR = 25; + // Only the first 25 errors are given codes in + // https://heycam.github.io/webidl/#idl-DOMException const unsigned short NOT_READABLE_ERR = 26; + const unsigned short OPERATION_ERR = 27; // Error code as u16 readonly attribute unsigned short code; diff --git a/components/script/dom/webidls/XRWebGLLayer.webidl b/components/script/dom/webidls/XRWebGLLayer.webidl index f551096fc05..f83e1e4c35a 100644 --- a/components/script/dom/webidls/XRWebGLLayer.webidl +++ b/components/script/dom/webidls/XRWebGLLayer.webidl @@ -30,9 +30,9 @@ interface XRWebGLLayer : XRLayer { readonly attribute boolean stencil; readonly attribute boolean alpha; - // readonly attribute WebGLFramebuffer framebuffer; - // readonly attribute unsigned long framebufferWidth; - // readonly attribute unsigned long framebufferHeight; + readonly attribute WebGLFramebuffer framebuffer; + readonly attribute unsigned long framebufferWidth; + readonly attribute unsigned long framebufferHeight; // // Methods XRViewport? getViewport(XRView view); diff --git a/components/script/dom/xrsession.rs b/components/script/dom/xrsession.rs index 1c29978e2ae..50e89a773dc 100644 --- a/components/script/dom/xrsession.rs +++ b/components/script/dom/xrsession.rs @@ -103,7 +103,7 @@ impl XRSession { ret } - pub fn with_session(&self, with: F) { + pub fn with_session R>(&self, with: F) -> R { let session = self.session.borrow(); with(&session) } diff --git a/components/script/dom/xrviewport.rs b/components/script/dom/xrviewport.rs index e3065a51d43..f0b013a317e 100644 --- a/components/script/dom/xrviewport.rs +++ b/components/script/dom/xrviewport.rs @@ -8,36 +8,26 @@ use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::globalscope::GlobalScope; use dom_struct::dom_struct; +use euclid::TypedRect; +use webxr_api::Viewport; #[dom_struct] pub struct XRViewport { reflector_: Reflector, - x: u32, - y: u32, - width: u32, - height: u32, + viewport: TypedRect, } impl XRViewport { - fn new_inherited(x: u32, y: u32, width: u32, height: u32) -> XRViewport { + fn new_inherited(viewport: TypedRect) -> XRViewport { XRViewport { reflector_: Reflector::new(), - x, - y, - width, - height, + viewport, } } - pub fn new( - global: &GlobalScope, - x: u32, - y: u32, - width: u32, - height: u32, - ) -> DomRoot { + pub fn new(global: &GlobalScope, viewport: TypedRect) -> DomRoot { reflect_dom_object( - Box::new(XRViewport::new_inherited(x, y, width, height)), + Box::new(XRViewport::new_inherited(viewport)), global, XRViewportBinding::Wrap, ) @@ -47,21 +37,21 @@ impl XRViewport { impl XRViewportMethods for XRViewport { /// https://immersive-web.github.io/webxr/#dom-xrviewport-x fn X(&self) -> i32 { - self.x as i32 + self.viewport.origin.x } /// https://immersive-web.github.io/webxr/#dom-xrviewport-y fn Y(&self) -> i32 { - self.y as i32 + self.viewport.origin.y } /// https://immersive-web.github.io/webxr/#dom-xrviewport-width fn Width(&self) -> i32 { - self.width as i32 + self.viewport.size.width } /// https://immersive-web.github.io/webxr/#dom-xrviewport-height fn Height(&self) -> i32 { - self.height as i32 + self.viewport.size.height } } diff --git a/components/script/dom/xrwebgllayer.rs b/components/script/dom/xrwebgllayer.rs index 16653383a0b..a2a7c93f37c 100644 --- a/components/script/dom/xrwebgllayer.rs +++ b/components/script/dom/xrwebgllayer.rs @@ -6,10 +6,15 @@ use crate::dom::bindings::codegen::Bindings::XRViewBinding::{XREye, XRViewMethod use crate::dom::bindings::codegen::Bindings::XRWebGLLayerBinding; use crate::dom::bindings::codegen::Bindings::XRWebGLLayerBinding::XRWebGLLayerInit; use crate::dom::bindings::codegen::Bindings::XRWebGLLayerBinding::XRWebGLLayerMethods; +use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextBinding::WebGLRenderingContextMethods; +use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; +use crate::dom::bindings::error::Error; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::globalscope::GlobalScope; +use crate::dom::webgl_validations::types::TexImageTarget; +use crate::dom::webglframebuffer::WebGLFramebuffer; use crate::dom::webglrenderingcontext::WebGLRenderingContext; use crate::dom::window::Window; use crate::dom::xrlayer::XRLayer; @@ -17,6 +22,9 @@ use crate::dom::xrsession::XRSession; use crate::dom::xrview::XRView; use crate::dom::xrviewport::XRViewport; use dom_struct::dom_struct; +use js::rust::CustomAutoRooter; +use std::convert::TryInto; +use webxr_api::Views; #[dom_struct] pub struct XRWebGLLayer { @@ -27,6 +35,7 @@ pub struct XRWebGLLayer { alpha: bool, context: Dom, session: Dom, + framebuffer: Dom, } impl XRWebGLLayer { @@ -34,6 +43,7 @@ impl XRWebGLLayer { session: &XRSession, context: &WebGLRenderingContext, init: &XRWebGLLayerInit, + framebuffer: &WebGLFramebuffer, ) -> XRWebGLLayer { XRWebGLLayer { xrlayer: XRLayer::new_inherited(), @@ -43,6 +53,7 @@ impl XRWebGLLayer { alpha: init.alpha, context: Dom::from_ref(context), session: Dom::from_ref(session), + framebuffer: Dom::from_ref(framebuffer), } } @@ -51,21 +62,82 @@ impl XRWebGLLayer { session: &XRSession, context: &WebGLRenderingContext, init: &XRWebGLLayerInit, + framebuffer: &WebGLFramebuffer, ) -> DomRoot { reflect_dom_object( - Box::new(XRWebGLLayer::new_inherited(session, context, init)), + Box::new(XRWebGLLayer::new_inherited( + session, + context, + init, + framebuffer, + )), global, XRWebGLLayerBinding::Wrap, ) } + /// https://immersive-web.github.io/webxr/#dom-xrwebgllayer-xrwebgllayer pub fn Constructor( global: &Window, session: &XRSession, context: &WebGLRenderingContext, init: &XRWebGLLayerInit, ) -> Fallible> { - Ok(XRWebGLLayer::new(&global.global(), session, context, init)) + let cx = global.get_cx(); + let old_fbo = context.bound_framebuffer(); + let old_texture = context + .textures() + .active_texture_for_image_target(TexImageTarget::Texture2D); + + // Step 8.2. "Initialize layer’s framebuffer to a new opaque framebuffer created with context." + let framebuffer = context.CreateFramebuffer().ok_or(Error::Operation)?; + + // Step 8.3. "Allocate and initialize resources compatible with session’s XR device, + // including GPU accessible memory buffers, as required to support the compositing of layer." + + // Create a new texture with size given by the session's recommended resolution + let texture = context.CreateTexture().ok_or(Error::Operation)?; + let resolution = session.with_session(|s| s.recommended_framebuffer_resolution()); + let mut pixels = CustomAutoRooter::new(None); + context.BindTexture(constants::TEXTURE_2D, Some(&texture)); + let sc = context.TexImage2D( + constants::TEXTURE_2D, + 0, + constants::RGBA, + resolution.width, + resolution.height, + 0, + constants::RGBA, + constants::UNSIGNED_BYTE, + pixels.root(cx), + ); + + // Bind the new texture to the framebuffer + context.BindFramebuffer(constants::FRAMEBUFFER, Some(&framebuffer)); + context.FramebufferTexture2D( + constants::FRAMEBUFFER, + constants::COLOR_ATTACHMENT0, + constants::TEXTURE_2D, + Some(&texture), + 0, + ); + + // Restore the WebGL state while complaining about global mutable state + context.BindTexture(constants::TEXTURE_2D, old_texture.as_ref().map(|t| &**t)); + context.BindFramebuffer(constants::FRAMEBUFFER, old_fbo.as_ref().map(|f| &**f)); + + // Step 8.4: "If layer’s resources were unable to be created for any reason, + // throw an OperationError and abort these steps." + sc.or(Err(Error::Operation))?; + + // Step 9. "Return layer." + Ok(XRWebGLLayer::new( + &global.global(), + session, + context, + init, + &framebuffer, + )) } } @@ -95,28 +167,48 @@ impl XRWebGLLayerMethods for XRWebGLLayer { DomRoot::from_ref(&self.context) } + /// https://immersive-web.github.io/webxr/#dom-xrwebgllayer-framebuffer + fn Framebuffer(&self) -> DomRoot { + DomRoot::from_ref(&self.framebuffer) + } + + /// https://immersive-web.github.io/webxr/#dom-xrwebgllayer-framebufferwidth + fn FramebufferWidth(&self) -> u32 { + self.framebuffer + .size() + .unwrap_or((0, 0)) + .0 + .try_into() + .unwrap_or(0) + } + + /// https://immersive-web.github.io/webxr/#dom-xrwebgllayer-framebufferheight + fn FramebufferHeight(&self) -> u32 { + self.framebuffer + .size() + .unwrap_or((0, 0)) + .1 + .try_into() + .unwrap_or(0) + } + /// https://immersive-web.github.io/webxr/#dom-xrwebgllayer-getviewport fn GetViewport(&self, view: &XRView) -> Option> { if self.session != view.session() { return None; } - let size = self.context.size(); + let views = self.session.with_session(|s| s.views().clone()); - let x = if view.Eye() == XREye::Left { - 0 - } else { - size.width / 2 + let viewport = match (view.Eye(), views) { + (XREye::None, Views::Mono(view)) => view.viewport, + (XREye::Left, Views::Stereo(view, _)) => view.viewport, + (XREye::Right, Views::Stereo(_, view)) => view.viewport, + // The spec doesn't really say what to do in this case + // https://github.com/immersive-web/webxr/issues/769 + _ => return None, }; - // XXXManishearth this assumes the WebVR default of canvases being cut in half - // which need not be generally true for all devices, and will not work in - // inline VR mode - Some(XRViewport::new( - &self.global(), - x, - 0, - size.width / 2, - size.height, - )) + + Some(XRViewport::new(&self.global(), viewport)) } } From f2766cf6f34030c177586cfef2d1d054bd2b5a36 Mon Sep 17 00:00:00 2001 From: Alan Jeffrey Date: Thu, 18 Jul 2019 11:00:16 -0500 Subject: [PATCH 2/4] Added wpt webxr tests for XR layer's viewports and framebuffer --- tests/wpt/metadata/MANIFEST.json | 12 +++- .../webxr/idlharness.https.window.js.ini | 9 --- .../xrWebGLLayer_framebuffer.https.html.ini | 4 ++ .../webxr/xrWebGLLayer_framebuffer.https.html | 58 +++++++++++++++++++ .../webxr/xrWebGLLayer_viewports.https.html | 18 +++++- 5 files changed, 89 insertions(+), 12 deletions(-) create mode 100644 tests/wpt/metadata/webxr/xrWebGLLayer_framebuffer.https.html.ini create mode 100644 tests/wpt/web-platform-tests/webxr/xrWebGLLayer_framebuffer.https.html diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json index 0b1df3155f9..9dea0607a71 100644 --- a/tests/wpt/metadata/MANIFEST.json +++ b/tests/wpt/metadata/MANIFEST.json @@ -410359,6 +410359,12 @@ {} ] ], + "webxr/xrWebGLLayer_framebuffer.https.html": [ + [ + "webxr/xrWebGLLayer_framebuffer.https.html", + {} + ] + ], "webxr/xrWebGLLayer_viewports.https.html": [ [ "webxr/xrWebGLLayer_viewports.https.html", @@ -688112,8 +688118,12 @@ "956edba98365d90eb180ad3c9697dae098bd25db", "testharness" ], + "webxr/xrWebGLLayer_framebuffer.https.html": [ + "7c4ff17c2547995afbf561850faaf92b6aa5e56f", + "testharness" + ], "webxr/xrWebGLLayer_viewports.https.html": [ - "9553a445e43153b716d55c7f2be606dd548b808e", + "8cfccff3c01dedb41db4f26563824ce0cdb65ad3", "testharness" ], "workers/META.yml": [ diff --git a/tests/wpt/metadata/webxr/idlharness.https.window.js.ini b/tests/wpt/metadata/webxr/idlharness.https.window.js.ini index 17bdd9d9913..b3906bc63f5 100644 --- a/tests/wpt/metadata/webxr/idlharness.https.window.js.ini +++ b/tests/wpt/metadata/webxr/idlharness.https.window.js.ini @@ -86,9 +86,6 @@ [XRSessionEvent interface object name] expected: FAIL - [XRWebGLLayer interface: attribute framebufferHeight] - expected: FAIL - [XRInputSourceEvent interface: attribute inputSource] expected: FAIL @@ -128,9 +125,6 @@ [XRRay interface object name] expected: FAIL - [XRWebGLLayer interface: attribute framebufferWidth] - expected: FAIL - [XRInputSourceArray interface: existence and properties of interface prototype object's @@unscopables property] expected: FAIL @@ -236,9 +230,6 @@ [XRInputSourceArray interface: existence and properties of interface prototype object's "constructor" property] expected: FAIL - [XRWebGLLayer interface: attribute framebuffer] - expected: FAIL - [XRInputSourceEvent interface object length] expected: FAIL diff --git a/tests/wpt/metadata/webxr/xrWebGLLayer_framebuffer.https.html.ini b/tests/wpt/metadata/webxr/xrWebGLLayer_framebuffer.https.html.ini new file mode 100644 index 00000000000..0b342979202 --- /dev/null +++ b/tests/wpt/metadata/webxr/xrWebGLLayer_framebuffer.https.html.ini @@ -0,0 +1,4 @@ +[xrWebGLLayer_framebuffer.https.html] + [XRWebGLLayer reports a valid framebuffer for inline sessions] + expected: FAIL + diff --git a/tests/wpt/web-platform-tests/webxr/xrWebGLLayer_framebuffer.https.html b/tests/wpt/web-platform-tests/webxr/xrWebGLLayer_framebuffer.https.html new file mode 100644 index 00000000000..7c4ff17c254 --- /dev/null +++ b/tests/wpt/web-platform-tests/webxr/xrWebGLLayer_framebuffer.https.html @@ -0,0 +1,58 @@ + + + + + + + + diff --git a/tests/wpt/web-platform-tests/webxr/xrWebGLLayer_viewports.https.html b/tests/wpt/web-platform-tests/webxr/xrWebGLLayer_viewports.https.html index 9553a445e43..8cfccff3c01 100644 --- a/tests/wpt/web-platform-tests/webxr/xrWebGLLayer_viewports.https.html +++ b/tests/wpt/web-platform-tests/webxr/xrWebGLLayer_viewports.https.html @@ -22,6 +22,8 @@ let testFunction = function(session, fakeDeviceController, t) { let layer = xrFrame.session.renderState.baseLayer; for (view of viewer_pose.views) { let viewport = layer.getViewport(view); + let index = (view.eye === "right"? 1: 0); + let params = fakeDeviceInitParams.views[index]; // Ensure the returned object is an XRViewport object assert_not_equals(viewport, null); @@ -30,8 +32,20 @@ let testFunction = function(session, fakeDeviceController, t) { // Ensure the viewport dimensions are valid assert_greater_than_equal(viewport.x, 0); assert_greater_than_equal(viewport.y, 0); - assert_greater_than_equal(viewport.width, 1); - assert_greater_than_equal(viewport.height, 1); + assert_equals(viewport.width, params.resolution.width); + assert_equals(viewport.height, params.resolution.height); + + // Ensure none of the viewports overlap + for (other of viewer_pose.views) { + if (view !== other) { + let otherport = layer.getViewport(other); + let no_overlap = (viewport.x + viewport.width <= otherport.x) || + (otherport.x + otherport.width <= viewport.x) || + (viewport.y + viewport.height <= otherport.y) || + (otherport.y + otherport.height <= viewport.y); + assert_true(no_overlap, "Overlap between viewport " + view.eye + " and " + other.eye); + } + } } // Finished test. From c08ef4cb237342744c21ff392b4156d11db30db9 Mon Sep 17 00:00:00 2001 From: Alan Jeffrey Date: Thu, 18 Jul 2019 16:48:06 -0500 Subject: [PATCH 3/4] Dead code elimination --- components/script/dom/webglrenderingcontext.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index d413bd1ac71..6e249a38ed0 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -349,10 +349,6 @@ impl WebGLRenderingContext { } } - pub fn size(&self) -> Size2D { - self.size.get() - } - // Helper function for validating framebuffer completeness in // calls touching the framebuffer. From the GLES 2.0.25 spec, // page 119: From 23f15c94efe800db6bbee44a3a5d7464f5c19f31 Mon Sep 17 00:00:00 2001 From: Alan Jeffrey Date: Thu, 18 Jul 2019 16:54:29 -0500 Subject: [PATCH 4/4] Decoupled DOMErrorName from legacy error codes --- components/script/dom/domexception.rs | 12 ++++++------ components/script/dom/webidls/DOMException.webidl | 4 ---- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/components/script/dom/domexception.rs b/components/script/dom/domexception.rs index 0df528edb87..3cfe6092dd1 100644 --- a/components/script/dom/domexception.rs +++ b/components/script/dom/domexception.rs @@ -13,7 +13,7 @@ use crate::dom::globalscope::GlobalScope; use dom_struct::dom_struct; #[repr(u16)] -#[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf)] +#[derive(Clone, Copy, Debug, Eq, JSTraceable, MallocSizeOf, Ord, PartialEq, PartialOrd)] pub enum DOMErrorName { IndexSizeError = DOMExceptionConstants::INDEX_SIZE_ERR, HierarchyRequestError = DOMExceptionConstants::HIERARCHY_REQUEST_ERR, @@ -36,8 +36,8 @@ pub enum DOMErrorName { TimeoutError = DOMExceptionConstants::TIMEOUT_ERR, InvalidNodeTypeError = DOMExceptionConstants::INVALID_NODE_TYPE_ERR, DataCloneError = DOMExceptionConstants::DATA_CLONE_ERR, - NotReadableError = DOMExceptionConstants::NOT_READABLE_ERR, - OperationError = DOMExceptionConstants::OPERATION_ERR, + NotReadableError, + OperationError, } impl DOMErrorName { @@ -152,11 +152,11 @@ impl DOMException { } impl DOMExceptionMethods for DOMException { - // https://heycam.github.io/webidl/#dfn-DOMException + // https://heycam.github.io/webidl/#dom-domexception-code fn Code(&self) -> u16 { match DOMErrorName::from(&self.name) { - Some(code) => code as u16, - None => 0 as u16, + Some(code) if code <= DOMErrorName::DataCloneError => code as u16, + _ => 0, } } diff --git a/components/script/dom/webidls/DOMException.webidl b/components/script/dom/webidls/DOMException.webidl index 80bf319fdd5..1c7bca4ce66 100644 --- a/components/script/dom/webidls/DOMException.webidl +++ b/components/script/dom/webidls/DOMException.webidl @@ -38,10 +38,6 @@ interface DOMException { const unsigned short TIMEOUT_ERR = 23; const unsigned short INVALID_NODE_TYPE_ERR = 24; const unsigned short DATA_CLONE_ERR = 25; - // Only the first 25 errors are given codes in - // https://heycam.github.io/webidl/#idl-DOMException - const unsigned short NOT_READABLE_ERR = 26; - const unsigned short OPERATION_ERR = 27; // Error code as u16 readonly attribute unsigned short code;