From 4e64a1c682183a5f982f9b6b9cbc6d99b4a3b6ba Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Wed, 1 Apr 2020 11:36:25 +0200 Subject: [PATCH] Add some comments and remove obsolete allow attributes --- components/script/dom/node.rs | 10 +++++++--- components/script/dom/shadowroot.rs | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 1a889ae0ac1..f9007bcf9c6 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -1414,6 +1414,10 @@ impl<'dom> LayoutNodeHelpers<'dom> for LayoutDom<'dom, Node> { } } + // FIXME(nox): get_flag/set_flag (especially the latter) are not safe because + // they mutate stuff while values of this type can be used from multiple + // threads at once, this should be revisited. + #[inline] #[allow(unsafe_code)] unsafe fn get_flag(self, flag: NodeFlags) -> bool { @@ -1441,6 +1445,9 @@ impl<'dom> LayoutNodeHelpers<'dom> for LayoutDom<'dom, Node> { unsafe { self.unsafe_get().children_count.get() } } + // FIXME(nox): How we handle style and layout data needs to be completely + // revisited so we can do that more cleanly and safely in layout 2020. + #[inline] #[allow(unsafe_code)] unsafe fn get_style_and_layout_data(self) -> Option { @@ -1490,19 +1497,16 @@ impl<'dom> LayoutNodeHelpers<'dom> for LayoutDom<'dom, Node> { None } - #[allow(unsafe_code)] fn image_url(self) -> Option { self.downcast::() .expect("not an image!") .image_url() } - #[allow(unsafe_code)] fn image_data(self) -> Option<(Option>, Option)> { self.downcast::().map(|e| e.image_data()) } - #[allow(unsafe_code)] fn image_density(self) -> Option { self.downcast::() .expect("not an image!") diff --git a/components/script/dom/shadowroot.rs b/components/script/dom/shadowroot.rs index 7e375c4fbba..f1c0567a399 100644 --- a/components/script/dom/shadowroot.rs +++ b/components/script/dom/shadowroot.rs @@ -271,6 +271,8 @@ impl<'dom> LayoutShadowRootHelpers<'dom> for LayoutDom<'dom, ShadowRoot> { unsafe { &self.unsafe_get().author_styles.borrow_for_layout().data } } + // FIXME(nox): This uses the dreaded borrow_mut_for_layout so this should + // probably be revisited. #[inline] #[allow(unsafe_code)] unsafe fn flush_stylesheets(