summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-03-16 18:03:43 +0100
committerAndreas Kling <kling@serenityos.org>2021-03-16 18:10:21 +0100
commitefc6060df08ce05e9e267dc7b7d925930595333c (patch)
tree772102243639894c71b7729c015948c4371d23e1 /Userland
parentd2d69f3efb14e9e68b7ce29c7b9e99aa18dc3d9c (diff)
downloadserenity-efc6060df08ce05e9e267dc7b7d925930595333c.zip
LibWeb: Dispatch "resize" events on the Window object
It's a little awkward that we do this in two places, but IPWV and OOPWV currently implement resizing a little differently from each other so we need to cover both paths.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/Page/Frame.cpp13
-rw-r--r--Userland/Libraries/LibWeb/UIEvents/EventNames.h4
2 files changed, 13 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/Page/Frame.cpp b/Userland/Libraries/LibWeb/Page/Frame.cpp
index 4c90e16fa1..658694aab8 100644
--- a/Userland/Libraries/LibWeb/Page/Frame.cpp
+++ b/Userland/Libraries/LibWeb/Page/Frame.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,12 +25,15 @@
*/
#include <LibWeb/DOM/Document.h>
+#include <LibWeb/DOM/Event.h>
+#include <LibWeb/DOM/Window.h>
#include <LibWeb/HTML/HTMLAnchorElement.h>
#include <LibWeb/InProcessWebView.h>
#include <LibWeb/Layout/BreakNode.h>
#include <LibWeb/Layout/InitialContainingBlockBox.h>
#include <LibWeb/Layout/TextNode.h>
#include <LibWeb/Page/Frame.h>
+#include <LibWeb/UIEvents/EventNames.h>
namespace Web {
@@ -113,8 +116,10 @@ void Frame::set_viewport_rect(const Gfx::IntRect& rect)
if (m_size != rect.size()) {
m_size = rect.size();
- if (m_document)
+ if (m_document) {
+ m_document->window().dispatch_event(DOM::Event::create(UIEvents::EventNames::resize));
m_document->update_layout();
+ }
did_change = true;
}
@@ -134,8 +139,10 @@ void Frame::set_size(const Gfx::IntSize& size)
if (m_size == size)
return;
m_size = size;
- if (m_document)
+ if (m_document) {
+ m_document->window().dispatch_event(DOM::Event::create(UIEvents::EventNames::resize));
m_document->update_layout();
+ }
for (auto* client : m_viewport_clients)
client->frame_did_set_viewport_rect(viewport_rect());
diff --git a/Userland/Libraries/LibWeb/UIEvents/EventNames.h b/Userland/Libraries/LibWeb/UIEvents/EventNames.h
index 3667a32f9b..adb1e3cdd5 100644
--- a/Userland/Libraries/LibWeb/UIEvents/EventNames.h
+++ b/Userland/Libraries/LibWeb/UIEvents/EventNames.h
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2020, the SerenityOS developers.
+ * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -40,7 +41,8 @@ namespace Web::UIEvents::EventNames {
__ENUMERATE_UI_EVENT(mousemove) \
__ENUMERATE_UI_EVENT(mouseout) \
__ENUMERATE_UI_EVENT(mouseover) \
- __ENUMERATE_UI_EVENT(mouseup)
+ __ENUMERATE_UI_EVENT(mouseup) \
+ __ENUMERATE_UI_EVENT(resize)
#define __ENUMERATE_UI_EVENT(name) extern FlyString name;
ENUMERATE_UI_EVENTS