Bug 1406446 - part 2: Android widget should use API of InputContextAction rather than accessing EventStateManager r?jchen draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 24 Oct 2017 02:53:19 +0900
changeset 693073 9342753e9be38d4040d1cdf3da5e1e79c2182351
parent 693072 35eed069c61400825564af003c1468d09c1d458a
child 738943 292aab607fa1c7f6cb0676c4da033c6b17de1b9e
push id87700
push usermasayuki@d-toybox.com
push dateSat, 04 Nov 2017 03:05:21 +0000
reviewersjchen
bugs1406446, 1402461
milestone58.0a1
Bug 1406446 - part 2: Android widget should use API of InputContextAction rather than accessing EventStateManager r?jchen Basically, widget code shouldn't access API in dom/events as far as possible since it's difficult to care widget code when other developers to change under dom/. This patch backouts the patch for bug 1402461 which made GeckoEditableSupport depend on EventStateManager in dom/events. Now, necessary information is in InputContextAction and same condition should be shared with Windows. MozReview-Commit-ID: LMlrizswxUj
widget/android/GeckoEditableSupport.cpp
--- a/widget/android/GeckoEditableSupport.cpp
+++ b/widget/android/GeckoEditableSupport.cpp
@@ -7,17 +7,16 @@
 #include "GeckoEditableSupport.h"
 
 #include "AndroidRect.h"
 #include "KeyEvent.h"
 #include "PuppetWidget.h"
 #include "nsIContent.h"
 #include "nsISelection.h"
 
-#include "mozilla/EventStateManager.h"
 #include "mozilla/IMEStateManager.h"
 #include "mozilla/TextComposition.h"
 #include "mozilla/TextEventDispatcherListener.h"
 #include "mozilla/TextEvents.h"
 
 #include <android/api-level.h>
 #include <android/input.h>
 #include <android/log.h>
@@ -1354,32 +1353,31 @@ GeckoEditableSupport::SetInputContext(co
 {
     MOZ_ASSERT(mEditable);
 
     ALOGIME("IME: SetInputContext: s=0x%X, 0x%X, action=0x%X, 0x%X",
             aContext.mIMEState.mEnabled, aContext.mIMEState.mOpen,
             aAction.mCause, aAction.mFocusChange);
 
     mInputContext = aContext;
-    const bool isUserAction = EventStateManager::IsHandlingUserInput();
 
     if (mInputContext.mIMEState.mEnabled == IMEState::ENABLED &&
-        isUserAction &&
-        aAction.mFocusChange == InputContextAction::FOCUS_NOT_CHANGED) {
+        aAction.UserMightRequestOpenVKB()) {
         // Don't reset keyboard when we should simply open the vkb
         mEditable->NotifyIME(GeckoEditableListener::NOTIFY_IME_OPEN_VKB);
         return;
     }
 
     if (mIMEUpdatingContext) {
         return;
     }
     mIMEUpdatingContext = true;
 
     RefPtr<GeckoEditableSupport> self(this);
+    bool isUserAction = aAction.IsHandlingUserInput();
     nsAppShell::PostEvent([this, self, isUserAction] {
         nsCOMPtr<nsIWidget> widget = GetWidget();
 
         mIMEUpdatingContext = false;
         if (!widget || widget->Destroyed()) {
             return;
         }
         mEditable->NotifyIMEContext(mInputContext.mIMEState.mEnabled,