Skip to content

Truly independent web browser

LibWeb: Keep inline box edges of collapsed whitespace

Andreas Klingcfc8bb44f4ad
diff --git a/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs
index 915f7ba1fe4..7e4d28260f5 100644
--- a/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs
@@ -1641,6 +1641,8 @@ impl<'context> InlineFormattingContext<'context> {
max_content_lines.append(self, items, prepared, index);
min_content_lines.append(self, items, prepared, index);
}
+ max_content_lines.append_pending_start_edges();
+ min_content_lines.append_pending_start_edges();
let (max_content_inline_size, first_line_max_content) =
max_content_lines.lines.finish_measurement_and_first_line();
let min_content_inline_size = min_content_lines.lines.finish_measurement();
@@ -2029,6 +2031,7 @@ impl<'context> InlineFormattingContext<'context> {
let mut leading_border = CssPixels::default();
let mut leading_padding = CssPixels::default();
let mut leading_right_to_left_end_margin = CssPixels::default();
+ let mut collapsed_whitespace_node = NodeSlotId::INVALID;
let mut absolute_boxes = Vec::new();
let mut previous_text_item_allows_overflow_break_after = false;
let mut whitespace_measured_next_run = false;
@@ -2082,6 +2085,28 @@ impl<'context> InlineFormattingContext<'context> {
.last()
.is_none_or(|line| line.is_empty_or_ends_in_whitespace() || line.has_block_level_box);
if item.is_collapsible_whitespace && line_starts_with_whitespace {
+ // NB: The whitespace disappears, but the inline boxes that end with it still end on this line.
+ collapsed_whitespace_node = item.node;
+ leading_margin += item.margin_start;
+ leading_border += item.border_start;
+ leading_padding += item.padding_start;
+ leading_right_to_left_end_margin += item.entered_right_to_left_end_margin;
+ let zero = CssPixels::default();
+ if item.margin_end != zero || item.border_end != zero || item.padding_end != zero {
+ // NB: A box that ends here started on this line, so its start edges come before its end edges.
+ line_builder.append_start_edges_of_collapsed_whitespace(
+ item.node,
+ std::mem::take(&mut leading_margin),
+ std::mem::take(&mut leading_border),
+ std::mem::take(&mut leading_padding),
+ );
+ line_builder.append_end_edges_of_collapsed_whitespace(
+ item.node,
+ item.margin_end,
+ item.border_end,
+ item.padding_end,
+ );
+ }
if self.style(self.style_source(item.node)).text_wrap_mode() == text_wrap_mode::WRAP {
let next_inline_size = iterator.next_inline_run_size(self).unwrap_or_default();
if next_inline_size > CssPixels::default() {
@@ -2089,21 +2114,20 @@ impl<'context> InlineFormattingContext<'context> {
line_builder.break_if_needed(next_inline_size);
}
}
- leading_margin += item.margin_start;
- leading_border += item.border_start;
- leading_padding += item.padding_start;
- leading_right_to_left_end_margin += item.entered_right_to_left_end_margin;
continue;
}
- item.margin_start += leading_margin;
- item.border_start += leading_border;
- item.padding_start += leading_padding;
- item.entered_right_to_left_end_margin += leading_right_to_left_end_margin;
- leading_margin = CssPixels::default();
- leading_border = CssPixels::default();
- leading_padding = CssPixels::default();
- leading_right_to_left_end_margin = CssPixels::default();
+ // NB: A float is not on the line, so the leading edges wait for the next item that is.
+ if item.type_ != inline_level_iterator::ItemType::FloatingElement {
+ item.margin_start += leading_margin;
+ item.border_start += leading_border;
+ item.padding_start += leading_padding;
+ item.entered_right_to_left_end_margin += leading_right_to_left_end_margin;
+ leading_margin = CssPixels::default();
+ leading_border = CssPixels::default();
+ leading_padding = CssPixels::default();
+ leading_right_to_left_end_margin = CssPixels::default();
+ }
match item.type_ {
inline_level_iterator::ItemType::InlineEdge => {
@@ -2113,6 +2137,12 @@ impl<'context> InlineFormattingContext<'context> {
line_builder.append_inline_edge(&item);
}
inline_level_iterator::ItemType::ForcedBreak => {
+ line_builder.append_start_edges_of_collapsed_whitespace(
+ collapsed_whitespace_node,
+ item.margin_start,
+ item.border_start,
+ item.padding_start,
+ );
self.current_line_start.set(fragmentation::LinePosition {
item_index: item_index + 1,
offset_in_node: 0,
@@ -2197,6 +2227,12 @@ impl<'context> InlineFormattingContext<'context> {
|| item.margin_start != CssPixels::default()
|| item.border_start != CssPixels::default()
|| item.padding_start != CssPixels::default();
+ line_builder.append_start_edges_of_collapsed_whitespace(
+ collapsed_whitespace_node,
+ item.margin_start,
+ item.border_start,
+ item.padding_start,
+ );
line_builder.append_static_position_marker(item.node, preceded);
absolute_boxes.push(item.node);
}
@@ -2336,6 +2372,15 @@ impl<'context> InlineFormattingContext<'context> {
}
}
}
+ if iterator.items().is_empty() {
+ line_builder.append_start_edges_of_collapsed_whitespace(
+ collapsed_whitespace_node,
+ leading_margin,
+ leading_border,
+ leading_padding,
+ );
+ line_builder.keep_line_of_collapsed_whitespace_edges();
+ }
BrokenLines {
absolute_boxes,
state_at_clamp_point,
@@ -3177,6 +3222,7 @@ pub(super) struct LinesWithoutLineBoxes {
first_line: Option<FirstLineMaxContent>,
inline_size: CssPixels,
has_fragments: bool,
+ has_edges_of_collapsed_whitespace: bool,
ends_in_whitespace: bool,
trailing_whitespace_wraps: bool,
trailing_whitespace_inline_size: CssPixels,
@@ -3253,6 +3299,13 @@ impl LinesWithoutLineBoxes {
}
}
+ fn append_edges_of_collapsed_whitespace(&mut self, margin: CssPixels, border: CssPixels, padding: CssPixels) {
+ self.inline_size += margin + border + padding;
+ self.has_edges_of_collapsed_whitespace |= [margin, border, padding]
+ .iter()
+ .any(|edge| *edge != CssPixels::default());
+ }
+
fn note_line(&mut self, inline_size: CssPixels) {
let floats_beside_line = std::mem::take(&mut self.floats_beside_line);
self.greatest_inline_size = self
@@ -3262,12 +3315,16 @@ impl LinesWithoutLineBoxes {
.get_or_insert(floats_beside_line.beside_first_line(inline_size.max(CssPixels::default())));
self.inline_size = CssPixels::default();
self.has_fragments = false;
+ self.has_edges_of_collapsed_whitespace = false;
self.ends_in_whitespace = false;
self.trailing_whitespace_inline_size = CssPixels::default();
}
fn finish(&mut self) {
- if self.has_fragments || !self.floats_beside_line.is_empty() {
+ if self.has_edges_of_collapsed_whitespace {
+ self.start_line_if_empty();
+ }
+ if self.has_fragments || self.has_edges_of_collapsed_whitespace || !self.floats_beside_line.is_empty() {
self.note_line(self.inline_size - self.trailing_whitespace_inline_size);
self.follows_forced_break = false;
}
@@ -3338,6 +3395,8 @@ impl ContentSizingLines {
std::mem::take(&mut self.previous_text_item_breaks_between_graphemes);
let line_is_empty_or_ends_in_whitespace = self.lines.is_empty_or_ends_in_whitespace();
if item.is_collapsible_whitespace && line_is_empty_or_ends_in_whitespace {
+ self.lines
+ .append_edges_of_collapsed_whitespace(item.margin_end, item.border_end, item.padding_end);
if self.lines.breaks_before_next_fragment()
&& matches!(
context.text_item_wrap_opportunity(
@@ -3384,7 +3443,11 @@ impl ContentSizingLines {
item.margin_end,
);
match item.type_ {
- inline_level_iterator::ItemType::ForcedBreak => self.lines.force_break(),
+ inline_level_iterator::ItemType::ForcedBreak => {
+ self.lines
+ .append_edges_of_collapsed_whitespace(margin_start, border_start, padding_start);
+ self.lines.force_break();
+ }
inline_level_iterator::ItemType::InlineEdge => {
self.lines.append(border_box_inline_size, false, CssPixels::default());
}
@@ -3392,8 +3455,11 @@ impl ContentSizingLines {
self.lines
.append_atomic_inline(border_box_inline_size, self.container_wraps);
}
- // An absolutely positioned box only takes a static position, which the pending inline edges attach to.
- inline_level_iterator::ItemType::AbsolutelyPositionedElement => {}
+ // An absolutely positioned box only takes a static position, which comes after the pending inline edges.
+ inline_level_iterator::ItemType::AbsolutelyPositionedElement => {
+ self.lines
+ .append_edges_of_collapsed_whitespace(margin_start, border_start, padding_start);
+ }
inline_level_iterator::ItemType::BlockLevelBox | inline_level_iterator::ItemType::FloatingElement => {
unreachable!(
"content sizing places floats beside lines and sizes block-level boxes as lines of their own"
@@ -3479,6 +3545,14 @@ impl ContentSizingLines {
}
}
+ fn append_pending_start_edges(&mut self) {
+ self.lines.append_edges_of_collapsed_whitespace(
+ std::mem::take(&mut self.pending_start_margin),
+ std::mem::take(&mut self.pending_start_border),
+ std::mem::take(&mut self.pending_start_padding),
+ );
+ }
+
fn append_float(&mut self, context: &InlineFormattingContext<'_>, item: &inline_level_iterator::Item) {
let margin_box_inline_size = |content_inline_size| {
line_box::inline_advance(
diff --git a/Libraries/LibWeb/Rust/src/layout/line_box.rs b/Libraries/LibWeb/Rust/src/layout/line_box.rs
index 4e1c85a3625..494555618f5 100644
--- a/Libraries/LibWeb/Rust/src/layout/line_box.rs
+++ b/Libraries/LibWeb/Rust/src/layout/line_box.rs
@@ -191,6 +191,10 @@ impl LineBoxData {
.max(content_block_size + border_box_block_start + border_box_block_end);
}
+ pub(crate) fn advance_inline_length(&mut self, inline_size: CssPixels) {
+ self.record.inline_length += inline_size;
+ }
+
pub(crate) fn add_static_position_marker(&mut self, box_: Node, preceded_by_inline_box_start_edges: bool) {
self.static_position_markers.push(StaticPositionMarker {
box_,
diff --git a/Libraries/LibWeb/Rust/src/layout/line_builder.rs b/Libraries/LibWeb/Rust/src/layout/line_builder.rs
index 687f5bf2cdd..a1630ab7401 100644
--- a/Libraries/LibWeb/Rust/src/layout/line_builder.rs
+++ b/Libraries/LibWeb/Rust/src/layout/line_builder.rs
@@ -72,6 +72,7 @@ pub(crate) struct LineBuilder<'builder, 'context> {
only_finds_line_breaks: bool,
current_block_offset: CssPixels,
max_block_size_on_current_line: CssPixels,
+ nodes_with_edges_of_collapsed_whitespace: Vec<(Node, 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,
@@ -140,6 +141,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(),
+ nodes_with_edges_of_collapsed_whitespace: Vec::new(),
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),
@@ -297,6 +299,7 @@ impl<'builder, 'context> LineBuilder<'builder, 'context> {
) {
// FIXME: Respect inline direction.
+ self.keep_line_of_collapsed_whitespace_edges();
let line_index = self.ensure_last_line_index();
{
let mut line = self.line_mut(line_index);
@@ -469,18 +472,35 @@ impl<'builder, 'context> LineBuilder<'builder, 'context> {
}
pub(crate) fn append_inline_edge(&mut self, item: &inline_level_iterator::Item) {
+ self.append_empty_fragment(
+ item.node,
+ item.border_start + item.padding_start,
+ item.border_end + item.padding_end,
+ item.margin_start,
+ item.margin_end,
+ );
+ }
+
+ fn append_empty_fragment(
+ &mut self,
+ node: Node,
+ leading_size: CssPixels,
+ trailing_size: CssPixels,
+ leading_margin: CssPixels,
+ trailing_margin: CssPixels,
+ ) {
self.prepare_to_append_inline_content();
let line_index = self.ensure_last_line_index();
- let facts = self.fragment_facts(item.node);
+ let facts = self.fragment_facts(node);
let block_size = TextLayoutBounds::new(self.style(facts.style_source), None).block_size();
self.line_mut(line_index).add_fragment(
- item.node,
+ node,
0,
0,
- item.border_start + item.padding_start,
- item.border_end + item.padding_end,
- item.margin_start,
- item.margin_end,
+ leading_size,
+ trailing_size,
+ leading_margin,
+ trailing_margin,
CssPixels::default(),
block_size,
CssPixels::default(),
@@ -493,6 +513,74 @@ impl<'builder, 'context> LineBuilder<'builder, 'context> {
self.max_block_size_on_current_line = self.max_block_size_on_current_line.max(block_size);
}
+ /// Collapsed whitespace adds no fragment, so that whitespace after it keeps collapsing too.
+ fn append_edges_of_collapsed_whitespace(
+ &mut self,
+ margin: CssPixels,
+ border: CssPixels,
+ padding: CssPixels,
+ ) -> bool {
+ let none = CssPixels::default();
+ if margin == none && border == none && padding == none {
+ return false;
+ }
+ self.prepare_to_append_inline_content();
+ let line_index = self.ensure_last_line_index();
+ self.line_mut(line_index)
+ .advance_inline_length(margin + border + padding);
+ true
+ }
+
+ pub(crate) fn append_start_edges_of_collapsed_whitespace(
+ &mut self,
+ node: Node,
+ margin: CssPixels,
+ border: CssPixels,
+ padding: CssPixels,
+ ) {
+ if self.append_edges_of_collapsed_whitespace(margin, border, padding) {
+ let inline_offset = self.line(self.line_count() - 1).inline_length;
+ self.note_edges_of_collapsed_whitespace(node, inline_offset);
+ }
+ }
+
+ fn note_edges_of_collapsed_whitespace(&mut self, node: Node, inline_offset: CssPixels) {
+ match self.nodes_with_edges_of_collapsed_whitespace.last_mut() {
+ Some(last) if last.0 == node => last.1 = inline_offset,
+ _ => self
+ .nodes_with_edges_of_collapsed_whitespace
+ .push((node, inline_offset)),
+ }
+ }
+
+ pub(crate) fn append_end_edges_of_collapsed_whitespace(
+ &mut self,
+ node: Node,
+ margin: CssPixels,
+ border: CssPixels,
+ padding: CssPixels,
+ ) {
+ if self.append_edges_of_collapsed_whitespace(margin, border, padding) {
+ let inline_offset = self.line(self.line_count() - 1).inline_length - (margin + border + padding);
+ self.note_edges_of_collapsed_whitespace(node, inline_offset);
+ }
+ }
+
+ /// Nonzero inline-axis edges keep a line box even when it contains no text.
+ /// https://drafts.csswg.org/css-inline-3/#invisible-line-boxes
+ pub(crate) fn keep_line_of_collapsed_whitespace_edges(&mut self) {
+ let nodes = std::mem::take(&mut self.nodes_with_edges_of_collapsed_whitespace);
+ if nodes.is_empty() || !self.current_line_is_empty() {
+ return;
+ }
+ let none = CssPixels::default();
+ for (node, inline_offset) in nodes {
+ // NB: The line has already advanced past these edges, so each fragment goes back to where its node was.
+ let distance = self.line(self.line_count() - 1).inline_length - inline_offset;
+ self.append_empty_fragment(node, none, none, none - distance, distance);
+ }
+ }
+
pub(crate) fn append_text_item(
&mut self,
item: &mut inline_level_iterator::Item,
@@ -602,6 +690,7 @@ impl<'builder, 'context> LineBuilder<'builder, 'context> {
}
pub(crate) fn finish_current_line_before_block_level_box(&mut self) {
+ self.keep_line_of_collapsed_whitespace_edges();
if self.line_count() == 0 || self.line(self.line_count() - 1).is_empty() {
return;
}
diff --git a/Tests/LibWeb/Layout/expected/block-and-inline/inline-box-end-edges-on-collapsed-whitespace.txt b/Tests/LibWeb/Layout/expected/block-and-inline/inline-box-end-edges-on-collapsed-whitespace.txt
index 3a42abd34ca..20a9c78223d 100644
--- a/Tests/LibWeb/Layout/expected/block-and-inline/inline-box-end-edges-on-collapsed-whitespace.txt
+++ b/Tests/LibWeb/Layout/expected/block-and-inline/inline-box-end-edges-on-collapsed-whitespace.txt
@@ -1,8 +1,8 @@
Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
- BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 216 0+0+0] [BFC] children: not-inline
- BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 200 0+0+8] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 456 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 440 0+0+8] children: not-inline
BlockContainer <div> at [8,8] [0+0+0 784 0+0+0] [0+0+0 20 0+0+0] children: inline
- frag 0 from TextNode start: 0, length: 1, rect: [29.6875,8 14.453125x20] baseline: 16
+ frag 0 from TextNode start: 0, length: 1, rect: [49.6875,8 14.453125x20] baseline: 16
"X"
InlineNode <span.margin> at [8,8] [0+0+0 21.6875 0+0+20] [0+0+0 20 0+0+0]
InlineNode <b> at [8,8] [0+0+0 21.6875 0+0+0] [0+0+0 20 0+0+0]
@@ -12,7 +12,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children
TextNode <#text> (not painted)
TextNode <#text> (not painted)
BlockContainer <div> at [8,28] [0+0+0 784 0+0+0] [0+0+0 20 0+0+0] children: inline
- frag 0 from TextNode start: 0, length: 1, rect: [29.6875,28 14.453125x20] baseline: 16
+ frag 0 from TextNode start: 0, length: 1, rect: [49.6875,28 14.453125x20] baseline: 16
"X"
InlineNode <span.padding> at [8,28] [0+0+0 21.6875 20+0+0] [0+0+0 20 0+0+0]
InlineNode <b> at [8,28] [0+0+0 21.6875 0+0+0] [0+0+0 20 0+0+0]
@@ -22,7 +22,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children
TextNode <#text> (not painted)
TextNode <#text> (not painted)
BlockContainer <div> at [8,48] [0+0+0 784 0+0+0] [0+0+0 20 0+0+0] children: inline
- frag 0 from TextNode start: 0, length: 1, rect: [29.6875,48 14.453125x20] baseline: 16
+ frag 0 from TextNode start: 0, length: 1, rect: [49.6875,48 14.453125x20] baseline: 16
"X"
InlineNode <span.border> at [8,48] [0+0+0 21.6875 0+20+0] [0+0+0 20 0+0+0]
InlineNode <b> at [8,48] [0+0+0 21.6875 0+0+0] [0+0+0 20 0+0+0]
@@ -32,13 +32,13 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children
TextNode <#text> (not painted)
TextNode <#text> (not painted)
BlockContainer <div> at [8,68] [0+0+0 784 0+0+0] [0+0+0 20 0+0+0] children: inline
- frag 0 from TextNode start: 0, length: 1, rect: [8,68 14.453125x20] baseline: 16
+ frag 0 from TextNode start: 0, length: 1, rect: [28,68 14.453125x20] baseline: 16
"X"
InlineNode <span.margin> at [8,68] [0+0+0 0 0+0+20] [0+0+0 20 0+0+0]
TextNode <#text> (not painted)
TextNode <#text> (not painted)
BlockContainer <div> at [8,88] [0+0+0 784 0+0+0] [0+0+0 20 0+0+0] children: inline
- frag 0 from TextNode start: 0, length: 1, rect: [8,88 14.453125x20] baseline: 16
+ frag 0 from TextNode start: 0, length: 1, rect: [48,88 14.453125x20] baseline: 16
"X"
InlineNode <span.margin> at [8,88] [0+0+0 0 0+0+20] [0+0+0 20 0+0+0]
InlineNode <span.margin> at [8,88] [0+0+0 0 0+0+20] [0+0+0 20 0+0+0]
@@ -61,14 +61,14 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children
TextNode <#text> (not painted)
TextNode <#text> (not painted)
TextNode <#text> (not painted)
- InlineNode <span.negative> at [9.6875,128] [-20+0+0 14.453125 0+0+0] [0+0+0 20 0+0+0]
- frag 0 from TextNode start: 0, length: 1, rect: [9.6875,128 14.453125x20] baseline: 16
+ InlineNode <span.negative> at [29.6875,128] [-20+0+0 14.453125 0+0+0] [0+0+0 20 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [29.6875,128 14.453125x20] baseline: 16
"X"
TextNode <#text> (not painted)
BlockContainer <(anonymous)> at [8,148] [0+0+0 784 0+0+0] [0+0+0 20 0+0+0] children: inline
- frag 0 from BlockContainer start: 0, length: 0, rect: [8,148 36.140625x20] baseline: 16
- BlockContainer <div.shrink-to-fit> at [8,148] inline-block [0+0+0 36.140625 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
- frag 0 from TextNode start: 0, length: 1, rect: [29.6875,148 14.453125x20] baseline: 16
+ frag 0 from BlockContainer start: 0, length: 0, rect: [8,148 56.140625x20] baseline: 16
+ BlockContainer <div.shrink-to-fit> at [8,148] inline-block [0+0+0 56.140625 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [49.6875,148 14.453125x20] baseline: 16
"X"
InlineNode <span.margin> at [8,148] [0+0+0 21.6875 0+0+20] [0+0+0 20 0+0+0]
InlineNode <b> at [8,148] [0+0+0 21.6875 0+0+0] [0+0+0 20 0+0+0]
@@ -78,16 +78,119 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children
TextNode <#text> (not painted)
TextNode <#text> (not painted)
TextNode <#text> (not painted)
- BlockContainer <div.narrow> at [8,168] [0+0+0 60 0+0+724] [0+0+0 40 0+0+0] children: inline
- frag 0 from TextNode start: 0, length: 4, rect: [8,188 57.8125x20] baseline: 16
+ BlockContainer <div> at [8,168] [0+0+0 784 0+0+0] [0+0+0 20 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [28,168 14.453125x20] baseline: 16
+ "X"
+ InlineNode <span.padding> at [8,168] [0+0+0 0 20+0+0] [0+0+0 20 0+0+0]
+ TextNode <#text> (not painted)
+ BlockContainer <span> at [28,168] positioned [0+0+0 13.875 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [28,168 13.875x20] baseline: 16
+ "Y"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,188] [0+0+0 784 0+0+0] [0+0+0 20 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [28,188 14.453125x20] baseline: 16
+ "X"
+ InlineNode <span.padding> at [8,188] [0+0+0 0 20+0+0] [0+0+0 20 0+0+0]
+ TextNode <#text> (not painted)
+ BlockContainer <span> at [778.125,188] floating [0+0+0 13.875 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [778.125,188 13.875x20] baseline: 16
+ "Y"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,208] [0+0+0 784 0+0+0] [0+0+0 20 0+0+0] children: inline
+ InlineNode <span.padding> at [8,208] [0+0+0 0 20+0+0] [0+0+0 20 0+0+0]
+ frag 0 from TextNode start: 0, length: 0, rect: [8,208 0x20] baseline: 16
+ TextNode <#text> (not painted)
+ BlockContainer <span> at [28,208] positioned [0+0+0 13.875 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [28,208 13.875x20] baseline: 16
+ "Y"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,228] [0+0+0 784 0+0+0] [0+0+0 20 0+0+0] children: inline
+ InlineNode <span> at [28,228] [0+0+20 0 0+0+0] [0+0+0 20 0+0+0]
+ frag 0 from TextNode start: 0, length: 0, rect: [28,228 0x20] baseline: 16
+ TextNode <#text> (not painted)
+ BlockContainer <span> at [778.125,228] floating [0+0+0 13.875 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [778.125,228 13.875x20] baseline: 16
+ "Y"
+ TextNode <#text> (not painted)
+ BlockContainer <(anonymous)> at [8,248] [0+0+0 784 0+0+0] [0+0+0 40 0+0+0] children: inline
+ frag 0 from BlockContainer start: 0, length: 0, rect: [8,248 20x20] baseline: 16
+ frag 1 from BlockContainer start: 0, length: 0, rect: [8,268 33.875x20] baseline: 16
+ BlockContainer <div.shrink-to-fit> at [8,248] inline-block [0+0+0 20 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ InlineNode <span.padding> at [8,248] [0+0+0 0 20+0+0] [0+0+0 20 0+0+0]
+ frag 0 from TextNode start: 0, length: 0, rect: [8,248 0x20] baseline: 16
+ TextNode <#text> (not painted)
+ BlockContainer <span> at [28,248] positioned [0+0+0 13.875 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [28,248 13.875x20] baseline: 16
+ "Y"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BreakNode <br> (not painted)
+ BlockContainer <div.shrink-to-fit> at [8,268] inline-block [0+0+0 33.875 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ InlineNode <span> at [28,268] [0+0+20 0 0+0+0] [0+0+0 20 0+0+0]
+ frag 0 from TextNode start: 0, length: 0, rect: [28,268 0x20] baseline: 16
+ TextNode <#text> (not painted)
+ BlockContainer <span> at [28,268] floating [0+0+0 13.875 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [28,268 13.875x20] baseline: 16
+ "Y"
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,288] [0+0+0 784 0+0+0] [0+0+0 40 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,308 14.453125x20] baseline: 16
+ "X"
+ InlineNode <span> at [28,288] [0+0+20 0 0+0+0] [0+0+0 20 0+0+0]
+ frag 0 from TextNode start: 0, length: 0, rect: [28,288 0x20] baseline: 16
+ TextNode <#text> (not painted)
+ BlockContainer <span> at [778.125,288] floating [0+0+0 13.875 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [778.125,288 13.875x20] baseline: 16
+ "Y"
+ TextNode <#text> (not painted)
+ BreakNode <br> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,328] [0+0+0 784 0+0+0] [0+0+0 20 0+0+0] children: inline
+ InlineNode <span.padding> at [8,328] [0+0+0 0 20+0+-20] [0+0+0 20 0+0+0]
+ frag 0 from TextNode start: 0, length: 0, rect: [8,328 0x20] baseline: 16
+ TextNode <#text> (not painted)
+ BlockContainer <span> at [8,328] positioned [0+0+0 13.875 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [8,328 13.875x20] baseline: 16
+ "Y"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,348] [0+0+0 784 0+0+0] [0+0+0 20 0+0+0] children: inline
+ InlineNode <span.padding> at [28,348] [0+0+20 0 20+0+0] [0+0+0 20 0+0+0]
+ frag 0 from TextNode start: 0, length: 0, rect: [28,348 0x20] baseline: 16
+ TextNode <#text> (not painted)
+ BlockContainer <span> at [48,348] positioned [0+0+0 13.875 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [48,348 13.875x20] baseline: 16
+ "Y"
+ TextNode <#text> (not painted)
+ BlockContainer <div> at [8,368] [0+0+0 784 0+0+0] [0+0+0 20 0+0+0] children: inline
+ InlineNode <span.padding> at [8,368] [0+0+0 0 20+0+0] [0+0+0 20 0+0+0]
+ frag 0 from TextNode start: 0, length: 0, rect: [8,368 0x20] baseline: 16
+ TextNode <#text> (not painted)
+ InlineNode <span.padding> at [28,368] [0+0+0 0 20+0+0] [0+0+0 20 0+0+0]
+ frag 0 from TextNode start: 0, length: 0, rect: [28,368 0x20] baseline: 16
+ TextNode <#text> (not painted)
+ BlockContainer <span> at [48,368] positioned [0+0+0 13.875 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 1, rect: [48,368 13.875x20] baseline: 16
+ "Y"
+ TextNode <#text> (not painted)
+ BlockContainer <div.narrow> at [8,388] [0+0+0 60 0+0+724] [0+0+0 20 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [28,388 57.8125x20] baseline: 16
+ "XXXX"
+ InlineNode <span.padding> at [8,388] [0+0+0 0 20+0+0] [0+0+0 20 0+0+0]
+ TextNode <#text> (not painted)
+ TextNode <#text> (not painted)
+ BlockContainer <div.narrow> at [8,408] [0+0+0 60 0+0+724] [0+0+0 40 0+0+0] children: inline
+ frag 0 from TextNode start: 0, length: 4, rect: [8,428 57.8125x20] baseline: 16
"XXXX"
- InlineNode <span.margin> at [8,168] [0+0+0 11.6875 0+0+20] [0+0+0 20 0+0+0]
- InlineNode <b> at [8,168] [0+0+0 11.6875 0+0+0] [0+0+0 20 0+0+0]
- frag 0 from TextNode start: 0, length: 1, rect: [8,168 11.6875x20] baseline: 16
+ InlineNode <span.margin> at [8,408] [0+0+0 11.6875 0+0+20] [0+0+0 20 0+0+0]
+ InlineNode <b> at [8,408] [0+0+0 11.6875 0+0+0] [0+0+0 20 0+0+0]
+ frag 0 from TextNode start: 0, length: 1, rect: [8,408 11.6875x20] baseline: 16
"a"
TextNode <#text> (not painted)
TextNode <#text> (not painted)
TextNode <#text> (not painted)
SC for Viewport<#document> [0,0 800x600] (z-index: auto)
- SC for BlockContainer<HTML> [0,0 800x216] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x456] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/input/block-and-inline/inline-box-end-edges-on-collapsed-whitespace.html b/Tests/LibWeb/Layout/input/block-and-inline/inline-box-end-edges-on-collapsed-whitespace.html
index 527fd0d89e7..eed6c60b81f 100644
--- a/Tests/LibWeb/Layout/input/block-and-inline/inline-box-end-edges-on-collapsed-whitespace.html
+++ b/Tests/LibWeb/Layout/input/block-and-inline/inline-box-end-edges-on-collapsed-whitespace.html
@@ -30,4 +30,16 @@
<div>a <span class="margin"></span> X</div>
<div><span class="margin"><b>a </b> </span> <span class="negative">X</span></div>
<div class="shrink-to-fit"><span class="margin"><b>a </b> </span>X</div>
+<div><span class="padding"> </span><span style="position: absolute">Y</span>X</div>
+<div><span class="padding"> </span><span style="float: right">Y</span>X</div>
+<div><span class="padding"> </span><span style="position: absolute">Y</span></div>
+<div><span style="padding-left: 20px"> </span><span style="float: right">Y</span></div>
+<div class="shrink-to-fit"><span class="padding"> </span><span style="position: absolute">Y</span></div>
+<br>
+<div class="shrink-to-fit"><span style="padding-left: 20px"> </span><span style="float: right">Y</span></div>
+<div><span style="padding-left: 20px"> </span><span style="float: right">Y</span><br>X</div>
+<div><span class="padding" style="margin-right: -20px"> </span><span style="position: absolute">Y</span></div>
+<div><span class="padding" style="padding-left: 20px"> </span><span style="position: absolute">Y</span></div>
+<div><span class="padding"> </span><span class="padding"> </span><span style="position: absolute">Y</span></div>
+<div class="narrow"><span class="padding"> </span>XXXX</div>
<div class="narrow"><span class="margin"><b>a </b> </span>XXXX</div>
diff --git a/Tests/LibWeb/Text/expected/intrinsic-inline-content-sizing.txt b/Tests/LibWeb/Text/expected/intrinsic-inline-content-sizing.txt
index ab471dcec2a..6e6a767c300 100644
--- a/Tests/LibWeb/Text/expected/intrinsic-inline-content-sizing.txt
+++ b/Tests/LibWeb/Text/expected/intrinsic-inline-content-sizing.txt
@@ -1,9 +1,9 @@
words: 160x20, 50x60, 160x20, 120x40
collapsed whitespace: 100x20, 50x40, 100x20, 100x20
inline edges: 178x20, 59x60, 178x20, 120x40
-adjacent inline edges: 111x20, 61x40, 111x20, 111x20
+adjacent inline edges: 114x20, 64x40, 114x20, 114x20
inline edges before break: 50x40, 50x40, 50x40, 50x40
-inline edges before absolute: 50x20, 50x20, 50x20, 50x20
+inline edges before absolute: 56x20, 56x20, 56x20, 56x20
nowrap: 160x20, 160x20, 160x20, 160x20
pre: 135x40, 135x40, 135x40, 135x40
pre-wrap: 140x40, 50x100, 140x40, 120x60