mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:38:11 +00:00
LibWeb: Pass correct state to TextNode::compute_text_for_rendering()
This is poorly factored. TextNode needs to know whether the most recently inserted fragment on the current line was empty or ended in whitespace. This is used when deciding what to do with leading whitespace in text nodes. Let's keep this working for now, but we should eventually sort this out and make text chunk iteration not depend on this information.
This commit is contained in:
parent
36e2799131
commit
b1fd801436
2 changed files with 7 additions and 6 deletions
|
@ -45,8 +45,10 @@ Optional<InlineLevelIterator::Item> InlineLevelIterator::next(float available_wi
|
|||
if (is<Layout::TextNode>(*m_current_node)) {
|
||||
auto& text_node = static_cast<Layout::TextNode&>(*m_current_node);
|
||||
|
||||
if (!m_text_node_context.has_value())
|
||||
enter_text_node(text_node);
|
||||
if (!m_text_node_context.has_value()) {
|
||||
bool previous_is_empty_or_ends_in_whitespace = m_container.line_boxes().is_empty() || m_container.line_boxes().last().is_empty_or_ends_in_whitespace();
|
||||
enter_text_node(text_node, previous_is_empty_or_ends_in_whitespace);
|
||||
}
|
||||
|
||||
auto chunk_opt = m_text_node_context->chunk_iterator.next();
|
||||
if (!chunk_opt.has_value()) {
|
||||
|
@ -104,7 +106,7 @@ Optional<InlineLevelIterator::Item> InlineLevelIterator::next(float available_wi
|
|||
};
|
||||
}
|
||||
|
||||
void InlineLevelIterator::enter_text_node(Layout::TextNode& text_node)
|
||||
void InlineLevelIterator::enter_text_node(Layout::TextNode& text_node, bool previous_is_empty_or_ends_in_whitespace)
|
||||
{
|
||||
bool do_collapse = true;
|
||||
bool do_wrap_lines = true;
|
||||
|
@ -128,8 +130,7 @@ void InlineLevelIterator::enter_text_node(Layout::TextNode& text_node)
|
|||
do_respect_linebreaks = true;
|
||||
}
|
||||
|
||||
// FIXME: Pass the correct value for the last boolean!
|
||||
text_node.compute_text_for_rendering(do_collapse, true);
|
||||
text_node.compute_text_for_rendering(do_collapse, previous_is_empty_or_ends_in_whitespace);
|
||||
|
||||
m_text_node_context = TextNodeContext {
|
||||
.do_collapse = do_collapse,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue