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

Unified Diff: chrome/browser/resources/history/history.js

Issue 685783003: history: fix more focus oddness. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more fixes Created 6 years, 1 month 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
Index: chrome/browser/resources/history/history.js
diff --git a/chrome/browser/resources/history/history.js b/chrome/browser/resources/history/history.js
index f2a12feaa485b054765126bb268c92ffc4809576..14f25e64bd537937c9a0085748b19d1f4a47281a 100644
--- a/chrome/browser/resources/history/history.js
+++ b/chrome/browser/resources/history/history.js
@@ -212,7 +212,7 @@ Visit.prototype.getResultDOM = function(propertyBag) {
if (!isMobileVersion()) {
// Clicking anywhere in the entryBox will check/uncheck the checkbox.
entryBox.setAttribute('for', checkbox.id);
- entryBox.addEventListener('mousedown', entryBoxMousedown);
+ entryBox.addEventListener('mousedown', this.handleMousedown_.bind(this));
entryBox.addEventListener('click', entryBoxClick);
entryBox.addEventListener('keydown', this.handleKeydown_.bind(this));
}
@@ -499,6 +499,20 @@ Visit.prototype.handleKeydown_ = function(e) {
};
/**
+ * @param {Event} event A mousedown event.
+ * @private
+ */
+Visit.prototype.handleMousedown_ = function(event) {
+ // Prevent text selection when shift-clicking to select multiple entries.
+ if (event.shiftKey) {
+ event.preventDefault();
+
+ if (this.model_.getView().isInFocusGrid(event.target))
+ event.target.focus();
+ }
+};
+
+/**
* Removes a history entry on click or keydown and finds a new entry to focus.
* @param {Event} e A click or keydown event.
* @private
@@ -898,6 +912,29 @@ HistoryFocusObserver.prototype = {
};
///////////////////////////////////////////////////////////////////////////////
+// HistoryFocusGrid:
+
+/**
+ * @param {Node=} opt_boundary
+ * @param {cr.ui.FocusRow.Observer=} opt_observer
+ * @constructor
+ * @extends {cr.ui.FocusGrid}
+ */
+function HistoryFocusGrid(opt_boundary, opt_observer) {
+ cr.ui.FocusGrid.apply(this, arguments);
+}
+
+HistoryFocusGrid.prototype = {
+ __proto__: cr.ui.FocusGrid.prototype,
+
+ /** @override */
+ onMousedown: function(row, e) {
+ return !!findAncestorByClass(e.target, 'menu-button');
+ },
+};
+
+
+///////////////////////////////////////////////////////////////////////////////
// HistoryView:
/**
@@ -911,8 +948,8 @@ function HistoryView(model) {
this.editButtonTd_ = $('edit-button');
this.editingControlsDiv_ = $('editing-controls');
this.resultDiv_ = $('results-display');
- this.focusGrid_ = new cr.ui.FocusGrid(this.resultDiv_,
- new HistoryFocusObserver);
+ this.focusGrid_ = new HistoryFocusGrid(this.resultDiv_,
+ new HistoryFocusObserver);
this.pageDiv_ = $('results-pagination');
this.model_ = model;
this.pageIndex_ = 0;
@@ -1254,6 +1291,14 @@ HistoryView.prototype.positionNotificationBar = function() {
}
};
+/**
+ * @param {Element} el An element to look for.
+ * @return {boolean} Whether |el| is in |this.focusGrid_|.
+ */
+HistoryView.prototype.isInFocusGrid = function(el) {
+ return !!this.focusGrid_.getPositionForTarget(el);
+};
+
// HistoryView, private: ------------------------------------------------------
/**
@@ -2163,12 +2208,6 @@ function updateParentCheckbox(checkbox) {
groupCheckbox.checked = false;
}
-function entryBoxMousedown(event) {
- // Prevent text selection when shift-clicking to select multiple entries.
- if (event.shiftKey)
- event.preventDefault();
-}
-
/**
* Handle click event for entryBoxes.
* @param {!Event} event A click event.
« no previous file with comments | « no previous file | chrome/test/data/webui/history_browsertest.js » ('j') | chrome/test/data/webui/history_browsertest.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698