Commit c3865e34 authored by dbeam@chromium.org's avatar dbeam@chromium.org

history: Use keyIdentifier instead of keyCode where possible.

TBR=dmazzoni@chromium.org
BUG=393489

Review URL: https://codereview.chromium.org/444513002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287489 0039d316-1c4b-4281-b951-d872f2087c98
parent 8d368d62
...@@ -483,24 +483,21 @@ Visit.prototype.getFocusableControls_ = function() { ...@@ -483,24 +483,21 @@ Visit.prototype.getFocusableControls_ = function() {
* @private * @private
*/ */
Visit.prototype.handleKeydown_ = function(e) { Visit.prototype.handleKeydown_ = function(e) {
var keyCode = e.keyCode; if (e.keyCode == 8 || e.keyCode == 46) { // Delete or Backspace.
if (keyCode == 8 || keyCode == 46) { // Delete or Backspace.
if (!this.model_.isDeletingVisits()) if (!this.model_.isDeletingVisits())
this.removeEntryFromHistory_(e); this.removeEntryFromHistory_(e);
return; return;
} }
var target = e.target; var target = e.target;
if (target != document.activeElement || !(keyCode == 37 || keyCode == 39)) { var key = e.keyIdentifier;
// Handling key code for inactive element or key wasn't left or right. if (target != document.activeElement || !(key == 'Left' || key == 'Right'))
return; return;
}
var controls = this.getFocusableControls_(); var controls = this.getFocusableControls_();
for (var i = 0; i < controls.length; ++i) { for (var i = 0; i < controls.length; ++i) {
if (controls[i].contains(target)) { if (controls[i].contains(target)) {
/** @const */ var isLeft = e.keyCode == 37; var toFocus = key == 'Left' ? controls[i - 1] : controls[i + 1];
var toFocus = isLeft ? controls[i - 1] : controls[i + 1];
if (toFocus) { if (toFocus) {
this.focusControl(toFocus); this.focusControl(toFocus);
e.preventDefault(); e.preventDefault();
...@@ -1684,14 +1681,14 @@ HistoryView.prototype.swapFocusedVisit_ = function(visit) { ...@@ -1684,14 +1681,14 @@ HistoryView.prototype.swapFocusedVisit_ = function(visit) {
*/ */
HistoryView.prototype.handleKeydown_ = function(e) { HistoryView.prototype.handleKeydown_ = function(e) {
// Only handle up or down arrows on the focused element. // Only handle up or down arrows on the focused element.
var keyCode = e.keyCode, target = e.target; var key = e.keyIdentifier, target = e.target;
if (target != document.activeElement || !(keyCode == 38 || keyCode == 40)) if (target != document.activeElement || !(key == 'Up' || key == 'Down'))
return; return;
var entry = findAncestorByClass(e.target, 'entry'); var entry = findAncestorByClass(e.target, 'entry');
var visit = entry && entry.visit; var visit = entry && entry.visit;
this.swapFocusedVisit_(keyCode == 38 ? this.getVisitBefore_(visit) : this.swapFocusedVisit_(key == 'Up' ? this.getVisitBefore_(visit) :
this.getVisitAfter_(visit)); this.getVisitAfter_(visit));
}; };
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment