1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:37:46 +00:00

LibWeb: Make TextNode::ChunkIterator emit an empty chunk for content:""

This ensures that we create a line box for content:"", which would
otherwise get pruned by the empty line cleanup in IFC.

The empty line box is important in this case, since it gives us a
reference point for measuring the automatic height of the IFC's
containing block. By having an empty line, we can now correctly measure
the impact of vertical margins on a generated box with content:""
and allow them to contribute to the block height.
This commit is contained in:
Andreas Kling 2022-10-14 12:38:02 +02:00
parent c70801ddbc
commit b062a0fb7c
3 changed files with 16 additions and 3 deletions

View file

@ -85,9 +85,10 @@ void TextNode::compute_text_for_rendering(bool collapse)
m_text_for_rendering = builder.to_string();
}
TextNode::ChunkIterator::ChunkIterator(StringView text, bool wrap_lines, bool respect_linebreaks)
TextNode::ChunkIterator::ChunkIterator(StringView text, bool wrap_lines, bool respect_linebreaks, bool is_generated_empty_string)
: m_wrap_lines(wrap_lines)
, m_respect_linebreaks(respect_linebreaks)
, m_should_emit_one_empty_chunk(is_generated_empty_string)
, m_utf8_view(text)
, m_iterator(m_utf8_view.begin())
{
@ -95,6 +96,17 @@ TextNode::ChunkIterator::ChunkIterator(StringView text, bool wrap_lines, bool re
Optional<TextNode::Chunk> TextNode::ChunkIterator::next()
{
if (m_should_emit_one_empty_chunk) {
m_should_emit_one_empty_chunk = false;
return Chunk {
.view = {},
.start = 0,
.length = 0,
.has_breaking_newline = false,
.is_all_whitespace = false,
};
}
if (m_iterator == m_utf8_view.end())
return {};