Skip to content

Truly independent web browser

LibWeb: Let outside list markers contribute to the first line box

Shannon Boothcc9cac3d8eb9
diff --git a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
index 9d41423de7f..d600b70c619 100644
--- a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
@@ -263,6 +263,9 @@ pub(crate) struct ChildrenSummary {
/// Whether the children laid out include the outside marker of the container, which the container places after
/// them.
pub(crate) includes_list_item_marker: bool,
+ /// The block size of the line box that the outside marker of the container creates, where the children laid out
+ /// hold no line box for it.
+ pub(crate) outside_marker_line_box_block_size: Option<CssPixels>,
/// Whether margins do not collapse through one of the children laid out, which keeps them from collapsing through
/// the container.
pub(crate) has_child_whose_margins_do_not_collapse_through: bool,
@@ -542,6 +545,42 @@ enum BreakMode {
NoBreaks,
}
+/// The extents of an outside marker around its first baseline.
+// https://drafts.csswg.org/css-lists-3/#list-style-position-outside
+// The size or contents of the marker box may affect the height of the principal block box and/or the height of its
+// first line box, and in some cases may cause the creation of a new line box; this interaction is also not defined.
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub(crate) struct OutsideMarkerLine {
+ pub(crate) ascent: CssPixels,
+ pub(crate) descent: CssPixels,
+}
+
+impl OutsideMarkerLine {
+ fn enclosing(self, other: Self) -> Self {
+ Self {
+ ascent: self.ascent.max(other.ascent),
+ descent: self.descent.max(other.descent),
+ }
+ }
+}
+
+/// An outside marker laid out before the contents of its list item, which is placed once they are laid out.
+struct LaidOutOutsideMarker {
+ marker: Node,
+ laid_out_box: run_state::LaidOutChildBox,
+ fragment_arrival: Option<fragment_tree::RunRootFragment>,
+}
+
+impl LaidOutOutsideMarker {
+ fn line(&self) -> Option<OutsideMarkerLine> {
+ let baseline = self.laid_out_box.baselines.first?;
+ Some(OutsideMarkerLine {
+ ascent: baseline,
+ descent: self.laid_out_box.cells.content_block_size() - baseline,
+ })
+ }
+}
+
// https://www.w3.org/TR/css-display/#block-formatting-context
pub(crate) struct BlockFormattingContext<'pass> {
run: FormattingContextRun<'pass>,
@@ -552,6 +591,11 @@ pub(crate) struct BlockFormattingContext<'pass> {
pub(super) previous_line_data: Option<std::sync::Arc<inline_content::InlineContent>>,
block_offset_of_current_block_container: Cell<Option<CssPixels>>,
margin_state: RefCell<BlockMarginState>,
+ /// The outside markers of the list items whose first line box is yet to be laid out.
+ outside_marker_line: Cell<Option<OutsideMarkerLine>>,
+ /// The block size of the line box that the outside marker of the root creates, where its contents hold no line
+ /// box for it.
+ outside_marker_line_box_block_size_of_root: Cell<Option<CssPixels>>,
floats: RefCell<Vec<FloatingBox>>,
bands: RefCell<SmallVec<[FloatBand; 4]>>,
lowest_left_margin_edge: Cell<CssPixels>,
@@ -680,6 +724,8 @@ impl<'pass> BlockFormattingContext<'pass> {
previous_line_data,
block_offset_of_current_block_container: Cell::new(None),
margin_state: RefCell::new(BlockMarginState::default()),
+ outside_marker_line: Cell::new(None),
+ outside_marker_line_box_block_size_of_root: Cell::new(None),
floats: RefCell::new(Vec::new()),
bands: RefCell::new(smallvec![FloatBand::default()]),
lowest_left_margin_edge: Cell::new(CssPixels::default()),
@@ -2153,6 +2199,81 @@ impl<'pass> BlockFormattingContext<'pass> {
inline_space_used_before_list_item_elements_formatted: inline_formatting_context::SpaceUsedByFloats,
list_item_first_baseline: Option<CssPixels>,
) -> Option<CssPixels> {
+ let marker = self.layout_outside_marker(run, list_item)?;
+ Some(self.place_outside_marker(
+ marker,
+ list_item,
+ inline_space_used_before_list_item_elements_formatted,
+ list_item_first_baseline,
+ ))
+ }
+
+ /// Lays out the outside marker of `list_item` before the contents of the list item, and makes the marker
+ /// contribute to the first line box laid out in them. Returns the marker, and the marker line that was pending
+ /// before it, which `finish_contents_of_list_item` restores once the contents are laid out.
+ fn layout_outside_marker_before_contents(
+ &self,
+ run: &FormattingContextRun<'pass>,
+ list_item: BlockContainer,
+ ) -> (Option<LaidOutOutsideMarker>, Option<OutsideMarkerLine>) {
+ let previous = self.outside_marker_line.get();
+ let marker = self.layout_outside_marker(run, list_item);
+ if let Some(line) = marker.as_ref().and_then(LaidOutOutsideMarker::line) {
+ self.outside_marker_line
+ .set(Some(previous.map_or(line, |previous| previous.enclosing(line))));
+ }
+ (marker, previous)
+ }
+
+ /// Ends the contribution of the outside marker of `list_item` to the first line box of its `contents`. Contents
+ /// without a line box leave the marker line of an enclosing list item pending.
+ fn finish_contents_of_list_item(
+ &self,
+ list_item: Node,
+ (marker, previous): &(Option<LaidOutOutsideMarker>, Option<OutsideMarkerLine>),
+ contents: &mut ChildrenSummary,
+ ) {
+ if self.outside_marker_line.get().is_some() {
+ self.outside_marker_line.set(*previous);
+ }
+ if contents.baselines.first.is_none()
+ && let Some(marker_line) = marker.as_ref().and_then(LaidOutOutsideMarker::line)
+ {
+ let (_, block_size) = self.line_box_created_by_outside_marker(list_item, marker_line);
+ contents.outside_marker_line_box_block_size = Some(block_size);
+ }
+ }
+
+ // https://drafts.csswg.org/css-lists-3/#list-style-position-outside
+ // The size or contents of the marker box may affect the height of the principal block box and/or the height of
+ // its first line box, and in some cases may cause the creation of a new line box; this interaction is also not
+ // defined.
+ /// The baseline and block size of the line box that the outside marker of `list_item` creates, where the list item
+ /// holds no line box for it. Like any line box, it starts with the strut of the list item.
+ fn line_box_created_by_outside_marker(
+ &self,
+ list_item: Node,
+ marker_line: OutsideMarkerLine,
+ ) -> (CssPixels, CssPixels) {
+ let style = self.style(list_item);
+ let strut_ascent = line_builder::LineBuilder::baseline_for_style(style, style.line_height());
+ let baseline = strut_ascent.max(marker_line.ascent);
+ (
+ baseline,
+ baseline + (style.line_height() - strut_ascent).max(marker_line.descent),
+ )
+ }
+
+ /// The extents of the outside markers that the next line box laid out in this formatting context contributes to.
+ pub(crate) fn pending_outside_marker_line(&self) -> Option<OutsideMarkerLine> {
+ self.outside_marker_line.get()
+ }
+
+ fn layout_outside_marker(
+ &self,
+ run: &FormattingContextRun<'pass>,
+ list_item: BlockContainer,
+ ) -> Option<LaidOutOutsideMarker> {
let marker = self.facts(list_item.node).list_item_marker();
if marker.is_invalid() {
return None;
@@ -2168,7 +2289,6 @@ impl<'pass> BlockFormattingContext<'pass> {
return None;
}
let mut marker_cells = self.keep_marker_for_its_run(list_item, marker);
- let marker_style = self.style(marker);
let marker_constraints = ContainingBlockConstraints {
percentage_basis_inline_size: Some(list_item.cells.content_inline_size),
..ContainingBlockConstraints::default()
@@ -2205,7 +2325,29 @@ impl<'pass> BlockFormattingContext<'pass> {
list_item.percentage_block_insets_have_definite_basis,
);
marker_outcome.report_percentage_block_size_dependency_of(run, marker);
+ Some(LaidOutOutsideMarker {
+ marker,
+ laid_out_box: marker_box,
+ fragment_arrival,
+ })
+ }
+ /// Places the outside `marker` of `list_item`, and returns the block end of the marker's border box in the list
+ /// item.
+ fn place_outside_marker(
+ &self,
+ marker: LaidOutOutsideMarker,
+ list_item: BlockContainer,
+ inline_space_used_before_list_item_elements_formatted: inline_formatting_context::SpaceUsedByFloats,
+ list_item_first_baseline: Option<CssPixels>,
+ ) -> CssPixels {
+ let marker_line = marker.line();
+ let LaidOutOutsideMarker {
+ marker,
+ laid_out_box: marker_box,
+ fragment_arrival,
+ } = marker;
+ let marker_style = self.style(marker);
let marker_metrics = marker_box.cells;
let marker_block_size = marker_metrics.content_block_size();
let marker_inline_size = marker_metrics.content_inline_size();
@@ -2219,6 +2361,9 @@ impl<'pass> BlockFormattingContext<'pass> {
&& let Some(marker_first_baseline) = marker_box.baselines.first
{
list_item_first_baseline - marker_first_baseline
+ } else if let Some(marker_line) = marker_line {
+ let (baseline, _) = self.line_box_created_by_outside_marker(list_item.node, marker_line);
+ baseline - marker_line.ascent
} else {
round_css_pixels(Self::marker_centered_block_offset(
marker_style.line_height(),
@@ -2237,11 +2382,9 @@ impl<'pass> BlockFormattingContext<'pass> {
None,
fragment_arrival,
);
- Some(
- marker_block_offset
- + marker_block_size
- + marker_metrics.border_box_bottom(marker_metrics.uses_collapsing_borders_model()),
- )
+ marker_block_offset
+ + marker_block_size
+ + marker_metrics.border_box_bottom(marker_metrics.uses_collapsing_borders_model())
}
/// Lays out the contents of `node`, a child with a formatting context of its own, and returns its result where a
@@ -2340,6 +2483,9 @@ impl<'pass> BlockFormattingContext<'pass> {
content_offset,
},
);
+ if baselines_in_containing_block.first.is_some() {
+ self.outside_marker_line.set(None);
+ }
Some(BlockLevelBoxOutcome {
content_offset,
is_placed: laid_out.content_offset.is_some(),
@@ -2746,6 +2892,7 @@ impl<'pass> BlockFormattingContext<'pass> {
}
let mut baselines_of_contents_laid_out_in_this_flow = None;
let mut summary_of_children_laid_out_in_this_flow = None;
+ let mut outside_marker_laid_out_before_contents = None;
let mut fragment_arrival_of_child_with_own_formatting_context = None;
// NB: A child its own run laid out is placed as that run handed it back, and any other with its cells here.
let mut child_handed_back_by_its_run = None;
@@ -2848,7 +2995,11 @@ impl<'pass> BlockFormattingContext<'pass> {
self.incoming_container_token.replace(continuation.clone());
let node_as_block_container =
BlockContainer::laid_out_in(&self.run.callbacks, node, self.metrics_of(sized_child), block_container);
- let children_summary = if facts.children_are_inline() {
+ if is_list_item_box && continuation.is_none() {
+ outside_marker_laid_out_before_contents =
+ Some(self.layout_outside_marker_before_contents(run, node_as_block_container));
+ }
+ let mut children_summary = if facts.children_are_inline() {
self.layout_inline_children(
run,
node_as_block_container,
@@ -2865,6 +3016,9 @@ impl<'pass> BlockFormattingContext<'pass> {
space_available_for_children,
)
};
+ if let Some(outside_marker) = &outside_marker_laid_out_before_contents {
+ self.finish_contents_of_list_item(node, outside_marker, &mut children_summary);
+ }
baselines_of_contents_laid_out_in_this_flow = Some(children_summary.baselines);
summary_of_children_laid_out_in_this_flow = Some(children_summary);
if is_in_flow_candidate {
@@ -3017,16 +3171,23 @@ impl<'pass> BlockFormattingContext<'pass> {
self.break_mode.set(break_mode_outside);
// Now that our children are formatted we place the ListItemBox with the left space we remembered.
- if is_list_item_box && !has_independent_formatting_context && continuation.is_none() {
+ if let Some((outside_marker, _)) = outside_marker_laid_out_before_contents {
let list_item_first_baseline = baselines_of_contents_laid_out_in_this_flow
.expect("a list item in this flow had its contents laid out")
.first;
- let marker_border_box_block_end = self.layout_list_item_marker(
- run,
- BlockContainer::laid_out_in(&self.run.callbacks, node, self.metrics_of(sized_child), block_container),
- inline_space_used_before_children_formatted,
- list_item_first_baseline,
- );
+ let marker_border_box_block_end = outside_marker.map(|outside_marker| {
+ self.place_outside_marker(
+ outside_marker,
+ BlockContainer::laid_out_in(
+ &self.run.callbacks,
+ node,
+ self.metrics_of(sized_child),
+ block_container,
+ ),
+ inline_space_used_before_children_formatted,
+ list_item_first_baseline,
+ )
+ });
if let Some(summary) = summary_of_children_laid_out_in_this_flow.as_mut()
&& let Some(marker_border_box_block_end) = marker_border_box_block_end
{
@@ -3222,6 +3383,7 @@ impl<'pass> BlockFormattingContext<'pass> {
block_container_inline_size,
self.style(block_container).direction() == direction::RTL,
self.margin_state.borrow().clone(),
+ self.outside_marker_line.get(),
);
let validity = fc_run_cache::run_root_validity(callbacks, node);
// NB: The committed subtree is reused only while it is the one the stored layout produced.
@@ -3273,6 +3435,7 @@ impl<'pass> BlockFormattingContext<'pass> {
self.cells_laid_out_here(sized_child).set(entry.cells);
let flow_position = self.flow_position();
*self.margin_state.borrow_mut() = entry.outgoing_margins.clone();
+ self.outside_marker_line.set(entry.outgoing_outside_marker_line);
formatting_context::propagate_percentage_block_size_dependency_to_containing_block(
self.run.state,
&self.run.callbacks,
@@ -3348,6 +3511,7 @@ impl<'pass> BlockFormattingContext<'pass> {
},
flow_position_advance: self.flow_position() - flow_position,
outgoing_margins: self.margin_state.borrow().clone(),
+ outgoing_outside_marker_line: self.outside_marker_line.get(),
margin_box_bottom_from_flow_position: content_offset.y
+ used.content_block_size()
+ used.margin_box_bottom(used.uses_collapsing_borders_model())
@@ -4595,6 +4759,10 @@ impl<'pass> BlockFormattingContext<'pass> {
self.record_derived_baselines_of_root_box(baselines);
return;
}
+ // NB: A fieldset places no outside marker.
+ let outside_marker_laid_out_before_contents =
+ (root_facts.is_list_item_box() && self.run.fragmentainer.is_none() && !root_facts.is_fieldset_box())
+ .then(|| self.layout_outside_marker_before_contents(run, self.root_block_container()));
let mut children_summary = if root_facts.is_table_wrapper() {
self.layout_table_wrapper_children(run, root_input, available_space)
} else if root_facts.children_are_inline() {
@@ -4617,6 +4785,11 @@ impl<'pass> BlockFormattingContext<'pass> {
if let Some(lines) = children_summary.lines.take() {
*self.root_lines.borrow_mut() = used_values::LineDataState::Building(Box::new(lines));
}
+ if let Some(outside_marker) = &outside_marker_laid_out_before_contents {
+ self.finish_contents_of_list_item(self.run.box_, outside_marker, &mut children_summary);
+ self.outside_marker_line_box_block_size_of_root
+ .set(children_summary.outside_marker_line_box_block_size);
+ }
let baselines = children_summary.baselines;
self.record_derived_baselines_of_root_box(baselines);
@@ -4641,9 +4814,9 @@ impl<'pass> BlockFormattingContext<'pass> {
}
}
- if root_facts.is_list_item_box() && self.run.fragmentainer.is_none() {
- self.layout_list_item_marker(
- run,
+ if let Some((Some(outside_marker), _)) = outside_marker_laid_out_before_contents {
+ self.place_outside_marker(
+ outside_marker,
self.root_block_container(),
input.sizing.outer_float_intrusion_before_list_item_children,
self.derived_baselines_of_root_box().first,
@@ -4666,6 +4839,12 @@ impl<'pass> BlockFormattingContext<'pass> {
offset_from_relatively_positioned_inline_ancestors: FfiCssPixelPoint,
) -> bool {
let line_index = line_builder.line_index_for_block_level_box();
+ // NB: The outside marker line goes to the first line box in the contents of its list item. A line before this
+ // block holding content is past that; otherwise the block's own contents may hold it.
+ let line_box_precedes_block = line_builder.has_line_box_before(line_index);
+ if line_box_precedes_block {
+ self.outside_marker_line.set(None);
+ }
let current_block_offset = line_builder.current_block_offset();
let saved = self
.block_offset_of_current_block_container
@@ -4697,6 +4876,9 @@ impl<'pass> BlockFormattingContext<'pass> {
.get()
.unwrap_or_else(|| line_builder.current_block_offset());
self.block_offset_of_current_block_container.set(saved);
+ if !line_box_precedes_block {
+ line_builder.set_outside_marker_line(self.outside_marker_line.get());
+ }
let outcome = outcome.expect("the flow holds a block-level box that interrupts its lines");
assert!(
outcome.is_placed,
@@ -5119,7 +5301,11 @@ impl<'pass> BlockFormattingContext<'pass> {
self.run.callbacks,
self,
);
- context.run()
+ let summary = context.run();
+ if summary.baselines.first.is_some() {
+ self.outside_marker_line.set(None);
+ }
+ summary
}
fn compute_automatic_block_size_for_block_level_element(
@@ -5144,6 +5330,11 @@ impl<'pass> BlockFormattingContext<'pass> {
node,
automatic_content_block_size,
)
+ .max(
+ children
+ .and_then(|children| children.outside_marker_line_box_block_size)
+ .unwrap_or_default(),
+ )
}
fn automatic_block_size_for_block_level_element_disregarding_marker(
@@ -5318,7 +5509,11 @@ impl<'pass> BlockFormattingContext<'pass> {
if self.run.fragmentainer.is_some() {
return block_size;
}
- floor_list_item_automatic_block_size_by_marker_line_height(self.run.callbacks, self.run.box_, block_size)
+ floor_list_item_automatic_block_size_by_marker_line_height(self.run.callbacks, self.run.box_, block_size).max(
+ self.outside_marker_line_box_block_size_of_root
+ .get()
+ .unwrap_or_default(),
+ )
}
fn line_clamp_subtree_contains_line(&self, node: Node) -> bool {
diff --git a/Libraries/LibWeb/Rust/src/layout/in_flow_block_cache.rs b/Libraries/LibWeb/Rust/src/layout/in_flow_block_cache.rs
index 7c686cd4c28..69b5dbf1b3c 100644
--- a/Libraries/LibWeb/Rust/src/layout/in_flow_block_cache.rs
+++ b/Libraries/LibWeb/Rust/src/layout/in_flow_block_cache.rs
@@ -23,6 +23,7 @@ pub(super) struct InFlowBlockKey {
pub(super) containing_block_inline_size: CssPixels,
pub(super) containing_block_is_right_to_left: bool,
pub(super) incoming_margins: block_formatting_context::BlockMarginState,
+ pub(super) incoming_outside_marker_line: Option<block_formatting_context::OutsideMarkerLine>,
pub(super) run_root: Node,
pub(super) treat_block_axis_percentage_insets_as_auto_beyond_root: bool,
pub(super) initial_containing_block_size: (CssPixels, CssPixels),
@@ -36,12 +37,14 @@ impl InFlowBlockKey {
containing_block_inline_size: CssPixels,
containing_block_is_right_to_left: bool,
incoming_margins: block_formatting_context::BlockMarginState,
+ incoming_outside_marker_line: Option<block_formatting_context::OutsideMarkerLine>,
) -> Self {
Self {
input,
containing_block_inline_size,
containing_block_is_right_to_left,
incoming_margins,
+ incoming_outside_marker_line,
run_root: run.box_,
treat_block_axis_percentage_insets_as_auto_beyond_root: run
.treat_block_axis_percentage_insets_as_auto_beyond_root,
@@ -67,6 +70,7 @@ pub(super) struct InFlowBlockEntry {
pub(super) offset_from_flow_position: FfiCssPixelPoint,
pub(super) flow_position_advance: CssPixels,
pub(super) outgoing_margins: block_formatting_context::BlockMarginState,
+ pub(super) outgoing_outside_marker_line: Option<block_formatting_context::OutsideMarkerLine>,
pub(super) margin_box_bottom_from_flow_position: CssPixels,
pub(super) depends_on_percentage_block_size: bool,
/// The fragment the stored layout placed. The committed subtree is reused only while it is still that fragment.
diff --git a/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs
index 7ff9f4f82c8..03dd7fc84c0 100644
--- a/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs
@@ -2307,7 +2307,13 @@ impl<'context> InlineFormattingContext<'context> {
let fragmentation = self.parent.line_root_fragmentation(self.containing_block);
let resume = fragmentation.and_then(|fragmentation| fragmentation.resume);
let balances_lines = self.balances_lines(&iterator, fragmentation);
- let (reused_lines, reused_item_count) = if self.parent.has_line_clamp() || resume.is_some() || balances_lines {
+ // NB: A reused first line box keeps the outside marker it was laid out with.
+ let (reused_lines, reused_item_count) = if self.parent.has_line_clamp()
+ || resume.is_some()
+ || balances_lines
+ || self.parent.pending_outside_marker_line().is_some()
+ || self.facts(self.containing_block).is_list_item_box()
+ {
Default::default()
} else {
self.parent
diff --git a/Libraries/LibWeb/Rust/src/layout/line_builder.rs b/Libraries/LibWeb/Rust/src/layout/line_builder.rs
index fd74e037e8f..aa749af3b53 100644
--- a/Libraries/LibWeb/Rust/src/layout/line_builder.rs
+++ b/Libraries/LibWeb/Rust/src/layout/line_builder.rs
@@ -72,6 +72,8 @@ pub(crate) struct LineBuilder<'builder, 'context> {
only_finds_line_breaks: bool,
current_block_offset: CssPixels,
max_block_size_on_current_line: CssPixels,
+ /// The outside markers that the first line box this builder lays out contributes to.
+ outside_marker_line: Option<block_formatting_context::OutsideMarkerLine>,
unbreakable_run_inline_size_interrupted_by_float: CssPixels,
text_indentation: inline_formatting_context::TextIndentation,
direction: u8,
@@ -138,6 +140,7 @@ impl<'builder, 'context> LineBuilder<'builder, 'context> {
only_finds_line_breaks: false,
current_block_offset: CssPixels::default(),
max_block_size_on_current_line: CssPixels::default(),
+ outside_marker_line: context.parent.pending_outside_marker_line(),
unbreakable_run_inline_size_interrupted_by_float: CssPixels::default(),
text_indentation: inline_formatting_context::TextIndentation::of(style, containing_inline_size),
direction: style.direction(),
@@ -879,9 +882,33 @@ impl<'builder, 'context> LineBuilder<'builder, 'context> {
line_box_baseline = adjusted_baseline;
}
}
+ if let Some(marker_line) = self.outside_marker_line(line_index)
+ && marker_line.ascent > line_box_baseline
+ {
+ should_align_strut_to_line_box_baseline = true;
+ line_box_baseline = marker_line.ascent;
+ }
(line_box_baseline, should_align_strut_to_line_box_baseline)
}
+ /// The outside markers whose list items have the line at `line_index` as their first line box.
+ fn outside_marker_line(&self, line_index: usize) -> Option<block_formatting_context::OutsideMarkerLine> {
+ let line = self.line(line_index);
+ if line.is_empty() || line.has_block_level_box || self.has_line_box_before(line_index) {
+ return None;
+ }
+ self.outside_marker_line
+ }
+
+ /// Whether a line before the line at `line_index` holds content.
+ pub(crate) fn has_line_box_before(&self, line_index: usize) -> bool {
+ (0..line_index).any(|index| !self.line(index).is_empty())
+ }
+
+ pub(crate) fn set_outside_marker_line(&mut self, marker_line: Option<block_formatting_context::OutsideMarkerLine>) {
+ self.outside_marker_line = marker_line;
+ }
+
// https://drafts.csswg.org/css2/#line-height
pub(crate) fn update_last_line(&mut self, has_immediate_continuation: bool) {
if !self.last_line_needs_update {
@@ -1074,6 +1101,10 @@ impl<'builder, 'context> LineBuilder<'builder, 'context> {
};
let mut earliest = strut_start;
let mut latest = strut_end;
+ if let Some(marker_line) = self.outside_marker_line(line_index) {
+ earliest = earliest.min(self.current_block_offset + line_box_baseline - marker_line.ascent);
+ latest = latest.max(self.current_block_offset + line_box_baseline + marker_line.descent);
+ }
let mut aligned_subtrees: Vec<LineRelativeAlignedSubtree> = Vec::new();
let mut first_unshifted_text_baseline: Option<CssPixels> = None;
let current_block_offset = self.current_block_offset;
diff --git a/Tests/LibWeb/Layout/expected/list-item-marker-content-height.txt b/Tests/LibWeb/Layout/expected/list-item-marker-content-height.txt
index b6bdc9998c7..27d300f867b 100644
--- a/Tests/LibWeb/Layout/expected/list-item-marker-content-height.txt
+++ b/Tests/LibWeb/Layout/expected/list-item-marker-content-height.txt
@@ -5,20 +5,20 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children
BlockContainer <(anonymous)> at [48,16] [0+0+0 744 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)
ListItemBox <li> at [48,16] [0+0+0 744 0+0+0] [0+0+0 30 0+0+0] children: inline
- frag 0 from TextNode start: 0, length: 1, rect: [48,16 6.34375x16] baseline: 12.796875
+ frag 0 from TextNode start: 0, length: 1, rect: [48,27 6.34375x16] baseline: 12.796875
"1"
- ListItemMarkerBox <(anonymous)> at [13,4.796875] [0+0+0 35.03125 0+0+0] [0+0+0 30 0+0+0] [BFC] children: inline
- frag 0 from GeneratedTextNode start: 0, length: 3, rect: [13,4.796875 35.03125x30] baseline: 24
+ ListItemMarkerBox <(anonymous)> at [13,15.796875] [0+0+0 35.03125 0+0+0] [0+0+0 30 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 3, rect: [13,15.796875 35.03125x30] baseline: 24
"1. "
GeneratedTextNode <(anonymous)> (not painted)
TextNode <#text> (not painted)
BlockContainer <(anonymous)> at [48,46] [0+0+0 744 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)
ListItemBox <li> at [48,46] [0+0+0 744 0+0+0] [0+0+0 30 0+0+0] children: inline
- frag 0 from TextNode start: 0, length: 1, rect: [48,46 8.8125x16] baseline: 12.796875
+ frag 0 from TextNode start: 0, length: 1, rect: [48,57 8.8125x16] baseline: 12.796875
"2"
- ListItemMarkerBox <(anonymous)> at [8,34.796875] [0+0+0 39.671875 0+0+0] [0+0+0 30 0+0+0] [BFC] children: inline
- frag 0 from GeneratedTextNode start: 0, length: 3, rect: [8,34.796875 39.671875x30] baseline: 24
+ ListItemMarkerBox <(anonymous)> at [8,45.796875] [0+0+0 39.671875 0+0+0] [0+0+0 30 0+0+0] [BFC] children: inline
+ frag 0 from GeneratedTextNode start: 0, length: 3, rect: [8,45.796875 39.671875x30] baseline: 24
"2. "
GeneratedTextNode <(anonymous)> (not painted)
TextNode <#text> (not painted)
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/add-inline-child-after-marker-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/add-inline-child-after-marker-001-ref.html
new file mode 100644
index 00000000000..0c1d2397d75
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/add-inline-child-after-marker-001-ref.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Lists: Add inline child after marker</title>
+
+<p>The test passes if you see the list marker followed by the text "inline" and "axxx" in a line below.</p>
+
+<ul>
+ <li>
+ <span>inline</span>
+ <div style="overflow:hidden;">
+ <span>a</span>xxx
+ </div>
+ </li>
+</ul>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/add-inline-child-after-marker-002-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/add-inline-child-after-marker-002-ref.html
new file mode 100644
index 00000000000..f7d113d3780
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/add-inline-child-after-marker-002-ref.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Lists: Add inline child after marker</title>
+
+<p>The test passes if you see the list marker followed by the text "axxx" in the same line.</p>
+
+<ul>
+ <li>
+ <span> </span>
+ <div style="overflow:hidden;">
+ <span>a</span>xxx
+ </div>
+ </li>
+</ul>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/li-insert-child-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/li-insert-child-ref.html
new file mode 100644
index 00000000000..bbf2e66a0df
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/li-insert-child-ref.html
@@ -0,0 +1,51 @@
+<!DOCTYPE HTML>
+<!--
+ Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<html><head>
+ <meta charset="utf-8">
+ <title>Reference: Insert text node as first child in LI</title>
+ <link rel="author" title="Mats Palmgren" href="mailto:[email protected]">
+ <style>
+ ul.inside { list-style-position: inside; }
+ .before::before { content: "before"; }
+ .after::after { content: "after"; }
+ </style>
+</head>
+<body>
+
+<ul class="inside">
+ <li>AB</li>
+</ul>
+
+<ul class="inside">
+ <li class="before">AB</li>
+</ul>
+
+<ul class="inside">
+ <li class="after">AB</li>
+</ul>
+
+<ul class="inside">
+ <li class="before after">AB</li>
+</ul>
+
+<ul>
+ <li>AB</li>
+</ul>
+
+<ul>
+ <li class="before">AB</li>
+</ul>
+
+<ul>
+ <li class="after">AB</li>
+</ul>
+
+<ul>
+ <li class="before after">AB</li>
+</ul>
+
+</body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/li-with-height-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/li-with-height-001-ref.html
new file mode 100644
index 00000000000..486009d5604
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/li-with-height-001-ref.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Lists: list with height</title>
+
+<p>The test passes if "second" is in the following line of "first".</p>
+<ul>
+ <li id="li_target" style="height:200px; border:1px solid black; width:200px">
+ first<div id="div_target" style="overflow:hidden;">second</div>
+ </li>
+</ul>
+
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/li-with-overflow-hidden-change-list-style-position-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/li-with-overflow-hidden-change-list-style-position-001-ref.html
new file mode 100644
index 00000000000..a3ea8b66ee0
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/li-with-overflow-hidden-change-list-style-position-001-ref.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Lists: test inside and outside switch</title>
+
+<p>The test passes if the first li is inside and the second one is outside.</p>
+
+<ul>
+ <li style="list-style-position: inside;">
+ <div style="overflow:hidden;">
+ outside to inside
+ </div>
+ </li>
+</ul>
+
+<ul>
+ <li style="list-style-position: outside;">
+ <div style="overflow:hidden;">
+ inside to outside
+ </div>
+ </li>
+</ul>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/list-and-flex-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/list-and-flex-001-ref.html
new file mode 100644
index 00000000000..d7be687125a
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/list-and-flex-001-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Lists: test list with flex as its first child</title>
+
+<p>There should be no extra line generated between the marker and the flex.</p>
+
+<ul>
+ <li>
+ <div style="border: 1px black solid;">
+ <div style="display: inline-flex; align-items: flex-end; height: 200px;">
+ <span style="line-height: 50px">text</span>
+ </div>
+ </div>
+ </li>
+</ul>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/list-marker-alignment-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/list-marker-alignment-ref.html
new file mode 100644
index 00000000000..acbc73e284c
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/list-marker-alignment-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<style>::marker { font-family:inherit; }</style>
+<div style="display:inline-block;">
+ <ul>
+ <li>
+ xx
+ </li>
+ xx
+ </ul>
+</div>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/list-marker-font-size-mutation-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/list-marker-font-size-mutation-ref.html
new file mode 100644
index 00000000000..ce9833ff353
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/list-marker-font-size-mutation-ref.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Reftest Reference</title>
+<style>
+li { list-style-type: "\627\644\641"; font-size: 32px; }
+</style>
+<ul><li>text</li></ul>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/list-marker-with-lineheight-and-overflow-hidden-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/list-marker-with-lineheight-and-overflow-hidden-001-ref.html
new file mode 100644
index 00000000000..ae6486147e2
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/list-marker-with-lineheight-and-overflow-hidden-001-ref.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Lists: test list with overflow:hidden and line-height firstchild</title>
+
+<p>This test passes if there is a marker for each li and followed by "text" in the same line.</p>
+
+<ul>
+ <li>
+ <div style="line-height:100px;">
+ <span>text</span>
+ </div>
+ </li>
+</ul>
+<ul>
+ <li style="list-style-image: url(resources/white.gif);">
+ <div style="line-height:100px;">text</div>
+ </li>
+</ul>
+
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/list-style-type-decimal-line-height-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/list-style-type-decimal-line-height-ref.html
new file mode 100644
index 00000000000..856fe43d8ef
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/list-style-type-decimal-line-height-ref.html
@@ -0,0 +1,43 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>CSS Lists Reference - check that the line height is the same between different forms of ::markers</title>
+<link rel="author" title="Mats Palmgren" href="mailto:[email protected]">
+<style>
+ div {
+ display: grid;
+ grid-template-columns: 100px 100px auto;
+ align-items: start;
+ background: red;
+ }
+ li {
+ line-height: 100%;
+ counter-set: list-item 1;
+ }
+ ol {
+ margin: 0;
+ padding: 0;
+ padding-left: 40px;
+ background: green;
+ }
+ ::marker {
+ content: "1. ";
+ }
+</style>
+
+<div>
+ <ol>
+ <li>foo</li>
+ <li>bar</li>
+ <li>baz</li>
+ </ol>
+ <ol>
+ <li>foo</li>
+ <li>bar</li>
+ <li>baz</li>
+ </ol>
+ <ol>
+ <li>foo</li>
+ <li>bar</li>
+ <li>baz</li>
+ </ol>
+</div>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/outside-marker-in-multicol-relpos-content-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/outside-marker-in-multicol-relpos-content-ref.html
new file mode 100644
index 00000000000..913ab015b8b
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/outside-marker-in-multicol-relpos-content-ref.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+.list {
+ display: list-item;
+ columns: 2;
+ column-fill: auto;
+ height: 100px;
+ padding-inline-start: 20px;
+ width: 100px;
+ margin-left: 20px;
+}
+
+.list::marker {
+ color: magenta;
+}
+
+.columnFiller {
+ height: 100px;
+ width: 20px;
+ background: green;
+}
+</style>
+</head>
+<body>
+<div class="list">
+ <div class="columnFiller"></div>
+ <div class="itemContent">item</div>
+</div>
+</body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/outside-marker-position-with-cached-line-content-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/outside-marker-position-with-cached-line-content-ref.html
new file mode 100644
index 00000000000..f2d5bc2a200
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/outside-marker-position-with-cached-line-content-ref.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Outside list marker position does not depend on text-overflow</title>
+<link rel="stylesheet" type="text/css" href="../../fonts/ahem.css">
+<style>
+ body { margin: 0 }
+ ul { margin: 0; padding-left: 40px }
+ li { font-family: Ahem; font-size: 20px }
+ .indented { padding-left: 40px }
+</style>
+</head>
+<body>
+ <ul><li><div class="indented" style="width: max-content">one</div></li></ul>
+
+ <ul><li><div style="display: flex"><div class="indented">two</div></div></li></ul>
+
+ <ul><li><div style="display: grid"><div class="indented">three</div></div></li></ul>
+
+ <ul><li><div class="indented" style="display: inline-block">four</div></li></ul>
+
+ <ul><li><div style="display: table"><div class="indented" style="display: table-cell">five</div></div></li></ul>
+
+ <ul><li><div style="width: max-content; border-left: 40px solid transparent">six</div></li></ul>
+</body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/outside-marker-with-block-in-nested-inline-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/outside-marker-with-block-in-nested-inline-ref.html
new file mode 100644
index 00000000000..5f5703d3780
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/outside-marker-with-block-in-nested-inline-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>An outside list marker aligns with the block a nested inline's content starts with</title>
+<link rel="stylesheet" type="text/css" href="../../fonts/ahem.css">
+<style>
+ body { margin: 0; font: 20px/1 Ahem }
+ ul { margin: 0; padding-inline-start: 40px }
+</style>
+</head>
+<body>
+ <ul><li><span><div>xx</div></span><br></li></ul>
+</body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/outside-marker-with-float-in-content-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/outside-marker-with-float-in-content-ref.html
new file mode 100644
index 00000000000..1b29ac19152
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/outside-marker-with-float-in-content-ref.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>A float in the list item's content does not move the outside marker</title>
+<link rel="stylesheet" type="text/css" href="../../fonts/ahem.css">
+<style>
+ body { margin: 0; font: 20px/1 Ahem }
+ ul { margin: 0; padding-inline-start: 60px }
+ .box { display: inline-block; width: 60px; height: 20px; background: green; vertical-align: top }
+</style>
+</head>
+<body>
+ <ul><li><div><span class="box"></span>xx</div></li></ul>
+</body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/outside-marker-with-relpos-block-content-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/outside-marker-with-relpos-block-content-ref.html
new file mode 100644
index 00000000000..95dc807ec5d
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/outside-marker-with-relpos-block-content-ref.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+.list {
+ margin: 0;
+ padding-inline-start: 20px;
+ font: 16px/1.4 monospace;
+}
+
+.itemContent {
+ margin: 0;
+}
+</style>
+</head>
+<body>
+<ol class="list">
+ <li class="item"><p class="itemContent">Item A</p></li>
+ <li class="item"><p class="itemContent">Item B</p></li>
+ <li class="item"><p class="itemContent">Item C</p></li>
+</ol>
+</body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/outside-marker-with-text-indent-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/outside-marker-with-text-indent-ref.html
new file mode 100644
index 00000000000..66e9df90a50
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/outside-marker-with-text-indent-ref.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>text-indent moves the line, not the outside list marker</title>
+<link rel="stylesheet" type="text/css" href="../../fonts/ahem.css">
+<style>
+ body { margin: 0; font: 20px/1 Ahem }
+ ul { margin: 0; padding-inline-start: 60px }
+ div { padding-inline-start: 60px }
+</style>
+</head>
+<body>
+ <ul><li><div>xx</div></li></ul>
+</body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/resources/white.gif b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/resources/white.gif
new file mode 100644
index 00000000000..3aa2098dc88
Binary files /dev/null and b/Tests/LibWeb/Ref/expected/wpt-import/css/css-lists/resources/white.gif differ
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/marker-font-properties-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/marker-font-properties-ref.html
new file mode 100644
index 00000000000..a8fb980ff09
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/marker-font-properties-ref.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS Test: ::marker formatting with font properties reference file</title>
+<link rel="author" title="Daniel Bates" href="mailto:[email protected]">
+<style>
+ol {
+ line-height: 30px;
+}
+
+li {
+ font-family: sans-serif;
+ font-size: 24px;
+ font-style: italic;
+ font-variant: small-caps;
+ font-weight: bold;
+ list-style-type: lower-alpha;
+ font-variant-numeric: tabular-nums;
+}
+</style>
+</head>
+<body>
+<ol>
+ <li></li>
+</ol>
+</body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/marker-inherit-line-height-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/marker-inherit-line-height-ref.html
new file mode 100644
index 00000000000..cb14caeb0f9
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/marker-inherit-line-height-ref.html
@@ -0,0 +1,17 @@
+<!doctype html>
+<title>Reference: Check that :marker inherits line-height</title>
+<link rel="stylesheet" type="text/css" href="../../fonts/ahem.css" />
+<style>
+div {
+ font: 128px/1 Ahem;
+ border: 2px solid blue;
+ background: orange;
+ color: black;
+}
+</style>
+
+<p>There should be two black rectangles below with no space between them and
+ the border above/below.</p>
+<div>
+ 1. X
+</div>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/marker-intrinsic-contribution-002-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/marker-intrinsic-contribution-002-ref.html
new file mode 100644
index 00000000000..bfae577499c
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/marker-intrinsic-contribution-002-ref.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Reference: intrinsic contribution of ::marker</title>
+<link rel="author" title="Oriol Brufau" href="mailto:[email protected]">
+<style>
+li {
+ border: 5px solid;
+ float: left;
+ clear: left;
+}
+.inside {
+ list-style-position: inside;
+}
+.symbol {
+ list-style-type: disc;
+}
+.decimal {
+ list-style-type: decimal;
+}
+.string {
+ list-style-type: "string";
+}
+.content::marker {
+ content: "content";
+}
+</style>
+<ol class="inside">
+ <li class="symbol"></li>
+ <li class="decimal"></li>
+ <li class="string"></li>
+ <li class="content"></li>
+</ol>
+<ol>
+ <li class="symbol"></li>
+ <li class="decimal"></li>
+ <li class="string"></li>
+ <li class="content"></li>
+</ol>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/marker-line-height-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/marker-line-height-ref.html
new file mode 100644
index 00000000000..a32fb812f10
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-pseudo/marker-line-height-ref.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<meta charset="utf-8" />
+<title>CSS Reftest Reference</title>
+<link rel="author" title="Oriol Brufau" href="mailto:[email protected]" />
+<style>
+::marker { font-family: inherit; }
+ol {
+ float: left;
+ width: 50px;
+ list-style-position: inside;
+ line-height: 3;
+}
+li:first-child {
+ list-style-type: disc;
+}
+div {
+ line-height: 1;
+}
+</style>
+<ol>
+ <li></li>
+ <li></li>
+ <li></li>
+ <li></li>
+</ol>
+<ol>
+ <li></li>
+ <li></li>
+ <li></li>
+ <li></li>
+</ol>
+<ol>
+ <li><div>x</div></li>
+ <li><div>x</div></li>
+ <li><div>x</div></li>
+ <li><div>x</div></li>
+</ol>
+<ol>
+ <li><div>x</div></li>
+ <li><div>x</div></li>
+ <li><div>x</div></li>
+ <li><div>x</div></li>
+</ol>
diff --git a/Tests/LibWeb/Ref/input/overflow-hidden-list-item-clips-outside-marker.html b/Tests/LibWeb/Ref/input/overflow-hidden-list-item-clips-outside-marker.html
index 04ac6958d1a..dc771a20c34 100644
--- a/Tests/LibWeb/Ref/input/overflow-hidden-list-item-clips-outside-marker.html
+++ b/Tests/LibWeb/Ref/input/overflow-hidden-list-item-clips-outside-marker.html
@@ -19,7 +19,6 @@
li::marker {
color: red;
- font-size: 40px;
}
</style>
<ul>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/add-inline-child-after-marker-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/add-inline-child-after-marker-001.html
new file mode 100644
index 00000000000..0cb0cc0409b
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/add-inline-child-after-marker-001.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Lists: Add inline child after marker</title>
+<link rel=help href="https://www.w3.org/TR/CSS22/generate.html#lists">
+<link rel=match href="../../../../expected/wpt-import/css/css-lists/add-inline-child-after-marker-001-ref.html">
+<!-- https://bugs.chromium.org/p/chromium/issues/detail?id=344941 -->
+
+<p>The test passes if you see the list marker followed by the text "inline" and "axxx" in a line below.</p>
+
+<ul>
+ <li id="liTarget">
+ <div id="divTarget" style="overflow:hidden;">
+ <span>a</span>xxx
+ </div>
+ </li>
+</ul>
+<script>
+ document.body.offsetHeight;
+ var new_span=document.createElement("span");
+ var text_node=document.createTextNode("inline");
+ new_span.appendChild(text_node);
+
+ var div_target=document.getElementById("divTarget");
+ var li_target=document.getElementById("liTarget");
+ li_target.insertBefore(new_span,div_target);
+</script>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/add-inline-child-after-marker-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/add-inline-child-after-marker-002.html
new file mode 100644
index 00000000000..a249286d400
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/add-inline-child-after-marker-002.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Lists: Add inline child after marker</title>
+<link rel=help href="https://www.w3.org/TR/CSS22/generate.html#lists">
+<link rel=match href="../../../../expected/wpt-import/css/css-lists/add-inline-child-after-marker-002-ref.html">
+<!-- https://bugs.chromium.org/p/chromium/issues/detail?id=1049633 -->
+
+<p>The test passes if you see the list marker followed by the text "axxx" in the same line.</p>
+
+<ul>
+ <li id="liTarget">
+ <div id="divTarget" style="overflow:hidden;">
+ <span>a</span>xxx
+ </div>
+ </li>
+</ul>
+<script>
+ document.body.offsetHeight;
+ var new_span=document.createElement("span");
+ var text_node=document.createTextNode(" ");
+ new_span.appendChild(text_node);
+
+ var div_target=document.getElementById("divTarget");
+ var li_target=document.getElementById("liTarget");
+ li_target.insertBefore(new_span,div_target);
+</script>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/li-insert-child.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/li-insert-child.html
new file mode 100644
index 00000000000..e2b9178486c
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/li-insert-child.html
@@ -0,0 +1,60 @@
+<!DOCTYPE HTML>
+<!--
+ Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<html class="reftest-wait"><head>
+ <meta charset="utf-8">
+ <title>Test: Insert text node as first child in LI</title>
+ <link rel="author" title="Mats Palmgren" href="mailto:[email protected]">
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1567773">
+ <link rel="match" href="../../../../expected/wpt-import/css/css-lists/li-insert-child-ref.html">
+ <style>
+ ul.inside { list-style-position: inside; }
+ .before::before { content: "before"; }
+ .after::after { content: "after"; }
+ </style>
+</head>
+<body>
+
+<ul class="inside">
+ <li>B</li>
+</ul>
+
+<ul class="inside">
+ <li class="before">B</li>
+</ul>
+
+<ul class="inside">
+ <li class="after">B</li>
+</ul>
+
+<ul class="inside">
+ <li class="before after">B</li>
+</ul>
+
+<ul>
+ <li>B</li>
+</ul>
+
+<ul>
+ <li class="before">B</li>
+</ul>
+
+<ul>
+ <li class="after">B</li>
+</ul>
+
+<ul>
+ <li class="before after">B</li>
+</ul>
+
+<script>
+document.body.offsetHeight;
+let items = Array.prototype.slice.call(document.querySelectorAll('li'));
+items.map(li => li.insertBefore(document.createTextNode('A'), li.firstChild));
+document.documentElement.className = '';
+</script>
+
+</body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/li-with-height-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/li-with-height-001.html
new file mode 100644
index 00000000000..f20d813edea
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/li-with-height-001.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Lists: list with height</title>
+<link rel=help href="https://www.w3.org/TR/CSS22/generate.html#lists">
+<link rel=match href="../../../../expected/wpt-import/css/css-lists/li-with-height-001-ref.html">
+<meta name="assert" content="This is to check the behavior of adding an element at the begining of li" />
+
+<p>The test passes if "second" is in the following line of "first".</p>
+
+<ul>
+ <li id="li_target" style="height:200px; border:1px solid black; width:200px">
+ <div id="div_target" style="overflow:hidden;">second</div>
+ </li>
+</ul>
+
+<script>
+ document.body.clientHeight;
+
+ var text_node = document.createTextNode("first");
+ var li_target = document.getElementById("li_target");
+ var div_target = document.getElementById("div_target");
+ li_target.insertBefore(text_node,div_target);
+</script>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/li-with-overflow-hidden-change-list-style-position-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/li-with-overflow-hidden-change-list-style-position-001.html
new file mode 100644
index 00000000000..dedc2fc20eb
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/li-with-overflow-hidden-change-list-style-position-001.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Lists: test inside and outside switch</title>
+<link rel=help href="https://www.w3.org/TR/CSS22/generate.html#lists">
+<link rel=match href="../../../../expected/wpt-import/css/css-lists/li-with-overflow-hidden-change-list-style-position-001-ref.html">
+<!-- https://bugs.chromium.org/p/chromium/issues/detail?id=344941 -->
+
+<p>The test passes if the first li is inside and the second one is outside.</p>
+
+<ul>
+ <li id="outSide" style="list-style-position: outside;">
+ <div style="overflow:hidden;">
+ outside to inside
+ </div>
+ </li>
+</ul>
+
+<ul>
+ <li id="inSide" style="list-style-position: inside;">
+ <div style="overflow:hidden;">
+ inside to outside
+ </div>
+ </li>
+</ul>
+<script>
+ document.body.offsetHeight;
+
+ var outside_li=document.getElementById("outSide");
+ outside_li.style.listStylePosition = "inside";
+ document.body.offsetHeight;
+
+ var inside_li=document.getElementById("inSide");
+ inside_li.style.listStylePosition = "outside";
+ document.body.offsetHeight;
+
+</script>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/list-and-flex-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/list-and-flex-001.html
new file mode 100644
index 00000000000..be7d85c10fe
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/list-and-flex-001.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Lists: test list with flex as its first child</title>
+<link rel=help href="https://www.w3.org/TR/CSS22/generate.html#lists">
+<link rel=match href="../../../../expected/wpt-import/css/css-lists/list-and-flex-001-ref.html">
+<meta name=fuzzy content="maxDifference=0-8; totalPixels=0-10">
+<!-- https://bugs.chromium.org/p/chromium/issues/detail?id=767408 -->
+
+<p>There should be no extra line generated between the marker and the flex.</p>
+
+<ul>
+ <li>
+ <div style="border: 1px black solid;">
+ <div style="display: flex; align-items: flex-end; height: 200px;">
+ <span style="line-height: 50px">text</span>
+ </div>
+ </div>
+ </li>
+</ul>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/list-marker-alignment.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/list-marker-alignment.html
new file mode 100644
index 00000000000..061c6e30257
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/list-marker-alignment.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<link rel="help" href="https://crbug.com/1051181">
+<link rel="match" href="../../../../expected/wpt-import/css/css-lists/list-marker-alignment-ref.html">
+<meta name="assert" content="This test checks the list marker aligns to the first baseline.">
+<style>::marker { font-family:inherit; }</style>
+<div style="display:inline-block;">
+ <ul>
+ <li>
+ <p>
+ xx<br>xx
+ </p>
+ </li>
+ </ul>
+</div>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/list-marker-font-size-mutation.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/list-marker-font-size-mutation.html
new file mode 100644
index 00000000000..c7884bd48d3
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/list-marker-font-size-mutation.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Lists: marker follows a font change made after layout</title>
+<link rel="help" href="https://drafts.csswg.org/css-lists-3/#marker-pseudo">
+<link rel="match" href="../../../../expected/wpt-import/css/css-lists/list-marker-font-size-mutation-ref.html">
+<meta name="assert" content="Changing the font-size of a list item updates its marker, including when the marker text needs bidi resolution.">
+<style>
+li {
+ list-style-type: "\627\644\641";
+ font-size: 16px;
+}
+</style>
+<ul><li>text</li></ul>
+<script>
+document.body.offsetLeft;
+document.querySelector("li").style.fontSize = "32px";
+</script>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/list-marker-with-lineheight-and-overflow-hidden-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/list-marker-with-lineheight-and-overflow-hidden-001.html
new file mode 100644
index 00000000000..f51ec6e1534
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/list-marker-with-lineheight-and-overflow-hidden-001.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Lists: test list with overflow:hidden and line-height firstchild</title>
+<link rel=help href="https://www.w3.org/TR/CSS22/generate.html#lists">
+<link rel=match href="../../../../expected/wpt-import/css/css-lists/list-marker-with-lineheight-and-overflow-hidden-001-ref.html">
+<!-- https://bugs.chromium.org/p/chromium/issues/detail?id=344941 -->
+
+<p>This test passes if there is a marker for each li and followed by "text" in the same line.</p>
+
+<ul>
+ <li>
+ <div style="overflow:hidden; line-height:100px;">
+ <span>text</span>
+ </div>
+ </li>
+</ul>
+
+<ul>
+ <li style="list-style-image: url(resources/white.gif);">
+ <div style="overflow:hidden; line-height:100px;">text</div>
+ </li>
+</ul>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/list-style-type-decimal-line-height.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/list-style-type-decimal-line-height.html
new file mode 100644
index 00000000000..7f10b006827
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/list-style-type-decimal-line-height.html
@@ -0,0 +1,49 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>CSS Lists Test - check that the line height is the same between different forms of ::markers</title>
+<link rel="author" title="Mats Palmgren" href="mailto:[email protected]">
+<link rel="help" href="https://drafts.csswg.org/css-lists-3/#text-markers">
+<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=942017">
+<link rel="match" href="../../../../expected/wpt-import/css/css-lists/list-style-type-decimal-line-height-ref.html">
+<style>
+ div {
+ display: grid;
+ grid-template-columns: 100px 100px auto;
+ align-items: start;
+ background: red;
+ }
+ li {
+ line-height: 100%;
+ counter-set: list-item 1;
+ }
+ ol {
+ margin: 0;
+ padding: 0;
+ padding-left: 40px;
+ background: green;
+ }
+ ol:nth-child(2) > li {
+ list-style-type: "1. ";
+ }
+ ol:nth-child(3) > ::marker {
+ content: counter(list-item) ". ";
+ }
+</style>
+
+<div>
+ <ol>
+ <li>foo</li>
+ <li>bar</li>
+ <li>baz</li>
+ </ol>
+ <ol>
+ <li>foo</li>
+ <li>bar</li>
+ <li>baz</li>
+ </ol>
+ <ol>
+ <li>foo</li>
+ <li>bar</li>
+ <li>baz</li>
+ </ol>
+</div>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/outside-marker-in-multicol-relpos-content.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/outside-marker-in-multicol-relpos-content.html
new file mode 100644
index 00000000000..88e6070004a
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/outside-marker-in-multicol-relpos-content.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS Lists: outside marker position for content flowing into a later multicol column</title>
+<link rel="help" href="https://drafts.csswg.org/css-lists-3/#list-style-position-property">
+<link rel="author" title="Yulun Wu" href="mailto:[email protected]">
+<link rel="match" href="../../../../expected/wpt-import/css/css-lists/outside-marker-in-multicol-relpos-content-ref.html">
+<meta name="assert" content="An outside list marker for content that flows into a later column of a multi-column list item must paint adjacent to that column; relative positioning of the item content must not shift it.">
+<style>
+.container {
+ margin-left: 20px;
+}
+.list {
+ display: list-item;
+ columns: 2;
+ column-fill: auto;
+ height: 100px;
+ padding-inline-start: 20px;
+ width: 100px;
+}
+
+.list::marker {
+ color: magenta;
+}
+
+.columnFiller {
+ height: 100px;
+ width: 20px;
+ background: green;
+}
+
+.itemContent {
+ position: relative;
+}
+</style>
+</head>
+<body>
+<div class="container">
+ <div class="list">
+ <div class="columnFiller"></div>
+ <div class="itemContent">item</div>
+ </div>
+</div>
+</body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/outside-marker-position-with-cached-line-content.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/outside-marker-position-with-cached-line-content.html
new file mode 100644
index 00000000000..81f588c8f5f
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/outside-marker-position-with-cached-line-content.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Outside list marker position does not depend on text-overflow</title>
+<link rel="help" href="https://drafts.csswg.org/css-lists-3/#list-style-position-outside">
+<link rel="match" href="../../../../expected/wpt-import/css/css-lists/outside-marker-position-with-cached-line-content-ref.html">
+<link rel="stylesheet" type="text/css" href="../../fonts/ahem.css">
+<style>
+ body { margin: 0 }
+ ul { margin: 0; padding-left: 40px }
+ li { font-family: Ahem; font-size: 20px }
+ .indented { padding-left: 40px }
+ .ellipsis { text-overflow: ellipsis }
+</style>
+</head>
+<body>
+ <ul><li><div class="indented ellipsis" style="width: max-content">one</div></li></ul>
+
+ <ul><li><div style="display: flex"><div class="indented ellipsis">two</div></div></li></ul>
+
+ <ul><li><div style="display: grid"><div class="indented ellipsis">three</div></div></li></ul>
+
+ <ul><li><div class="indented ellipsis" style="display: inline-block">four</div></li></ul>
+
+ <ul><li><div style="display: table"><div class="indented ellipsis" style="display: table-cell">five</div></div></li></ul>
+
+ <ul><li><div class="ellipsis" style="width: max-content; border-left: 40px solid transparent">six</div></li></ul>
+</body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/outside-marker-with-block-in-nested-inline.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/outside-marker-with-block-in-nested-inline.html
new file mode 100644
index 00000000000..bc08a77f5cc
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/outside-marker-with-block-in-nested-inline.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>An outside list marker aligns with the block a nested inline's content starts with</title>
+<link rel="help" href="https://drafts.csswg.org/css-lists-3/#list-style-position-outside">
+<link rel="match" href="../../../../expected/wpt-import/css/css-lists/outside-marker-with-block-in-nested-inline-ref.html">
+<link rel="stylesheet" type="text/css" href="../../fonts/ahem.css">
+<style>
+ body { margin: 0; font: 20px/1 Ahem }
+ ul { margin: 0; padding-inline-start: 40px }
+</style>
+</head>
+<body>
+ <ul><li><span><span><div>xx</div></span></span><br></li></ul>
+</body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/outside-marker-with-float-in-content.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/outside-marker-with-float-in-content.html
new file mode 100644
index 00000000000..036c8b4fd13
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/outside-marker-with-float-in-content.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>A float in the list item's content does not move the outside marker</title>
+<link rel="help" href="https://drafts.csswg.org/css-lists-3/#list-style-position-property">
+<link rel="match" href="../../../../expected/wpt-import/css/css-lists/outside-marker-with-float-in-content-ref.html">
+<link rel="stylesheet" type="text/css" href="../../fonts/ahem.css">
+<style>
+ body { margin: 0; font: 20px/1 Ahem }
+ ul { margin: 0; padding-inline-start: 60px }
+ .float { float: left; width: 60px; height: 20px; background: green }
+</style>
+</head>
+<body>
+ <ul><li><div><div class="float"></div>xx</div></li></ul>
+</body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/outside-marker-with-relpos-block-content.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/outside-marker-with-relpos-block-content.html
new file mode 100644
index 00000000000..f0b6e6b6dcc
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/outside-marker-with-relpos-block-content.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS Lists: outside marker position with relatively positioned list and block content</title>
+<link rel="help" href="https://drafts.csswg.org/css-lists-3/#list-style-position-property">
+<link rel="author" title="Yulun Wu" href="mailto:[email protected]">
+<link rel="match" href="../../../../expected/wpt-import/css/css-lists/outside-marker-with-relpos-block-content-ref.html">
+<meta name="assert" content="Outside list markers must not overlap when the list and its block-level item content are relatively positioned.">
+<style>
+.list {
+ position: relative;
+ margin: 0;
+ padding-inline-start: 20px;
+ font: 16px/1.4 monospace;
+}
+
+.itemContent {
+ position: relative;
+ margin: 0;
+}
+</style>
+</head>
+<body>
+<ol class="list">
+ <li class="item"><p class="itemContent">Item A</p></li>
+ <li class="item"><p class="itemContent">Item B</p></li>
+ <li class="item"><p class="itemContent">Item C</p></li>
+</ol>
+</body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/outside-marker-with-text-indent.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/outside-marker-with-text-indent.html
new file mode 100644
index 00000000000..65330578982
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/outside-marker-with-text-indent.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>text-indent moves the line, not the outside list marker</title>
+<link rel="help" href="https://drafts.csswg.org/css-lists-3/#list-style-position-property">
+<link rel="help" href="https://drafts.csswg.org/css-text-3/#text-indent-property">
+<link rel="match" href="../../../../expected/wpt-import/css/css-lists/outside-marker-with-text-indent-ref.html">
+<link rel="stylesheet" type="text/css" href="../../fonts/ahem.css">
+<style>
+ body { margin: 0; font: 20px/1 Ahem }
+ ul { margin: 0; padding-inline-start: 60px }
+ div { text-indent: 60px }
+</style>
+</head>
+<body>
+ <ul><li><div>xx</div></li></ul>
+</body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/resources/white.gif b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/resources/white.gif
new file mode 100644
index 00000000000..3aa2098dc88
Binary files /dev/null and b/Tests/LibWeb/Ref/input/wpt-import/css/css-lists/resources/white.gif differ
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/marker-font-properties.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/marker-font-properties.html
new file mode 100644
index 00000000000..f5b78af5180
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/marker-font-properties.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS Test: ::marker formatting with font properties</title>
+<link rel="author" title="Daniel Bates" href="mailto:[email protected]">
+<link rel="match" href="../../../../expected/wpt-import/css/css-pseudo/marker-font-properties-ref.html">
+<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#marker-pseudo">
+<meta name="assert" content="Tests ::marker rendering with font properties">
+<style>
+ol {
+ line-height: 30px;
+}
+
+li {
+ list-style-type: lower-alpha;
+}
+
+li::marker, span {
+ font-family: sans-serif;
+ font-size: 24px;
+ font-style: italic;
+ font-variant: small-caps;
+ font-weight: bold;
+}
+</style>
+</head>
+<body>
+<ol>
+ <li><span><!-- FIXME: Needed to ensure consistent baseline position with expected result in Chromium and WebKit (why?). --></span></li>
+</ol>
+</body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/marker-inherit-line-height.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/marker-inherit-line-height.html
new file mode 100644
index 00000000000..d93adb4ad4a
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/marker-inherit-line-height.html
@@ -0,0 +1,30 @@
+<!doctype html>
+<title>Check that :marker inherits line-height</title>
+<link rel=help href="https://drafts.csswg.org/css-pseudo-4/#tree-abiding">
+<link rel=help href="https://drafts.csswg.org/css-pseudo-4/#marker-pseudo">
+<link rel=help href="https://drafts.csswg.org/css-display-3/#list-items">
+<link rel=help href="https://bugzilla.mozilla.org/show_bug.cgi?id=1415759">
+<link rel=match href=../../../../expected/wpt-import/css/css-pseudo/marker-inherit-line-height-ref.html>
+<link rel="stylesheet" type="text/css" href="../../fonts/ahem.css" />
+<style>
+div {
+ font: 128px/1 Ahem;
+ border: 2px solid blue;
+ background: orange;
+ color: black;
+}
+ol {
+ margin: 0;
+ padding: 0;
+ list-style-position: inside;
+ list-style-type: decimal;
+}
+</style>
+
+<p>There should be two black rectangles below with no space between them and
+ the border above/below.</p>
+<div>
+ <ol>
+ <li>X
+ </ol>
+</div>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/marker-intrinsic-contribution-002.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/marker-intrinsic-contribution-002.html
new file mode 100644
index 00000000000..528fcb72725
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/marker-intrinsic-contribution-002.html
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<meta charset="utf-8">
+<title>CSS Test: intrinsic contribution of ::marker</title>
+<link rel="author" title="Oriol Brufau" href="mailto:[email protected]">
+<link rel="match" href="../../../../expected/wpt-import/css/css-pseudo/marker-intrinsic-contribution-002-ref.html">
+<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#marker-pseudo">
+<link rel="help" href="https://drafts.csswg.org/css-sizing-3/#intrinsic">
+<meta name="assert" content="Checks that that the intrinsic contribution of a ::marker is updated when 'list-style-position' changes.">
+<style>
+li {
+ border: 5px solid;
+ float: left;
+ clear: left;
+}
+.inside {
+ list-style-position: inside;
+}
+.symbol {
+ list-style-type: disc;
+}
+.decimal {
+ list-style-type: decimal;
+}
+.string {
+ list-style-type: "string";
+}
+.content::marker {
+ content: "content";
+}
+</style>
+<ol>
+ <li class="symbol"></li>
+ <li class="decimal"></li>
+ <li class="string"></li>
+ <li class="content"></li>
+</ol>
+<ol class="inside">
+ <li class="symbol"></li>
+ <li class="decimal"></li>
+ <li class="string"></li>
+ <li class="content"></li>
+</ol>
+<script src="../../common/reftest-wait.js"></script>
+<script>
+"use strict";
+// Use a "load" event listener and requestAnimationFrame to ensure that
+// the markers will have been laid out.
+addEventListener("load", function() {
+ requestAnimationFrame(() => {
+ for (let list of document.querySelectorAll("ol")) {
+ list.classList.toggle("inside");
+ }
+ takeScreenshot();
+ });
+}, {once: true});
+</script>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/marker-line-height.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/marker-line-height.html
new file mode 100644
index 00000000000..e9de52ffe96
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-pseudo/marker-line-height.html
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>::marker supports 'line-height'</title>
+<link rel="author" title="Oriol Brufau" href="mailto:[email protected]" />
+<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#marker-pseudo">
+<link rel="help" href="https://drafts.csswg.org/css-inline/#propdef-line-height">
+<link rel="match" href="../../../../expected/wpt-import/css/css-pseudo/marker-line-height-ref.html">
+<meta name="assert" content="Checks that ::marker supports 'line-height', both explicitly set or inherited from an ancestor">
+<style>
+::marker { font-family: inherit; }
+ol {
+ float: left;
+ width: 50px;
+ list-style-position: inside;
+}
+ol, ol div {
+ line-height: 1;
+ font-size: 1rem;
+}
+.line-height.explicit ::marker,
+.line-height.inherit {
+ line-height: 3;
+}
+.line-height.inherit li {
+ font-size: 0; /* Remove the strut, which would defeat the test */
+}
+.line-height.inherit ::marker {
+ font-size: 1rem; /* Restore the font-size */
+}
+.marker-disc {
+ list-style-type: disc;
+}
+.marker-decimal {
+ list-style-type: decimal;
+}
+.marker-string {
+ list-style-type: "3. ";
+}
+.marker-content::marker {
+ content: "4. ";
+}
+</style>
+<ol class="line-height explicit">
+ <li class="marker-disc"></li>
+ <li class="marker-decimal"></li>
+ <li class="marker-string"></li>
+ <li class="marker-content"></li>
+</ol>
+<ol class="line-height inherit">
+ <li class="marker-disc"></li>
+ <li class="marker-decimal"></li>
+ <li class="marker-string"></li>
+ <li class="marker-content"></li>
+</ol>
+<ol class="line-height explicit">
+ <li class="marker-disc"><div>x</div></li>
+ <li class="marker-decimal"><div>x</div></li>
+ <li class="marker-string"><div>x</div></li>
+ <li class="marker-content"><div>x</div></li>
+</ol>
+<ol class="line-height inherit">
+ <li class="marker-disc"><div>x</div></li>
+ <li class="marker-decimal"><div>x</div></li>
+ <li class="marker-string"><div>x</div></li>
+ <li class="marker-content"><div>x</div></li>
+</ol>
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-lists/list-and-block-textarea-001.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-lists/list-and-block-textarea-001.txt
new file mode 100644
index 00000000000..263590a2484
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-lists/list-and-block-textarea-001.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass list and block textarea
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-lists/list-and-margin-collapse-001.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-lists/list-and-margin-collapse-001.txt
new file mode 100644
index 00000000000..f96635a8849
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-lists/list-and-margin-collapse-001.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass list and margin collapse
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-lists/list-and-margin-collapse-002.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-lists/list-and-margin-collapse-002.txt
new file mode 100644
index 00000000000..f96635a8849
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-lists/list-and-margin-collapse-002.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass list and margin collapse
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-lists/list-and-writing-mode-001.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-lists/list-and-writing-mode-001.txt
new file mode 100644
index 00000000000..79ae9345a5f
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-lists/list-and-writing-mode-001.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass list and writing-mode
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-pseudo/marker-intrinsic-contribution-001.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-pseudo/marker-intrinsic-contribution-001.txt
new file mode 100644
index 00000000000..74a22631897
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-pseudo/marker-intrinsic-contribution-001.txt
@@ -0,0 +1,13 @@
+Harness status: OK
+
+Found 8 tests
+
+8 Pass
+Pass Intrinsic contribution of outside symbol marker
+Pass Intrinsic contribution of outside decimal marker
+Pass Intrinsic contribution of outside string marker
+Pass Intrinsic contribution of outside content marker
+Pass Intrinsic contribution of inside symbol marker
+Pass Intrinsic contribution of inside decimal marker
+Pass Intrinsic contribution of inside string marker
+Pass Intrinsic contribution of inside content marker
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-lists/list-and-block-textarea-001.html b/Tests/LibWeb/Text/input/wpt-import/css/css-lists/list-and-block-textarea-001.html
new file mode 100644
index 00000000000..54af18f3c92
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-lists/list-and-block-textarea-001.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Lists: test list with textarea as its first child</title>
+<link rel=help href="https://www.w3.org/TR/CSS22/generate.html#lists">
+<!-- https://bugs.chromium.org/p/chromium/issues/detail?id=767408 -->
+
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+
+<style>
+
+ul, textarea {
+ font-size: 16px;
+}
+</style>
+
+<div id="log"></div>
+
+<ul>
+ <li id="target1">
+ <textarea id="target2" rows="3" cols="20" style="display:block; height:45px">
+ hello
+ </textarea>
+ </li>
+</ul>
+
+<script>
+test(function() {
+ var height1 = document.getElementById("target1").offsetHeight;
+ var height2 = document.getElementById("target2").offsetHeight;
+ assert_equals(height1, height2, "List marker and textarea should be in the same line, no line-break between them.")
+}, "list and block textarea");
+
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-lists/list-and-margin-collapse-001.html b/Tests/LibWeb/Text/input/wpt-import/css/css-lists/list-and-margin-collapse-001.html
new file mode 100644
index 00000000000..0bc8031c03b
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-lists/list-and-margin-collapse-001.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Lists: test the margin collapse of marker</title>
+<link rel=help href="https://www.w3.org/TR/CSS22/generate.html#lists">
+<!-- https://bugs.chromium.org/p/chromium/issues/detail?id=767408 -->
+
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+
+<div id="log"></div>
+
+<ul id="target" style="margin-top:100px;">
+ <li>
+ <div style="overflow:hidden; margin-top:100px; height:25px;"><a href="#">xxx</a></div>
+ </li>
+</ul>
+
+<script>
+test(function() {
+ var height = document.getElementById("target").clientHeight;
+ assert_equals(height, 25, "the height of ul should be 25px")
+}, "list and margin collapse");
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-lists/list-and-margin-collapse-002.html b/Tests/LibWeb/Text/input/wpt-import/css/css-lists/list-and-margin-collapse-002.html
new file mode 100644
index 00000000000..f1265643015
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-lists/list-and-margin-collapse-002.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Lists: test the margin collapse of marker</title>
+<link rel=help href="https://www.w3.org/TR/CSS22/generate.html#lists">
+<link rel="help" href="http://crbug.com/969741">
+
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+
+<div id="log"></div>
+
+<div id="target_with_marker" style="overflow:hidden; width:100px;">
+ <div style="margin-bottom:100px;"></div>
+ <div style="display:list-item; margin-left:100px; height:0px;"></div>
+ <div style="margin-top:100px;"></div>
+</div>
+
+<div id="target_without_marker" style="overflow:hidden; width:100px;">
+ <div style="margin-bottom:100px;"></div>
+ <div style="display:list-item; margin-left:100px; list-style:none;"></div>
+ <div style="margin-top:100px;"></div>
+</div>
+
+<script>
+test(function() {
+ var height_with_marker = document.getElementById("target_with_marker").clientHeight;
+ assert_equals(height_with_marker, 200, "Should not allow margin-collapsing through if list is with marker.");
+ var height_without_marker = document.getElementById("target_without_marker").clientHeight;
+ assert_equals(height_without_marker, 100, "Should allow margin-collapsing through if list is without marker.");
+}, "list and margin collapse");
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-lists/list-and-writing-mode-001.html b/Tests/LibWeb/Text/input/wpt-import/css/css-lists/list-and-writing-mode-001.html
new file mode 100644
index 00000000000..0d841bc8d0f
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-lists/list-and-writing-mode-001.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Lists: test list with root writing-mode as its first child</title>
+<link rel=help href="https://www.w3.org/TR/CSS22/generate.html#lists">
+<!-- https://bugs.chromium.org/p/chromium/issues/detail?id=767408 -->
+
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+
+<div id="log"></div>
+
+<ul>
+ <li id="target">
+ <div style="writing-mode: vertical-lr; height: 45px;">a b c</div>
+ </li>
+</ul>
+
+<script>
+test(function() {
+ var height = document.getElementById("target").offsetHeight;
+ assert_equals(height, 45, "the height of li should be 45px, and no extra line generated")
+}, "list and writing-mode");
+</script>
+
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-pseudo/marker-intrinsic-contribution-001.html b/Tests/LibWeb/Text/input/wpt-import/css/css-pseudo/marker-intrinsic-contribution-001.html
new file mode 100644
index 00000000000..0742da58f50
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-pseudo/marker-intrinsic-contribution-001.html
@@ -0,0 +1,70 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Test: intrinsic contribution of ::marker</title>
+<link rel="author" title="Oriol Brufau" href="mailto:[email protected]">
+<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#marker-pseudo">
+<link rel="help" href="https://drafts.csswg.org/css-sizing-3/#intrinsic">
+<meta name="assert" content="Checks that that outside markers have an intrinsic contribution of 0, and inside markers greater than 0.">
+<link rel="stylesheet" type="text/css" href="../../fonts/ahem.css" />
+<style>
+li {
+ font: 10px/1 Ahem;
+ border: 5px solid orange;
+ float: left;
+ clear: left;
+}
+.inside {
+ list-style-position: inside;
+}
+.symbol {
+ list-style-type: disc;
+}
+.decimal {
+ list-style-type: decimal;
+}
+.string {
+ list-style-type: "string";
+}
+.content::marker {
+ content: "content";
+}
+</style>
+<div id="log"></div>
+<ol class="outside">
+ <li class="symbol" data-width="0"></li>
+ <li class="decimal" data-width="0"></li>
+ <li class="string" data-width="0"></li>
+ <li class="content" data-width="0"></li>
+</ol>
+<ol class="inside">
+ <li class="symbol" data-min-width="0"></li>
+ <li class="decimal" data-width="30"></li>
+ <li class="string" data-width="60"></li>
+ <li class="content" data-width="70"></li>
+</ol>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+"use strict";
+function check(item, msg) {
+ test(function() {
+ if (item.dataset.width) {
+ assert_equals(item.clientWidth, +item.dataset.width, "clientWidth");
+ } else {
+ assert_greater_than(item.clientWidth, +item.dataset.minWidth, "clientWidth");
+ }
+ }, msg);
+}
+
+setup({ explicit_done: true });
+
+document.fonts.ready.then(() => {
+ for (let item of document.querySelectorAll(".outside > li")) {
+ check(item, `Intrinsic contribution of outside ${item.className} marker`);
+ }
+ for (let item of document.querySelectorAll(".inside > li")) {
+ check(item, `Intrinsic contribution of inside ${item.className} marker`);
+ }
+ done();
+});
+</script>