aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlcanvaselement.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2025-03-16 09:46:14 -0400
committerGitHub <noreply@github.com>2025-03-16 13:46:14 +0000
commitd35da38a2fd6f093967e74f704612391b4988e69 (patch)
tree96c8705a5a597be25ac74b58043e57b3e06992f4 /components/script/dom/htmlcanvaselement.rs
parent3ecd1c069978f6ceb20e4ee6af599fbef425e9da (diff)
downloadservo-d35da38a2fd6f093967e74f704612391b4988e69.tar.gz
servo-d35da38a2fd6f093967e74f704612391b4988e69.zip
Cleanups for future script crate split (#35987)
* script: Avoid direct impl blocks on generated dicts and unions. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Remove references to codegen-specific import module. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Fix tidy. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Diffstat (limited to 'components/script/dom/htmlcanvaselement.rs')
-rw-r--r--components/script/dom/htmlcanvaselement.rs25
1 files changed, 13 insertions, 12 deletions
diff --git a/components/script/dom/htmlcanvaselement.rs b/components/script/dom/htmlcanvaselement.rs
index b12a6cd0f4a..42a526ce348 100644
--- a/components/script/dom/htmlcanvaselement.rs
+++ b/components/script/dom/htmlcanvaselement.rs
@@ -29,7 +29,9 @@ use style::attr::AttrValue;
use crate::canvas_context::CanvasContext as _;
pub(crate) use crate::canvas_context::*;
+use crate::conversions::Convert;
use crate::dom::attr::Attr;
+use crate::dom::bindings::callback::ExceptionHandling;
use crate::dom::bindings::cell::{DomRefCell, Ref, ref_filter_map};
use crate::dom::bindings::codegen::Bindings::HTMLCanvasElementBinding::{
BlobCallback, HTMLCanvasElementMethods, RenderingContext,
@@ -39,7 +41,6 @@ use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGL
use crate::dom::bindings::codegen::UnionTypes::HTMLCanvasElementOrOffscreenCanvas;
use crate::dom::bindings::conversions::ConversionResult;
use crate::dom::bindings::error::{Error, Fallible};
-use crate::dom::bindings::import::module::ExceptionHandling;
use crate::dom::bindings::inheritance::Castable;
use crate::dom::bindings::num::Finite;
use crate::dom::bindings::refcounted::Trusted;
@@ -342,9 +343,9 @@ impl HTMLCanvasElement {
fn get_gl_attributes(cx: JSContext, options: HandleValue) -> Option<GLContextAttributes> {
unsafe {
match WebGLContextAttributes::new(cx, options) {
- Ok(ConversionResult::Success(ref attrs)) => Some(From::from(attrs)),
- Ok(ConversionResult::Failure(ref error)) => {
- throw_type_error(*cx, error);
+ Ok(ConversionResult::Success(attrs)) => Some(attrs.convert()),
+ Ok(ConversionResult::Failure(error)) => {
+ throw_type_error(*cx, &error);
None
},
_ => {
@@ -702,15 +703,15 @@ impl VirtualMethods for HTMLCanvasElement {
}
}
-impl<'a> From<&'a WebGLContextAttributes> for GLContextAttributes {
- fn from(attrs: &'a WebGLContextAttributes) -> GLContextAttributes {
+impl Convert<GLContextAttributes> for WebGLContextAttributes {
+ fn convert(self) -> GLContextAttributes {
GLContextAttributes {
- alpha: attrs.alpha,
- depth: attrs.depth,
- stencil: attrs.stencil,
- antialias: attrs.antialias,
- premultiplied_alpha: attrs.premultipliedAlpha,
- preserve_drawing_buffer: attrs.preserveDrawingBuffer,
+ alpha: self.alpha,
+ depth: self.depth,
+ stencil: self.stencil,
+ antialias: self.antialias,
+ premultiplied_alpha: self.premultipliedAlpha,
+ preserve_drawing_buffer: self.preserveDrawingBuffer,
}
}
}