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
--- 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);
}
});
}
},
};