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.
This commit is contained in:
Andreas Kling 2023-12-08 10:54:40 +01:00
parent 8118ea764f
commit 81daf1752b

View file

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