Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3610)

Unified Diff: chrome/browser/resources/uber/uber_utils.js

Issue 682393002: history/settings/extensions/help: focus current frame on mousedown if necessary (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: arv@ review Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/webui/resources/js/cr/ui/menu_button.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/uber/uber_utils.js
diff --git a/chrome/browser/resources/uber/uber_utils.js b/chrome/browser/resources/uber/uber_utils.js
index 3d85044dc1897c105e4feef1584810e11282c852..d4f30db61d303cf6751b5abc37b0d03b81c15010 100644
--- a/chrome/browser/resources/uber/uber_utils.js
+++ b/chrome/browser/resources/uber/uber_utils.js
@@ -8,7 +8,6 @@
*/
cr.define('uber', function() {
-
/**
* Fixed position header elements on the page to be shifted by handleScroll.
* @type {NodeList}
@@ -21,6 +20,7 @@ cr.define('uber', function() {
function onContentFrameLoaded() {
headerElements = document.getElementsByTagName('header');
document.addEventListener('scroll', handleScroll);
+ document.addEventListener('mousedown', handleMouseDownInFrame, true);
invokeMethodOnParent('ready');
@@ -38,7 +38,6 @@ cr.define('uber', function() {
/**
* Handles scroll events on the document. This adjusts the position of all
* headers and updates the parent frame when the page is scrolled.
- * @private
*/
function handleScroll() {
var scrollLeft = scrollLeftForDocument(document);
@@ -54,6 +53,16 @@ cr.define('uber', function() {
}
/**
+ * Tells the parent to focus the current frame if the mouse goes down in the
+ * current frame (and it doesn't already have focus).
+ * @param {Event} e A mousedown event.
+ */
+ function handleMouseDownInFrame(e) {
+ if (!e.isSynthetic && !document.hasFocus())
+ window.focus();
+ }
+
+ /**
* Handles 'message' events on window.
* @param {Event} e The message event.
*/
@@ -74,7 +83,6 @@ cr.define('uber', function() {
/**
* This is called when a user selects this frame via the navigation bar
* frame (and is triggered via postMessage() from the uber page).
- * @private
*/
function handleFrameSelected() {
setScrollTopForDocument(document, 0);
@@ -101,7 +109,9 @@ cr.define('uber', function() {
* settings/history/extensions don't need to know about their embedder.
*/
function handleMouseDown() {
- document.body.dispatchEvent(new MouseEvent('mousedown'));
+ var mouseEvent = new MouseEvent('mousedown');
+ mouseEvent.isSynthetic = true;
+ document.dispatchEvent(mouseEvent);
}
/**
@@ -129,7 +139,6 @@ cr.define('uber', function() {
* @param {string} method The name of the method to invoke.
* @param {?=} opt_params Optional property bag of parameters to pass to the
* invoked method.
- * @private
*/
function invokeMethodOnParent(method, opt_params) {
if (!hasParent())
@@ -144,7 +153,6 @@ cr.define('uber', function() {
* @param {?=} opt_params Optional property bag of parameters to pass to the
* invoked method.
* @param {string=} opt_url The origin of the target window.
- * @private
*/
function invokeMethodOnWindow(targetWindow, method, opt_params, opt_url) {
var data = {method: method, params: opt_params};
@@ -158,7 +166,6 @@ cr.define('uber', function() {
* @param {Object} state A state object for replaceState and pushState.
* @param {string} path The path the page navigated to.
* @param {boolean} replace If true, navigate with replacement.
- * @private
*/
function updateHistory(state, path, replace) {
var historyFunction = replace ?
« no previous file with comments | « no previous file | ui/webui/resources/js/cr/ui/menu_button.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698