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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/treeoutline.js

Issue 2390783006: [DevTools] Accessibility: Show siblings and children of selected node (Closed)
Patch Set: UI feedback from Chris Created 4 years, 1 month 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 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 if (!this.selectedTreeElement || event.shiftKey || event.metaKey || event.ct rlKey) 206 if (!this.selectedTreeElement || event.shiftKey || event.metaKey || event.ct rlKey)
207 return; 207 return;
208 208
209 var handled = false; 209 var handled = false;
210 var nextSelectedElement; 210 var nextSelectedElement;
211 if (event.key === 'ArrowUp' && !event.altKey) { 211 if (event.key === 'ArrowUp' && !event.altKey) {
212 handled = this.selectPrevious(); 212 handled = this.selectPrevious();
213 } else if (event.key === 'ArrowDown' && !event.altKey) { 213 } else if (event.key === 'ArrowDown' && !event.altKey) {
214 handled = this.selectNext(); 214 handled = this.selectNext();
215 } else if (event.key === 'ArrowLeft') { 215 } else if (event.key === 'ArrowLeft') {
216 if (this.selectedTreeElement.expanded) { 216 handled = this.selectedTreeElement.collapseOrAscend(event.altKey);
dgozman 2016/11/03 22:07:29 Time to rebase atop the other change?
aboxhall 2016/11/04 22:31:17 Done.
217 if (event.altKey)
218 this.selectedTreeElement.collapseRecursively();
219 else
220 this.selectedTreeElement.collapse();
221 handled = true;
222 } else if (this.selectedTreeElement.parent && !this.selectedTreeElement.pa rent.root) {
223 handled = true;
224 if (this.selectedTreeElement.parent.selectable) {
225 nextSelectedElement = this.selectedTreeElement.parent;
226 while (nextSelectedElement && !nextSelectedElement.selectable)
227 nextSelectedElement = nextSelectedElement.parent;
228 handled = nextSelectedElement ? true : false;
229 } else if (this.selectedTreeElement.parent)
230 this.selectedTreeElement.parent.collapse();
231 }
232 } else if (event.key === 'ArrowRight') { 217 } else if (event.key === 'ArrowRight') {
233 if (!this.selectedTreeElement.revealed()) { 218 if (!this.selectedTreeElement.revealed()) {
234 this.selectedTreeElement.reveal(); 219 this.selectedTreeElement.reveal();
235 handled = true; 220 handled = true;
236 } else if (this.selectedTreeElement._expandable) { 221 } else {
237 handled = true; 222 handled = this.selectedTreeElement.descendOrExpand(event.altKey);
238 if (this.selectedTreeElement.expanded) {
239 nextSelectedElement = this.selectedTreeElement.firstChild();
240 while (nextSelectedElement && !nextSelectedElement.selectable)
241 nextSelectedElement = nextSelectedElement.nextSibling;
242 handled = nextSelectedElement ? true : false;
243 } else {
244 if (event.altKey)
245 this.selectedTreeElement.expandRecursively();
246 else
247 this.selectedTreeElement.expand();
248 }
249 } 223 }
250 } else if (event.keyCode === 8 /* Backspace */ || event.keyCode === 46 /* De lete */) 224 } else if (event.keyCode === 8 /* Backspace */ || event.keyCode === 46 /* De lete */)
251 handled = this.selectedTreeElement.ondelete(); 225 handled = this.selectedTreeElement.ondelete();
252 else if (isEnterKey(event)) 226 else if (isEnterKey(event))
253 handled = this.selectedTreeElement.onenter(); 227 handled = this.selectedTreeElement.onenter();
254 else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Space.code) 228 else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Space.code)
255 handled = this.selectedTreeElement.onspace(); 229 handled = this.selectedTreeElement.onspace();
256 230
257 if (nextSelectedElement) {
258 nextSelectedElement.reveal();
259 nextSelectedElement.select(false, true);
260 }
261
262 if (handled) 231 if (handled)
263 event.consume(true); 232 event.consume(true);
264 } 233 }
265 234
266 /** 235 /**
267 * @param {!TreeElement} treeElement 236 * @param {!TreeElement} treeElement
268 * @param {boolean} center 237 * @param {boolean} center
269 */ 238 */
270 _deferredScrollIntoView(treeElement, center) { 239 _deferredScrollIntoView(treeElement, center) {
271 if (!this._treeElementToScrollIntoView) 240 if (!this._treeElementToScrollIntoView)
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 820
852 while (item) { 821 while (item) {
853 if (depth < maxDepth) 822 if (depth < maxDepth)
854 item.expand(); 823 item.expand();
855 item = item.traverseNextTreeElement(false, this, (depth >= maxDepth), info ); 824 item = item.traverseNextTreeElement(false, this, (depth >= maxDepth), info );
856 depth += info.depthChange; 825 depth += info.depthChange;
857 } 826 }
858 } 827 }
859 828
860 /** 829 /**
830 * @param {boolean} altKey
831 * @return {boolean}
832 */
833 collapseOrAscend(altKey) {
834 if (this.expanded) {
835 if (altKey)
836 this.collapseRecursively();
837 else
838 this.collapse();
839 return true;
840 }
841
842 if (!this.parent || this.parent.root)
843 return false;
844
845 var handled = true;
846 var nextSelectedElement;
847 if (this.parent.selectable) {
848 nextSelectedElement = this.parent;
849 while (nextSelectedElement && !nextSelectedElement.selectable)
850 nextSelectedElement = nextSelectedElement.parent;
851 handled = nextSelectedElement ? true : false;
852 } else if (this.parent) {
853 this.parent.collapse();
854 }
855
856 if (nextSelectedElement) {
857 nextSelectedElement.reveal();
858 nextSelectedElement.select(false, true);
859 }
860
861 return handled;
862 }
863
864 /**
865 * @param {boolean} altKey
866 * @return {boolean}
867 */
868 descendOrExpand(altKey) {
869 if (!this._expandable)
870 return false;
871
872 var handled = true;
873 var nextSelectedElement;
874 if (this.expanded) {
875 nextSelectedElement = this.firstChild();
876 while (nextSelectedElement && !nextSelectedElement.selectable)
877 nextSelectedElement = nextSelectedElement.nextSibling;
878 handled = nextSelectedElement ? true : false;
879 } else {
880 if (altKey)
881 this.expandRecursively();
882 else
883 this.expand();
884 }
885
886 if (nextSelectedElement) {
887 nextSelectedElement.reveal();
888 nextSelectedElement.select(false, true);
889 }
890
891 return handled;
892 }
893
894 /**
861 * @param {boolean=} center 895 * @param {boolean=} center
862 */ 896 */
863 reveal(center) { 897 reveal(center) {
864 var currentAncestor = this.parent; 898 var currentAncestor = this.parent;
865 while (currentAncestor && !currentAncestor.root) { 899 while (currentAncestor && !currentAncestor.root) {
866 if (!currentAncestor.expanded) 900 if (!currentAncestor.expanded)
867 currentAncestor.expand(); 901 currentAncestor.expand();
868 currentAncestor = currentAncestor.parent; 902 currentAncestor = currentAncestor.parent;
869 } 903 }
870 904
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 var paddingLeftValue = window.getComputedStyle(this._listItemNode).paddingLe ft; 1116 var paddingLeftValue = window.getComputedStyle(this._listItemNode).paddingLe ft;
1083 console.assert(paddingLeftValue.endsWith('px')); 1117 console.assert(paddingLeftValue.endsWith('px'));
1084 var computedLeftPadding = parseFloat(paddingLeftValue); 1118 var computedLeftPadding = parseFloat(paddingLeftValue);
1085 var left = this._listItemNode.totalOffsetLeft() + computedLeftPadding; 1119 var left = this._listItemNode.totalOffsetLeft() + computedLeftPadding;
1086 return event.pageX >= left && event.pageX <= left + TreeElement._ArrowToggle Width && this._expandable; 1120 return event.pageX >= left && event.pageX <= left + TreeElement._ArrowToggle Width && this._expandable;
1087 } 1121 }
1088 }; 1122 };
1089 1123
1090 /** @const */ 1124 /** @const */
1091 TreeElement._ArrowToggleWidth = 10; 1125 TreeElement._ArrowToggleWidth = 10;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698