From 910fded48240a63b37154c5da20103b29122bbd9 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 16 Mar 2022 18:50:56 +0100 Subject: [PATCH] LibWeb: Flush any pending layout updates before processing mouse events We want to make sure the layout and paint trees are up-to-date before handling any mouse events. --- Userland/Libraries/LibWeb/Page/EventHandler.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp index 4ddd821db6..c92bfecf1d 100644 --- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp @@ -129,6 +129,9 @@ Painting::PaintableBox const* EventHandler::paint_root() const bool EventHandler::handle_mousewheel(const Gfx::IntPoint& position, unsigned int buttons, unsigned int modifiers, int wheel_delta_x, int wheel_delta_y) { + if (m_browsing_context.active_document()) + m_browsing_context.active_document()->update_layout(); + if (!paint_root()) return false; @@ -151,6 +154,9 @@ bool EventHandler::handle_mousewheel(const Gfx::IntPoint& position, unsigned int bool EventHandler::handle_mouseup(const Gfx::IntPoint& position, unsigned button, unsigned modifiers) { + if (m_browsing_context.active_document()) + m_browsing_context.active_document()->update_layout(); + if (!paint_root()) return false; @@ -203,6 +209,9 @@ bool EventHandler::handle_mouseup(const Gfx::IntPoint& position, unsigned button bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned button, unsigned modifiers) { + if (m_browsing_context.active_document()) + m_browsing_context.active_document()->update_layout(); + if (!paint_root()) return false; @@ -324,6 +333,9 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned buttons, unsigned modifiers) { + if (m_browsing_context.active_document()) + m_browsing_context.active_document()->update_layout(); + if (!paint_root()) return false;