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

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: add clarifying comments 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 * This function gets called when the [focus-row-control] element receives
18 * the focus event.
17 * @override 19 * @override
18 * @param {!cr.ui.FocusRow} row 20 * @param {!cr.ui.FocusRow} row
19 * @param {!Event} e 21 * @param {!Event} e
20 */ 22 */
21 onFocus: function(row, e) { 23 onFocus: function(row, e) {
22 this.listItem_.lastFocused = e.path[0]; 24 this.listItem_.lastFocused = e.path[0];
25 this.listItem_.tabIndex = -1;
23 }, 26 },
24 27
25 /** 28 /**
26 * @override 29 * @override
27 * @param {!cr.ui.FocusRow} row The row that detected a keydown. 30 * @param {!cr.ui.FocusRow} row The row that detected a keydown.
28 * @param {!Event} e 31 * @param {!Event} e
29 * @return {boolean} Whether the event was handled. 32 * @return {boolean} Whether the event was handled.
30 */ 33 */
31 onKeydown: function(row, e) { 34 onKeydown: function(row, e) {
32 // Prevent iron-list from changing the focus on enter. 35 // Prevent iron-list from changing the focus on enter.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 var controls = this.root.querySelectorAll('[focus-row-control]'); 133 var controls = this.root.querySelectorAll('[focus-row-control]');
131 134
132 for (var i = 0; i < controls.length; i++) { 135 for (var i = 0; i < controls.length; i++) {
133 this.row_.addItem( 136 this.row_.addItem(
134 controls[i].getAttribute('focus-type'), 137 controls[i].getAttribute('focus-type'),
135 /** @type {HTMLElement} */ (controls[i])); 138 /** @type {HTMLElement} */ (controls[i]));
136 } 139 }
137 } 140 }
138 }, 141 },
139 142
140 /** @private */ 143 /**
144 * This function gets called when the row itself receives the focus event.
145 * @private
146 */
141 onFocus_: function() { 147 onFocus_: function() {
142 if (this.mouseFocused_) { 148 if (this.mouseFocused_) {
143 this.mouseFocused_ = false; // Consume and reset flag. 149 this.mouseFocused_ = false; // Consume and reset flag.
144 return; 150 return;
145 } 151 }
146 152
147 if (this.lastFocused) { 153 if (this.lastFocused) {
148 this.row_.getEquivalentElement(this.lastFocused).focus(); 154 this.row_.getEquivalentElement(this.lastFocused).focus();
149 } else { 155 } else {
150 var firstFocusable = assert(this.row_.getFirstFocusable()); 156 var firstFocusable = assert(this.row_.getFirstFocusable());
(...skipping 12 matching lines...) Expand all
163 /** @private */ 169 /** @private */
164 onMouseDown_: function() { 170 onMouseDown_: function() {
165 this.mouseFocused_ = true; // Set flag to not do any control-focusing. 171 this.mouseFocused_ = true; // Set flag to not do any control-focusing.
166 }, 172 },
167 173
168 /** @private */ 174 /** @private */
169 onBlur_: function() { 175 onBlur_: function() {
170 this.mouseFocused_ = false; // Reset flag since it's not active anymore. 176 this.mouseFocused_ = false; // Reset flag since it's not active anymore.
171 } 177 }
172 }; 178 };
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