From 4966fa4aedcef92ff916d533d6496f922f023362 Mon Sep 17 00:00:00 2001 From: Gingeh <39150378+Gingeh@users.noreply.github.com> Date: Fri, 14 Feb 2025 20:58:38 +1100 Subject: [PATCH] LibWeb: Prevent crash with custom cursor We don't support custom cursors, use the default instead of crashing. Also clean up a bit of dead code from when Cursor was optional. --- Libraries/LibWeb/CSS/ComputedProperties.cpp | 3 +++ Libraries/LibWeb/Page/EventHandler.cpp | 7 ++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Libraries/LibWeb/CSS/ComputedProperties.cpp b/Libraries/LibWeb/CSS/ComputedProperties.cpp index b87179ddedc..3d449625fb2 100644 --- a/Libraries/LibWeb/CSS/ComputedProperties.cpp +++ b/Libraries/LibWeb/CSS/ComputedProperties.cpp @@ -953,6 +953,9 @@ ContentVisibility ComputedProperties::content_visibility() const Cursor ComputedProperties::cursor() const { auto const& value = property(PropertyID::Cursor); + // FIXME: We don't currently support custom cursors. + if (value.is_url()) + return Cursor::Auto; return keyword_to_cursor(value.to_keyword()).release_value(); } diff --git a/Libraries/LibWeb/Page/EventHandler.cpp b/Libraries/LibWeb/Page/EventHandler.cpp index e64658b93c9..4076719dda9 100644 --- a/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Libraries/LibWeb/Page/EventHandler.cpp @@ -83,12 +83,9 @@ static bool parent_element_for_event_dispatch(Painting::Paintable& paintable, GC return node && layout_node; } -static Gfx::StandardCursor cursor_css_to_gfx(Optional cursor) +static Gfx::StandardCursor cursor_css_to_gfx(CSS::Cursor cursor) { - if (!cursor.has_value()) { - return Gfx::StandardCursor::None; - } - switch (cursor.value()) { + switch (cursor) { case CSS::Cursor::Crosshair: case CSS::Cursor::Cell: return Gfx::StandardCursor::Crosshair;