LibWeb: Ensure Elements don't need style update after computing style

Previously, we set the "needs style update" flag to false at the
beginning of recomputing the style. This meant that if any code within
the cascade set this flag to true, then we would end style computation
thinking the element still needed its style updating. This could occur
when starting a transition, and would make TreeBuilder crash.

By ensuring that we always set the flag to false at the very end of
style computation, this is avoided, along with any similar issues - I
noticed a comment in `Animation::cancel()` which sounds like a
workaround was needed for a similar problem previously.
This commit is contained in:
Sam Atkins 2024-09-30 11:18:55 +01:00 committed by Andreas Kling
parent de588a97c0
commit 8c79edac08
Notes: github-actions[bot] 2024-09-30 11:05:50 +00:00
2 changed files with 2 additions and 1 deletions

View file

@ -2298,6 +2298,8 @@ RefPtr<StyleProperties> StyleComputer::compute_style_impl(DOM::Element& element,
return style;
}
ScopeGuard guard { [&element]() { element.set_needs_style_update(false); } };
auto style = StyleProperties::create();
// 1. Perform the cascade. This produces the "specified style"
bool did_match_any_pseudo_element_rules = false;

View file

@ -533,7 +533,6 @@ static CSS::RequiredInvalidationAfterStyleChange compute_required_invalidation(C
CSS::RequiredInvalidationAfterStyleChange Element::recompute_style()
{
set_needs_style_update(false);
VERIFY(parent());
auto& style_computer = document().style_computer();