mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Introduce LayoutDom::to_layout_slice
It generalises <LayoutDom<Element>>::attrs.
This commit is contained in:
parent
72c0771299
commit
dd750c6f86
2 changed files with 10 additions and 8 deletions
|
@ -736,6 +736,15 @@ where
|
|||
debug_assert!(thread_state::get().is_layout());
|
||||
self.value
|
||||
}
|
||||
|
||||
/// Transforms a slice of Dom<T> into a slice of LayoutDom<T>.
|
||||
// FIXME(nox): This should probably be done through a ToLayout trait.
|
||||
pub unsafe fn to_layout_slice(slice: &'dom [Dom<T>]) -> &'dom [LayoutDom<'dom, T>] {
|
||||
// This doesn't compile if Dom and LayoutDom don't have the same
|
||||
// representation.
|
||||
let _ = mem::transmute::<Dom<T>, LayoutDom<T>>;
|
||||
&*(slice as *const [Dom<T>] as *const [LayoutDom<T>])
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper trait for safer manipulations of `Option<Heap<T>>` values.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue