Bug 1447866 - GeckoEditableSupport::SendIMEDummyKeyEvent() should set native key bindings to none before dispatching keyboard events which are marked as "processed by IME" r?esawin draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 23 Mar 2018 11:54:01 +0900
changeset 772475 058452225359f9dccab02a8226dfe87e649b38e6
parent 772474 e212c731c9c3fe379088f31264f39e798c11c172
child 772555 07e519237781310077e821650a45d8297b583b0c
push id103919
push usermasayuki@d-toybox.com
push dateMon, 26 Mar 2018 06:36:16 +0000
reviewersesawin
bugs1447866
milestone61.0a1
Bug 1447866 - GeckoEditableSupport::SendIMEDummyKeyEvent() should set native key bindings to none before dispatching keyboard events which are marked as "processed by IME" r?esawin When EditorEventListener receives keyboard events, it tries to execute native key bindings which are stored by each keyboard event. For performance reason in e10s, TabParent initializes native key binding information of every keyboard event before sending it to the remote process. Therefore, PuppetWidget checks if every keyboard event has native key binding information. However, the native key binding information of dummy keyboard events marked as "processed by IME" on Android are never initialized before sending PuppetWidget. Therefore, we hit MOZ_ASSERT in PuppetWidget. This patch makes GeckoEditableSuppor::SendIMEDummyKeyEvent() set native key binding information to "none" before dispatching every keyboard event since keyboard events during composition shouldn't cause any edit actions. MozReview-Commit-ID: Bk532ahCQP6
widget/android/GeckoEditableSupport.cpp
--- a/widget/android/GeckoEditableSupport.cpp
+++ b/widget/android/GeckoEditableSupport.cpp
@@ -695,16 +695,21 @@ GeckoEditableSupport::SendIMEDummyKeyEve
     WidgetKeyboardEvent event(true, msg, aWidget);
     event.mTime = PR_Now() / 1000;
     // TODO: If we can know scan code of the key event which caused replacing
     //       composition string, we should set mCodeNameIndex here.  Then,
     //       we should rename this method because it becomes not a "dummy"
     //       keyboard event.
     event.mKeyCode = NS_VK_PROCESSKEY;
     event.mKeyNameIndex = KEY_NAME_INDEX_Process;
+    // KeyboardEvents marked as "processed by IME" shouldn't cause any edit
+    // actions.  So, we should set their native key binding to none before
+    // dispatch to avoid crash on PuppetWidget and avoid running redundant
+    // path to look for native key bindings.
+    event.PreventNativeKeyBindings();
     NS_ENSURE_SUCCESS_VOID(BeginInputTransaction(mDispatcher));
     mDispatcher->DispatchKeyboardEvent(msg, event, status);
 }
 
 void
 GeckoEditableSupport::AddIMETextChange(const IMETextChange& aChange)
 {
     mIMETextChanges.AppendElement(aChange);