diff --git a/components/layout_thread/dom_wrapper.rs b/components/layout_thread/dom_wrapper.rs index d6b33c40c99..da605b9958b 100644 --- a/components/layout_thread/dom_wrapper.rs +++ b/components/layout_thread/dom_wrapper.rs @@ -170,7 +170,7 @@ impl<'lr> TShadowRoot for ServoShadowRoot<'lr> { } fn host(&self) -> ServoLayoutElement<'lr> { - ServoLayoutElement::from_layout_js(unsafe { self.shadow_root.get_host_for_layout() }) + ServoLayoutElement::from_layout_js(self.shadow_root.get_host_for_layout()) } fn style_data<'a>(&self) -> Option<&'a CascadeData> diff --git a/components/layout_thread_2020/dom_wrapper.rs b/components/layout_thread_2020/dom_wrapper.rs index 436a88b1d9e..c96585a4456 100644 --- a/components/layout_thread_2020/dom_wrapper.rs +++ b/components/layout_thread_2020/dom_wrapper.rs @@ -177,7 +177,7 @@ impl<'lr> TShadowRoot for ServoShadowRoot<'lr> { } fn host(&self) -> ServoLayoutElement<'lr> { - ServoLayoutElement::from_layout_js(unsafe { self.shadow_root.get_host_for_layout() }) + ServoLayoutElement::from_layout_js(self.shadow_root.get_host_for_layout()) } fn style_data<'a>(&self) -> Option<&'a CascadeData> diff --git a/components/script/dom/shadowroot.rs b/components/script/dom/shadowroot.rs index 6dd2ee122e6..df9337eabcc 100644 --- a/components/script/dom/shadowroot.rs +++ b/components/script/dom/shadowroot.rs @@ -240,7 +240,7 @@ impl ShadowRootMethods for ShadowRoot { #[allow(unsafe_code)] pub trait LayoutShadowRootHelpers<'dom> { - unsafe fn get_host_for_layout(self) -> LayoutDom<'dom, Element>; + fn get_host_for_layout(self) -> LayoutDom<'dom, Element>; unsafe fn get_style_data_for_layout(self) -> &'dom AuthorStyles; unsafe fn flush_stylesheets( self, @@ -253,11 +253,13 @@ pub trait LayoutShadowRootHelpers<'dom> { impl<'dom> LayoutShadowRootHelpers<'dom> for LayoutDom<'dom, ShadowRoot> { #[inline] #[allow(unsafe_code)] - unsafe fn get_host_for_layout(self) -> LayoutDom<'dom, Element> { - (*self.unsafe_get()) - .host - .get_inner_as_layout() - .expect("We should never do layout on a detached shadow root") + fn get_host_for_layout(self) -> LayoutDom<'dom, Element> { + unsafe { + self.unsafe_get() + .host + .get_inner_as_layout() + .expect("We should never do layout on a detached shadow root") + } } #[inline]