Bug 1374862 - Avoid setting gHandled when we don't handle signals. r=Masayuki draft
authorBlake Kaplan <mrbkap@gmail.com>
Tue, 20 Jun 2017 17:03:09 -0700
changeset 608636 c9cf17fb4d2214ec31e381990f4ccb951e22af65
parent 608576 16fb9739ca1ee6af945b34715d8ba9730761e33e
child 637373 c65dc836cf9b97e5cad4f3bdced97bef5dbdd159
push id68354
push userbmo:mrbkap@mozilla.com
push dateThu, 13 Jul 2017 22:59:34 +0000
reviewersMasayuki
bugs1374862
milestone56.0a1
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
widget/gtk/NativeKeyBindings.cpp
--- 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];