diff options
author | Josh Matthews <josh@joshmatthews.net> | 2025-03-16 09:46:14 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-16 13:46:14 +0000 |
commit | d35da38a2fd6f093967e74f704612391b4988e69 (patch) | |
tree | 96c8705a5a597be25ac74b58043e57b3e06992f4 /components/script/canvas_context.rs | |
parent | 3ecd1c069978f6ceb20e4ee6af599fbef425e9da (diff) | |
download | servo-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/canvas_context.rs')
-rw-r--r-- | components/script/canvas_context.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/components/script/canvas_context.rs b/components/script/canvas_context.rs index 752b749c97c..8bf188a5aa9 100644 --- a/components/script/canvas_context.rs +++ b/components/script/canvas_context.rs @@ -64,8 +64,13 @@ pub(crate) trait CanvasContext { } } -impl HTMLCanvasElementOrOffscreenCanvas { - pub(crate) fn size(&self) -> Size2D<u64> { +pub(crate) trait CanvasHelpers { + fn size(&self) -> Size2D<u64>; + fn canvas(&self) -> Option<&HTMLCanvasElement>; +} + +impl CanvasHelpers for HTMLCanvasElementOrOffscreenCanvas { + fn size(&self) -> Size2D<u64> { match self { HTMLCanvasElementOrOffscreenCanvas::HTMLCanvasElement(canvas) => { canvas.get_size().cast() @@ -74,7 +79,7 @@ impl HTMLCanvasElementOrOffscreenCanvas { } } - pub(crate) fn canvas(&self) -> Option<&HTMLCanvasElement> { + fn canvas(&self) -> Option<&HTMLCanvasElement> { match self { HTMLCanvasElementOrOffscreenCanvas::HTMLCanvasElement(canvas) => Some(canvas), HTMLCanvasElementOrOffscreenCanvas::OffscreenCanvas(canvas) => canvas.placeholder(), |