summaryrefslogtreecommitdiff
path: root/Libraries/LibWeb/Layout/LineBox.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-06-13 14:59:17 +0200
committerAndreas Kling <kling@serenityos.org>2020-06-13 15:03:16 +0200
commit07ccaa1934395494825606526ed51c1d5c652555 (patch)
tree35be5bce7afe59c27becec78943cb63a480b07a5 /Libraries/LibWeb/Layout/LineBox.cpp
parent4ab1b0b43681323e5d0e6b0572781ff70ab74a15 (diff)
downloadserenity-07ccaa1934395494825606526ed51c1d5c652555.zip
LibWeb: Teach line layout to collapse whitespace across fragments
This kind of HTML now produces a single piece of whitespace: <span> </span> <span> </span> <span> </span> We achieve this by checking if the last fragment on the last line ends in whitespace. If so, we either don't add a fragment at all (for the current chunk) or we simply skip over all whitespace at the head of the current chunk (instead of collapsing it to a single ' '.)
Diffstat (limited to 'Libraries/LibWeb/Layout/LineBox.cpp')
-rw-r--r--Libraries/LibWeb/Layout/LineBox.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/Libraries/LibWeb/Layout/LineBox.cpp b/Libraries/LibWeb/Layout/LineBox.cpp
index e9842e391f..b4ae0e08f8 100644
--- a/Libraries/LibWeb/Layout/LineBox.cpp
+++ b/Libraries/LibWeb/Layout/LineBox.cpp
@@ -73,4 +73,11 @@ void LineBox::trim_trailing_whitespace()
}
}
+bool LineBox::ends_in_whitespace() const
+{
+ if (m_fragments.is_empty())
+ return false;
+ return m_fragments.last().ends_in_whitespace();
+}
+
}