1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:07:44 +00:00

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.
This commit is contained in:
Andreas Kling 2022-03-16 18:50:56 +01:00
parent 0e8b538e0a
commit 910fded482

View file

@ -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;