1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:47:35 +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

@ -23,9 +23,9 @@ public:
void append_text_chunk(TextNode const&, size_t offset_in_node, size_t length_in_node, float leading_size, float trailing_size, float leading_margin, float trailing_margin, float content_width, float content_height);
// Returns whether a line break occurred.
bool break_if_needed(LayoutMode layout_mode, float next_item_width, bool should_force_break)
bool break_if_needed(LayoutMode layout_mode, float next_item_width)
{
if (should_break(layout_mode, next_item_width, should_force_break)) {
if (should_break(layout_mode, next_item_width)) {
break_line();
return true;
}
@ -45,7 +45,7 @@ public:
private:
void begin_new_line(bool increment_y);
bool should_break(LayoutMode, float next_item_width, bool should_force_break);
bool should_break(LayoutMode, float next_item_width);
LineBox& ensure_last_line_box();