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

Side by Side Diff: chrome/browser/resources/downloads/manager.js

Issue 1281483008: Move downloads.FocusRow.shouldFocus to cr.ui.FocusRow.isFocusable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@focus-row2
Patch Set: whoops Created 5 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('downloads', function() { 5 cr.define('downloads', function() {
6 /** 6 /**
7 * Class to own and manage download items. 7 * Class to own and manage download items.
8 * @constructor 8 * @constructor
9 */ 9 */
10 function Manager() {} 10 function Manager() {}
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 * @private 126 * @private
127 */ 127 */
128 updateItem_: function(data) { 128 updateItem_: function(data) {
129 var activeElement = document.activeElement; 129 var activeElement = document.activeElement;
130 130
131 var item = this.idMap_[data.id]; 131 var item = this.idMap_[data.id];
132 item.update(data); 132 item.update(data);
133 var focusRow = this.decorateItem_(item); 133 var focusRow = this.decorateItem_(item);
134 134
135 if (focusRow.contains(activeElement) && 135 if (focusRow.contains(activeElement) &&
136 !downloads.FocusRow.shouldFocus(activeElement)) { 136 !cr.ui.FocusRow.isFocusable(activeElement)) {
137 focusRow.getEquivalentElement(activeElement).focus(); 137 focusRow.getEquivalentElement(activeElement).focus();
138 } 138 }
139 }, 139 },
140 140
141 /** 141 /**
142 * Rebuild the focusGrid_ using the elements that each download will have. 142 * Rebuild the focusGrid_ using the elements that each download will have.
143 * @private 143 * @private
144 */ 144 */
145 rebuildFocusGrid_: function() { 145 rebuildFocusGrid_: function() {
146 var activeElement = document.activeElement; 146 var activeElement = document.activeElement;
147 147
148 /** @private {!cr.ui.FocusGrid} */ 148 /** @private {!cr.ui.FocusGrid} */
149 this.focusGrid_ = this.focusGrid_ || new cr.ui.FocusGrid(); 149 this.focusGrid_ = this.focusGrid_ || new cr.ui.FocusGrid();
150 this.focusGrid_.destroy(); 150 this.focusGrid_.destroy();
151 151
152 this.items_.forEach(function(item) { 152 this.items_.forEach(function(item) {
153 var focusRow = this.decorateItem_(item); 153 var focusRow = this.decorateItem_(item);
154 this.focusGrid_.addRow(focusRow); 154 this.focusGrid_.addRow(focusRow);
155 155
156 if (focusRow.contains(activeElement) && 156 if (focusRow.contains(activeElement) &&
157 !downloads.FocusRow.shouldFocus(activeElement)) { 157 !cr.ui.FocusRow.isFocusable(activeElement)) {
158 focusRow.getEquivalentElement(activeElement).focus(); 158 focusRow.getEquivalentElement(activeElement).focus();
159 } 159 }
160 }, this); 160 }, this);
161 this.focusGrid_.ensureRowActive(); 161 this.focusGrid_.ensureRowActive();
162 }, 162 },
163 163
164 /** 164 /**
165 * @param {!downloads.ItemView} item An item to decorate as a FocusRow. 165 * @param {!downloads.ItemView} item An item to decorate as a FocusRow.
166 * @return {!downloads.FocusRow} |item| decorated as a FocusRow. 166 * @return {!downloads.FocusRow} |item| decorated as a FocusRow.
167 * @private 167 * @private
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 }; 255 };
256 256
257 Manager.size = function() { 257 Manager.size = function() {
258 return Manager.getInstance().size_(); 258 return Manager.getInstance().size_();
259 }; 259 };
260 260
261 return {Manager: Manager}; 261 return {Manager: Manager};
262 }); 262 });
263 263
264 window.addEventListener('DOMContentLoaded', downloads.Manager.onLoad); 264 window.addEventListener('DOMContentLoaded', downloads.Manager.onLoad);
OLDNEW
« no previous file with comments | « chrome/browser/resources/downloads/focus_row.js ('k') | ui/webui/resources/js/cr/ui/focus_row.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698