mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:57:35 +00:00
LibWeb: Swallow whitespace when it causes us to break the line
This fixes an issue seen on Acid3 where the instruction text would shift around when moving from "white-space:pre-wrap" to "white-space:normal".
This commit is contained in:
parent
02e97b3313
commit
f4ed4b2806
1 changed files with 9 additions and 0 deletions
|
@ -253,8 +253,17 @@ void InlineFormattingContext::generate_line_boxes(LayoutMode layout_mode)
|
|||
case InlineLevelIterator::Item::Type::Text: {
|
||||
auto& text_node = verify_cast<Layout::TextNode>(*item.node);
|
||||
if (line_builder.break_if_needed(layout_mode, item.border_box_width())) {
|
||||
// If whitespace caused us to break, we swallow the whitespace instead of
|
||||
// putting it on the next line.
|
||||
|
||||
// If we're in a whitespace-collapsing context, we can simply check the flag.
|
||||
if (item.is_collapsible_whitespace)
|
||||
break;
|
||||
|
||||
// In whitespace-preserving contexts (white-space: pre*), we have to check manually.
|
||||
auto view = text_node.text_for_rendering().substring_view(item.offset_in_node, item.length_in_node);
|
||||
if (view.is_whitespace())
|
||||
break;
|
||||
}
|
||||
line_builder.append_text_chunk(
|
||||
text_node,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue