Skip to content

Commit

Permalink
Cherry-pick 268085@main (ab8e3bc). https://bugs.webkit.org/show_bug.c…
Browse files Browse the repository at this point in the history
…gi?id=261674

    [GTK4] NativeWebWheelEvent crashes on wheel event tests
    https://bugs.webkit.org/show_bug.cgi?id=261674

    Reviewed by Michael Catanzaro.

    The GdkEvent API in GTK4 won't play ball when given a NULL event.
    When synthesizing wheel events we might pass a NULL event to the
    event factory, so make sure that the methods that call GDK API
    on it are NULL-safe.

    * Source/WebCore/platform/gtk/GtkUtilities.cpp:
    (WebCore::wallTimeForEvent):
    * Source/WebKit/Shared/gtk/WebEventFactory.cpp:
    (WebKit::modifiersForEvent):

    Canonical link: https://commits.webkit.org/268085@main
  • Loading branch information
csaavedra authored and aperezdc committed Oct 19, 2023
1 parent c29a26a commit fab6790
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Source/WebCore/platform/gtk/GtkUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ WallTime wallTimeForEvent(const GdkEvent* event)
// g_get_monotonic_time() continues to do so as well, and so long as
// MonotonicTime continues to use g_get_monotonic_time().
#if USE(GTK4)
if (!event)
return WallTime::now();
auto time = gdk_event_get_time(const_cast<GdkEvent*>(event));
#else
auto time = gdk_event_get_time(event);
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/Shared/gtk/WebEventFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static inline OptionSet<WebEventModifier> modifiersForEvent(const GdkEvent* even
GdkModifierType state;

// Check for a valid state in GdkEvent.
if (!gdk_event_get_state(event, &state))
if (!event || !gdk_event_get_state(event, &state))
return modifiers;

if (state & GDK_CONTROL_MASK)
Expand Down

0 comments on commit fab6790

Please sign in to comment.