LibWeb: Fire resize event at VisualViewport in the resize steps

Used on x.com to determine the layout to use on resize.
This commit is contained in:
Luke Wilde 2025-01-28 15:29:05 +00:00 committed by Andreas Kling
parent d21bac8028
commit 18b75afef8
Notes: github-actions[bot] 2025-01-29 08:24:46 +00:00

View file

@ -3191,6 +3191,8 @@ void Document::run_the_resize_steps()
// (e.g. as a result of the user resizing the browser window, or changing the page zoom scale factor,
// or an iframe elements dimensions are changed) since the last time these steps were run,
// fire an event named resize at the Window object associated with doc.
// 2. If the VisualViewport associated with doc has had its scale, width, or height properties changed
// since the last time these steps were run, fire an event named resize at the VisualViewport.
auto viewport_size = viewport_rect().size().to_type<int>();
bool is_initial_size = !m_last_viewport_size.has_value();
@ -3203,6 +3205,10 @@ void Document::run_the_resize_steps()
auto window_resize_event = DOM::Event::create(realm(), UIEvents::EventNames::resize);
window_resize_event->set_is_trusted(true);
window()->dispatch_event(window_resize_event);
auto visual_viewport_resize_event = DOM::Event::create(realm(), UIEvents::EventNames::resize);
visual_viewport_resize_event->set_is_trusted(true);
visual_viewport()->dispatch_event(visual_viewport_resize_event);
}
schedule_layout_update();