Commit 1d1405a2 authored by hcarmona's avatar hcarmona Committed by Commit bot

Fix Closure Compilation for chrome://downloads and chrome://history

Changes in https://codereview.chromium.org/807593005/ broke Closure Compilation.

BUG=427670, 452870

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

Cr-Commit-Position: refs/heads/master@{#314718}
parent b4bc7328
......@@ -8,10 +8,14 @@
'variables': {
'depends': [
'../../../../ui/webui/resources/js/action_link.js',
'../../../../ui/webui/resources/js/assert.js',
'../../../../ui/webui/resources/js/compiled_resources.gyp:load_time_data',
'../../../../ui/webui/resources/js/cr.js',
'../../../../ui/webui/resources/js/cr/ui.js',
'../../../../ui/webui/resources/js/cr/ui/command.js',
'../../../../ui/webui/resources/js/compiled_resources.gyp:load_time_data',
'../../../../ui/webui/resources/js/cr/ui/focus_grid.js',
'../../../../ui/webui/resources/js/cr/ui/focus_row.js',
'../../../../ui/webui/resources/js/event_tracker.js',
'../../../../ui/webui/resources/js/util.js',
],
'externs': ['<(CLOSURE_DIR)/externs/chrome_send_externs.js'],
......
......@@ -156,7 +156,7 @@ DownloadFocusRow.prototype = {
/**
* Determines if element should be focusable.
* @param {!Element} element
* @param {Element} element
* @return {boolean}
* @private
*/
......
......@@ -43,6 +43,7 @@ cr.define('cr.ui', function() {
* Row delegate to overwrite the behavior of a mouse click to deselect any row
* that wasn't clicked.
* @param {cr.ui.FocusGrid} focusGrid
* @constructor
* @implements {cr.ui.FocusRow.Delegate}
*/
FocusGrid.RowDelegate = function(focusGrid) {
......@@ -61,8 +62,9 @@ cr.define('cr.ui', function() {
return false;
// Only the clicked row should be active.
var target = assertInstanceof(e.target, Node);
this.focusGrid_.rows.forEach(function(row) {
row.makeRowActive(row.contains(e.target));
row.makeRowActive(row.contains(target));
});
e.preventDefault();
......@@ -80,7 +82,7 @@ cr.define('cr.ui', function() {
},
/**
* @param {EventTarget} target A target item to find in this grid.
* @param {Node} target A target item to find in this grid.
* @return {number} The row index. -1 if not found.
*/
getRowIndexForTarget: function(target) {
......@@ -97,7 +99,8 @@ cr.define('cr.ui', function() {
* @private
*/
onKeydown_: function(e) {
var rowIndex = this.getRowIndexForTarget(e.target);
var target = assertInstanceof(e.target, Node);
var rowIndex = this.getRowIndexForTarget(target);
if (rowIndex == -1)
return;
......@@ -122,7 +125,7 @@ cr.define('cr.ui', function() {
/**
* Keep track of the last column that the user manually focused.
* @param {Event} The focusin event.
* @param {Event} e The focusin event.
* @private
*/
onFocusin_: function(e) {
......@@ -131,8 +134,9 @@ cr.define('cr.ui', function() {
return;
}
if (this.getRowIndexForTarget(e.target) != -1)
this.lastFocused = e.target;
var target = assertInstanceof(e.target, Node);
if (this.getRowIndexForTarget(target) != -1)
this.lastFocused = target;
},
/**
......
......@@ -29,6 +29,7 @@ cr.define('cr.ui', function() {
* any focus change deactivates the row.
*
* @constructor
* @extends {HTMLDivElement}
*/
function FocusRow() {}
......@@ -59,7 +60,8 @@ cr.define('cr.ui', function() {
/**
* Should be called in the constructor to decorate |this|.
* @param {Node} boundary Focus events are ignored outside of this node.
* @param {FocusRow.Delegate=} opt_delegate A delegate to handle key events.
* @param {cr.ui.FocusRow.Delegate=} opt_delegate A delegate to handle key
* events.
*/
decorate: function(boundary, opt_delegate) {
/** @private {!Node} */
......@@ -90,7 +92,7 @@ cr.define('cr.ui', function() {
* which previously held focus.
* @return {!Element} The element that best matches sampleElement.
*/
getEquivalentElement: assertNotReached,
getEquivalentElement: function(sampleElement) { assertNotReached(); },
/**
* Add an element to this FocusRow. No-op if |element| is not provided.
......@@ -148,8 +150,9 @@ cr.define('cr.ui', function() {
* @private
*/
onFocusin_: function(e) {
if (this.boundary_.contains(assertInstanceof(e.target, Node)))
this.onFocusChange_(e.target);
var target = assertInstanceof(e.target, Element);
if (this.boundary_.contains(target))
this.onFocusChange_(target);
},
/**
......@@ -158,13 +161,14 @@ cr.define('cr.ui', function() {
* @private
*/
onKeydown_: function(e) {
if (!this.contains(e.target))
var element = assertInstanceof(e.target, Element);
if (!this.contains(element))
return;
if (this.delegate && this.delegate.onKeydown(this, e))
return;
var elementIndex = this.focusableElements.indexOf(e.target);
var elementIndex = this.focusableElements.indexOf(element);
var index = -1;
if (e.keyIdentifier == 'Left')
......@@ -194,7 +198,7 @@ cr.define('cr.ui', function() {
// Only accept the left mouse click.
if (!e.button) {
// Focus this row if the target is one of the elements in this row.
this.onFocusChange_(e.target);
this.onFocusChange_(assertInstanceof(e.target, Element));
}
},
};
......
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