Przeglądaj źródła

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. :^)
Andreas Kling 5 lat temu
rodzic
commit
f908a2718a
1 zmienionych plików z 6 dodań i 2 usunięć
  1. 6 2
      Libraries/LibHTML/Layout/LayoutText.cpp

+ 6 - 2
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();) {
     for (auto it = view.begin(); it != view.end();) {
-        if (*it == '\n')
+        bool did_commit = false;
+        if (*it == '\n') {
             commit_line(it);
             commit_line(it);
+            did_commit = true;
+        }
         ++it;
         ++it;
-        start_of_line = it;
+        if (did_commit)
+            start_of_line = it;
     }
     }
     if (start_of_line != view.end())
     if (start_of_line != view.end())
         commit_line(view.end());
         commit_line(view.end());