mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Introduce LayoutDom::is
Just like Castable::is.
This commit is contained in:
parent
9c8540af5c
commit
f014da9565
4 changed files with 14 additions and 6 deletions
|
@ -441,6 +441,15 @@ where
|
|||
debug_assert!(thread_state::get().is_layout());
|
||||
self.value.downcast::<U>().map(|value| LayoutDom { value })
|
||||
}
|
||||
|
||||
/// Returns whether this inner object is a U.
|
||||
pub fn is<U>(&self) -> bool
|
||||
where
|
||||
U: DerivedFrom<T>,
|
||||
{
|
||||
debug_assert!(thread_state::get().is_layout());
|
||||
self.value.is::<U>()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> LayoutDom<'_, T>
|
||||
|
|
|
@ -1316,7 +1316,7 @@ pub trait LayoutNodeHelpers<'dom> {
|
|||
unsafe fn owner_doc_for_layout(self) -> LayoutDom<'dom, Document>;
|
||||
fn containing_shadow_root_for_layout(self) -> Option<LayoutDom<'dom, ShadowRoot>>;
|
||||
|
||||
unsafe fn is_element_for_layout(self) -> bool;
|
||||
fn is_element_for_layout(self) -> bool;
|
||||
unsafe fn get_flag(self, flag: NodeFlags) -> bool;
|
||||
unsafe fn set_flag(self, flag: NodeFlags, value: bool);
|
||||
|
||||
|
@ -1347,9 +1347,8 @@ impl<'dom> LayoutNodeHelpers<'dom> for LayoutDom<'dom, Node> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn is_element_for_layout(self) -> bool {
|
||||
(*self.unsafe_get()).is::<Element>()
|
||||
fn is_element_for_layout(self) -> bool {
|
||||
self.is::<Element>()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue