1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:37:37 +00:00

LibWeb: Make text newlines in "pre" mode emit a ForcedBreak item

Instead of emitting a Text item with the "should_force_break" flag set
to true, newlines in newline-preserving text content now timply turn
into ForcedBreak items. This makes the <pre> element work again.
This commit is contained in:
Andreas Kling 2022-03-26 18:59:54 +01:00
parent d32630e17b
commit aefe1727fc
6 changed files with 14 additions and 11 deletions

View file

@ -142,13 +142,19 @@ Optional<InlineLevelIterator::Item> InlineLevelIterator::next(float available_wi
auto& chunk = chunk_opt.value();
float chunk_width = text_node.font().width(chunk.view) + text_node.font().glyph_spacing();
if (m_text_node_context->do_respect_linebreaks && chunk.has_breaking_newline) {
return Item {
.type = Item::Type::ForcedBreak,
};
}
Item item {
.type = Item::Type::Text,
.node = &text_node,
.offset_in_node = chunk.start,
.length_in_node = chunk.length,
.width = chunk_width,
.should_force_break = m_text_node_context->do_respect_linebreaks && chunk.has_breaking_newline,
.is_collapsible_whitespace = m_text_node_context->do_collapse && chunk.is_all_whitespace,
};