Bug 1278581 - Part 1 - Distinguish between no-last input and very recent user input. r?snorp draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Wed, 21 Mar 2018 20:53:30 +0100
changeset 775255 edc27e880dc2f7cde68dccf6081127cacf10c5e7
parent 775254 803722fa73ee82ad07e90d7892fd5eacefc177d1
child 775256 a866c855956660c383b1cca9da6610540f625978
child 775260 ab10a92a23ab7f4a38d255e56ad40db2b59a094d
child 775264 99d86f385510fd7a50cba892ab2601d53c25fd9f
push id104671
push usermozilla@buttercookie.de
push dateFri, 30 Mar 2018 18:41:23 +0000
reviewerssnorp
bugs1278581
milestone61.0a1
Bug 1278581 - Part 1 - Distinguish between no-last input and very recent user input. r?snorp As suggested during the review of the original patch, we actually need to distinguish between very recent user input (< 1 ms) and no known user input whatsoever. Otherwise, our logic to detect URL loads via the URL bar won't work if the user never interacted with Gecko content and only touched the native Android UI since starting the app. MozReview-Commit-ID: CbZNigwKcjN
dom/base/nsDOMWindowUtils.cpp
dom/interfaces/base/nsIDOMWindowUtils.idl
mobile/android/components/ContentDispatchChooser.js
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -3589,17 +3589,17 @@ nsDOMWindowUtils::GetIsHandlingUserInput
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::GetMillisSinceLastUserInput(double* aMillisSinceLastUserInput)
 {
   TimeStamp lastInput = EventStateManager::LatestUserInputStart();
   if (lastInput.IsNull()) {
-    *aMillisSinceLastUserInput = 0;
+    *aMillisSinceLastUserInput = -1.0f;
     return NS_OK;
   }
 
   *aMillisSinceLastUserInput = (TimeStamp::Now() - lastInput).ToMilliseconds();
   return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/dom/interfaces/base/nsIDOMWindowUtils.idl
+++ b/dom/interfaces/base/nsIDOMWindowUtils.idl
@@ -1644,17 +1644,18 @@ interface nsIDOMWindowUtils : nsISupport
   /**
    * Returns true if a user input is being handled.
    *
    * This calls EventStateManager::IsHandlingUserInput().
    */
   readonly attribute boolean isHandlingUserInput;
 
   /**
-   * Returns milliseconds elapsed since last user input was started
+   * Returns milliseconds elapsed since last user input was started.
+   * Returns -1 if there wasn't any previous user input.
    *
    * This relies on EventStateManager::LatestUserInputStart()
    */
   readonly attribute double millisSinceLastUserInput;
 
   /**
    * After calling the method, the window for which this DOMWindowUtils
    * was created can be closed using scripts.
--- a/mobile/android/components/ContentDispatchChooser.js
+++ b/mobile/android/components/ContentDispatchChooser.js
@@ -80,17 +80,17 @@ ContentDispatchChooser.prototype =
           return;
         }
 
         // We couldn't open this. If this was from a click, it's likely that we just
         // want this to fail silently. If the user entered this on the address bar, though,
         // we want to show the neterror page.
         let dwu = window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
         let millis = dwu.millisSinceLastUserInput;
-        if (millis > 0 && millis >= 1000) {
+        if (millis < 0 || millis >= 1000) {
           window.location.href = data.uri;
         } else {
           this._closeBlankWindow(window);
         }
       });
     }
   },
 };