1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-22 17:15:08 +00:00

LibHTML: Remove trailing whitespace in line boxes

After the splitting-into-lines pass, remove any trailing whitespace
from all of a block's line boxes.

This improves the appearance of text-align: justify/right :^)
This commit is contained in:
Andreas Kling 2019-10-20 17:18:28 +02:00
parent 570c6c8458
commit 3bd29ad98c
5 changed files with 52 additions and 10 deletions

View file

@ -17,9 +17,12 @@ void LineBoxFragment::render(RenderingContext& context)
bool LineBoxFragment::is_justifiable_whitespace() const
{
if (!is<LayoutText>(layout_node()))
return false;
auto& layout_text = to<LayoutText>(layout_node());
auto text = layout_text.node().data().substring_view(m_start, m_length);
return text == " ";
return text() == " ";
}
StringView LineBoxFragment::text() const
{
if (!is<LayoutText>(layout_node()))
return {};
return to<LayoutText>(layout_node()).node().data().substring_view(m_start, m_length);
}