Truly independent web browser
LibWeb: Count empty inline boxes in occupied line heights
sideshowbarker88bca8453282
diff --git a/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rsindex 9dfba3482df..472a08f5185 100644--- a/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs@@ -407,6 +407,11 @@ pub(crate) fn apply_to_fragments(marker.inline_offset += diff;}}+ for strut in &mut line.inline_box_struts {+ if strut.inline_offset > fragment.inline_offset {+ strut.inline_offset += diff;+ }+ }fragment.inline_length = justified_space_inline_size;}}@@ -439,6 +444,8 @@ struct PerLine {interrupting_block: Option<((CssPixels, CssPixels), CandidateLineCorners)>,first_fragment_index: Option<u32>,fragment_count: u32,+ /// Whether the inline box is on the line by its strut alone, with no fragment of its content there.+ is_strut: bool,}impl PerLine {@@ -451,6 +458,7 @@ impl PerLine {interrupting_block: None,first_fragment_index: None,fragment_count: 0,+ is_strut: false,}}}@@ -636,6 +644,32 @@ pub(crate) fn compute(ancestor = context.nearest_fragmented_inline_ancestor(ancestor);}}+ if !line.takes_inline_box_struts() {+ continue;+ }+ // An inline box that's on the line by its strut alone gets a piece there too, as wide as nothing.+ for strut in &line.inline_box_struts {+ let node_index = *node_to_index.entry(strut.box_).or_insert_with(|| {+ per_nodes.push(PerNode {+ node: strut.box_,+ parent_index: None,+ depth: nesting_depth(context, strut.box_),+ lines: Vec::new(),+ first_line_with_content: None,+ last_line_with_content: None,+ });+ per_nodes.len() - 1+ });+ let per_node = &mut per_nodes[node_index];+ let per_line = ensure_line(per_node, line_index);+ if per_line.first_fragment_index.is_some() {+ continue;+ }+ per_line.is_strut = true;+ note_contribution(per_line, strut.inline_offset, strut.inline_offset);+ per_node.first_line_with_content.get_or_insert(line_index);+ per_node.last_line_with_content = Some(line_index);+ }}let without_fragments: Vec<_> = context@@ -784,11 +818,21 @@ pub(crate) fn compute(};let border_block_start = content_block_start - border_padding_block_low;let border_block_length = content_block_length + border_padding_block_low + border_padding_block_high;- let rect = FfiCssPixelRect {- x: border_inline_start,- y: border_block_start,- width: border_inline_end - border_inline_start,- height: border_block_length,+ // NB: A placeholder piece holds the content box of its inline box.+ let rect = if line.is_strut {+ FfiCssPixelRect {+ x: contributions_inline_start,+ y: content_block_start,+ width: CssPixels::default(),+ height: content_block_length,+ }+ } else {+ FfiCssPixelRect {+ x: border_inline_start,+ y: border_block_start,+ width: border_inline_end - border_inline_start,+ height: border_block_length,+ }};staged.push(StagedPiece {piece: InlineBoxPieceData {@@ -801,7 +845,7 @@ pub(crate) fn compute(baseline: inline_box_baseline,accumulated_vertical_shift: inline_box_vertical_shift,present_edges: edge_bits(has_low_edge, has_high_edge),- is_geometry_only_placeholder: false,+ is_geometry_only_placeholder: line.is_strut,},depth,discovery_index: node_index,@@ -1642,6 +1686,7 @@ impl<'context> InlineFormattingContext<'context> {.collect(),static_position_markers: Vec::new(),inline_box_baselines: Vec::new(),+ inline_box_struts: Vec::new(),text_overflow_elision: None,block_level_box: None,};@@ -2305,6 +2350,8 @@ impl<'context> InlineFormattingContext<'context> {let mut items_after_clamp_point = Vec::new();let mut stopped_at_line_limit = false;let mut needs_float_fitting = !float_fit_trial;+ // https://quirks.spec.whatwg.org/#the-line-height-calculation-quirk+ let takes_struts_of_inline_boxes_without_text = !self.facts(self.containing_block).document_in_quirks_mode();loop {if float_fit_trial && line_builder.float_refit().is_some() {break;@@ -2327,6 +2374,36 @@ impl<'context> InlineFormattingContext<'context> {if let Some(consumed_item_nodes) = consumed_item_nodes.as_mut() {consumed_item_nodes.push((item_index, item.node));}+ // An inline box that holds no in-flow item is on the line that's current when the items reach it. And+ // whitespace never starts a line, so an empty inline box right after it is on this line too — even if+ // the line goes on to break at that whitespace.+ // NB: The start edges that collapsed whitespace left for the next item come before that item too.+ let pending_leading_edges =+ item_state.leading_margin + item_state.leading_border + item_state.leading_padding;+ if iterator.has_empty_inline_boxes() {+ for empty_box in iterator.empty_inline_boxes_before_last_item() {+ line_builder+ .add_strut_of_empty_inline_box(empty_box.node, pending_leading_edges + empty_box.leading_edges);+ }+ if item.is_collapsible_whitespace+ || (item.type_ == inline_level_iterator::ItemType::Text && item.is_ascii_whitespace(self))+ {+ for empty_box in iterator.empty_inline_boxes_after_last_item() {+ line_builder.add_strut_of_empty_inline_box(+ empty_box.node,+ pending_leading_edges + empty_box.leading_edges,+ );+ }+ }+ }+ // NB: The inline boxes around whitespace are on this line whether the whitespace stays there, collapses,+ // or ends up hanging off the end of the line.+ if item.is_collapsible_whitespace && takes_struts_of_inline_boxes_without_text {+ line_builder.add_struts_of_inline_boxes_around(+ item.node,+ pending_leading_edges + item.margin_start + item.border_start + item.padding_start,+ );+ }if let Some(offset_in_node) = pending_resume_offset.take()&& item.type_ == inline_level_iterator::ItemType::Text&& offset_in_node > item.offset_in_node@@ -2423,6 +2500,7 @@ impl<'context> InlineFormattingContext<'context> {});let continuation = iterator.next_unbreakable_run_inline_size(self);let position = iterator.forced_break_position(&item);+ line_builder.add_struts_of_inline_boxes_around(position.node, CssPixels::default());line_builder.break_line(line_builder::ForcedBreak::Yes, Some(position), continuation);if !item.node.is_invalid() && self.clear_floating_boxes(item.node) {line_builder.did_introduce_clearance(self.block_axis_float_clearance.get());@@ -2461,6 +2539,12 @@ impl<'context> InlineFormattingContext<'context> {item_state.leading_border += item.border_start;item_state.leading_padding += item.padding_start;item_state.leading_right_to_left_end_margin += item.entered_right_to_left_end_margin;+ // https://drafts.csswg.org/css2/#anonymous-block-level+ // NB: The inline boxes around the block-level box are broken around it, so they're on the line+ // before it and on the line after it.+ if takes_struts_of_inline_boxes_without_text {+ line_builder.add_struts_of_inline_boxes_around(item.node, CssPixels::default());+ }line_builder.finish_current_line_before_block_level_box();if float_fit_trial {break;@@ -2490,6 +2574,9 @@ impl<'context> InlineFormattingContext<'context> {self.margins_collapse_through_interrupting_blocks.borrow_mut().insert(item.node, collapses_through);+ if takes_struts_of_inline_boxes_without_text {+ line_builder.add_struts_of_inline_boxes_around(item.node, CssPixels::default());+ }}inline_level_iterator::ItemType::AbsolutelyPositionedElement => {if !self.facts(item.node).is_box() {@@ -2626,6 +2713,15 @@ impl<'context> InlineFormattingContext<'context> {}}if iterator.items().is_empty() {+ for empty_box in iterator.empty_inline_boxes_after_last_item() {+ line_builder.add_strut_of_empty_inline_box(+ empty_box.node,+ item_state.leading_margin+ + item_state.leading_border+ + item_state.leading_padding+ + empty_box.leading_edges,+ );+ }line_builder.append_start_edges_of_collapsed_whitespace(item_state.collapsed_whitespace_node,item_state.leading_margin,diff --git a/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs b/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rsindex f8ebd76371d..4d0a919778c 100644--- a/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs+++ b/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs@@ -834,6 +834,18 @@ struct PendingInlineEdge {takes_leading_metrics: bool,}+/// An inline box that holds no in-flow item.+#[derive(Clone, Copy)]+pub(crate) struct EmptyInlineBox {+ /// Where the box is among the items: the index of the item it comes before or, once the items are resolved, the+ /// number of items from that one to the last one.+ position: usize,+ pub(crate) node: Node,+ /// The start edges between the content before the box and the content of the box, which the item after them+ /// takes: those of the box, of the boxes around it that begin with it, and the end edges of empty boxes before it.+ pub(crate) leading_edges: CssPixels,+}+struct TextNodeContext<'pass> {chunks: std::sync::Arc<super::rendered_text::CachedTextChunks>,text: &'pass [u16],@@ -942,21 +954,34 @@ impl PreparedInlineContent {atomic_sizing: AtomicInlineSizing,) -> InlineLevelIterator {context.atomic_items_are_right_to_left = self.orders_atomic_items_right_to_left(context);- let (entered_box_model_nodes, items) = RunItemResolver {+ let (entered_box_model_nodes, empty_inline_boxes, items) = RunItemResolver {context,prepared: &self,atomic_sizing,pending_inline_edges: Vec::new(),box_model_node_stack: Vec::new(),entered_box_model_nodes: Vec::new(),+ in_flow_item_count: 0,+ item_count: 0,+ empty_inline_boxes: Vec::new(),+ empty_inline_boxes_after_item: Vec::new(),+ inline_boxes_ending_with_item: Vec::new(),accumulated_inline_size_for_tabs: CssPixels::default(),next_box_event: 0,next_tab_stop: 0,forced_break_owner: NodeSlotId::INVALID,}.resolve();+ let item_count = items.len();InlineLevelIterator {entered_box_model_nodes,+ empty_inline_boxes: empty_inline_boxes+ .into_iter()+ .map(|empty_box| EmptyInlineBox {+ position: item_count - empty_box.position,+ ..empty_box+ })+ .collect(),items: ItemQueue::Owned(items.into_iter()),items_kept_for_looking_ahead: 0,prepared: self,@@ -1620,8 +1645,16 @@ struct RunItemResolver<'resolver, 'context> {prepared: &'resolver PreparedInlineContent,atomic_sizing: AtomicInlineSizing,pending_inline_edges: Vec<PendingInlineEdge>,- box_model_node_stack: Vec<Node>,+ /// The inline boxes the resolver is inside, each with the number of in-flow items there were when it began.+ box_model_node_stack: Vec<(Node, usize)>,entered_box_model_nodes: Vec<Node>,+ in_flow_item_count: usize,+ item_count: usize,+ empty_inline_boxes: Vec<EmptyInlineBox>,+ /// The inline boxes that hold no in-flow item and come right after the item being resolved.+ empty_inline_boxes_after_item: Vec<EmptyInlineBox>,+ /// The inline boxes that end with the item about to be resolved, and hold no in-flow item before it.+ inline_boxes_ending_with_item: Vec<EmptyInlineBox>,accumulated_inline_size_for_tabs: CssPixels,next_box_event: usize,next_tab_stop: usize,@@ -1633,12 +1666,14 @@ impl<'context> RunItemResolver<'_, 'context> {self.context}- /// The inline boxes the items enter, and the items.- fn resolve(mut self) -> (Vec<Node>, Vec<Item>) {+ /// The inline boxes the items enter, the ones among them that hold no in-flow item (each with the index of the+ /// item it comes before), and the items.+ fn resolve(mut self) -> (Vec<Node>, Vec<EmptyInlineBox>, Vec<Item>) {let prepared = self.prepared;let mut items: Vec<Item> = Vec::with_capacity(prepared.items.len());let mut next_non_whitespace = 0;for (index, prepared_item) in prepared.items.iter().enumerate() {+ self.item_count = items.len();self.apply_inline_box_events_at(index, false);if !self.pending_inline_edges.is_empty()&& prepared_item.type_() == ItemType::Text@@ -1659,6 +1694,7 @@ impl<'context> RunItemResolver<'_, 'context> {.is_none_or(|next| matches!(next.type_(), ItemType::BlockLevelBox | ItemType::ForcedBreak)){// Whitespace at a line end disappears, but its inline box edges still belong on that line.+ self.keep_inline_boxes_ending_with_item_as_empty();continue;}}@@ -1674,6 +1710,16 @@ impl<'context> RunItemResolver<'_, 'context> {let next = prepared.items.get(index + 1).map(PreparedItem::node);self.append_unattached_edges(&mut items, InlineEdgeBoundary::BeforeBreak(next));}+ // NB: The boxes that begin or end within an item do so after its content, so they count it.+ if matches!(+ prepared_item.type_(),+ ItemType::Text | ItemType::Element | ItemType::ForcedBreak | ItemType::BlockLevelBox+ ) {+ self.in_flow_item_count += 1;+ self.inline_boxes_ending_with_item.clear();+ } else {+ self.keep_inline_boxes_ending_with_item_as_empty();+ }let item = self.resolve_item(index, prepared_item);if matches!(item.type_, ItemType::ForcedBreak | ItemType::BlockLevelBox) {self.accumulated_inline_size_for_tabs = CssPixels::default();@@ -1685,15 +1731,28 @@ impl<'context> RunItemResolver<'_, 'context> {self.forced_break_owner = prepared_item.node();}items.push(item);+ let position = items.len();+ self.empty_inline_boxes.extend(+ self.empty_inline_boxes_after_item+ .drain(..)+ .map(|empty_box| EmptyInlineBox { position, ..empty_box }),+ );if closes_boundary {let next = prepared.items.get(index + 1).map(PreparedItem::node);self.append_unattached_edges(&mut items, InlineEdgeBoundary::Closing(prepared_item.node(), next));}}+ self.item_count = items.len();self.apply_inline_box_events_at(prepared.items.len(), false);+ self.keep_inline_boxes_ending_with_item_as_empty();self.append_unattached_edges(&mut items, InlineEdgeBoundary::End);debug_assert_eq!(self.next_box_event, prepared.box_events.len());- (self.entered_box_model_nodes, items)+ (self.entered_box_model_nodes, self.empty_inline_boxes, items)+ }++ /// The item that these inline boxes end with isn't in-flow content, so they hold none.+ fn keep_inline_boxes_ending_with_item_as_empty(&mut self) {+ self.empty_inline_boxes.append(&mut self.inline_boxes_ending_with_item);}fn append_unattached_edges(&mut self, items: &mut Vec<Item>, boundary: InlineEdgeBoundary) {@@ -1753,7 +1812,13 @@ impl<'context> RunItemResolver<'_, 'context> {last.type_ == ItemType::ForcedBreak && is_ancestor(edge.node, self.forced_break_owner)}){- items.insert(items.len() - 1, item);+ let forced_break_index = items.len() - 1;+ items.insert(forced_break_index, item);+ for empty_box in &mut self.empty_inline_boxes {+ if empty_box.position > forced_break_index {+ empty_box.position += 1;+ }+ }} else {advance += item.border_box_inline_size();items.push(item);@@ -1820,7 +1885,7 @@ impl<'context> RunItemResolver<'_, 'context> {self.next_box_event += 1;match event.entered_box() {Some(node) => self.enter_node_with_box_model_metrics(node),- None => self.exit_node_with_box_model_metrics(event.leaves_before_item()),+ None => self.exit_node_with_box_model_metrics(event.leaves_before_item(), within_item),}}}@@ -1829,12 +1894,42 @@ impl<'context> RunItemResolver<'_, 'context> {self.entered_box_model_nodes.push(node);let sides = lay_out_entered_inline_box(self.context, node);self.keep_inline_edge(node, &sides, true, true);- self.box_model_node_stack.push(node);+ self.box_model_node_stack.push((node, self.in_flow_item_count));}- fn exit_node_with_box_model_metrics(&mut self, before_item: bool) {- let node = self.box_model_node_stack.pop().unwrap();+ fn exit_node_with_box_model_metrics(&mut self, before_item: bool, within_item: bool) {+ let (node, in_flow_item_count_at_start) = self.box_model_node_stack.pop().unwrap();let sides = self.context().sides_of_entered_inline_box(node);+ // https://quirks.spec.whatwg.org/#the-line-height-calculation-quirk+ // No item tells the line builder about an inline box that holds no in-flow item, so it's kept apart, for the+ // line it's on to take its strut from — except in quirks mode, where an inline box without text has none+ // unless it has a border or padding at its start or end.+ let none = CssPixels::default();+ if in_flow_item_count_at_start == self.in_flow_item_count+ && (!self.context().facts(node).document_in_quirks_mode()+ || sides.border_left != none+ || sides.border_right != none+ || sides.padding_left != none+ || sides.padding_right != none)+ {+ let empty_box = EmptyInlineBox {+ position: self.item_count,+ node,+ leading_edges: self+ .pending_inline_edges+ .iter()+ .filter(|edge| edge.takes_leading_metrics)+ .map(|edge| edge.physical.margin + edge.physical.border + edge.physical.padding)+ .fold(CssPixels::default(), |sum, edge| sum + edge),+ };+ if within_item {+ self.empty_inline_boxes_after_item.push(empty_box);+ } else if before_item {+ self.empty_inline_boxes.push(empty_box);+ } else {+ self.inline_boxes_ending_with_item.push(empty_box);+ }+ }self.keep_inline_edge(node, &sides, false, before_item);}@@ -2101,6 +2196,7 @@ fn lay_out_entered_inline_box(struct SharedInlineItems {items: std::rc::Rc<[Item]>,entered_box_model_nodes: std::rc::Rc<[Node]>,+ empty_inline_boxes: std::rc::Rc<[EmptyInlineBox]>,prepared: std::sync::Arc<PreparedInlineContent>,}@@ -2151,6 +2247,8 @@ impl ItemQueue {pub(crate) struct InlineLevelIterator {entered_box_model_nodes: Vec<Node>,+ /// The inline boxes that hold no in-flow item, in item order.+ empty_inline_boxes: std::rc::Rc<[EmptyInlineBox]>,items: ItemQueue,/// The number of items at the end that this iterator only shows to look ahead, and does not hand out.items_kept_for_looking_ahead: usize,@@ -2176,16 +2274,18 @@ impl InlineLevelIterator {(shared.items.clone(),shared.entered_box_model_nodes.clone(),+ shared.empty_inline_boxes.clone(),shared.prepared.clone(),)});- if let Some((items, entered_box_model_nodes, prepared)) = shared {+ if let Some((items, entered_box_model_nodes, empty_inline_boxes, prepared)) = shared {context.atomic_items_are_right_to_left = prepared.orders_atomic_items_right_to_left(context);for node in entered_box_model_nodes.iter() {lay_out_entered_inline_box(context, *node);}return Self {entered_box_model_nodes: entered_box_model_nodes.to_vec(),+ empty_inline_boxes,items: ItemQueue::Shared { items, next: 0 },items_kept_for_looking_ahead: 0,prepared,@@ -2202,12 +2302,14 @@ impl InlineLevelIterator {SharedInlineItems {items: shared_items.clone(),entered_box_model_nodes: iterator.entered_box_model_nodes.as_slice().into(),+ empty_inline_boxes: iterator.empty_inline_boxes.clone(),prepared: iterator.prepared.clone(),},);let laid_out_atomic_inlines = items.iter().any(|item| item.type_ == ItemType::Element);Self {entered_box_model_nodes: iterator.entered_box_model_nodes,+ empty_inline_boxes: iterator.empty_inline_boxes,items: if laid_out_atomic_inlines {ItemQueue::Owned(items.into_iter())} else {@@ -2246,6 +2348,33 @@ impl InlineLevelIterator {&self.entered_box_model_nodes}+ pub(crate) fn has_empty_inline_boxes(&self) -> bool {+ !self.empty_inline_boxes.is_empty()+ }++ /// The inline boxes that hold no in-flow item and come right before the item this iterator handed out last.+ pub(crate) fn empty_inline_boxes_before_last_item(&self) -> impl Iterator<Item = EmptyInlineBox> + '_ {+ self.empty_inline_boxes_before_items_left(self.items.as_slice().len() + 1)+ }++ /// The inline boxes that hold no in-flow item and come right after the item this iterator handed out last.+ pub(crate) fn empty_inline_boxes_after_last_item(&self) -> impl Iterator<Item = EmptyInlineBox> + '_ {+ self.empty_inline_boxes_before_items_left(self.items.as_slice().len())+ }++ fn empty_inline_boxes_before_items_left(&self, item_count: usize) -> impl Iterator<Item = EmptyInlineBox> + '_ {+ let boxes = &self.empty_inline_boxes;+ let start = if boxes.is_empty() {+ 0+ } else {+ boxes.partition_point(|empty_box| empty_box.position > item_count)+ };+ boxes[start..]+ .iter()+ .take_while(move |empty_box| empty_box.position == item_count)+ .copied()+ }+/// The content the items were resolved from, which their glyph runs are read against.pub(crate) fn prepared_content(&self) -> &PreparedInlineContent {&self.prepared@@ -2278,8 +2407,23 @@ impl InlineLevelIterator {/// ahead at the items after `range` up to `look_ahead_end`, without handing them out.pub(crate) fn duplicate(&self, range: std::ops::Range<usize>, look_ahead_end: usize) -> Self {let items: Vec<Item> = self.items()[range.start..look_ahead_end].to_vec();+ let empty_inline_boxes = if self.empty_inline_boxes.is_empty() {+ self.empty_inline_boxes.clone()+ } else {+ // NB: The copy ends at `look_ahead_end`, so each box counts the items left from there.+ let items_after_copy = self.items().len() - look_ahead_end;+ self.empty_inline_boxes+ .iter()+ .filter(|empty_box| (items_after_copy..=items_after_copy + items.len()).contains(&empty_box.position))+ .map(|empty_box| EmptyInlineBox {+ position: empty_box.position - items_after_copy,+ ..*empty_box+ })+ .collect()+ };Self {entered_box_model_nodes: self.entered_box_model_nodes.clone(),+ empty_inline_boxes,items: ItemQueue::Owned(items.into_iter()),items_kept_for_looking_ahead: look_ahead_end - range.end,prepared: self.prepared.clone(),diff --git a/Libraries/LibWeb/Rust/src/layout/line_box.rs b/Libraries/LibWeb/Rust/src/layout/line_box.rsindex fd98b2a8fa4..b4acf8666b1 100644--- a/Libraries/LibWeb/Rust/src/layout/line_box.rs+++ b/Libraries/LibWeb/Rust/src/layout/line_box.rs@@ -39,6 +39,15 @@ pub(crate) struct InlineBoxBaseline {pub(crate) accumulated_vertical_shift: CssPixels,}+/// An inline box on a line, and where on the line its content begins. No fragment on the line belongs to a box that's+/// empty, or to one whose content there is only whitespace that collapsed away, the forced break that ends the line,+/// or a block-level box the line stops at.+#[derive(Clone, Copy, Debug, PartialEq)]+pub(crate) struct InlineBoxStrut {+ pub(crate) box_: Node,+ pub(crate) inline_offset: CssPixels,+}+/// What text-overflow elided from the end of a line.#[derive(Clone, Copy, PartialEq)]pub(crate) struct TextOverflowElision {@@ -67,6 +76,11 @@ pub(crate) struct LineBoxData {pub(crate) fragments: Vec<line_box_fragment::LineBoxFragmentData>,pub(crate) static_position_markers: Vec<StaticPositionMarker>,pub(crate) inline_box_baselines: Vec<InlineBoxBaseline>,+ /// The inline boxes that are on the line whether or not a fragment on it belongs to them. One that no fragment+ /// belongs to takes part in the height and alignment of the line box by its strut (a box as wide as nothing, with+ /// its font and line height) — but only where the line holds content or ends in a forced break.+ /// https://drafts.csswg.org/css-inline-3/#invisible-line-boxes+ pub(crate) inline_box_struts: Vec<InlineBoxStrut>,pub(crate) text_overflow_elision: Option<TextOverflowElision>,/// The block-level box the line holds, where the line is interrupted for one.pub(crate) block_level_box: Option<BlockLevelBoxOnLine>,@@ -93,6 +107,7 @@ impl LineBoxData {fragments: Vec::new(),static_position_markers: Vec::new(),inline_box_baselines: Vec::new(),+ inline_box_struts: Vec::new(),text_overflow_elision: None,block_level_box: None,record: inline_content::LineRecord {@@ -228,6 +243,22 @@ impl LineBoxData {.copied()}+ /// Puts `box_` on the line, with its content beginning `leading_edges` past the content the line holds so far.+ pub(crate) fn add_inline_box_strut(&mut self, box_: Node, leading_edges: CssPixels) {+ if self.inline_box_struts.iter().any(|strut| strut.box_ == box_) {+ return;+ }+ self.inline_box_struts.push(InlineBoxStrut {+ box_,+ inline_offset: self.record.inline_length + leading_edges,+ });+ }++ /// Whether the struts of the inline boxes on the line count, which they don't on a line with nothing else on it.+ pub(crate) fn takes_inline_box_struts(&self) -> bool {+ !self.has_block_level_box && (!self.fragments.is_empty() || self.has_forced_break)+ }+pub(crate) fn clamp_static_position_markers_to_inline_length(&mut self) {for marker in &mut self.static_position_markers {if marker.inline_offset > self.record.inline_length {@@ -326,7 +357,16 @@ impl LineBoxData {}pub(crate) fn trim_trailing_whitespace(&mut self) {- self.calculate_or_trim_trailing_whitespace(true);+ let trimmed_inline_size = self.calculate_or_trim_trailing_whitespace(true);+ // An inline box after the trimmed whitespace is at the end of what the line keeps.+ if trimmed_inline_size != CssPixels::default()+ && let Some(last) = self.fragments.last()+ {+ let end = last.inline_offset + last.inline_length;+ for strut in &mut self.inline_box_struts {+ strut.inline_offset = strut.inline_offset.min(end);+ }+ }}pub(crate) fn trim_trailing_whitespace_before_block_ellipsis(&mut self) {diff --git a/Libraries/LibWeb/Rust/src/layout/line_builder.rs b/Libraries/LibWeb/Rust/src/layout/line_builder.rsindex a15f46df5b8..fe3ea55afbd 100644--- a/Libraries/LibWeb/Rust/src/layout/line_builder.rs+++ b/Libraries/LibWeb/Rust/src/layout/line_builder.rs@@ -723,6 +723,41 @@ impl<'builder, 'context> LineBuilder<'builder, 'context> {self.max_block_size_on_current_line = self.max_block_size_on_current_line.max(line_block_length);}+ /// Puts `box_`, an inline box that holds no in-flow content, at the end of the current line, for the line to take+ /// its strut from. Its content begins `leading_edges` past the content of the line: The item after the box takes+ /// the start edges between them. Such a box is on one line alone, so one that the line before this one holds+ /// stays there.+ pub(crate) fn add_strut_of_empty_inline_box(&mut self, box_: Node, leading_edges: CssPixels) {+ let line_index = self.ensure_last_line_index();+ if line_index > 0+ && self+ .line(line_index - 1)+ .inline_box_struts+ .iter()+ .any(|strut| strut.box_ == box_)+ {+ return;+ }+ let mut line = self.line_mut(line_index);+ let inline_offset = line.inline_length + leading_edges;+ match line.inline_box_struts.iter_mut().find(|strut| strut.box_ == box_) {+ Some(strut) => strut.inline_offset = inline_offset,+ None => line.add_inline_box_strut(box_, leading_edges),+ }+ }++ /// Puts the inline boxes that `node` is inside on the current line, for the line to take the strut of each one+ /// that no fragment on the line belongs to. `leading_edges` is the size of the start edges that `node` has yet to+ /// add to the line.+ pub(crate) fn add_struts_of_inline_boxes_around(&mut self, node: Node, leading_edges: CssPixels) {+ let line_index = self.ensure_last_line_index();+ let mut box_ = self.context().nearest_fragmented_inline_ancestor(node);+ while !box_.is_invalid() {+ self.line_mut(line_index).add_inline_box_strut(box_, leading_edges);+ box_ = self.context().nearest_fragmented_inline_ancestor(box_);+ }+ }+pub(crate) fn append_static_position_marker(&mut self, node: Node, preceded_by_start_edges: bool) {let line_index = self.ensure_last_line_index();self.line_mut(line_index)@@ -1180,6 +1215,14 @@ impl<'builder, 'context> LineBuilder<'builder, 'context> {if has_fragments {self.prepare_to_append_inline_content();}+ if self.line(line_index).takes_inline_box_struts() {+ let strut_count = self.line(line_index).inline_box_struts.len();+ for strut_index in 0..strut_count {+ let box_ = self.line(line_index).inline_box_struts[strut_index].box_;+ let block_size = TextLayoutBounds::new(self.style(box_), None).block_size();+ self.max_block_size_on_current_line = self.max_block_size_on_current_line.max(block_size);+ }+ }let containing_style = self.containing_style;let unclamped_line_block_size = self.max_block_size_on_current_line.max(containing_style.line_height());if !self.only_finds_line_breaks && (has_fragments || self.line(line_index).has_forced_break) {@@ -1339,6 +1382,20 @@ impl<'builder, 'context> LineBuilder<'builder, 'context> {marker.inline_offset += marker_inline_offset;marker.block_offset += block_offset + current_block_offset + shift;}+ {+ let mut line = self.line_mut(line_index);+ let content_inline_length = line.inline_length;+ let is_right_to_left = line.direction == direction::RTL;+ for strut in &mut line.inline_box_struts {+ let offset = strut.inline_offset.min(content_inline_length);+ strut.inline_offset = marker_inline_offset+ + if is_right_to_left {+ content_inline_length - offset+ } else {+ offset+ };+ }+ }{let mut line = self.line_mut(line_index);line.block_length = latest - earliest;@@ -1365,6 +1422,86 @@ impl<'builder, 'context> LineBuilder<'builder, 'context> {line_index: usize,inline_offset: CssPixels,block_offset: CssPixels,+ ) -> LineAlignment {+ // https://drafts.csswg.org/css-inline-3/#invisible-line-boxes+ // An inline box on the line with none of its content there is aligned like any other box, as a fragment as+ // wide as nothing. The line holds that fragment only while its fragments are aligned — so, nothing else+ // gets to see it.+ let fragment_count = self.line(line_index).fragments.len();+ for strut in self.inline_box_struts_without_fragments(line_index) {+ let fragment = self.fragment_of_inline_box_strut(line_index, strut);+ self.line_mut(line_index).push_fragment(fragment);+ }+ let alignment =+ self.align_fragments_and_struts_of_line(line_index, fragment_count, inline_offset, block_offset);+ self.line_mut(line_index).fragments.truncate(fragment_count);+ alignment+ }++ /// The struts of the line at `line_index` that count: those of inline boxes that no fragment on the line belongs+ /// to, on a line that isn't empty apart from them.+ fn inline_box_struts_without_fragments(&self, line_index: usize) -> Vec<line_box::InlineBoxStrut> {+ let line = self.line(line_index);+ if line.inline_box_struts.is_empty() || !line.takes_inline_box_struts() {+ return Vec::new();+ }+ let containing_block = self.context().containing_block;+ let holds_fragment = |box_: Node| {+ line.visible_fragments().any(|fragment| {+ let mut node = fragment.style_source;+ while !node.is_invalid() && node != containing_block {+ if node == box_ {+ return true;+ }+ node = self.context().parent_node(node);+ }+ false+ })+ };+ line.inline_box_struts+ .iter()+ .filter(|strut| !holds_fragment(strut.box_))+ .copied()+ .collect()+ }++ fn fragment_of_inline_box_strut(+ &self,+ line_index: usize,+ strut: line_box::InlineBoxStrut,+ ) -> line_box_fragment::LineBoxFragmentData {+ let style = self.style(strut.box_);+ let line = self.line(line_index);+ line_box_fragment::LineBoxFragmentData::new(+ strut.box_,+ 0,+ 0,+ strut.inline_offset,+ CssPixels::default(),+ CssPixels::default(),+ TextLayoutBounds::new(style, None).block_size(),+ CssPixels::default(),+ line.direction,+ line.writing_mode,+ None,+ line_box_fragment::FragmentBuildFacts {+ style_source: strut.box_,+ is_atomic_inline: false,+ white_space_collapse: style.white_space_collapse(),+ text_utf16: std::ptr::null(),+ text_length_in_code_units: 0,+ },+ )+ }++ /// Aligns the fragments of the line at `line_index`, the ones from `strut_fragment_start` on being those of the+ /// struts of inline boxes.+ fn align_fragments_and_struts_of_line(+ &self,+ line_index: usize,+ strut_fragment_start: usize,+ inline_offset: CssPixels,+ block_offset: CssPixels,) -> LineAlignment {let containing_style = self.containing_style();let strut_baseline = Self::baseline_for_style(containing_style, containing_style.line_height());@@ -1589,7 +1726,10 @@ impl<'builder, 'context> LineBuilder<'builder, 'context> {// subtree shift below, so they never count as unshifted.let fragment_is_unshifted =aligned_subtree.is_none() && accumulated_vertical_shift == CssPixels::default();- if first_unshifted_text_baseline.is_none() && fragment_is_unshifted {+ if first_unshifted_text_baseline.is_none()+ && fragment_is_unshifted+ && fragment_index < strut_fragment_start+ {first_unshifted_text_baseline = Some(fragment_baseline - current_block_offset);}}diff --git a/Libraries/LibWeb/Rust/src/painting/client_rects.rs b/Libraries/LibWeb/Rust/src/painting/client_rects.rsindex 6a8e9fd2132..1c1900fee8e 100644--- a/Libraries/LibWeb/Rust/src/painting/client_rects.rs+++ b/Libraries/LibWeb/Rust/src/painting/client_rects.rs@@ -71,6 +71,13 @@ fn for_each_inline_fragment_border_box_rect(};let root_positions = paintable_geometry::LineRootPositions::new(arena, root);let root_side = arena.committed_side_data(root);+ let rects_after_clamp = root_side+ .inline_content+ .as_ref()+ .and_then(|content| content.inline_box_rects_after_clamp.as_deref());+ // NB: An inline box whose content is all past the clamp point has a placeholder piece that isn't on any line.+ let is_on_lines_after_clamp =+ rects_after_clamp.is_some_and(|rects| rects.iter().any(|rect| rect.node == inline_paintable));let mut pushed_a_rect = false;let mut empty_piece_after_last_block = None;with_inline_pieces(arena, inline_paintable, |piece| {@@ -93,11 +100,23 @@ fn for_each_inline_fragment_border_box_rect(push_rect(block.border_box_rect);pushed_a_rect = true;empty_piece_after_last_block = Some(empty_piece_rect(&block, true));+ return true;+ }+ if piece.fragment_count != 0 || is_on_lines_after_clamp {+ return true;}- return true;}let root_position = root_positions.of_line(root_side.lines(), piece.line_index as usize);- push_rect(CssPixelRect::from(piece.border_box_rect).translated_by(root_position));+ let mut rect = CssPixelRect::from(piece.border_box_rect).translated_by(root_position);+ if piece.is_geometry_only_placeholder {+ // NB: The placeholder piece of an empty part of the inline box holds the content box of that part.+ let padding = paintable_geometry::committed_padding(arena, inline_paintable);+ let border = paintable_geometry::committed_border(arena, inline_paintable);+ rect = rect+ .inflated(padding.top, padding.right, padding.bottom, padding.left)+ .inflated(border.top, border.right, border.bottom, border.left);+ }+ push_rect(rect);pushed_a_rect = true;empty_piece_after_last_block = None;true@@ -105,11 +124,7 @@ fn for_each_inline_fragment_border_box_rect(if let Some(rect) = empty_piece_after_last_block {push_rect(rect);}- if let Some(rects) = root_side- .inline_content- .as_ref()- .and_then(|content| content.inline_box_rects_after_clamp.as_deref())- {+ if let Some(rects) = rects_after_clamp {for rect in rects.iter().filter(|rect| rect.node == inline_paintable) {push_rect(CssPixelRect::from(rect.rect).translated_by(root_positions.of_fragment(rect.box_fragment)));}diff --git a/Tests/LibWeb/Layout/expected/block-and-inline/inline-box-end-edges-of-empty-box.txt b/Tests/LibWeb/Layout/expected/block-and-inline/inline-box-end-edges-of-empty-box.txtindex 0c65f1ac770..edea4082f88 100644--- a/Tests/LibWeb/Layout/expected/block-and-inline/inline-box-end-edges-of-empty-box.txt+++ b/Tests/LibWeb/Layout/expected/block-and-inline/inline-box-end-edges-of-empty-box.txt@@ -7,7 +7,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] childrenfrag 1 from TextNode start: 0, length: 1, rect: [39.6875,8 14.453125x20] baseline: 16"X"TextNode <#text> (not painted)- InlineNode <span.margin> at [8,8] [0+0+0 0 0+0+20] [0+0+0 20 0+0+0]+ InlineNode <span.margin> at [19.6875,8] [0+0+0 0 0+0+20] [0+0+0 20 0+0+0]TextNode <#text> (not painted)BlockContainer <div> at [8,28] [0+0+0 784 0+0+0] [0+0+0 20 0+0+0] children: inlinefrag 0 from TextNode start: 0, length: 1, rect: [8,28 11.6875x20] baseline: 16@@ -15,7 +15,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] childrenfrag 1 from TextNode start: 0, length: 1, rect: [39.6875,28 14.453125x20] baseline: 16"X"TextNode <#text> (not painted)- InlineNode <span.padding> at [8,28] [0+0+0 0 20+0+0] [0+0+0 20 0+0+0]+ InlineNode <span.padding> at [19.6875,28] [0+0+0 0 20+0+0] [0+0+0 20 0+0+0]TextNode <#text> (not painted)BlockContainer <div> at [8,48] [0+0+0 784 0+0+0] [0+0+0 20 0+0+0] children: inlinefrag 0 from TextNode start: 0, length: 2, rect: [8,48 21.6875x20] baseline: 16@@ -23,7 +23,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] childrenfrag 1 from TextNode start: 0, length: 1, rect: [49.6875,48 14.453125x20] baseline: 16"X"TextNode <#text> (not painted)- InlineNode <span.margin> at [8,48] [0+0+0 0 0+0+20] [0+0+0 20 0+0+0]+ InlineNode <span.margin> at [29.6875,48] [0+0+0 0 0+0+20] [0+0+0 20 0+0+0]TextNode <#text> (not painted)BlockContainer <div> at [8,68] [0+0+0 784 0+0+0] [0+0+0 20 0+0+0] children: inlinefrag 0 from TextNode start: 0, length: 2, rect: [8,68 21.6875x20] baseline: 16@@ -31,7 +31,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] childrenfrag 1 from TextNode start: 1, length: 1, rect: [49.6875,68 14.453125x20] baseline: 16"X"TextNode <#text> (not painted)- InlineNode <span.margin> at [8,68] [0+0+0 0 0+0+20] [0+0+0 20 0+0+0]+ InlineNode <span.margin> at [29.6875,68] [0+0+0 0 0+0+20] [0+0+0 20 0+0+0]TextNode <#text> (not painted)BlockContainer <div> at [8,88] [0+0+0 784 0+0+0] [0+0+0 20 0+0+0] children: inlinefrag 0 from TextNode start: 0, length: 1, rect: [8,88 11.6875x20] baseline: 16@@ -39,7 +39,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] childrenfrag 1 from TextNode start: 0, length: 2, rect: [39.6875,88 24.453125x20] baseline: 16" X"TextNode <#text> (not painted)- InlineNode <span.margin> at [8,88] [0+0+0 0 0+0+20] [0+0+0 20 0+0+0]+ InlineNode <span.margin> at [19.6875,88] [0+0+0 0 0+0+20] [0+0+0 20 0+0+0]TextNode <#text> (not painted)BlockContainer <div> at [8,108] [0+0+0 784 0+0+0] [0+0+0 20 0+0+0] children: inlinefrag 0 from TextNode start: 0, length: 1, rect: [28,108 14.453125x20] baseline: 16@@ -52,8 +52,8 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] childrenfrag 1 from TextNode start: 0, length: 1, rect: [39.6875,128 14.453125x20] baseline: 16"X"TextNode <#text> (not painted)- InlineNode <span.margin> at [8,128] [0+0+0 0 0+0+20] [0+0+0 20 0+0+0]- InlineNode <b> at [8,128] [0+0+0 0 0+0+0] [0+0+0 20 0+0+0]+ InlineNode <span.margin> at [19.6875,128] [0+0+0 0 0+0+20] [0+0+0 20 0+0+0]+ InlineNode <b> at [19.6875,128] [0+0+0 0 0+0+0] [0+0+0 20 0+0+0]TextNode <#text> (not painted)BlockContainer <div> at [8,148] [0+0+0 784 0+0+0] [0+0+0 20 0+0+0] children: inlinefrag 0 from TextNode start: 0, length: 1, rect: [39.6875,148 14.453125x20] baseline: 16@@ -62,7 +62,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] childrenfrag 0 from TextNode start: 0, length: 1, rect: [8,148 11.6875x20] baseline: 16"a"TextNode <#text> (not painted)- InlineNode <b> at [8,148] [0+0+0 0 0+0+0] [0+0+0 20 0+0+0]+ InlineNode <b> at [19.6875,148] [0+0+0 0 0+0+0] [0+0+0 20 0+0+0]TextNode <#text> (not painted)BlockContainer <(anonymous)> at [8,168] [0+0+0 784 0+0+0] [0+0+0 20 0+0+0] children: inlinefrag 0 from BlockContainer start: 0, length: 0, rect: [8,168 46.140625x20] baseline: 16@@ -72,7 +72,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] childrenfrag 1 from TextNode start: 0, length: 1, rect: [39.6875,168 14.453125x20] baseline: 16"X"TextNode <#text> (not painted)- InlineNode <span.margin> at [8,168] [0+0+0 0 0+0+20] [0+0+0 20 0+0+0]+ InlineNode <span.margin> at [19.6875,168] [0+0+0 0 0+0+20] [0+0+0 20 0+0+0]TextNode <#text> (not painted)TextNode <#text> (not painted)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.txtindex 3e09ae94cf8..a84b2eaed00 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@@ -51,7 +51,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] childrenfrag 1 from TextNode start: 1, length: 1, rect: [49.6875,108 14.453125x20] baseline: 16"X"TextNode <#text> (not painted)- InlineNode <span.margin> at [8,108] [0+0+0 0 0+0+20] [0+0+0 20 0+0+0]+ InlineNode <span.margin> at [29.6875,108] [0+0+0 0 0+0+20] [0+0+0 20 0+0+0]TextNode <#text> (not painted)BlockContainer <div> at [8,128] [0+0+0 784 0+0+0] [0+0+0 20 0+0+0] children: inlineInlineNode <span.margin> at [8,128] [0+0+0 21.6875 0+0+20] [0+0+0 20 0+0+0]diff --git a/Tests/LibWeb/Layout/expected/block-and-inline/justify-line-before-interrupting-block.txt b/Tests/LibWeb/Layout/expected/block-and-inline/justify-line-before-interrupting-block.txtindex 5c5a80ed3f5..abe6a4288e2 100644--- a/Tests/LibWeb/Layout/expected/block-and-inline/justify-line-before-interrupting-block.txt+++ b/Tests/LibWeb/Layout/expected/block-and-inline/justify-line-before-interrupting-block.txt@@ -65,7 +65,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] childrenfrag 30 from TextNode start: 39, length: 2, rect: [180,55 20x10] baseline: 8"qq"TextNode <#text> (not painted)- InlineNode <span> at [0,20] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0]+ InlineNode <span> at [80,5] [0+0+0 0 0+0+0] [0+0+0 10 0+0+0]frag 0 from BlockContainer start: 0, length: 0, rect: [0,20 200x10] baseline: 0BlockContainer <div> at [0,20] [0+0+0 200 0+0+0] [0+0+0 10 0+0+0] children: not-inlineTextNode <#text> (not painted)diff --git a/Tests/LibWeb/Layout/expected/css-quotes-nesting.txt b/Tests/LibWeb/Layout/expected/css-quotes-nesting.txtindex a402c379246..ede64bfe0a6 100644--- a/Tests/LibWeb/Layout/expected/css-quotes-nesting.txt+++ b/Tests/LibWeb/Layout/expected/css-quotes-nesting.txt@@ -7,7 +7,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children"a"frag 1 from TextNode start: 0, length: 1, rect: [75.578125,8 4.5625x16] baseline: 13"i"- InlineNode <(anonymous)> at [8,8] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0]+ InlineNode <(anonymous)> at [8,8] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0]GeneratedTextNode <(anonymous)> (not painted)TextNode <#text> (not painted)InlineNode <span> at [17.34375,8] [0+0+0 58.234375 0+0+0] [0+0+0 16 0+0+0]@@ -15,7 +15,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children"b"frag 1 from TextNode start: 0, length: 1, rect: [66.28125,8 9.296875x16] baseline: 13"h"- InlineNode <(anonymous)> at [8,8] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0]+ InlineNode <(anonymous)> at [17.34375,8] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0]GeneratedTextNode <(anonymous)> (not painted)TextNode <#text> (not painted)InlineNode <span> at [26.8125,8] [0+0+0 39.46875 0+0+0] [0+0+0 16 0+0+0]@@ -23,7 +23,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children"c"frag 1 from TextNode start: 0, length: 1, rect: [58.71875,8 7.5625x16] baseline: 13"g"- InlineNode <(anonymous)> at [8,8] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0]+ InlineNode <(anonymous)> at [26.8125,8] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0]GeneratedTextNode <(anonymous)> (not painted)TextNode <#text> (not painted)InlineNode <span> at [35.703125,8] [0+0+0 23.015625 0+0+0] [0+0+0 16 0+0+0]@@ -31,28 +31,28 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children"d"frag 1 from TextNode start: 0, length: 1, rect: [52.28125,8 6.4375x16] baseline: 13"f"- InlineNode <(anonymous)> at [8,8] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0]+ InlineNode <(anonymous)> at [35.703125,8] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0]GeneratedTextNode <(anonymous)> (not painted)TextNode <#text> (not painted)InlineNode <span> at [43.5625,8] [0+0+0 8.71875 0+0+0] [0+0+0 16 0+0+0]frag 0 from TextNode start: 0, length: 1, rect: [43.5625,8 8.71875x16] baseline: 13"e"- InlineNode <(anonymous)> at [8,8] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0]+ InlineNode <(anonymous)> at [43.5625,8] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0]GeneratedTextNode <(anonymous)> (not painted)TextNode <#text> (not painted)- InlineNode <(anonymous)> at [8,8] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0]+ InlineNode <(anonymous)> at [52.28125,8] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0]GeneratedTextNode <(anonymous)> (not painted)TextNode <#text> (not painted)- InlineNode <(anonymous)> at [8,8] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0]+ InlineNode <(anonymous)> at [58.71875,8] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0]GeneratedTextNode <(anonymous)> (not painted)TextNode <#text> (not painted)- InlineNode <(anonymous)> at [8,8] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0]+ InlineNode <(anonymous)> at [66.28125,8] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0]GeneratedTextNode <(anonymous)> (not painted)TextNode <#text> (not painted)- InlineNode <(anonymous)> at [8,8] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0]+ InlineNode <(anonymous)> at [75.578125,8] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0]GeneratedTextNode <(anonymous)> (not painted)TextNode <#text> (not painted)- InlineNode <(anonymous)> at [8,8] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0]+ InlineNode <(anonymous)> at [80.140625,8] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0]GeneratedTextNode <(anonymous)> (not painted)BlockContainer <div.b> at [8,24] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inlineInlineNode <span> at [8,24] [0+0+0 130.578125 0+0+0] [0+0+0 16 0+0+0]diff --git a/Tests/LibWeb/Layout/expected/empty-pseudo-element-content.txt b/Tests/LibWeb/Layout/expected/empty-pseudo-element-content.txtindex c7a74db6114..c146593c49f 100644--- a/Tests/LibWeb/Layout/expected/empty-pseudo-element-content.txt+++ b/Tests/LibWeb/Layout/expected/empty-pseudo-element-content.txt@@ -4,7 +4,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] childrenBlockContainer <div.inline> at [8,8] [0+0+0 784 0+0+0] [0+0+0 20 0+0+0] children: inlinefrag 0 from TextNode start: 0, length: 6, rect: [22,8 51.640625x20] baseline: 16"inline"- InlineNode <(anonymous)> at [8,8] [0+2+5 0 5+2+0] [0+2+5 0 5+2+0]+ InlineNode <(anonymous)> at [15,8] [0+2+5 0 5+2+0] [0+2+5 20 5+2+0]GeneratedTextNode <(anonymous)> (not painted)TextNode <#text> (not painted)BlockContainer <div.inline-block> at [8,28] [0+0+0 784 0+0+0] [0+0+0 24 0+0+0] children: inlinediff --git a/Tests/LibWeb/Layout/expected/overflow-with-padding.txt b/Tests/LibWeb/Layout/expected/overflow-with-padding.txtindex ba7851e029c..dc4ad6a7abb 100644--- a/Tests/LibWeb/Layout/expected/overflow-with-padding.txt+++ b/Tests/LibWeb/Layout/expected/overflow-with-padding.txt@@ -8,7 +8,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] childrenfrag 1 from TextNode start: 48, length: 12, rect: [35,51 93.4375x16] baseline: 13"the padding."TextNode <#text> (not painted)- InlineNode <span> at [35,35] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0]+ InlineNode <span> at [128.4375,51] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0]BlockContainer <div.outer> at [34,156] [0+1+25 400 25+1+332] [0+1+25 70 25+1+0] [BFC] children: not-inline overflow: [9,131 452x234]BlockContainer <div.inner> at [35,157] [0+1+0 400 0+1+-2] [0+1+0 100 0+1+0] children: inlinefrag 0 from TextNode start: 0, length: 46, rect: [35,157 373.796875x16] baseline: 13diff --git a/Tests/LibWeb/Layout/expected/picture-source-media-query.txt b/Tests/LibWeb/Layout/expected/picture-source-media-query.txtindex a629d09cdc1..9b2568dc926 100644--- a/Tests/LibWeb/Layout/expected/picture-source-media-query.txt+++ b/Tests/LibWeb/Layout/expected/picture-source-media-query.txt@@ -4,7 +4,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] childrenInlineNode <picture> at [8,395] [0+0+0 400 0+0+0] [0+0+0 16 0+0+0]frag 0 from ImageBox start: 0, length: 0, rect: [8,8 400x400] baseline: 400TextNode <#text> (not painted)- InlineNode <source> at [8,8] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0]+ InlineNode <source> at [8,395] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0]TextNode <#text> (not painted)ImageBox <img> at [8,8] [0+0+0 400 0+0+0] [0+0+0 400 0+0+0] children: not-inlineTextNode <#text> (not painted)diff --git a/Tests/LibWeb/Layout/expected/pseudo-element-content-replacement-display-none.txt b/Tests/LibWeb/Layout/expected/pseudo-element-content-replacement-display-none.txtindex d1121f9b397..3a8561cda74 100644--- a/Tests/LibWeb/Layout/expected/pseudo-element-content-replacement-display-none.txt+++ b/Tests/LibWeb/Layout/expected/pseudo-element-content-replacement-display-none.txt@@ -16,7 +16,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] childrenfrag 0 from GeneratedTextNode start: 0, length: 7, rect: [8,24 58.703125x16] baseline: 13"[outer]"GeneratedTextNode <(anonymous)> (not painted)- InlineNode <span.hidden-close> at [8,24] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0]+ InlineNode <span.hidden-close> at [66.703125,24] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0]InlineNode <span.visible-inner> at [66.703125,24] [0+0+0 118.375 0+0+0] [0+0+0 16 0+0+0]InlineNode <(anonymous)> at [66.703125,24] [0+0+0 55.5 0+0+0] [0+0+0 16 0+0+0]frag 0 from GeneratedTextNode start: 0, length: 7, rect: [66.703125,24 55.5x16] baseline: 13diff --git a/Tests/LibWeb/Layout/expected/space-is-soft-line-break-opportunity.txt b/Tests/LibWeb/Layout/expected/space-is-soft-line-break-opportunity.txtindex d6f08a3ec25..cb5baa2a37c 100644--- a/Tests/LibWeb/Layout/expected/space-is-soft-line-break-opportunity.txt+++ b/Tests/LibWeb/Layout/expected/space-is-soft-line-break-opportunity.txt@@ -6,7 +6,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] childrenfrag 0 from TextNode start: 0, length: 3, rect: [9,9 33.921875x16] baseline: 13"ABC"TextNode <#text> (not painted)- InlineNode <span> at [9,9] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0]+ InlineNode <span> at [42.921875,9] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0]TextNode <#text> (not painted)InlineNode <span.nowrap> at [9,25] [0+0+0 33.921875 0+0+0] [0+0+0 16 0+0+0]frag 0 from TextNode start: 0, length: 3, rect: [9,25 33.921875x16] baseline: 13diff --git a/Tests/LibWeb/Layout/expected/tree-builder/content-list-mixed-items.txt b/Tests/LibWeb/Layout/expected/tree-builder/content-list-mixed-items.txtindex dafe7e473e2..41678a792dc 100644--- a/Tests/LibWeb/Layout/expected/tree-builder/content-list-mixed-items.txt+++ b/Tests/LibWeb/Layout/expected/tree-builder/content-list-mixed-items.txt@@ -43,7 +43,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] childrenBlockContainer <div.empty-attr> at [8,286] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inlinefrag 0 from TextNode start: 0, length: 10, rect: [8,286 84.265625x16] baseline: 13"empty attr"- InlineNode <(anonymous)> at [8,286] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0]+ InlineNode <(anonymous)> at [8,286] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0]GeneratedTextNode <(anonymous)> (not painted)TextNode <#text> (not painted)diff --git a/Tests/LibWeb/Layout/expected/tree-builder/first-letter-generated-content.txt b/Tests/LibWeb/Layout/expected/tree-builder/first-letter-generated-content.txtindex 7c842cf1fcd..642a03bae1e 100644--- a/Tests/LibWeb/Layout/expected/tree-builder/first-letter-generated-content.txt+++ b/Tests/LibWeb/Layout/expected/tree-builder/first-letter-generated-content.txt@@ -16,7 +16,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] childrenBlockContainer <p.empty-before> at [8,48] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inlinefrag 0 from TextNode start: 0, length: 3, rect: [20.296875,48 25.28125x16] baseline: 13"ext"- InlineNode <(anonymous)> at [8,48] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0]+ InlineNode <(anonymous)> at [8,48] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0]GeneratedTextNode <(anonymous)> (not painted)InlineNode <(anonymous)> at [8,48] [0+0+0 12.296875 0+0+0] [0+0+0 16 0+0+0]frag 0 from TextNode start: 0, length: 1, rect: [8,48 12.296875x16] baseline: 13diff --git a/Tests/LibWeb/Layout/expected/tree-builder/generated-content-item-shapes.txt b/Tests/LibWeb/Layout/expected/tree-builder/generated-content-item-shapes.txtindex c2747b479a5..bac6673e8fb 100644--- a/Tests/LibWeb/Layout/expected/tree-builder/generated-content-item-shapes.txt+++ b/Tests/LibWeb/Layout/expected/tree-builder/generated-content-item-shapes.txt@@ -4,7 +4,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] childrenBlockContainer <p.inline-close> at [8,16] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inlinefrag 0 from TextNode start: 0, length: 26, rect: [8,16 209.5x16] baseline: 13"inline close at depth zero"- InlineNode <(anonymous)> at [8,16] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0]+ InlineNode <(anonymous)> at [8,16] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0]TextNode <#text> (not painted)BlockContainer <p.block-close> at [8,48] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: not-inlineBlockContainer <(anonymous)> at [8,48] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] children: not-inline@@ -83,12 +83,12 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children"<2"GeneratedTextNode <(anonymous)> (not painted)TextNode <#text> (not painted)- InlineNode <(anonymous)> at [8,368] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0]+ InlineNode <(anonymous)> at [265.28125,368] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0]GeneratedTextNode <(anonymous)> (not painted)BlockContainer <p.inline-blank> at [8,400] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inlinefrag 0 from TextNode start: 0, length: 20, rect: [8,400 160.703125x16] baseline: 13"inline blank counter"- InlineNode <(anonymous)> at [8,400] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0]+ InlineNode <(anonymous)> at [8,400] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0]GeneratedTextNode <(anonymous)> (not painted)TextNode <#text> (not painted)BlockContainer <p.block-blank> at [8,432] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: not-inlinediff --git a/Tests/LibWeb/Layout/expected/tree-builder/quotes-no-open-no-close.txt b/Tests/LibWeb/Layout/expected/tree-builder/quotes-no-open-no-close.txtindex aff676f93df..0236624e0eb 100644--- a/Tests/LibWeb/Layout/expected/tree-builder/quotes-no-open-no-close.txt+++ b/Tests/LibWeb/Layout/expected/tree-builder/quotes-no-open-no-close.txt@@ -12,7 +12,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] childrenBlockContainer <p.no-open> at [8,48] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inlinefrag 0 from TextNode start: 0, length: 13, rect: [8,48 117.8125x16] baseline: 13"no-open-quote"- InlineNode <(anonymous)> at [8,48] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0]+ InlineNode <(anonymous)> at [8,48] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0]TextNode <#text> (not painted)BlockContainer <p.open> at [8,80] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inlinefrag 0 from TextNode start: 0, length: 18, rect: [24.09375,80 158.859375x16] baseline: 13@@ -25,7 +25,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] childrenBlockContainer <p.no-close> at [8,112] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inlinefrag 0 from TextNode start: 0, length: 14, rect: [8,112 121.25x16] baseline: 13"no-close-quote"- InlineNode <(anonymous)> at [8,112] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0]+ InlineNode <(anonymous)> at [8,112] [0+0+0 0 0+0+0] [0+0+0 16 0+0+0]TextNode <#text> (not painted)BlockContainer <p.open> at [8,144] [0+0+0 784 0+0+0] [16+0+0 16 0+0+16] children: inlinefrag 0 from TextNode start: 0, length: 19, rect: [24.09375,144 162.296875x16] baseline: 13diff --git a/Tests/LibWeb/Layout/expected/unbreakable-run-across-inline-box-boundaries.txt b/Tests/LibWeb/Layout/expected/unbreakable-run-across-inline-box-boundaries.txtindex e3daf817f53..ea56df67696 100644--- a/Tests/LibWeb/Layout/expected/unbreakable-run-across-inline-box-boundaries.txt+++ b/Tests/LibWeb/Layout/expected/unbreakable-run-across-inline-box-boundaries.txt@@ -235,13 +235,13 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] childrenfrag 0 from TextNode start: 0, length: 3, rect: [68,828 30x10] baseline: 8"ccc"TextNode <#text> (not painted)- InlineNode <b> at [8,828] [0+0+0 0 0+0+0] [0+0+0 10 0+0+0]+ InlineNode <b> at [98,828] [0+0+0 0 0+0+0] [0+0+0 10 0+0+0]TextNode <#text> (not painted)BlockContainer <div> at [8,848] [0+0+0 90 0+0+694] [0+0+0 10 0+0+10] children: inlinefrag 0 from TextNode start: 0, length: 9, rect: [8,848 90x10] baseline: 8"aa-bb-ccc"TextNode <#text> (not painted)- InlineNode <span> at [8,848] [0+0+0 0 0+0+0] [0+0+0 10 0+0+0]+ InlineNode <span> at [98,848] [0+0+0 0 0+0+0] [0+0+0 10 0+0+0]TextNode <#text> (not painted)BlockContainer <div> at [8,868] [0+0+0 70 0+0+714] [0+0+0 10 0+0+10] children: inlinefrag 0 from TextNode start: 0, length: 4, rect: [8,868 40x10] baseline: 8@@ -338,7 +338,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] childrenInlineNode <span> at [98,1038] [0+0+0 10 0+0+0] [0+0+0 10 0+0+0]frag 0 from TextNode start: 0, length: 1, rect: [98,1038 10x10] baseline: 8"d"- InlineNode <b> at [8,1038] [0+0+0 0 0+0+0] [0+0+0 10 0+0+0]+ InlineNode <b> at [98,1038] [0+0+0 0 0+0+0] [0+0+0 10 0+0+0]TextNode <#text> (not painted)TextNode <#text> (not painted)BlockContainer <div> at [8,1058] [0+0+0 100 0+0+684] [0+0+0 10 0+0+10] children: inline@@ -351,7 +351,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] childrenfrag 0 from TextNode start: 0, length: 1, rect: [88,1058 10x10] baseline: 8" "TextNode <#text> (not painted)- InlineNode <span> at [8,1058] [0+0+0 0 0+0+0] [0+0+0 10 0+0+0]+ InlineNode <span> at [98,1058] [0+0+0 0 0+0+0] [0+0+0 10 0+0+0]TextNode <#text> (not painted)TextNode <#text> (not painted)BlockContainer <div> at [8,1078] [0+0+0 40 0+0+744] [0+0+0 30 0+0+10] [BFC] children: inlinediff --git a/Tests/LibWeb/Ref/expected/text-overflow-first-glyph-after-empty-inline-ref.html b/Tests/LibWeb/Ref/expected/text-overflow-first-glyph-after-empty-inline-ref.htmlnew file mode 100644index 00000000000..99016088da5--- /dev/null+++ b/Tests/LibWeb/Ref/expected/text-overflow-first-glyph-after-empty-inline-ref.html@@ -0,0 +1,5 @@+<!DOCTYPE html>+<style>+ div { width: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 20px/1 monospace; }+</style>+<div>WWWWW</div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/CSS2/linebox/empty-inline-003-ref.xht b/Tests/LibWeb/Ref/expected/wpt-import/css/CSS2/linebox/empty-inline-003-ref.xhtnew file mode 100644index 00000000000..a6de93f17bf--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/CSS2/linebox/empty-inline-003-ref.xht@@ -0,0 +1,30 @@+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">++<html xmlns="http://www.w3.org/1999/xhtml">++ <head>++ <title>CSS Reftest Reference</title>++ <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />+ <link rel="author" title="Bruno Fassino" href="http://www.brunildo.org/" />++ <style type="text/css"><![CDATA[+ div+ {+ background-color: green;+ color: white;+ line-height: 5;+ }+ ]]></style>++ </head>++ <body>++ <p>Test passes if there is a wide filled green rectangle with one "X" in it and if there is <strong>no red</strong>.</p>++ <div>X</div>++ </body>+</html>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-inline/br-line-height-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-inline/br-line-height-ref.htmlnew file mode 100644index 00000000000..93b12a298e9--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-inline/br-line-height-ref.html@@ -0,0 +1,11 @@+<!doctype html>+<link rel="author" title="Seva Alipov" href="mailto:[email protected]">+<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1927699">+<link rel="stylesheet" type="text/css" href="../../fonts/ahem.css" />++<style>+ h1 {+ font: 25px/1 ahem;+ }+</style>+<h1>XXXXXX<br />XXXX<br />XXXXXXXXX<br />XXXX</h1>diff --git a/Tests/LibWeb/Ref/input/text-overflow-first-glyph-after-empty-inline.html b/Tests/LibWeb/Ref/input/text-overflow-first-glyph-after-empty-inline.htmlnew file mode 100644index 00000000000..2ab8e093b34--- /dev/null+++ b/Tests/LibWeb/Ref/input/text-overflow-first-glyph-after-empty-inline.html@@ -0,0 +1,7 @@+<!DOCTYPE html>+<link rel="match" href="../expected/text-overflow-first-glyph-after-empty-inline-ref.html">+<style>+ div { width: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 20px/1 monospace; }+</style>+<!-- An empty inline before the text shows nothing, so the first glyph is still clipped rather than dropped. -->+<div><span></span>WWWWW</div>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/CSS2/linebox/empty-inline-003.xht b/Tests/LibWeb/Ref/input/wpt-import/css/CSS2/linebox/empty-inline-003.xhtnew file mode 100644index 00000000000..dd371731e3f--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/CSS2/linebox/empty-inline-003.xht@@ -0,0 +1,55 @@+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">++<html xmlns="http://www.w3.org/1999/xhtml">++ <head>++ <title>CSS Test: Line height calculations - Empty inline elements influence</title>++ <link rel="help" href="http://www.w3.org/TR/CSS21/visudet.html#line-height" title="10.8 Line height calculations: the 'line-height' and 'vertical-align' properties" />+ <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" />+ <link rel="author" title="Bruno Fassino" href="http://www.brunildo.org/" />+ <link rel="match" href="../../../../../expected/wpt-import/css/CSS2/linebox/empty-inline-003-ref.xht" />++ <meta content="The line-height of an empty inline element influences the height of a line containing it with some other content" name="assert" />++ <style type="text/css"><![CDATA[+ div#rel-pos-wrapper {position: relative;}++ div#test+ {+ background-color: green;+ color: white;+ line-height: 1;+ }++ span#empty-inline-element {line-height: 5;}++ div#reference-overlapped-red+ {+ background-color: red;+ left: 0;+ line-height: 5;+ position: absolute;+ top: 0;+ width: 100%;+ z-index: -1;+ }+ ]]></style>++ </head>++ <body>++ <p>Test passes if there is a wide filled green rectangle with one "X" in it and if there is <strong>no red</strong>.</p>++ <div id="rel-pos-wrapper">++ <div id="test"><span id="empty-inline-element"></span>X</div>++ <div id="reference-overlapped-red">X</div>++ </div>++ </body>+</html>\ No newline at end of filediff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-inline/br-line-height.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-inline/br-line-height.htmlnew file mode 100644index 00000000000..7543405a7c3--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-inline/br-line-height.html@@ -0,0 +1,17 @@+<!doctype html>+<link rel="author" title="Seva Alipov" href="mailto:[email protected]">+<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1927699">+<link rel="match" href="../../../../expected/wpt-import/css/css-inline/br-line-height-ref.html">+<link rel="stylesheet" type="text/css" href="../../fonts/ahem.css" />++<style>+ br {+ line-height: 5;+ }++ h1 {+ font: 25px/1 ahem;+ line-height: 1;+ }+</style>+<h1>XXXXXX<br />XXXX<br />XXXXXXXXX<br />XXXX</h1>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-inline/model/phantom-line-boxes-001.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-inline/model/phantom-line-boxes-001.htmlnew file mode 100644index 00000000000..74478784610--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-inline/model/phantom-line-boxes-001.html@@ -0,0 +1,49 @@+<!DOCTYPE html>+<title>CSS Inline Layout Model: Phantom Line Boxes</title>+<link rel="author" title="Oriol Brufau" href="mailto:[email protected]">+<link rel="help" href="https://drafts.csswg.org/css-inline/#invisible-line-boxes">+<link rel="help" href="https://drafts.csswg.org/css2/#collapsing-margins">+<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/9344">+<link rel="match" href="../../../../../expected/wpt-import/css/css-inline/model/../../reference/ref-filled-green-200px-square.html">+<meta name="assert" content="Non-zero inline-axis margins, padding, or borders+ prevent a line box from becoming a phantom line box, and therefore prevent+ the inline formatting context from collapsing margins through.+ This test checks non-zero padding.">++<style>+.wrapper {+ float: left;+ width: 50px;+ background: red;+}+.wrapper.phantom {+ background: green;+}+.wrapper > div {+ line-height: 0;+ background: green;+}+.wrapper.phantom > div {+ background: red+}+.wrapper > div::after {+ content: "";+ display: flow-root;+ margin-top: 200px;+}+</style>++<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>++<div class="wrapper phantom">+ <div><span style="padding-top: 1px"></span></div>+</div>+<div class="wrapper phantom">+ <div><span style="padding-bottom: 1px"></span></div>+</div>+<div class="wrapper">+ <div><span style="padding-left: 1px"></span></div>+</div>+<div class="wrapper">+ <div><span style="padding-right: 1px"></span></div>+</div>diff --git a/Tests/LibWeb/Text/expected/abspos-in-block-inside-relpos-inline.txt b/Tests/LibWeb/Text/expected/abspos-in-block-inside-relpos-inline.txtindex cb63c54fb6d..7f78fd8795a 100644--- a/Tests/LibWeb/Text/expected/abspos-in-block-inside-relpos-inline.txt+++ b/Tests/LibWeb/Text/expected/abspos-in-block-inside-relpos-inline.txt@@ -1,2 +1,2 @@with-text: abspos at (20, 20), inline starts at (20, 20)-block-only: abspos at (20, 68), inline starts at (20, 68)+block-only: abspos at (60.1875, 52), inline starts at (60.1875, 52)diff --git a/Tests/LibWeb/Text/expected/accessibility-node-data-indirect.txt b/Tests/LibWeb/Text/expected/accessibility-node-data-indirect.txtindex f95a8021ec9..facd3e93169 100644--- a/Tests/LibWeb/Text/expected/accessibility-node-data-indirect.txt+++ b/Tests/LibWeb/Text/expected/accessibility-node-data-indirect.txt@@ -40,7 +40,7 @@ n0 generic bounds=8,8 784x188n0 generic bounds=8,8 784x188n1 status bounds=8,10 124x16 live=politen2 text leaf name="custom element" bounds=8,10 124x16 font="SerenitySans" 16 400 normal color=#000000 characters=0,0 8,0 18,0 28,0 34,0 45,0 57,0 65,0 74,0 78,0 87,0 99,0 108,0 117,0 lines=0@16- n3 generic bounds=8,8 0x20+ n3 generic bounds=132,10 0x16n4 generic bounds=8,28 784x20n5 banner bounds=8,28 784x20n6 text leaf name="section header" bounds=8,30 119x16 font="SerenitySans" 16 400 normal color=#000000 characters=0,0 9,0 18,0 26,0 33,0 38,0 48,0 58,0 66,0 75,0 84,0 93,0 101,0 110,0 lines=0@16@@ -58,7 +58,7 @@ n0 generic bounds=8,8 784x188n0 generic bounds=8,8 784x186n1 status bounds=8,10 124x16 live=politen2 text leaf name="custom element" bounds=8,10 124x16 font="SerenitySans" 16 400 normal color=#000000 characters=0,0 8,0 18,0 28,0 34,0 45,0 57,0 65,0 74,0 78,0 87,0 99,0 108,0 117,0 lines=0@16- n3 generic bounds=8,8 0x20+ n3 generic bounds=132,10 0x16n4 generic bounds=8,28 784x20n5 banner bounds=8,28 784x20n6 text leaf name="section header" bounds=8,30 119x16 font="SerenitySans" 16 400 normal color=#000000 characters=0,0 9,0 18,0 26,0 33,0 38,0 48,0 58,0 66,0 75,0 84,0 93,0 101,0 110,0 lines=0@16@@ -76,7 +76,7 @@ n0 generic bounds=8,8 784x186n0 generic bounds=8,8 784x186 editable multi_linen1 status bounds=8,10 124x16 live=polite editable multi_linen2 text leaf name="custom element" bounds=8,10 124x16 font="SerenitySans" 16 400 normal color=#000000 characters=0,0 8,0 18,0 28,0 34,0 45,0 57,0 65,0 74,0 78,0 87,0 99,0 108,0 117,0 lines=0@16- n3 generic bounds=8,8 0x20 editable multi_line+ n3 generic bounds=132,10 0x16 editable multi_linen4 generic bounds=8,28 784x20 editable multi_linen5 banner bounds=8,28 784x20 editable multi_linen6 text leaf name="section header" bounds=8,30 119x16 font="SerenitySans" 16 400 normal color=#000000 characters=0,0 9,0 18,0 26,0 33,0 38,0 48,0 58,0 66,0 75,0 84,0 93,0 101,0 110,0 lines=0@16@@ -94,7 +94,7 @@ n0 generic bounds=8,8 784x186 editable multi_linen0 generic bounds=8,8 784x186n1 status bounds=8,10 124x16 live=politen2 text leaf name="custom element" bounds=8,10 124x16 font="SerenitySans" 16 400 normal color=#000000 characters=0,0 8,0 18,0 28,0 34,0 45,0 57,0 65,0 74,0 78,0 87,0 99,0 108,0 117,0 lines=0@16- n3 generic bounds=8,8 0x20+ n3 generic bounds=132,10 0x16n4 generic bounds=8,28 784x20n5 banner bounds=8,28 784x20n6 text leaf name="section header" bounds=8,30 119x16 font="SerenitySans" 16 400 normal color=#000000 characters=0,0 9,0 18,0 26,0 33,0 38,0 48,0 58,0 66,0 75,0 84,0 93,0 101,0 110,0 lines=0@16@@ -112,7 +112,7 @@ n0 generic bounds=8,8 784x186n0 generic bounds=8,8 784x186n1 status bounds=8,10 124x16 live=politen2 text leaf name="custom element" bounds=8,10 124x16 font="SerenitySans" 16 400 normal color=#000000 characters=0,0 8,0 18,0 28,0 34,0 45,0 57,0 65,0 74,0 78,0 87,0 99,0 108,0 117,0 lines=0@16- n3 generic bounds=8,8 0x20+ n3 generic bounds=132,10 0x16n4 generic bounds=8,28 784x20n5 banner bounds=8,28 784x20n6 text leaf name="section header" bounds=8,30 119x16 font="SerenitySans" 16 400 normal color=#000000 characters=0,0 9,0 18,0 26,0 33,0 38,0 48,0 58,0 66,0 75,0 84,0 93,0 101,0 110,0 lines=0@16@@ -130,7 +130,7 @@ n0 generic bounds=8,8 784x186n0 generic bounds=8,8 784x186n1 status bounds=8,10 124x16 live=politen2 text leaf name="custom element" bounds=8,10 124x16 font="SerenitySans" 16 400 normal color=#000000 characters=0,0 8,0 18,0 28,0 34,0 45,0 57,0 65,0 74,0 78,0 87,0 99,0 108,0 117,0 lines=0@16- n3 generic bounds=8,8 0x20+ n3 generic bounds=132,10 0x16n4 generic bounds=8,28 784x20n5 banner bounds=8,28 784x20n6 text leaf name="section header" bounds=8,30 119x16 font="SerenitySans" 16 400 normal color=#000000 characters=0,0 9,0 18,0 26,0 33,0 38,0 48,0 58,0 66,0 75,0 84,0 93,0 101,0 110,0 lines=0@16diff --git a/Tests/LibWeb/Text/expected/css/inline-box-line-height-without-text.txt b/Tests/LibWeb/Text/expected/css/inline-box-line-height-without-text.txtnew file mode 100644index 00000000000..f9fab5fc02f--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/inline-box-line-height-without-text.txt@@ -0,0 +1,32 @@+br: 56+empty: 0+text: 56+image: 56+whitespace-before-br: 56+empty-before-br: 56+empty-before-text: 56+empty-after-text: 56+only-whitespace: 0+empty-before-image: 56+br-own-line-height: 56+nested-br: 56+two-br: 112+empty-before-two-br: 75+whitespace-before-text: 56+whitespace-after-text: 56+preserved-breaks: 112+block-in-inline: 10+empty-before-block: 10+collapsing-margin: 10+no-break-at-empty: 56+empty-before-soft-wrap: 75+whitespace-around-empty: 56+trailing-space-before-empty: 56+max-content-whitespace: 56+whitespace-at-soft-wrap: 75+empty-before-overflowing-image: 56+empty-before-overflowing-text: 56+max-content-whitespace width: 48+whitespace-at-soft-wrap span is on first line: true+trailing-space-before-empty text end: 100+trailing-space-before-empty span: 100diff --git a/Tests/LibWeb/Text/expected/css/inline-box-strut-client-rects.txt b/Tests/LibWeb/Text/expected/css/inline-box-strut-client-rects.txtnew file mode 100644index 00000000000..526e0039cb0--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/inline-box-strut-client-rects.txt@@ -0,0 +1,12 @@+two-br: (0,5 0x10) (0,25 0x10)+br-then-text: (0,5 0x10) (0,25 10x10)+text-br-br: (0,5 10x10) (0,25 0x10)+nested-in-padding: (30,5 0x10)+nested-in-padding-with-text: (30,5 0x10)+after-empty-with-padding: (30,5 0x10)+own-padding: (15,5 20x10)+nested-ws: (30,5 10x10)+justify: (40,5 0x10)+justify-ws: (20,5 20x10)+justify-br: (50,5 0x10)+ellipsis: (40,5 0x10)diff --git a/Tests/LibWeb/Text/expected/css/inline-box-struts-in-quirks-mode.txt b/Tests/LibWeb/Text/expected/css/inline-box-struts-in-quirks-mode.txtnew file mode 100644index 00000000000..e9277ad7951--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/inline-box-struts-in-quirks-mode.txt@@ -0,0 +1,85 @@+block-after-text: 30+block-before-text: 30+block-between-text: 90+block-between-outer-text: 50+empty-then-sibling-block: 30+wrap-space-then-empty: 40+wrap-empty-then-space: 40+wrap-space-then-collapsed-space: 40+wrap-space-in-span: 40+wrap-anywhere: 40+close-after-br: 80+close-after-wrap: 80+open-before-wrap: 80+empty-after-br: 20+empty-before-br-then-text: 40+br-in-span-after-text: 60+br-then-text-in-span: 120+br-in-nested-b: 60+alone: 0+alone-top: 0+alone-with-float: 0+alone-with-abspos: 0+abspos-only-then-text: 20+float-only-then-text: 20+with-padding: 60+lh0: 20+nested-taller: 20+nested-in-top: 20+nested-shifted: 20+nested-outer-shifted: 20+two-empties: 20+rtl: 20+pre-space: 60+tall-top-image: 100+generated: 20+generated-on-block: 20+empty-in-inline-block: 20+nowrap-empty: 20+text-then-empty-top: 20+empty-display-contents: 20+empty-text-node-span: 20+va-top: 20+va-br-top: 60+va-bottom: 20+va-br-bottom: 60+va-middle: 20+va-10px: 20+va-br-10px: 60+va--10px: 20+va-br--10px: 60+va-super: 20+va-br-super: 60+va-sub: 20+va-br-sub: 60+va-text-top: 20+va-text-bottom: 20+va-br-text-bottom: 60+va-50%: 20+va-baseline: 20+va-br-baseline: 60+vertical-rl-empty-text: 20+vertical-rl-br: 60+vertical-rl-alone: 0+vertical-lr-empty-text: 20+vertical-lr-br: 60+vertical-lr-alone: 0+sideways-rl-empty-text: 20+sideways-rl-br: 60+sideways-rl-alone: 0+abspos-only-after-br: 20+abspos-only-after-br-then-text: 40+empty-after-br-then-text: 40+empty-after-nested-br: 20+empty-after-float: 20+empty-between-spaces-wrap: 40+two-lines-two-empties: 60+pre-wrap-space-then-empty: 40+empty-with-margin: 20+empty-with-padding-then-text: 60+wide-space-then-empty: 20+wide-empty-between-spaces: 20+wide-space-in-span: 60+wide-right-aligned: 20+wide-rtl: 20+wide-centered-br: 60diff --git a/Tests/LibWeb/Text/expected/css/inline-box-struts.txt b/Tests/LibWeb/Text/expected/css/inline-box-struts.txtnew file mode 100644index 00000000000..a8f9ff2d601--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/inline-box-struts.txt@@ -0,0 +1,85 @@+block-after-text: 70+block-before-text: 70+block-between-text: 130+block-between-outer-text: 130+empty-then-sibling-block: 70+wrap-space-then-empty: 80 span@(40,5 0x50)+wrap-empty-then-space: 80 span@(40,5 0x50)+wrap-space-then-collapsed-space: 80 span@(40,5 0x50)+wrap-space-in-span: 80 span@(40,5 0x50)+wrap-anywhere: 80 span@(60,5 0x50)+close-after-br: 80 span@(0,5 50x50)+close-after-wrap: 80 span@(0,5 100x50)+open-before-wrap: 80 span@(0,25 100x50)+empty-after-br: 20+empty-before-br-then-text: 80+br-in-span-after-text: 60+br-then-text-in-span: 120+br-in-nested-b: 60+alone: 0+alone-top: 0+alone-with-float: 0+alone-with-abspos: 0+abspos-only-then-text: 60+float-only-then-text: 60+with-padding: 60+lh0: 20+lh0-alone-br: 20+nested-taller: 90+nested-in-top: 60+nested-shifted: 90+nested-outer-shifted: 79+two-empties: 60+rtl: 60+pre-space: 60+inline-block: 60+tall-top-image: 100+generated: 60+generated-on-block: 60+empty-in-inline-block: 60+nowrap-empty: 60 span@(60,5 0x50)+text-then-empty-top: 60+empty-display-contents: 60+empty-text-node-span: 60+va-top: 60+va-br-top: 60+va-bottom: 60+va-br-bottom: 60+va-10px: 60+va-br-10px: 60+va--10px: 60+va-br--10px: 60+va-super: 60+va-br-super: 60+va-sub: 60+va-br-sub: 60+va-text-bottom: 60+va-br-text-bottom: 60+va-50%: 79+va-br-50%: 79+va-baseline: 60+va-br-baseline: 60+vertical-rl-empty-text: 60+vertical-rl-br: 60+vertical-rl-alone: 0+vertical-lr-empty-text: 60+vertical-lr-br: 60+vertical-lr-alone: 0+sideways-rl-empty-text: 60+sideways-rl-br: 60+sideways-rl-alone: 0+abspos-only-after-br: 20+abspos-only-after-br-then-text: 80+empty-after-br-then-text: 80+empty-after-nested-br: 20+empty-after-image: 60+empty-after-float: 60+empty-between-spaces-wrap: 80 span@(40,5 0x50)+two-lines-two-empties: 140 span@(40,5 0x50)+empty-with-margin: 60+empty-with-padding-then-text: 60+wide-space-then-empty: 60 span@(60,5 0x50)+wide-empty-between-spaces: 60 span@(60,5 0x50)+wide-space-in-span: 60 span@(40,5 50x50)+wide-right-aligned: 60 span@(300,5 0x50)+wide-centered-br: 60 span@(170,5 0x50)diff --git a/Tests/LibWeb/Text/expected/selection-line-boundary-after-newline-in-empty-span.txt b/Tests/LibWeb/Text/expected/selection-line-boundary-after-newline-in-empty-span.txtnew file mode 100644index 00000000000..489b3d0ec5a--- /dev/null+++ b/Tests/LibWeb/Text/expected/selection-line-boundary-after-newline-in-empty-span.txt@@ -0,0 +1 @@+line boundary from offset 0: 0diff --git a/Tests/LibWeb/Text/input/css/inline-box-line-height-without-text.html b/Tests/LibWeb/Text/input/css/inline-box-line-height-without-text.htmlnew file mode 100644index 00000000000..cede4150ac2--- /dev/null+++ b/Tests/LibWeb/Text/input/css/inline-box-line-height-without-text.html@@ -0,0 +1,52 @@+<!DOCTYPE html>+<style>+ @font-face { font-family: Ahem; src: url("../wpt-import/fonts/Ahem.ttf"); }+ body { font: 16px/19px serif; }+ .case > span { font-size: 51px; line-height: 56px; }+</style>+<div class="case" id="br"><span><br></span></div>+<div class="case" id="empty"><span></span></div>+<div class="case" id="text"><span>x</span></div>+<div class="case" id="image"><span><img style="width: 10px; height: 10px"></span></div>+<div class="case" id="whitespace-before-br"><span> </span><br></div>+<div class="case" id="empty-before-br"><span></span><br></div>+<div class="case" id="empty-before-text"><span></span>x</div>+<div class="case" id="empty-after-text">x<span></span></div>+<div class="case" id="only-whitespace"><span> </span></div>+<div class="case" id="empty-before-image"><span></span><img style="width: 10px; height: 10px"></div>+<div class="case" id="br-own-line-height"><span><br style="line-height: 100px"></span></div>+<div class="case" id="nested-br"><span><span style="font-size: 20px; line-height: 24px"><br></span></span></div>+<div class="case" id="two-br"><span><br><br></span></div>+<div class="case" id="empty-before-two-br"><span></span><br><br></div>+<div class="case" id="whitespace-before-text"><span> </span>x</div>+<div class="case" id="whitespace-after-text">x<span> </span></div>+<div class="case" id="preserved-breaks"><span style="white-space: pre"> </span></div>+<div class="case" id="block-in-inline"><span><div style="height: 10px"></div></span></div>+<div class="case" id="empty-before-block"><span></span><div style="height: 10px"></div></div>+<div class="case" id="collapsing-margin" style="margin-top: 10px"><span></span><div style="margin-top: 20px; height: 10px"></div></div>+<div class="case" id="no-break-at-empty" style="width: 60px; font-family: Ahem">MMMM<span></span>MMMM</div>+<div class="case" id="empty-before-soft-wrap" style="width: 150px; font-family: Ahem">word word<span></span> next</div>+<div class="case" id="whitespace-around-empty" style="width: 60px; font-family: Ahem">x <span></span> y</div>+<div class="case" id="trailing-space-before-empty" style="width: 100px; font-family: Ahem; text-align: right">x <span></span></div>+<div class="case" id="max-content-whitespace" style="width: max-content; font-family: Ahem">x <span></span> y</div>+<div class="case" id="whitespace-at-soft-wrap" style="width: 60px; font-family: Ahem"><b>AAA</b><span> </span><b>BBB</b></div>+<div class="case" id="empty-before-overflowing-image" style="width: 10px"><span></span><img style="width: 20px; height: 10px"></div>+<div class="case" id="empty-before-overflowing-text" style="width: 10px; font-family: Ahem"><span></span>AAA</div>+<script src="../include.js"></script>+<script>+ promiseTest(async () => {+ await document.fonts.ready;+ const results = Array.from(document.querySelectorAll(".case"), element =>+ `${element.id}: ${element.getBoundingClientRect().height}`);+ results.push(`max-content-whitespace width: ${document.getElementById("max-content-whitespace").getBoundingClientRect().width}`);+ const softWrap = document.getElementById("whitespace-at-soft-wrap");+ results.push(`whitespace-at-soft-wrap span is on first line: ${softWrap.querySelector("span").getBoundingClientRect().bottom <= softWrap.lastChild.getBoundingClientRect().top}`);+ const trailing = document.getElementById("trailing-space-before-empty");+ const range = document.createRange();+ range.setStart(trailing.firstChild, 0);+ range.setEnd(trailing.firstChild, 1);+ results.push(`trailing-space-before-empty text end: ${range.getBoundingClientRect().right - trailing.getBoundingClientRect().left}`);+ results.push(`trailing-space-before-empty span: ${trailing.querySelector("span").getBoundingClientRect().left - trailing.getBoundingClientRect().left}`);+ results.forEach(println);+ });+</script>diff --git a/Tests/LibWeb/Text/input/css/inline-box-strut-client-rects.html b/Tests/LibWeb/Text/input/css/inline-box-strut-client-rects.htmlnew file mode 100644index 00000000000..404674a72f3--- /dev/null+++ b/Tests/LibWeb/Text/input/css/inline-box-strut-client-rects.html@@ -0,0 +1,30 @@+<!DOCTYPE html>+<style>+ @font-face { font-family: Ahem; src: url("../wpt-import/fonts/Ahem.ttf"); }+ body { margin: 0; font: 10px/20px Ahem; }+ .case { position: relative; width: 300px; }+</style>+<div class="case" id="two-br"><span class="t"><br><br></span></div>+<div class="case" id="br-then-text"><span class="t"><br>x</span></div>+<div class="case" id="text-br-br"><span class="t">x<br><br></span></div>+<div class="case" id="nested-in-padding">x<span style="padding-left: 20px"><span class="t"></span></span>y</div>+<div class="case" id="nested-in-padding-with-text">x<span style="padding-left: 20px"><span class="t"></span>y</span></div>+<div class="case" id="after-empty-with-padding">x<span style="padding-right: 20px"></span><span class="t"></span>y</div>+<div class="case" id="own-padding">x<span class="t" style="padding-left: 20px; margin-left: 5px"></span>y</div>+<div class="case" id="nested-ws">x<span style="padding-left: 20px"><span class="t"> </span></span>y</div>+<div class="case" id="justify" style="width: 100px; text-align: justify">aa <span class="t"></span>bb cc dd</div>+<div class="case" id="justify-ws" style="width: 100px; text-align: justify">aa<span class="t"> </span>bb cc dd</div>+<div class="case" id="justify-br" style="width: 100px; text-align: justify">aa bb<span class="t"><br></span>cc</div>+<div class="case" id="ellipsis" style="width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap">aaaa<span class="t"></span>bbbbbb</div>+<script src="../include.js"></script>+<script>+ promiseTest(async () => {+ await document.fonts.ready;+ for (const element of document.querySelectorAll(".case")) {+ const origin = element.getBoundingClientRect();+ const rects = Array.from(element.querySelector(".t").getClientRects(), rect =>+ `(${rect.left - origin.left},${rect.top - origin.top} ${rect.width}x${rect.height})`);+ println(`${element.id}: ${rects.join(" ")}`);+ }+ });+</script>diff --git a/Tests/LibWeb/Text/input/css/inline-box-struts-in-quirks-mode.html b/Tests/LibWeb/Text/input/css/inline-box-struts-in-quirks-mode.htmlnew file mode 100644index 00000000000..dacc6655f5e--- /dev/null+++ b/Tests/LibWeb/Text/input/css/inline-box-struts-in-quirks-mode.html@@ -0,0 +1,104 @@+<!DOCTYPE quirks>+<style>+ @font-face { font-family: Ahem; src: url("../wpt-import/fonts/Ahem.ttf"); }+ body { margin: 0; font: 20px/20px Ahem; }+ .s { font-size: 50px; line-height: 60px; }+ .gen::before { content: ""; font-size: 50px; line-height: 60px; }+ .genblock::before { content: ""; font-size: 50px; line-height: 60px; }+ .case { position: relative; }+</style>+<div class="case" id="block-after-text">x<span class="s"><div style="height: 10px"></div></span></div>+<div class="case" id="block-before-text"><span class="s"><div style="height: 10px"></div></span>y</div>+<div class="case" id="block-between-text"><span class="s">a<div style="height: 10px"></div></span>y</div>+<div class="case" id="block-between-outer-text">x<span class="s"><div style="height: 10px"></div></span>y</div>+<div class="case" id="empty-then-sibling-block">x<span class="s"></span><div style="height: 10px"></div></div>+<div class="case" id="wrap-space-then-empty" style="width: 60px">xx <span class="s"></span>yy</div>+<div class="case" id="wrap-empty-then-space" style="width: 60px">xx<span class="s"></span> yy</div>+<div class="case" id="wrap-space-then-collapsed-space" style="width: 60px">xx <span class="s"> </span>yy</div>+<div class="case" id="wrap-space-in-span" style="width: 60px">xx<span class="s"> </span>yy</div>+<div class="case" id="wrap-anywhere" style="width: 60px; overflow-wrap: anywhere">xxx<span class="s"></span>yy</div>+<div class="case" id="close-after-br"><span class="s">x<br></span>y</div>+<div class="case" id="close-after-wrap" style="width: 60px"><span class="s">xx </span>yy</div>+<div class="case" id="open-before-wrap" style="width: 60px">xx <span class="s">yy</span></div>+<div class="case" id="empty-after-br">x<br><span class="s"></span></div>+<div class="case" id="empty-before-br-then-text"><span class="s"></span><br>x</div>+<div class="case" id="br-in-span-after-text">x<span class="s"><br></span></div>+<div class="case" id="br-then-text-in-span"><span class="s"><br>x</span></div>+<div class="case" id="br-in-nested-b"><span class="s"><b><br></b></span></div>+<div class="case" id="alone"><span class="s"></span></div>+<div class="case" id="alone-top"><span class="s" style="vertical-align: top"></span></div>+<div class="case" id="alone-with-float"><span class="s"></span><div style="float: left; width: 5px; height: 5px"></div></div>+<div class="case" id="alone-with-abspos"><span class="s"><div style="position: absolute"></div></span></div>+<div class="case" id="abspos-only-then-text"><span class="s"><div style="position: absolute"></div></span>x</div>+<div class="case" id="float-only-then-text"><span class="s"><div style="float: left; width: 5px; height: 5px"></div></span>x</div>+<div class="case" id="with-padding"><span class="s" style="padding-left: 1px"></span></div>+<div class="case" id="lh0"><span style="font-size: 50px; line-height: 0"></span>x</div>+<div class="case" id="nested-taller"><span class="s"><span style="line-height: 90px"></span></span>x</div>+<div class="case" id="nested-in-top"><span style="vertical-align: top"><span class="s"></span></span>x</div>+<div class="case" id="nested-shifted"><span class="s"><span style="vertical-align: 30px"></span></span>x</div>+<div class="case" id="nested-outer-shifted"><span style="vertical-align: 30px"><span class="s"></span></span>x</div>+<div class="case" id="two-empties"><span class="s"></span><span class="s" style="vertical-align: top"></span>x</div>+<div class="case" id="rtl" style="direction: rtl"><span class="s"></span>x</div>+<div class="case" id="pre-space"><span class="s" style="white-space: pre"> </span></div>+<div class="case" id="tall-top-image"><span class="s" style="vertical-align: bottom"></span><div style="display: inline-block; width: 5px; height: 100px; vertical-align: top"></div></div>+<div class="case" id="generated"><span class="gen"></span>x</div>+<div class="case genblock" id="generated-on-block">x</div>+<div class="case" id="empty-in-inline-block"><div style="display: inline-block"><span class="s"></span>x</div></div>+<div class="case" id="nowrap-empty" style="width: 60px; white-space: nowrap">xx <span class="s"></span>yy</div>+<div class="case" id="text-then-empty-top">x<span class="s" style="vertical-align: top"></span></div>+<div class="case" id="empty-display-contents"><span class="s"><span style="display: contents"></span></span>x</div>+<div class="case" id="empty-text-node-span"><span class="s"><!-- c --></span>x</div>+<div class="case" id="va-top"><span class="s" style="vertical-align: top"></span>x</div>+<div class="case" id="va-br-top"><span class="s" style="vertical-align: top"><br></span></div>+<div class="case" id="va-bottom"><span class="s" style="vertical-align: bottom"></span>x</div>+<div class="case" id="va-br-bottom"><span class="s" style="vertical-align: bottom"><br></span></div>+<div class="case" id="va-middle"><span class="s" style="vertical-align: middle"></span>x</div>+<div class="case" id="va-10px"><span class="s" style="vertical-align: 10px"></span>x</div>+<div class="case" id="va-br-10px"><span class="s" style="vertical-align: 10px"><br></span></div>+<div class="case" id="va--10px"><span class="s" style="vertical-align: -10px"></span>x</div>+<div class="case" id="va-br--10px"><span class="s" style="vertical-align: -10px"><br></span></div>+<div class="case" id="va-super"><span class="s" style="vertical-align: super"></span>x</div>+<div class="case" id="va-br-super"><span class="s" style="vertical-align: super"><br></span></div>+<div class="case" id="va-sub"><span class="s" style="vertical-align: sub"></span>x</div>+<div class="case" id="va-br-sub"><span class="s" style="vertical-align: sub"><br></span></div>+<div class="case" id="va-text-top"><span class="s" style="vertical-align: text-top"></span>x</div>+<div class="case" id="va-text-bottom"><span class="s" style="vertical-align: text-bottom"></span>x</div>+<div class="case" id="va-br-text-bottom"><span class="s" style="vertical-align: text-bottom"><br></span></div>+<div class="case" id="va-50%"><span class="s" style="vertical-align: 50%"></span>x</div>+<div class="case" id="va-baseline"><span class="s" style="vertical-align: baseline"></span>x</div>+<div class="case" id="va-br-baseline"><span class="s" style="vertical-align: baseline"><br></span></div>+<div class="case v" id="vertical-rl-empty-text" style="writing-mode: vertical-rl; height: 200px"><span class="s"></span>x</div>+<div class="case v" id="vertical-rl-br" style="writing-mode: vertical-rl; height: 200px"><span class="s"><br></span></div>+<div class="case v" id="vertical-rl-alone" style="writing-mode: vertical-rl; height: 200px"><span class="s"></span></div>+<div class="case v" id="vertical-lr-empty-text" style="writing-mode: vertical-lr; height: 200px"><span class="s"></span>x</div>+<div class="case v" id="vertical-lr-br" style="writing-mode: vertical-lr; height: 200px"><span class="s"><br></span></div>+<div class="case v" id="vertical-lr-alone" style="writing-mode: vertical-lr; height: 200px"><span class="s"></span></div>+<div class="case v" id="sideways-rl-empty-text" style="writing-mode: sideways-rl; height: 200px"><span class="s"></span>x</div>+<div class="case v" id="sideways-rl-br" style="writing-mode: sideways-rl; height: 200px"><span class="s"><br></span></div>+<div class="case v" id="sideways-rl-alone" style="writing-mode: sideways-rl; height: 200px"><span class="s"></span></div>+<div class="case" id="abspos-only-after-br">x<br><span class="s"><div style="position: absolute"></div></span></div>+<div class="case" id="abspos-only-after-br-then-text">x<br><span class="s"><div style="position: absolute"></div></span>y</div>+<div class="case" id="empty-after-br-then-text">x<br><span class="s"></span>y</div>+<div class="case" id="empty-after-nested-br"><b>x<br></b><span class="s"></span></div>+<div class="case" id="empty-after-float"><div style="float: left; width: 5px; height: 5px"></div><span class="s"></span>x</div>+<div class="case" id="empty-between-spaces-wrap" style="width: 60px">xx <span class="s"></span> yy</div>+<div class="case" id="two-lines-two-empties" style="width: 60px">xx <span class="s"></span>yy <span class="s"></span>zz</div>+<div class="case" id="pre-wrap-space-then-empty" style="width: 60px; white-space: pre-wrap">xx <span class="s"></span>yy</div>+<div class="case" id="empty-with-margin"><span class="s" style="margin-left: 5px"></span>x</div>+<div class="case" id="empty-with-padding-then-text"><span class="s" style="padding-left: 5px"></span>x</div>+<div class="case" id="wide-space-then-empty" style="width: 300px">xx <span class="s"></span>yy</div>+<div class="case" id="wide-empty-between-spaces" style="width: 300px">xx <span class="s"></span> yy</div>+<div class="case" id="wide-space-in-span" style="width: 300px">xx<span class="s"> </span>yy</div>+<div class="case" id="wide-right-aligned" style="width: 300px; text-align: right">xx <span class="s"></span></div>+<div class="case" id="wide-rtl" style="width: 300px; direction: rtl">xx <span class="s"></span>yy</div>+<div class="case" id="wide-centered-br" style="width: 300px; text-align: center">xx<span class="s"><br></span></div>+<script src="../include.js"></script>+<script>+ promiseTest(async () => {+ await document.fonts.ready;+ for (const element of document.querySelectorAll(".case")) {+ const rect = element.getBoundingClientRect();+ println(`${element.id}: ${element.classList.contains("v") ? rect.width : rect.height}`);+ }+ });+</script>diff --git a/Tests/LibWeb/Text/input/css/inline-box-struts.html b/Tests/LibWeb/Text/input/css/inline-box-struts.htmlnew file mode 100644index 00000000000..ec931ce0e61--- /dev/null+++ b/Tests/LibWeb/Text/input/css/inline-box-struts.html@@ -0,0 +1,111 @@+<!DOCTYPE html>+<style>+ @font-face { font-family: Ahem; src: url("../wpt-import/fonts/Ahem.ttf"); }+ body { margin: 0; font: 20px/20px Ahem; }+ .s { font-size: 50px; line-height: 60px; }+ .gen::before { content: ""; font-size: 50px; line-height: 60px; }+ .genblock::before { content: ""; font-size: 50px; line-height: 60px; }+ .case { position: relative; }+</style>+<div class="case" id="block-after-text">x<span class="s"><div style="height: 10px"></div></span></div>+<div class="case" id="block-before-text"><span class="s"><div style="height: 10px"></div></span>y</div>+<div class="case" id="block-between-text"><span class="s">a<div style="height: 10px"></div></span>y</div>+<div class="case" id="block-between-outer-text">x<span class="s"><div style="height: 10px"></div></span>y</div>+<div class="case" id="empty-then-sibling-block">x<span class="s"></span><div style="height: 10px"></div></div>+<div class="case" id="wrap-space-then-empty" style="width: 60px">xx <span class="s"></span>yy</div>+<div class="case" id="wrap-empty-then-space" style="width: 60px">xx<span class="s"></span> yy</div>+<div class="case" id="wrap-space-then-collapsed-space" style="width: 60px">xx <span class="s"> </span>yy</div>+<div class="case" id="wrap-space-in-span" style="width: 60px">xx<span class="s"> </span>yy</div>+<div class="case" id="wrap-anywhere" style="width: 60px; overflow-wrap: anywhere">xxx<span class="s"></span>yy</div>+<div class="case" id="close-after-br"><span class="s">x<br></span>y</div>+<div class="case" id="close-after-wrap" style="width: 60px"><span class="s">xx </span>yy</div>+<div class="case" id="open-before-wrap" style="width: 60px">xx <span class="s">yy</span></div>+<div class="case" id="empty-after-br">x<br><span class="s"></span></div>+<div class="case" id="empty-before-br-then-text"><span class="s"></span><br>x</div>+<div class="case" id="br-in-span-after-text">x<span class="s"><br></span></div>+<div class="case" id="br-then-text-in-span"><span class="s"><br>x</span></div>+<div class="case" id="br-in-nested-b"><span class="s"><b><br></b></span></div>+<div class="case" id="alone"><span class="s"></span></div>+<div class="case" id="alone-top"><span class="s" style="vertical-align: top"></span></div>+<div class="case" id="alone-with-float"><span class="s"></span><div style="float: left; width: 5px; height: 5px"></div></div>+<div class="case" id="alone-with-abspos"><span class="s"><div style="position: absolute"></div></span></div>+<div class="case" id="abspos-only-then-text"><span class="s"><div style="position: absolute"></div></span>x</div>+<div class="case" id="float-only-then-text"><span class="s"><div style="float: left; width: 5px; height: 5px"></div></span>x</div>+<div class="case" id="with-padding"><span class="s" style="padding-left: 1px"></span></div>+<div class="case" id="lh0"><span style="font-size: 50px; line-height: 0"></span>x</div>+<div class="case" id="lh0-alone-br"><span style="font-size: 50px; line-height: 0"><br></span></div>+<div class="case" id="nested-taller"><span class="s"><span style="line-height: 90px"></span></span>x</div>+<div class="case" id="nested-in-top"><span style="vertical-align: top"><span class="s"></span></span>x</div>+<div class="case" id="nested-shifted"><span class="s"><span style="vertical-align: 30px"></span></span>x</div>+<div class="case" id="nested-outer-shifted"><span style="vertical-align: 30px"><span class="s"></span></span>x</div>+<div class="case" id="two-empties"><span class="s"></span><span class="s" style="vertical-align: top"></span>x</div>+<div class="case" id="rtl" style="direction: rtl"><span class="s"></span>x</div>+<div class="case" id="pre-space"><span class="s" style="white-space: pre"> </span></div>+<div class="case" id="inline-block"><span class="s"></span><div style="display: inline-block; width: 5px; height: 30px"></div></div>+<div class="case" id="tall-top-image"><span class="s" style="vertical-align: bottom"></span><div style="display: inline-block; width: 5px; height: 100px; vertical-align: top"></div></div>+<div class="case" id="generated"><span class="gen"></span>x</div>+<div class="case genblock" id="generated-on-block">x</div>+<div class="case" id="empty-in-inline-block"><div style="display: inline-block"><span class="s"></span>x</div></div>+<div class="case" id="nowrap-empty" style="width: 60px; white-space: nowrap">xx <span class="s"></span>yy</div>+<div class="case" id="text-then-empty-top">x<span class="s" style="vertical-align: top"></span></div>+<div class="case" id="empty-display-contents"><span class="s"><span style="display: contents"></span></span>x</div>+<div class="case" id="empty-text-node-span"><span class="s"><!-- c --></span>x</div>+<div class="case" id="va-top"><span class="s" style="vertical-align: top"></span>x</div>+<div class="case" id="va-br-top"><span class="s" style="vertical-align: top"><br></span></div>+<div class="case" id="va-bottom"><span class="s" style="vertical-align: bottom"></span>x</div>+<div class="case" id="va-br-bottom"><span class="s" style="vertical-align: bottom"><br></span></div>+<div class="case" id="va-10px"><span class="s" style="vertical-align: 10px"></span>x</div>+<div class="case" id="va-br-10px"><span class="s" style="vertical-align: 10px"><br></span></div>+<div class="case" id="va--10px"><span class="s" style="vertical-align: -10px"></span>x</div>+<div class="case" id="va-br--10px"><span class="s" style="vertical-align: -10px"><br></span></div>+<div class="case" id="va-super"><span class="s" style="vertical-align: super"></span>x</div>+<div class="case" id="va-br-super"><span class="s" style="vertical-align: super"><br></span></div>+<div class="case" id="va-sub"><span class="s" style="vertical-align: sub"></span>x</div>+<div class="case" id="va-br-sub"><span class="s" style="vertical-align: sub"><br></span></div>+<div class="case" id="va-text-bottom"><span class="s" style="vertical-align: text-bottom"></span>x</div>+<div class="case" id="va-br-text-bottom"><span class="s" style="vertical-align: text-bottom"><br></span></div>+<div class="case" id="va-50%"><span class="s" style="vertical-align: 50%"></span>x</div>+<div class="case" id="va-br-50%"><span class="s" style="vertical-align: 50%"><br></span></div>+<div class="case" id="va-baseline"><span class="s" style="vertical-align: baseline"></span>x</div>+<div class="case" id="va-br-baseline"><span class="s" style="vertical-align: baseline"><br></span></div>+<div class="case v" id="vertical-rl-empty-text" style="writing-mode: vertical-rl; height: 200px"><span class="s"></span>x</div>+<div class="case v" id="vertical-rl-br" style="writing-mode: vertical-rl; height: 200px"><span class="s"><br></span></div>+<div class="case v" id="vertical-rl-alone" style="writing-mode: vertical-rl; height: 200px"><span class="s"></span></div>+<div class="case v" id="vertical-lr-empty-text" style="writing-mode: vertical-lr; height: 200px"><span class="s"></span>x</div>+<div class="case v" id="vertical-lr-br" style="writing-mode: vertical-lr; height: 200px"><span class="s"><br></span></div>+<div class="case v" id="vertical-lr-alone" style="writing-mode: vertical-lr; height: 200px"><span class="s"></span></div>+<div class="case v" id="sideways-rl-empty-text" style="writing-mode: sideways-rl; height: 200px"><span class="s"></span>x</div>+<div class="case v" id="sideways-rl-br" style="writing-mode: sideways-rl; height: 200px"><span class="s"><br></span></div>+<div class="case v" id="sideways-rl-alone" style="writing-mode: sideways-rl; height: 200px"><span class="s"></span></div>+<div class="case" id="abspos-only-after-br">x<br><span class="s"><div style="position: absolute"></div></span></div>+<div class="case" id="abspos-only-after-br-then-text">x<br><span class="s"><div style="position: absolute"></div></span>y</div>+<div class="case" id="empty-after-br-then-text">x<br><span class="s"></span>y</div>+<div class="case" id="empty-after-nested-br"><b>x<br></b><span class="s"></span></div>+<div class="case" id="empty-after-image"><div style="display: inline-block; width: 5px; height: 5px"></div><span class="s"></span></div>+<div class="case" id="empty-after-float"><div style="float: left; width: 5px; height: 5px"></div><span class="s"></span>x</div>+<div class="case" id="empty-between-spaces-wrap" style="width: 60px">xx <span class="s"></span> yy</div>+<div class="case" id="two-lines-two-empties" style="width: 60px">xx <span class="s"></span>yy <span class="s"></span>zz</div>+<div class="case" id="empty-with-margin"><span class="s" style="margin-left: 5px"></span>x</div>+<div class="case" id="empty-with-padding-then-text"><span class="s" style="padding-left: 5px"></span>x</div>+<div class="case" id="wide-space-then-empty" style="width: 300px">xx <span class="s"></span>yy</div>+<div class="case" id="wide-empty-between-spaces" style="width: 300px">xx <span class="s"></span> yy</div>+<div class="case" id="wide-space-in-span" style="width: 300px">xx<span class="s"> </span>yy</div>+<div class="case" id="wide-right-aligned" style="width: 300px; text-align: right">xx <span class="s"></span></div>+<div class="case" id="wide-centered-br" style="width: 300px; text-align: center">xx<span class="s"><br></span></div>+<script src="../include.js"></script>+<script>+ promiseTest(async () => {+ await document.fonts.ready;+ for (const element of document.querySelectorAll(".case")) {+ const rect = element.getBoundingClientRect();+ let line = `${element.id}: ${element.classList.contains("v") ? rect.width : rect.height}`;+ // NB: The cases that tell which line an inline box is on, or where it is on its line, print its rect.+ const span = element.querySelector("span.s");+ if (span && /wrap|close-after|open-before|two-lines|^wide/.test(element.id)) {+ const spanRect = span.getBoundingClientRect();+ line += ` span@(${spanRect.left - rect.left},${spanRect.top - rect.top} ${spanRect.width}x${spanRect.height})`;+ }+ println(line);+ }+ });+</script>diff --git a/Tests/LibWeb/Text/input/selection-line-boundary-after-newline-in-empty-span.html b/Tests/LibWeb/Text/input/selection-line-boundary-after-newline-in-empty-span.htmlnew file mode 100644index 00000000000..f54c7456fb1--- /dev/null+++ b/Tests/LibWeb/Text/input/selection-line-boundary-after-newline-in-empty-span.html@@ -0,0 +1,14 @@+<!doctype html>+<pre><span id="target">+X</span></pre>+<script src="include.js"></script>+<script>+ test(() => {+ // The first line holds just the newline, and the span's start on it holds no caret position.+ const text = document.getElementById("target").firstChild;+ const selection = getSelection();+ selection.collapse(text, 0);+ selection.modify("extend", "forward", "lineboundary");+ println(`line boundary from offset 0: ${selection.focusOffset}`);+ });+</script>