mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Make layout methods accessing rare data be safe
They don't do anything fancy so there is no additional unsafety calling them compared to using LayoutDom in the first place, the usual story of all those changes.
This commit is contained in:
parent
414d477b54
commit
9c8540af5c
4 changed files with 36 additions and 41 deletions
|
@ -583,8 +583,7 @@ pub trait LayoutElementHelpers<'dom> {
|
|||
fn insert_selector_flags(self, flags: ElementSelectorFlags);
|
||||
fn has_selector_flags(self, flags: ElementSelectorFlags) -> bool;
|
||||
/// The shadow root this element is a host of.
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_shadow_root_for_layout(self) -> Option<LayoutDom<'dom, ShadowRoot>>;
|
||||
fn get_shadow_root_for_layout(self) -> Option<LayoutDom<'dom, ShadowRoot>>;
|
||||
fn get_attr_for_layout(
|
||||
self,
|
||||
namespace: &Namespace,
|
||||
|
@ -1038,14 +1037,16 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
|
|||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_shadow_root_for_layout(self) -> Option<LayoutDom<'dom, ShadowRoot>> {
|
||||
self.unsafe_get()
|
||||
.rare_data
|
||||
.borrow_for_layout()
|
||||
.as_ref()?
|
||||
.shadow_root
|
||||
.as_ref()
|
||||
.map(|sr| sr.to_layout())
|
||||
fn get_shadow_root_for_layout(self) -> Option<LayoutDom<'dom, ShadowRoot>> {
|
||||
unsafe {
|
||||
self.unsafe_get()
|
||||
.rare_data
|
||||
.borrow_for_layout()
|
||||
.as_ref()?
|
||||
.shadow_root
|
||||
.as_ref()
|
||||
.map(|sr| sr.to_layout())
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue