Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 /** | 5 /** |
| 6 * @param {{lastFocused: Object}} listItem | 6 * @param {{lastFocused: Object}} listItem |
| 7 * @constructor | 7 * @constructor |
| 8 * @implements {cr.ui.FocusRow.Delegate} | 8 * @implements {cr.ui.FocusRow.Delegate} |
| 9 */ | 9 */ |
| 10 function FocusRowDelegate(listItem) { | 10 function FocusRowDelegate(listItem) { |
| 11 /** @private */ | 11 /** @private */ |
| 12 this.listItem_ = listItem; | 12 this.listItem_ = listItem; |
| 13 } | 13 } |
| 14 | 14 |
| 15 FocusRowDelegate.prototype = { | 15 FocusRowDelegate.prototype = { |
| 16 /** | 16 /** |
| 17 * @override | 17 * @override |
| 18 * @param {!cr.ui.FocusRow} row | 18 * @param {!cr.ui.FocusRow} row |
| 19 * @param {!Event} e | 19 * @param {!Event} e |
| 20 */ | 20 */ |
| 21 onFocus: function(row, e) { | 21 onFocus: function(row, e) { |
|
hcarmona
2017/06/08 18:57:50
When does this |onFocus| get called?
scottchen
2017/06/08 22:55:35
When a control element (i,e, [focus-row-control])
hcarmona
2017/06/08 23:21:31
Sounds good. Let's add a short comment to both foc
scottchen
2017/06/09 00:06:00
Done.
| |
| 22 this.listItem_.lastFocused = e.path[0]; | 22 this.listItem_.lastFocused = e.path[0]; |
| 23 this.listItem_.tabIndex = -1; | |
| 23 }, | 24 }, |
| 24 | 25 |
| 25 /** | 26 /** |
| 26 * @override | 27 * @override |
| 27 * @param {!cr.ui.FocusRow} row The row that detected a keydown. | 28 * @param {!cr.ui.FocusRow} row The row that detected a keydown. |
| 28 * @param {!Event} e | 29 * @param {!Event} e |
| 29 * @return {boolean} Whether the event was handled. | 30 * @return {boolean} Whether the event was handled. |
| 30 */ | 31 */ |
| 31 onKeydown: function(row, e) { | 32 onKeydown: function(row, e) { |
| 32 // Prevent iron-list from changing the focus on enter. | 33 // Prevent iron-list from changing the focus on enter. |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 | 132 |
| 132 for (var i = 0; i < controls.length; i++) { | 133 for (var i = 0; i < controls.length; i++) { |
| 133 this.row_.addItem( | 134 this.row_.addItem( |
| 134 controls[i].getAttribute('focus-type'), | 135 controls[i].getAttribute('focus-type'), |
| 135 /** @type {HTMLElement} */ (controls[i])); | 136 /** @type {HTMLElement} */ (controls[i])); |
| 136 } | 137 } |
| 137 } | 138 } |
| 138 }, | 139 }, |
| 139 | 140 |
| 140 /** @private */ | 141 /** @private */ |
| 141 onFocus_: function() { | 142 onFocus_: function() { |
|
hcarmona
2017/06/08 18:57:50
Vs this |onFocus_|?
IIUC, they both set tabIndex
scottchen
2017/06/08 22:55:35
This is when the row gets focused. This function e
hcarmona
2017/06/08 23:21:31
Acknowledged.
| |
| 142 if (this.mouseFocused_) { | 143 if (this.mouseFocused_) { |
| 143 this.mouseFocused_ = false; // Consume and reset flag. | 144 this.mouseFocused_ = false; // Consume and reset flag. |
| 144 return; | 145 return; |
| 145 } | 146 } |
| 146 | 147 |
| 147 if (this.lastFocused) { | 148 if (this.lastFocused) { |
| 148 this.row_.getEquivalentElement(this.lastFocused).focus(); | 149 this.row_.getEquivalentElement(this.lastFocused).focus(); |
| 149 } else { | 150 } else { |
| 150 var firstFocusable = assert(this.row_.getFirstFocusable()); | 151 var firstFocusable = assert(this.row_.getFirstFocusable()); |
| 151 firstFocusable.focus(); | 152 firstFocusable.focus(); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 163 /** @private */ | 164 /** @private */ |
| 164 onMouseDown_: function() { | 165 onMouseDown_: function() { |
| 165 this.mouseFocused_ = true; // Set flag to not do any control-focusing. | 166 this.mouseFocused_ = true; // Set flag to not do any control-focusing. |
| 166 }, | 167 }, |
| 167 | 168 |
| 168 /** @private */ | 169 /** @private */ |
| 169 onBlur_: function() { | 170 onBlur_: function() { |
| 170 this.mouseFocused_ = false; // Reset flag since it's not active anymore. | 171 this.mouseFocused_ = false; // Reset flag since it's not active anymore. |
| 171 } | 172 } |
| 172 }; | 173 }; |
| OLD | NEW |