mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 21:29:06 +00:00
LibWeb: Move pessimistic :has() invalidation hack to invalidate_style()
We basically need to do this for every invocation of invalidate_style() right now, so let's just do it inside invalidate_style() itself. Fixes one missing invalidation issue caught by a WPT test. :^)
This commit is contained in:
parent
22a66bb1c2
commit
6dad8ea584
Notes:
github-actions[bot]
2024-10-27 17:41:21 +00:00
Author: https://github.com/awesomekling
Commit: 6dad8ea584
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2002
4 changed files with 14 additions and 29 deletions
|
@ -206,13 +206,7 @@ void Node::set_text_content(Optional<String> const& maybe_content)
|
|||
// Otherwise, do nothing.
|
||||
|
||||
if (is_connected()) {
|
||||
// FIXME: If there are any :has() selectors, we currently invalidate style for the whole document.
|
||||
// We need to find a way to invalidate less!
|
||||
if (document().style_computer().has_has_selectors()) {
|
||||
document().invalidate_style(StyleInvalidationReason::NodeSetTextContent);
|
||||
} else {
|
||||
invalidate_style(StyleInvalidationReason::NodeSetTextContent);
|
||||
}
|
||||
invalidate_style(StyleInvalidationReason::NodeSetTextContent);
|
||||
document().invalidate_layout_tree();
|
||||
}
|
||||
|
||||
|
@ -397,6 +391,13 @@ void Node::invalidate_style(StyleInvalidationReason reason)
|
|||
if (is_character_data())
|
||||
return;
|
||||
|
||||
// FIXME: This is very not optimal! We should figure out a smaller set of elements to invalidate,
|
||||
// but right now the :has() selector means we have to invalidate everything.
|
||||
if (!is_document() && document().style_computer().has_has_selectors()) {
|
||||
document().invalidate_style(reason);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!needs_style_update() && !document().needs_full_style_update()) {
|
||||
dbgln_if(STYLE_INVALIDATION_DEBUG, "Invalidate style ({}): {}", to_string(reason), debug_description());
|
||||
}
|
||||
|
@ -888,13 +889,7 @@ void Node::remove(bool suppress_observers)
|
|||
// Since the tree structure has changed, we need to invalidate both style and layout.
|
||||
// In the future, we should find a way to only invalidate the parts that actually need it.
|
||||
|
||||
// FIXME: If there are any :has() selectors, we currently invalidate style for the whole document.
|
||||
// We need to find a way to invalidate less!
|
||||
if (document().style_computer().has_has_selectors()) {
|
||||
document().invalidate_style(StyleInvalidationReason::NodeRemove);
|
||||
} else {
|
||||
invalidate_style(StyleInvalidationReason::NodeRemove);
|
||||
}
|
||||
invalidate_style(StyleInvalidationReason::NodeRemove);
|
||||
|
||||
// NOTE: If we didn't have a layout node before, rebuilding the layout tree isn't gonna give us one
|
||||
// after we've been removed from the DOM.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue