mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Make OpaqueLayoutAndStyleData just a bit less opaque
It now stores a NonNull<dyn Any>.
This commit is contained in:
parent
e47e884cc7
commit
4c61baee30
11 changed files with 83 additions and 65 deletions
|
@ -8,17 +8,15 @@ use crate::data::StyleAndLayoutData;
|
|||
use script_layout_interface::wrapper_traits::GetLayoutData;
|
||||
|
||||
pub trait GetRawData {
|
||||
fn get_raw_data(&self) -> Option<&StyleAndLayoutData>;
|
||||
unsafe fn get_raw_data(&self) -> Option<&StyleAndLayoutData>;
|
||||
}
|
||||
|
||||
impl<'dom, T> GetRawData for T
|
||||
where
|
||||
T: GetLayoutData<'dom>,
|
||||
{
|
||||
fn get_raw_data(&self) -> Option<&StyleAndLayoutData> {
|
||||
self.get_style_and_layout_data().map(|opaque| {
|
||||
let container = opaque.ptr.as_ptr() as *mut StyleAndLayoutData;
|
||||
unsafe { &*container }
|
||||
})
|
||||
unsafe fn get_raw_data(&self) -> Option<&StyleAndLayoutData> {
|
||||
self.get_style_and_layout_data()
|
||||
.map(|opaque| opaque.downcast_ref().unwrap())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue