Bug 1374862 - Avoid setting gHandled when we don't handle signals. r=Masayuki
This avoids a fatal assertion for some key events when focus isn't on a text
input.
MozReview-Commit-ID: Hqr6LNW61Kn
--- a/widget/gtk/NativeKeyBindings.cpp
+++ b/widget/gtk/NativeKeyBindings.cpp
@@ -59,16 +59,21 @@ static const Command sDeleteCommands[][2
{ CommandDoNothing, CommandDoNothing } // WHITESPACE
};
static void
delete_from_cursor_cb(GtkWidget *w, GtkDeleteType del_type,
gint count, gpointer user_data)
{
g_signal_stop_emission_by_name(w, "delete_from_cursor");
+ if (count == 0) {
+ // Nothing to do.
+ return;
+ }
+
bool forward = count > 0;
#if (MOZ_WIDGET_GTK == 3)
// Ignore GTK's Ctrl-K keybinding introduced in GTK 3.14 and removed in
// 3.18 if the user has custom bindings set. See bug 1176929.
if (del_type == GTK_DELETE_PARAGRAPH_ENDS && forward && GTK_IS_ENTRY(w) &&
!gtk_check_version(3, 14, 1) && gtk_check_version(3, 17, 9)) {
GtkStyleContext* context = gtk_widget_get_style_context(w);
@@ -168,16 +173,21 @@ static const Command sMoveCommands[][2][
}
};
static void
move_cursor_cb(GtkWidget *w, GtkMovementStep step, gint count,
gboolean extend_selection, gpointer user_data)
{
g_signal_stop_emission_by_name(w, "move_cursor");
+ if (count == 0) {
+ // Nothing to do.
+ return;
+ }
+
gHandled = true;
bool forward = count > 0;
if (uint32_t(step) >= ArrayLength(sMoveCommands)) {
// unsupported movement type
return;
}
Command command = sMoveCommands[step][extend_selection][forward];