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

Side by Side Diff: chrome/browser/resources/settings/focus_row_behavior.js

Issue 2930683003: MD Settings: fix focus-row-behavior allowing invisible focus on rows. (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698