mirror of
https://github.com/servo/servo.git
synced 2025-08-11 08:25:32 +01:00
Replace OpaqueStyleAndLayoutData by StyleAndOpaqueLayoutData
This commit is contained in:
parent
88d79fe46d
commit
030a1cf8fb
12 changed files with 129 additions and 162 deletions
|
@ -6,17 +6,7 @@ use crate::element_data::LayoutDataForElement;
|
|||
use atomic_refcell::AtomicRefCell;
|
||||
use script_layout_interface::StyleData;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct StyleAndLayoutData {
|
||||
pub style_data: StyleData,
|
||||
pub(super) layout_data: AtomicRefCell<LayoutDataForElement>,
|
||||
}
|
||||
|
||||
impl StyleAndLayoutData {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
style_data: StyleData::new(),
|
||||
layout_data: Default::default(),
|
||||
}
|
||||
}
|
||||
pub struct StyleAndLayoutData<'dom> {
|
||||
pub style_data: &'dom StyleData,
|
||||
pub(super) layout_data: &'dom AtomicRefCell<LayoutDataForElement>,
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ pub mod context;
|
|||
pub mod data;
|
||||
pub mod display_list;
|
||||
mod dom_traversal;
|
||||
mod element_data;
|
||||
pub mod element_data;
|
||||
mod flow;
|
||||
mod formatting_contexts;
|
||||
mod fragments;
|
||||
|
|
|
@ -5,18 +5,21 @@
|
|||
#![allow(unsafe_code)]
|
||||
|
||||
use crate::data::StyleAndLayoutData;
|
||||
use script_layout_interface::wrapper_traits::GetOpaqueStyleAndLayoutData;
|
||||
use script_layout_interface::wrapper_traits::GetStyleAndOpaqueLayoutData;
|
||||
|
||||
pub trait GetStyleAndLayoutData<'dom> {
|
||||
fn get_style_and_layout_data(self) -> Option<&'dom StyleAndLayoutData>;
|
||||
fn get_style_and_layout_data(self) -> Option<StyleAndLayoutData<'dom>>;
|
||||
}
|
||||
|
||||
impl<'dom, T> GetStyleAndLayoutData<'dom> for T
|
||||
where
|
||||
T: GetOpaqueStyleAndLayoutData<'dom>,
|
||||
T: GetStyleAndOpaqueLayoutData<'dom>,
|
||||
{
|
||||
fn get_style_and_layout_data(self) -> Option<&'dom StyleAndLayoutData> {
|
||||
self.get_opaque_style_and_layout_data()
|
||||
.map(|opaque| opaque.downcast_ref().unwrap())
|
||||
fn get_style_and_layout_data(self) -> Option<StyleAndLayoutData<'dom>> {
|
||||
self.get_style_and_opaque_layout_data()
|
||||
.map(|data| StyleAndLayoutData {
|
||||
style_data: &data.style_data,
|
||||
layout_data: data.generic_data.downcast_ref().unwrap(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue