mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +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,25 +6,14 @@ use crate::construct::ConstructionResult;
|
|||
use atomic_refcell::AtomicRefCell;
|
||||
use script_layout_interface::StyleData;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct StyleAndLayoutData {
|
||||
pub struct StyleAndLayoutData<'dom> {
|
||||
/// The style data associated with a node.
|
||||
pub style_data: StyleData,
|
||||
pub style_data: &'dom StyleData,
|
||||
/// The layout data associated with a node.
|
||||
pub layout_data: AtomicRefCell<LayoutData>,
|
||||
}
|
||||
|
||||
impl StyleAndLayoutData {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
style_data: StyleData::new(),
|
||||
layout_data: AtomicRefCell::new(LayoutData::new()),
|
||||
}
|
||||
}
|
||||
pub layout_data: &'dom AtomicRefCell<LayoutData>,
|
||||
}
|
||||
|
||||
/// Data that layout associates with a node.
|
||||
#[repr(C)]
|
||||
pub struct LayoutData {
|
||||
/// The current results of flow construction for this node. This is either a
|
||||
/// flow or a `ConstructionItem`. See comments in `construct.rs` for more
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
use crate::construct::ConstructionResult;
|
||||
use crate::context::LayoutContext;
|
||||
use crate::data::StyleAndLayoutData;
|
||||
use crate::display_list::items::{DisplayList, OpaqueNode, ScrollOffsetMap};
|
||||
use crate::display_list::IndexableText;
|
||||
use crate::flow::{Flow, GetBaseFlow};
|
||||
|
@ -1036,24 +1035,12 @@ fn inner_text_collection_steps<'dom>(
|
|||
_ => child,
|
||||
};
|
||||
|
||||
let element_data = {
|
||||
&node
|
||||
.get_opaque_style_and_layout_data()
|
||||
.as_ref()
|
||||
.map(|opaque| {
|
||||
&opaque
|
||||
.downcast_ref::<StyleAndLayoutData>()
|
||||
.unwrap()
|
||||
.style_data
|
||||
.element_data
|
||||
})
|
||||
let element_data = match node.get_style_and_opaque_layout_data() {
|
||||
Some(data) => &data.style_data.element_data,
|
||||
None => continue,
|
||||
};
|
||||
|
||||
if element_data.is_none() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let style = match element_data.unwrap().borrow().styles.get_primary() {
|
||||
let style = match element_data.borrow().styles.get_primary() {
|
||||
None => continue,
|
||||
Some(style) => style.clone(),
|
||||
};
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
use crate::data::{LayoutData, LayoutDataFlags, StyleAndLayoutData};
|
||||
use atomic_refcell::{AtomicRef, AtomicRefMut};
|
||||
use script_layout_interface::wrapper_traits::GetOpaqueStyleAndLayoutData;
|
||||
use script_layout_interface::wrapper_traits::GetStyleAndOpaqueLayoutData;
|
||||
use script_layout_interface::wrapper_traits::{ThreadSafeLayoutElement, ThreadSafeLayoutNode};
|
||||
use style::dom::{NodeInfo, TNode};
|
||||
use style::selector_parser::RestyleDamage;
|
||||
|
@ -47,7 +47,7 @@ pub trait LayoutNodeLayoutData<'dom> {
|
|||
|
||||
impl<'dom, T> LayoutNodeLayoutData<'dom> for T
|
||||
where
|
||||
T: GetOpaqueStyleAndLayoutData<'dom>,
|
||||
T: GetStyleAndOpaqueLayoutData<'dom>,
|
||||
{
|
||||
fn borrow_layout_data(self) -> Option<AtomicRef<'dom, LayoutData>> {
|
||||
self.get_style_and_layout_data()
|
||||
|
@ -66,16 +66,19 @@ where
|
|||
}
|
||||
|
||||
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