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
|
@ -4,8 +4,8 @@
|
|||
|
||||
use bitflags::Flags;
|
||||
use layout_api::LayoutDamage;
|
||||
use layout_api::wrapper_traits::LayoutNode;
|
||||
use script::layout_dom::ServoLayoutNode;
|
||||
use layout_api::wrapper_traits::{LayoutNode, ThreadSafeLayoutNode};
|
||||
use script::layout_dom::ServoThreadSafeLayoutNode;
|
||||
use style::context::{SharedStyleContext, StyleContext};
|
||||
use style::data::ElementData;
|
||||
use style::dom::{NodeInfo, TElement, TNode};
|
||||
|
@ -15,7 +15,6 @@ use style::values::computed::Display;
|
|||
|
||||
use crate::context::LayoutContext;
|
||||
use crate::dom::{DOMLayoutData, NodeExt};
|
||||
use crate::dom_traversal::iter_child_nodes;
|
||||
|
||||
pub struct RecalcStyle<'a> {
|
||||
context: &'a LayoutContext<'a>,
|
||||
|
@ -97,7 +96,7 @@ where
|
|||
#[servo_tracing::instrument(skip_all)]
|
||||
pub(crate) fn compute_damage_and_repair_style(
|
||||
context: &SharedStyleContext,
|
||||
node: ServoLayoutNode<'_>,
|
||||
node: ServoThreadSafeLayoutNode<'_>,
|
||||
damage_from_environment: RestyleDamage,
|
||||
) -> RestyleDamage {
|
||||
compute_damage_and_repair_style_inner(context, node, damage_from_environment)
|
||||
|
@ -105,7 +104,7 @@ pub(crate) fn compute_damage_and_repair_style(
|
|||
|
||||
pub(crate) fn compute_damage_and_repair_style_inner(
|
||||
context: &SharedStyleContext,
|
||||
node: ServoLayoutNode<'_>,
|
||||
node: ServoThreadSafeLayoutNode<'_>,
|
||||
damage_from_parent: RestyleDamage,
|
||||
) -> RestyleDamage {
|
||||
let mut element_damage;
|
||||
|
@ -136,7 +135,7 @@ pub(crate) fn compute_damage_and_repair_style_inner(
|
|||
}
|
||||
|
||||
let mut damage_from_children = RestyleDamage::empty();
|
||||
for child in iter_child_nodes(node) {
|
||||
for child in node.children() {
|
||||
if child.is_element() {
|
||||
damage_from_children |=
|
||||
compute_damage_and_repair_style_inner(context, child, damage_for_children);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue