mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-29 04:39:10 +00:00
LibWeb: Move "needs layout update" flag from DOM to layout tree
This is in preparation for allowing anonymous boxes to retain their intrinsic size cache across layouts.
This commit is contained in:
parent
a122685896
commit
3c15fec303
Notes:
github-actions[bot]
2025-04-20 22:32:22 +00:00
Author: https://github.com/awesomekling
Commit: 3c15fec303
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4411
11 changed files with 51 additions and 44 deletions
|
@ -1281,4 +1281,25 @@ void NodeWithStyleAndBoxModelMetrics::visit_edges(Cell::Visitor& visitor)
|
|||
visitor.visit(m_continuation_of_node);
|
||||
}
|
||||
|
||||
void Node::set_needs_layout_update(DOM::SetNeedsLayoutReason reason)
|
||||
{
|
||||
if (m_needs_layout_update)
|
||||
return;
|
||||
|
||||
if constexpr (UPDATE_LAYOUT_DEBUG) {
|
||||
// NOTE: We check some conditions here to avoid debug spam in documents that don't do layout.
|
||||
auto navigable = this->navigable();
|
||||
if (navigable && navigable->active_document() == &document())
|
||||
dbgln_if(UPDATE_LAYOUT_DEBUG, "NEED LAYOUT {}", DOM::to_string(reason));
|
||||
}
|
||||
|
||||
m_needs_layout_update = true;
|
||||
|
||||
for (auto* ancestor = parent(); ancestor; ancestor = ancestor->parent()) {
|
||||
if (ancestor->m_needs_layout_update)
|
||||
break;
|
||||
ancestor->m_needs_layout_update = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2023, Andreas Kling <andreas@ladybird.org>
|
||||
* Copyright (c) 2018-2025, Andreas Kling <andreas@ladybird.org>
|
||||
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -45,6 +45,10 @@ public:
|
|||
DOM::Element const* pseudo_element_generator() const;
|
||||
DOM::Element* pseudo_element_generator();
|
||||
|
||||
bool needs_layout_update() const { return m_needs_layout_update; }
|
||||
void set_needs_layout_update(DOM::SetNeedsLayoutReason);
|
||||
void reset_needs_layout_update() { m_needs_layout_update = false; }
|
||||
|
||||
bool is_generated() const { return m_generated_for.has_value(); }
|
||||
bool is_generated_for_before_pseudo_element() const { return m_generated_for == CSS::GeneratedPseudoElement::Before; }
|
||||
bool is_generated_for_after_pseudo_element() const { return m_generated_for == CSS::GeneratedPseudoElement::After; }
|
||||
|
@ -215,6 +219,8 @@ private:
|
|||
|
||||
bool m_has_been_wrapped_in_table_wrapper { false };
|
||||
|
||||
bool m_needs_layout_update { false };
|
||||
|
||||
Optional<CSS::GeneratedPseudoElement> m_generated_for {};
|
||||
|
||||
u32 m_initial_quote_nesting_level { 0 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue