Bug 1409113 - Add nsIPresShell::HasHandledUserInput() status to InputContext r=masayuki a=Sylvestre
authorJames Willcox <snorp@snorp.net>
Tue, 21 Nov 2017 16:28:36 -0600
changeset 704531 c97b0b34d8cc61d33138ee8b9ad73c5c2c21fea2
parent 704530 60ef3560d15ae3f7b8efa5833a14c5f12f6f56e6
child 704532 d0eadbf8ab5bda4be4aecdbb08df007e138760c1
push id91167
push userbmo:csadilek@mozilla.com
push dateTue, 28 Nov 2017 16:21:38 +0000
reviewersmasayuki, Sylvestre
bugs1409113
milestone58.0
Bug 1409113 - Add nsIPresShell::HasHandledUserInput() status to InputContext r=masayuki a=Sylvestre MozReview-Commit-ID: 60x35NKEzhA
dom/events/IMEStateManager.cpp
widget/IMEData.h
--- a/dom/events/IMEStateManager.cpp
+++ b/dom/events/IMEStateManager.cpp
@@ -1274,16 +1274,19 @@ IMEStateManager::SetIMEState(const IMESt
   NS_ENSURE_TRUE_VOID(aWidget);
 
   InputContext context;
   context.mIMEState = aState;
   context.mOrigin = aOrigin;
   context.mMayBeIMEUnaware = context.mIMEState.IsEditable() &&
     sCheckForIMEUnawareWebApps && MayBeIMEUnawareWebApp(aContent);
 
+  context.mHasHandledUserInput =
+    aPresContext && aPresContext->PresShell()->HasHandledUserInput();
+
   context.mInPrivateBrowsing =
     aPresContext &&
     nsContentUtils::IsInPrivateBrowsing(aPresContext->Document());
 
   if (aContent &&
       aContent->IsAnyOfHTMLElements(nsGkAtoms::input, nsGkAtoms::textarea)) {
     if (!aContent->IsHTMLElement(nsGkAtoms::textarea)) {
       // <input type=number> has an anonymous <input type=text> descendant
--- a/widget/IMEData.h
+++ b/widget/IMEData.h
@@ -320,16 +320,21 @@ struct InputContext final
   };
   Origin mOrigin;
 
   /* True if the webapp may be unaware of IME events such as input event or
    * composiion events. This enables a key-events-only mode on Android for
    * compatibility with webapps relying on key listeners. */
   bool mMayBeIMEUnaware;
 
+  /**
+   * True if the document has ever received user input
+   */
+  bool mHasHandledUserInput;
+
   /* Whether the owning document of the input element has been loaded
    * in private browsing mode. */
   bool mInPrivateBrowsing;
 
   bool IsOriginMainProcess() const
   {
     return mOrigin == ORIGIN_MAIN;
   }