From 18b37e676bcd50f754cd189444080fc547c9d48a Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Wed, 3 Apr 2024 10:41:19 +0200 Subject: 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. --- components/script/dom/htmliframeelement.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'components/script/dom/htmliframeelement.rs') diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index 23613c9f1ba..6d2cd80689a 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -515,15 +515,13 @@ pub trait HTMLIFrameElementLayoutMethods { impl HTMLIFrameElementLayoutMethods for LayoutDom<'_, HTMLIFrameElement> { #[inline] - #[allow(unsafe_code)] fn pipeline_id(self) -> Option { - unsafe { (self.unsafe_get()).pipeline_id.get() } + (self.unsafe_get()).pipeline_id.get() } #[inline] - #[allow(unsafe_code)] fn browsing_context_id(self) -> Option { - unsafe { (self.unsafe_get()).browsing_context_id.get() } + (self.unsafe_get()).browsing_context_id.get() } fn get_width(self) -> LengthOrPercentageOrAuto { -- cgit v1.2.3