aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/canvasrenderingcontext2d.rs
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2024-04-03 10:41:19 +0200
committerGitHub <noreply@github.com>2024-04-03 08:41:19 +0000
commit18b37e676bcd50f754cd189444080fc547c9d48a (patch)
treeca2e235d13b6f9b19cff9172810b0c6f08265f3b /components/script/dom/canvasrenderingcontext2d.rs
parent8aaff613342568c13e9141758b770788694d2f84 (diff)
downloadservo-18b37e676bcd50f754cd189444080fc547c9d48a.tar.gz
servo-18b37e676bcd50f754cd189444080fc547c9d48a.zip
script: Reduce the use of `unsafe` in LayoutDom (#31979)
Remove the use of unsafe code in the layout wrappers of the DOM. The main change here is that `unsafe_get()` no longer needs to be an unsafe method, which allows us to transitively remove or reduce unsafe blocks from callers. The function itself is not renamed, because it's still a bit dangerous to start removing the layers of abstraction from actual DOM nodes. In addition `init_style_and_opaque_layout_data` can be merged into `initialize_data`, which removes one more unsafe method. Finally, a "Safety" section is added to some unsafe methods.
Diffstat (limited to 'components/script/dom/canvasrenderingcontext2d.rs')
-rw-r--r--components/script/dom/canvasrenderingcontext2d.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs
index a12cc5e8e3a..1f4c8bd7152 100644
--- a/components/script/dom/canvasrenderingcontext2d.rs
+++ b/components/script/dom/canvasrenderingcontext2d.rs
@@ -127,23 +127,20 @@ impl CanvasRenderingContext2D {
}
pub trait LayoutCanvasRenderingContext2DHelpers {
- #[allow(unsafe_code)]
- unsafe fn get_ipc_renderer(self) -> IpcSender<CanvasMsg>;
+ fn get_ipc_renderer(self) -> IpcSender<CanvasMsg>;
fn get_canvas_id(self) -> CanvasId;
}
impl LayoutCanvasRenderingContext2DHelpers for LayoutDom<'_, CanvasRenderingContext2D> {
- #[allow(unsafe_code)]
- unsafe fn get_ipc_renderer(self) -> IpcSender<CanvasMsg> {
+ fn get_ipc_renderer(self) -> IpcSender<CanvasMsg> {
(self.unsafe_get()).canvas_state.get_ipc_renderer().clone()
}
- #[allow(unsafe_code)]
fn get_canvas_id(self) -> CanvasId {
// FIXME(nox): This relies on the fact that CanvasState::get_canvas_id
// does nothing fancy but it would be easier to trust a
// LayoutDom<_>-like type that would wrap the &CanvasState.
- unsafe { self.unsafe_get().canvas_state.get_canvas_id() }
+ self.unsafe_get().canvas_state.get_canvas_id()
}
}