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. |