mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Make LayoutShadowRootHelpers::get_host_for_layout be safe
This commit is contained in:
parent
68d5cfffd5
commit
f712b0bcf8
3 changed files with 10 additions and 8 deletions
|
@ -170,7 +170,7 @@ impl<'lr> TShadowRoot for ServoShadowRoot<'lr> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn host(&self) -> ServoLayoutElement<'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>
|
fn style_data<'a>(&self) -> Option<&'a CascadeData>
|
||||||
|
|
|
@ -177,7 +177,7 @@ impl<'lr> TShadowRoot for ServoShadowRoot<'lr> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn host(&self) -> ServoLayoutElement<'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>
|
fn style_data<'a>(&self) -> Option<&'a CascadeData>
|
||||||
|
|
|
@ -240,7 +240,7 @@ impl ShadowRootMethods for ShadowRoot {
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
pub trait LayoutShadowRootHelpers<'dom> {
|
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<StyleSheetInDocument>;
|
unsafe fn get_style_data_for_layout(self) -> &'dom AuthorStyles<StyleSheetInDocument>;
|
||||||
unsafe fn flush_stylesheets<E: TElement>(
|
unsafe fn flush_stylesheets<E: TElement>(
|
||||||
self,
|
self,
|
||||||
|
@ -253,12 +253,14 @@ pub trait LayoutShadowRootHelpers<'dom> {
|
||||||
impl<'dom> LayoutShadowRootHelpers<'dom> for LayoutDom<'dom, ShadowRoot> {
|
impl<'dom> LayoutShadowRootHelpers<'dom> for LayoutDom<'dom, ShadowRoot> {
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn get_host_for_layout(self) -> LayoutDom<'dom, Element> {
|
fn get_host_for_layout(self) -> LayoutDom<'dom, Element> {
|
||||||
(*self.unsafe_get())
|
unsafe {
|
||||||
|
self.unsafe_get()
|
||||||
.host
|
.host
|
||||||
.get_inner_as_layout()
|
.get_inner_as_layout()
|
||||||
.expect("We should never do layout on a detached shadow root")
|
.expect("We should never do layout on a detached shadow root")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue