Bug 1344752 - Guard against blurring when replacing text; r=esawin
authorJim Chen <nchen@mozilla.com>
Fri, 10 Mar 2017 14:10:15 -0500
changeset 347172 72479abe01240e9a7a4f49dca9abf2d84b264f74
parent 347171 ffeffef36f34c0cf16aed96e2f8bb06af07a2a4c
child 347173 1ed753667e0bbedc381c2322bcae5dc8a3f264d4
push id31491
push usercbook@mozilla.com
push dateMon, 13 Mar 2017 14:24:00 +0000
treeherdermozilla-central@8d9fd089cabd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin
bugs1344752
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1344752 - Guard against blurring when replacing text; r=esawin Inside OnImeReplaceText, an action can cause the editor to blur and mDispatcher to be reset. We should guard against that and abandon subsequent actions.
widget/android/GeckoEditableSupport.cpp
--- a/widget/android/GeckoEditableSupport.cpp
+++ b/widget/android/GeckoEditableSupport.cpp
@@ -806,61 +806,61 @@ GeckoEditableSupport::OnImeReplaceText(i
                     AutoCacheNativeKeyCommands autoCache(
                             static_cast<PuppetWidget*>(widget.get()));
                     // Don't use native key bindings.
                     autoCache.CacheNoCommands();
                     mDispatcher->MaybeDispatchKeypressEvents(*event, status);
                 } else {
                     mDispatcher->MaybeDispatchKeypressEvents(*event, status);
                 }
-                if (widget->Destroyed()) {
+                if (!mDispatcher || widget->Destroyed()) {
                     break;
                 }
             }
             mIMEKeyEvents.Clear();
             return;
         }
 
         if (aStart != aEnd) {
             // Perform a deletion first.
             WidgetContentCommandEvent event(
                     true, eContentCommandDelete, widget);
             event.mTime = PR_Now() / 1000;
             widget->DispatchEvent(&event, status);
-            if (widget->Destroyed()) {
+            if (!mDispatcher || widget->Destroyed()) {
                 return;
             }
         }
     } else if (composition->String().Equals(string)) {
         /* If the new text is the same as the existing composition text,
          * the NS_COMPOSITION_CHANGE event does not generate a text
          * change notification. However, the Java side still expects
          * one, so we manually generate a notification. */
         IMETextChange dummyChange;
         dummyChange.mStart = aStart;
         dummyChange.mOldEnd = dummyChange.mNewEnd = aEnd;
         AddIMETextChange(dummyChange);
     }
 
     if (mInputContext.mMayBeIMEUnaware) {
         SendIMEDummyKeyEvent(widget, eKeyDown);
-        if (widget->Destroyed()) {
+        if (!mDispatcher || widget->Destroyed()) {
             return;
         }
     }
 
     if (composing) {
         mDispatcher->SetPendingComposition(string, mIMERanges);
         mDispatcher->FlushPendingComposition(status);
         // Ensure IME ranges are empty.
         mIMERanges->Clear();
     } else if (!string.IsEmpty() || mDispatcher->IsComposing()) {
         mDispatcher->CommitComposition(status, &string);
     }
-    if (widget->Destroyed()) {
+    if (!mDispatcher || widget->Destroyed()) {
         return;
     }
 
     if (mInputContext.mMayBeIMEUnaware) {
         SendIMEDummyKeyEvent(widget, eKeyUp);
         // Widget may be destroyed after dispatching the above event.
     }
 }