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:
Andreas Kling 2025-04-18 20:40:14 +02:00 committed by Andreas Kling
parent a122685896
commit 3c15fec303
Notes: github-actions[bot] 2025-04-20 22:32:22 +00:00
11 changed files with 51 additions and 44 deletions

View file

@ -763,7 +763,8 @@ void HTMLImageElement::add_callbacks_to_image_request(GC::Ref<ImageRequest> imag
document().list_of_available_images().add(key, *image_data, true);
set_needs_style_update(true);
set_needs_layout_update(DOM::SetNeedsLayoutReason::HTMLImageElementUpdateTheImageData);
if (auto layout_node = this->layout_node())
layout_node->set_needs_layout_update(DOM::SetNeedsLayoutReason::HTMLImageElementUpdateTheImageData);
// 4. If maybe omit events is not set or previousURL is not equal to urlString, then fire an event named load at the img element.
if (!maybe_omit_events || previous_url != url_string.serialize())
@ -903,7 +904,8 @@ void HTMLImageElement::react_to_changes_in_the_environment()
image_request->prepare_for_presentation(*this);
// FIXME: This is ad-hoc, updating the layout here should probably be handled by prepare_for_presentation().
set_needs_style_update(true);
set_needs_layout_update(DOM::SetNeedsLayoutReason::HTMLImageElementReactToChangesInTheEnvironment);
if (auto layout_node = this->layout_node())
layout_node->set_needs_layout_update(DOM::SetNeedsLayoutReason::HTMLImageElementReactToChangesInTheEnvironment);
// 7. Fire an event named load at the img element.
dispatch_event(DOM::Event::create(realm(), HTML::EventNames::load));