1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 18:20:43 +09:00

LibWeb: Let HTML::EventLoop drive the firing of resize events

This commit is contained in:
Andreas Kling 2021-10-03 16:42:03 +02:00
parent 81ef2b646e
commit 6e341cd696
Notes: sideshowbarker 2024-07-18 04:38:32 +09:00
4 changed files with 38 additions and 11 deletions

View file

@ -57,6 +57,7 @@
#include <LibWeb/Page/BrowsingContext.h>
#include <LibWeb/Page/Page.h>
#include <LibWeb/SVG/TagNames.h>
#include <LibWeb/UIEvents/EventNames.h>
#include <LibWeb/UIEvents/KeyboardEvent.h>
#include <LibWeb/UIEvents/MouseEvent.h>
@ -1083,4 +1084,25 @@ String Document::visibility_state() const
return hidden() ? "hidden" : "visible";
}
// https://drafts.csswg.org/cssom-view/#run-the-resize-steps
void Document::run_the_resize_steps()
{
// 1. If docs viewport has had its width or height changed
// (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.
if (!browsing_context())
return;
auto viewport_size = browsing_context()->viewport_rect().size();
if (m_last_viewport_size == viewport_size)
return;
m_last_viewport_size = viewport_size;
dispatch_event(DOM::Event::create(UIEvents::EventNames::resize));
update_layout();
}
}