mirror of
https://github.com/servo/servo.git
synced 2025-09-27 23:30:08 +01:00
layout: Use ServoThreadSafeLayoutNode
in more places (#38626)
Use `ServoThreadSafeLayoutNode` in more places in layout rather than `ServoLayoutNode`. The former is meant to be used during layout, but layout 2020 was written against the latter. In general, this reduces the amount of conversion to the thread-safe version in many places in layout. In addition, an unused iterator from the `script` crate `ServoThreadSafeLayoutNodeChildrenIterator` is replaced with the child iterator from `layout`. The `layout` version must be directly in `script` now as it uses the dangerous variants of `next_sibling` and `first_child`, which allow encapsulating the unsafe bits into one module. This will ultimately be useful for storing the layout data of pseudo-element children of pseudo-elements properly. Testing: This should not change any behavior and thus is covered by existing tests. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
20ad1ce84e
commit
ee7c1d9109
20 changed files with 258 additions and 321 deletions
|
@ -52,15 +52,6 @@ pub trait LayoutNode<'dom>: Copy + Debug + TNode + Send + Sync {
|
|||
/// attempting to read or modify the opaque layout data of this node.
|
||||
unsafe fn initialize_style_and_layout_data<RequestedLayoutDataType: LayoutDataTrait>(&self);
|
||||
|
||||
/// Initialize this node with empty opaque layout data.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// This method is unsafe because it modifies the given node during
|
||||
/// layout. Callers should ensure that no other layout thread is
|
||||
/// attempting to read or modify the opaque layout data of this node.
|
||||
fn initialize_layout_data<RequestedLayoutDataType: LayoutDataTrait>(&self);
|
||||
|
||||
/// Get the [`StyleData`] for this node. Returns None if the node is unstyled.
|
||||
fn style_data(&self) -> Option<&'dom StyleData>;
|
||||
|
||||
|
@ -157,6 +148,15 @@ pub trait ThreadSafeLayoutNode<'dom>: Clone + Copy + Debug + NodeInfo + PartialE
|
|||
/// the parent until all the children have been processed.
|
||||
fn parent_style(&self) -> Arc<ComputedValues>;
|
||||
|
||||
/// Initialize this node with empty opaque layout data.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// This method is unsafe because it modifies the given node during
|
||||
/// layout. Callers should ensure that no other layout thread is
|
||||
/// attempting to read or modify the opaque layout data of this node.
|
||||
fn initialize_layout_data<RequestedLayoutDataType: LayoutDataTrait>(&self);
|
||||
|
||||
fn debug_id(self) -> usize;
|
||||
|
||||
/// Returns an iterator over this node's children.
|
||||
|
@ -186,16 +186,6 @@ pub trait ThreadSafeLayoutNode<'dom>: Clone + Copy + Debug + NodeInfo + PartialE
|
|||
}
|
||||
}
|
||||
|
||||
fn selected_style(&self) -> Arc<ComputedValues> {
|
||||
if let Some(el) = self.as_element() {
|
||||
el.selected_style()
|
||||
} else {
|
||||
debug_assert!(self.is_text_node());
|
||||
// TODO(stshine): What should the selected style be for text?
|
||||
self.parent_style()
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if this node contributes content. This is used in the implementation of
|
||||
/// `empty_cells` per CSS 2.1 § 17.6.1.1.
|
||||
fn is_content(&self) -> bool {
|
||||
|
@ -353,16 +343,6 @@ pub trait ThreadSafeLayoutElement<'dom>:
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn selected_style(&self) -> Arc<ComputedValues> {
|
||||
let data = self.style_data();
|
||||
data.styles
|
||||
.pseudos
|
||||
.get(&PseudoElement::Selection)
|
||||
.unwrap_or(data.styles.primary())
|
||||
.clone()
|
||||
}
|
||||
|
||||
fn is_shadow_host(&self) -> bool;
|
||||
|
||||
/// Returns whether this node is a body element of an html element root
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue