From f908a2718a7b1ecc7d8bea790596d02856c48356 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 3 Oct 2019 16:49:32 +0200 Subject: [PATCH] LibHTML: Make "white-space: pre" kinda work This is not ideal, as refusing to break lines will easily overflow the containing block, and we have no way of dealing with overflow yet. But as long as you provide enough width, it does look nice. :^) --- Libraries/LibHTML/Layout/LayoutText.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Libraries/LibHTML/Layout/LayoutText.cpp b/Libraries/LibHTML/Layout/LayoutText.cpp index fc7f5d7289..663a3e10b1 100644 --- a/Libraries/LibHTML/Layout/LayoutText.cpp +++ b/Libraries/LibHTML/Layout/LayoutText.cpp @@ -157,10 +157,14 @@ void LayoutText::for_each_source_line(Callback callback) const }; for (auto it = view.begin(); it != view.end();) { - if (*it == '\n') + bool did_commit = false; + if (*it == '\n') { commit_line(it); + did_commit = true; + } ++it; - start_of_line = it; + if (did_commit) + start_of_line = it; } if (start_of_line != view.end()) commit_line(view.end());