From 81daf1752b591c7fbacb710a0625004050776684 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 8 Dec 2023 10:54:40 +0100 Subject: [PATCH] LibWeb: Retreive CSS cursor before changing hovered node This fixes an elusive issue where changing the hovered node would cause a JS event handler to run, changing the shape of the paint tree before we had a chance to get the cursor. A more robust fix here will be to let paintables own their used/computed values (so they don't have to look into the layout tree for them) but that's a much bigger change. --- Userland/Libraries/LibWeb/Page/EventHandler.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp index 385f9fdd75..5398f00b00 100644 --- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp @@ -465,6 +465,7 @@ bool EventHandler::handle_mousemove(CSSPixelPoint position, CSSPixelPoint screen return false; } + auto const cursor = paintable->computed_values().cursor(); auto pointer_events = paintable->computed_values().pointer_events(); // FIXME: Handle other values for pointer-events. VERIFY(pointer_events != CSS::PointerEvents::None); @@ -482,13 +483,11 @@ bool EventHandler::handle_mousemove(CSSPixelPoint position, CSSPixelPoint screen is_hovering_link = true; if (node->is_text()) { - auto cursor = paintable->computed_values().cursor(); if (cursor == CSS::Cursor::Auto) hovered_node_cursor = Gfx::StandardCursor::IBeam; else hovered_node_cursor = cursor_css_to_gfx(cursor); } else if (node->is_element()) { - auto cursor = paintable->computed_values().cursor(); if (cursor == CSS::Cursor::Auto) hovered_node_cursor = Gfx::StandardCursor::Arrow; else