aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/flow
diff options
context:
space:
mode:
Diffstat (limited to 'components/layout/flow')
-rw-r--r--components/layout/flow/construct.rs85
-rw-r--r--components/layout/flow/float.rs5
-rw-r--r--components/layout/flow/inline/construct.rs7
-rw-r--r--components/layout/flow/inline/inline_box.rs3
-rw-r--r--components/layout/flow/root.rs30
5 files changed, 45 insertions, 85 deletions
diff --git a/components/layout/flow/construct.rs b/components/layout/flow/construct.rs
index 5ed567f513b..a50464123bc 100644
--- a/components/layout/flow/construct.rs
+++ b/components/layout/flow/construct.rs
@@ -33,16 +33,13 @@ use crate::style_ext::{ComputedValuesExt, DisplayGeneratingBox, DisplayInside, D
use crate::table::{AnonymousTableContent, Table};
impl BlockFormattingContext {
- pub(crate) fn construct<'dom, Node>(
+ pub(crate) fn construct(
context: &LayoutContext,
- info: &NodeAndStyleInfo<Node>,
+ info: &NodeAndStyleInfo<'_>,
contents: NonReplacedContents,
propagated_data: PropagatedBoxTreeData,
is_list_item: bool,
- ) -> Self
- where
- Node: NodeExt<'dom>,
- {
+ ) -> Self {
Self::from_block_container(BlockContainer::construct(
context,
info,
@@ -61,8 +58,8 @@ impl BlockFormattingContext {
}
}
-struct BlockLevelJob<'dom, Node> {
- info: NodeAndStyleInfo<Node>,
+struct BlockLevelJob<'dom> {
+ info: NodeAndStyleInfo<'dom>,
box_slot: BoxSlot<'dom>,
propagated_data: PropagatedBoxTreeData,
kind: BlockLevelCreator,
@@ -111,12 +108,12 @@ enum IntermediateBlockContainer {
///
/// This builder starts from the first child of a given DOM node
/// and does a preorder traversal of all of its inclusive siblings.
-pub(crate) struct BlockContainerBuilder<'dom, 'style, Node> {
+pub(crate) struct BlockContainerBuilder<'dom, 'style> {
context: &'style LayoutContext<'style>,
/// This NodeAndStyleInfo contains the root node, the corresponding pseudo
/// content designator, and the block container style.
- info: &'style NodeAndStyleInfo<Node>,
+ info: &'style NodeAndStyleInfo<'dom>,
/// The list of block-level boxes to be built for the final block container.
///
@@ -131,7 +128,7 @@ pub(crate) struct BlockContainerBuilder<'dom, 'style, Node> {
/// doesn't have a next sibling, we either reached the end of the container
/// root or there are ongoing inline-level boxes
/// (see `handle_block_level_element`).
- block_level_boxes: Vec<BlockLevelJob<'dom, Node>>,
+ block_level_boxes: Vec<BlockLevelJob<'dom>>,
/// Whether or not this builder has yet produced a block which would be
/// be considered the first line for the purposes of `text-indent`.
@@ -144,25 +141,22 @@ pub(crate) struct BlockContainerBuilder<'dom, 'style, Node> {
/// The [`NodeAndStyleInfo`] to use for anonymous block boxes pushed to the list of
/// block-level boxes, lazily initialized (see `end_ongoing_inline_formatting_context`).
- anonymous_box_info: Option<NodeAndStyleInfo<Node>>,
+ anonymous_box_info: Option<NodeAndStyleInfo<'dom>>,
/// A collection of content that is being added to an anonymous table. This is
/// composed of any sequence of internal table elements or table captions that
/// are found outside of a table.
- anonymous_table_content: Vec<AnonymousTableContent<'dom, Node>>,
+ anonymous_table_content: Vec<AnonymousTableContent<'dom>>,
}
impl BlockContainer {
- pub fn construct<'dom, Node>(
+ pub fn construct(
context: &LayoutContext,
- info: &NodeAndStyleInfo<Node>,
+ info: &NodeAndStyleInfo<'_>,
contents: NonReplacedContents,
propagated_data: PropagatedBoxTreeData,
is_list_item: bool,
- ) -> BlockContainer
- where
- Node: NodeExt<'dom>,
- {
+ ) -> BlockContainer {
let mut builder = BlockContainerBuilder::new(context, info, propagated_data);
if is_list_item {
@@ -186,13 +180,10 @@ impl BlockContainer {
}
}
-impl<'dom, 'style, Node> BlockContainerBuilder<'dom, 'style, Node>
-where
- Node: NodeExt<'dom>,
-{
+impl<'dom, 'style> BlockContainerBuilder<'dom, 'style> {
pub(crate) fn new(
context: &'style LayoutContext,
- info: &'style NodeAndStyleInfo<Node>,
+ info: &'style NodeAndStyleInfo<'dom>,
propagated_data: PropagatedBoxTreeData,
) -> Self {
BlockContainerBuilder {
@@ -274,7 +265,7 @@ where
false => self.propagated_data,
};
- let contents: Vec<AnonymousTableContent<'dom, Node>> =
+ let contents: Vec<AnonymousTableContent<'dom>> =
self.anonymous_table_content.drain(..).collect();
let last_text = match contents.last() {
Some(AnonymousTableContent::Text(info, text)) => Some((info.clone(), text.clone())),
@@ -312,13 +303,10 @@ where
}
}
-impl<'dom, Node> TraversalHandler<'dom, Node> for BlockContainerBuilder<'dom, '_, Node>
-where
- Node: NodeExt<'dom>,
-{
+impl<'dom> TraversalHandler<'dom> for BlockContainerBuilder<'dom, '_> {
fn handle_element(
&mut self,
- info: &NodeAndStyleInfo<Node>,
+ info: &NodeAndStyleInfo<'dom>,
display: DisplayGeneratingBox,
contents: Contents,
box_slot: BoxSlot<'dom>,
@@ -359,7 +347,7 @@ where
}
}
- fn handle_text(&mut self, info: &NodeAndStyleInfo<Node>, text: Cow<'dom, str>) {
+ fn handle_text(&mut self, info: &NodeAndStyleInfo<'dom>, text: Cow<'dom, str>) {
if text.is_empty() {
return;
}
@@ -379,14 +367,11 @@ where
}
}
-impl<'dom, Node> BlockContainerBuilder<'dom, '_, Node>
-where
- Node: NodeExt<'dom>,
-{
+impl<'dom> BlockContainerBuilder<'dom, '_> {
fn handle_list_item_marker_inside(
&mut self,
- marker_info: &NodeAndStyleInfo<Node>,
- container_info: &NodeAndStyleInfo<Node>,
+ marker_info: &NodeAndStyleInfo<'dom>,
+ container_info: &NodeAndStyleInfo<'dom>,
contents: Vec<crate::dom_traversal::PseudoElementContentItem>,
) {
// TODO: We do not currently support saving box slots for ::marker pseudo-elements
@@ -411,8 +396,8 @@ where
fn handle_list_item_marker_outside(
&mut self,
- marker_info: &NodeAndStyleInfo<Node>,
- container_info: &NodeAndStyleInfo<Node>,
+ marker_info: &NodeAndStyleInfo<'dom>,
+ container_info: &NodeAndStyleInfo<'dom>,
contents: Vec<crate::dom_traversal::PseudoElementContentItem>,
list_item_style: Arc<ComputedValues>,
) {
@@ -439,7 +424,7 @@ where
fn handle_inline_level_element(
&mut self,
- info: &NodeAndStyleInfo<Node>,
+ info: &NodeAndStyleInfo<'dom>,
display_inside: DisplayInside,
contents: Contents,
box_slot: BoxSlot<'dom>,
@@ -497,7 +482,7 @@ where
fn handle_block_level_element(
&mut self,
- info: &NodeAndStyleInfo<Node>,
+ info: &NodeAndStyleInfo<'dom>,
display_inside: DisplayInside,
contents: Contents,
box_slot: BoxSlot<'dom>,
@@ -565,7 +550,7 @@ where
fn handle_absolutely_positioned_element(
&mut self,
- info: &NodeAndStyleInfo<Node>,
+ info: &NodeAndStyleInfo<'dom>,
display_inside: DisplayInside,
contents: Contents,
box_slot: BoxSlot<'dom>,
@@ -597,7 +582,7 @@ where
fn handle_float_element(
&mut self,
- info: &NodeAndStyleInfo<Node>,
+ info: &NodeAndStyleInfo<'dom>,
display_inside: DisplayInside,
contents: Contents,
box_slot: BoxSlot<'dom>,
@@ -670,10 +655,7 @@ where
}
}
-impl<'dom, Node> BlockLevelJob<'dom, Node>
-where
- Node: NodeExt<'dom>,
-{
+impl BlockLevelJob<'_> {
fn finish(self, context: &LayoutContext) -> ArcRefCell<BlockLevelBox> {
let info = &self.info;
let block_level_box = match self.kind {
@@ -747,14 +729,7 @@ where
}
impl IntermediateBlockContainer {
- fn finish<'dom, Node>(
- self,
- context: &LayoutContext,
- info: &NodeAndStyleInfo<Node>,
- ) -> BlockContainer
- where
- Node: NodeExt<'dom>,
- {
+ fn finish(self, context: &LayoutContext, info: &NodeAndStyleInfo<'_>) -> BlockContainer {
match self {
IntermediateBlockContainer::Deferred {
contents,
diff --git a/components/layout/flow/float.rs b/components/layout/flow/float.rs
index dbc50c07603..f1ae2b4459a 100644
--- a/components/layout/flow/float.rs
+++ b/components/layout/flow/float.rs
@@ -22,7 +22,6 @@ use style::properties::ComputedValues;
use style::values::computed::Clear as StyleClear;
use crate::context::LayoutContext;
-use crate::dom::NodeExt;
use crate::dom_traversal::{Contents, NodeAndStyleInfo};
use crate::formatting_contexts::IndependentFormattingContext;
use crate::fragment_tree::{BoxFragment, CollapsedMargin};
@@ -885,9 +884,9 @@ impl FloatBandLink {
impl FloatBox {
/// Creates a new float box.
- pub fn construct<'dom>(
+ pub fn construct(
context: &LayoutContext,
- info: &NodeAndStyleInfo<impl NodeExt<'dom>>,
+ info: &NodeAndStyleInfo<'_>,
display_inside: DisplayInside,
contents: Contents,
propagated_data: PropagatedBoxTreeData,
diff --git a/components/layout/flow/inline/construct.rs b/components/layout/flow/inline/construct.rs
index 61292701a9f..74b0cf4ea7d 100644
--- a/components/layout/flow/inline/construct.rs
+++ b/components/layout/flow/inline/construct.rs
@@ -17,7 +17,6 @@ use super::{InlineBox, InlineBoxIdentifier, InlineBoxes, InlineFormattingContext
use crate::PropagatedBoxTreeData;
use crate::cell::ArcRefCell;
use crate::context::LayoutContext;
-use crate::dom::NodeExt;
use crate::dom_traversal::NodeAndStyleInfo;
use crate::flow::float::FloatBox;
use crate::formatting_contexts::IndependentFormattingContext;
@@ -225,11 +224,7 @@ impl InlineFormattingContextBuilder {
(identifier, block_in_inline_splits)
}
- pub(crate) fn push_text<'dom, Node: NodeExt<'dom>>(
- &mut self,
- text: Cow<'dom, str>,
- info: &NodeAndStyleInfo<Node>,
- ) {
+ pub(crate) fn push_text<'dom>(&mut self, text: Cow<'dom, str>, info: &NodeAndStyleInfo<'dom>) {
let white_space_collapse = info.style.clone_white_space_collapse();
let collapsed = WhitespaceCollapse::new(
text.chars(),
diff --git a/components/layout/flow/inline/inline_box.rs b/components/layout/flow/inline/inline_box.rs
index de79f876340..1c953c13074 100644
--- a/components/layout/flow/inline/inline_box.rs
+++ b/components/layout/flow/inline/inline_box.rs
@@ -12,7 +12,6 @@ use super::{InlineContainerState, InlineContainerStateFlags, inline_container_ne
use crate::ContainingBlock;
use crate::cell::ArcRefCell;
use crate::context::LayoutContext;
-use crate::dom::NodeExt;
use crate::dom_traversal::NodeAndStyleInfo;
use crate::fragment_tree::BaseFragmentInfo;
use crate::layout_box_base::LayoutBoxBase;
@@ -35,7 +34,7 @@ pub(crate) struct InlineBox {
}
impl InlineBox {
- pub(crate) fn new<'dom, Node: NodeExt<'dom>>(info: &NodeAndStyleInfo<Node>) -> Self {
+ pub(crate) fn new(info: &NodeAndStyleInfo) -> Self {
Self {
base: LayoutBoxBase::new(info.into(), info.style.clone()),
// This will be assigned later, when the box is actually added to the IFC.
diff --git a/components/layout/flow/root.rs b/components/layout/flow/root.rs
index bb9ff1d337a..e813777b6fe 100644
--- a/components/layout/flow/root.rs
+++ b/components/layout/flow/root.rs
@@ -6,12 +6,13 @@ use app_units::Au;
use atomic_refcell::AtomicRef;
use compositing_traits::display_list::AxesScrollSensitivity;
use malloc_size_of_derive::MallocSizeOf;
+use script::layout_dom::ServoLayoutNode;
use script_layout_interface::wrapper_traits::{
LayoutNode, ThreadSafeLayoutElement, ThreadSafeLayoutNode,
};
use script_layout_interface::{LayoutElementType, LayoutNodeType};
use servo_arc::Arc;
-use style::dom::OpaqueNode;
+use style::dom::{NodeInfo, OpaqueNode, TNode};
use style::properties::ComputedValues;
use style::values::computed::Overflow;
use style_traits::CSSPixel;
@@ -47,10 +48,7 @@ pub struct BoxTree {
}
impl BoxTree {
- pub fn construct<'dom, Node>(context: &LayoutContext, root_element: Node) -> Self
- where
- Node: 'dom + Copy + LayoutNode<'dom> + Send + Sync,
- {
+ pub fn construct(context: &LayoutContext, root_element: ServoLayoutNode<'_>) -> Self {
let boxes = construct_for_root_element(context, root_element);
// Zero box for `:root { display: none }`, one for the root element otherwise.
@@ -129,10 +127,7 @@ impl BoxTree {
/// * how intrinsic content sizes are computed eagerly makes it hard
/// to update those sizes for ancestors of the node from which we
/// made an incremental update.
- pub fn update<'dom, Node>(context: &LayoutContext, mut dirty_node: Node) -> bool
- where
- Node: 'dom + Copy + LayoutNode<'dom> + Send + Sync,
- {
+ pub fn update(context: &LayoutContext, mut dirty_node: ServoLayoutNode<'_>) -> bool {
#[allow(clippy::enum_variant_names)]
enum UpdatePoint {
AbsolutelyPositionedBlockLevelBox(ArcRefCell<BlockLevelBox>),
@@ -141,12 +136,9 @@ impl BoxTree {
AbsolutelyPositionedTaffyLevelBox(ArcRefCell<TaffyItemBox>),
}
- fn update_point<'dom, Node>(
- node: Node,
- ) -> Option<(Arc<ComputedValues>, DisplayInside, UpdatePoint)>
- where
- Node: NodeExt<'dom>,
- {
+ fn update_point(
+ node: ServoLayoutNode<'_>,
+ ) -> Option<(Arc<ComputedValues>, DisplayInside, UpdatePoint)> {
if !node.is_element() {
return None;
}
@@ -162,7 +154,7 @@ impl BoxTree {
return None;
}
- let layout_data = node.layout_data()?;
+ let layout_data = NodeExt::layout_data(&node)?;
if layout_data.pseudo_before_box.borrow().is_some() {
return None;
}
@@ -301,9 +293,9 @@ impl BoxTree {
}
}
-fn construct_for_root_element<'dom>(
+fn construct_for_root_element(
context: &LayoutContext,
- root_element: impl NodeExt<'dom>,
+ root_element: ServoLayoutNode<'_>,
) -> Vec<ArcRefCell<BlockLevelBox>> {
let info = NodeAndStyleInfo::new(root_element, root_element.style(context));
let box_style = info.style.get_box();
@@ -456,7 +448,7 @@ pub struct CanvasBackground {
}
impl CanvasBackground {
- fn for_root_element<'dom>(context: &LayoutContext, root_element: impl NodeExt<'dom>) -> Self {
+ fn for_root_element(context: &LayoutContext, root_element: ServoLayoutNode<'_>) -> Self {
let root_style = root_element.style(context);
let mut style = root_style;