mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:28:11 +00:00
LibWeb: Make whitespace collapsing stateless
Previously, the whitespace collapsing code had a parameter telling it whether the previous text node ended in whitespace. This was not actually necessary, so let's get rid of it.
This commit is contained in:
parent
66582a875f
commit
4575ab558b
4 changed files with 10 additions and 19 deletions
|
@ -123,11 +123,8 @@ Optional<InlineLevelIterator::Item> InlineLevelIterator::next(float available_wi
|
|||
if (is<Layout::TextNode>(*m_current_node)) {
|
||||
auto& text_node = static_cast<Layout::TextNode const&>(*m_current_node);
|
||||
|
||||
if (!m_text_node_context.has_value()) {
|
||||
auto& line_boxes = m_formatting_state.get(m_container).line_boxes;
|
||||
bool previous_is_empty_or_ends_in_whitespace = line_boxes.is_empty() || line_boxes.last().is_empty_or_ends_in_whitespace();
|
||||
enter_text_node(text_node, previous_is_empty_or_ends_in_whitespace);
|
||||
}
|
||||
if (!m_text_node_context.has_value())
|
||||
enter_text_node(text_node);
|
||||
|
||||
auto chunk_opt = m_text_node_context->next_chunk;
|
||||
if (!chunk_opt.has_value()) {
|
||||
|
@ -225,7 +222,7 @@ Optional<InlineLevelIterator::Item> InlineLevelIterator::next(float available_wi
|
|||
return item;
|
||||
}
|
||||
|
||||
void InlineLevelIterator::enter_text_node(Layout::TextNode const& text_node, bool previous_is_empty_or_ends_in_whitespace)
|
||||
void InlineLevelIterator::enter_text_node(Layout::TextNode const& text_node)
|
||||
{
|
||||
bool do_collapse = true;
|
||||
bool do_wrap_lines = true;
|
||||
|
@ -250,7 +247,7 @@ void InlineLevelIterator::enter_text_node(Layout::TextNode const& text_node, boo
|
|||
}
|
||||
|
||||
// FIXME: The const_cast here is gross.
|
||||
const_cast<TextNode&>(text_node).compute_text_for_rendering(do_collapse, previous_is_empty_or_ends_in_whitespace);
|
||||
const_cast<TextNode&>(text_node).compute_text_for_rendering(do_collapse);
|
||||
|
||||
m_text_node_context = TextNodeContext {
|
||||
.do_collapse = do_collapse,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue