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

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: Handle indirect children better 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 if (!this.selectedTreeElement || event.shiftKey || event.metaKey || even t.ctrlKey) 230 if (!this.selectedTreeElement || event.shiftKey || event.metaKey || even t.ctrlKey)
231 return; 231 return;
232 232
233 var handled = false; 233 var handled = false;
234 var nextSelectedElement; 234 var nextSelectedElement;
235 if (event.key === "ArrowUp" && !event.altKey) { 235 if (event.key === "ArrowUp" && !event.altKey) {
236 handled = this.selectPrevious(); 236 handled = this.selectPrevious();
237 } else if (event.key === "ArrowDown" && !event.altKey) { 237 } else if (event.key === "ArrowDown" && !event.altKey) {
238 handled = this.selectNext(); 238 handled = this.selectNext();
239 } else if (event.key === "ArrowLeft") { 239 } else if (event.key === "ArrowLeft") {
240 if (this.selectedTreeElement.expanded) { 240 handled = this.selectedTreeElement.collapseOrAscend(event.altKey);
241 if (event.altKey)
242 this.selectedTreeElement.collapseRecursively();
243 else
244 this.selectedTreeElement.collapse();
245 handled = true;
246 } else if (this.selectedTreeElement.parent && !this.selectedTreeElem ent.parent.root) {
247 handled = true;
248 if (this.selectedTreeElement.parent.selectable) {
249 nextSelectedElement = this.selectedTreeElement.parent;
250 while (nextSelectedElement && !nextSelectedElement.selectabl e)
251 nextSelectedElement = nextSelectedElement.parent;
252 handled = nextSelectedElement ? true : false;
253 } else if (this.selectedTreeElement.parent)
254 this.selectedTreeElement.parent.collapse();
255 }
256 } else if (event.key === "ArrowRight") { 241 } else if (event.key === "ArrowRight") {
257 if (!this.selectedTreeElement.revealed()) { 242 if (!this.selectedTreeElement.revealed()) {
258 this.selectedTreeElement.reveal(); 243 this.selectedTreeElement.reveal();
259 handled = true; 244 handled = true;
260 } else if (this.selectedTreeElement._expandable) { 245 } else {
261 handled = true; 246 handled = this.selectedTreeElement.descendOrExpand(event.altKey) ;
262 if (this.selectedTreeElement.expanded) {
263 nextSelectedElement = this.selectedTreeElement.firstChild();
264 while (nextSelectedElement && !nextSelectedElement.selectabl e)
265 nextSelectedElement = nextSelectedElement.nextSibling;
266 handled = nextSelectedElement ? true : false;
267 } else {
268 if (event.altKey)
269 this.selectedTreeElement.expandRecursively();
270 else
271 this.selectedTreeElement.expand();
272 }
273 } 247 }
274 } else if (event.keyCode === 8 /* Backspace */ || event.keyCode === 46 / * Delete */) 248 } else if (event.keyCode === 8 /* Backspace */ || event.keyCode === 46 / * Delete */)
275 handled = this.selectedTreeElement.ondelete(); 249 handled = this.selectedTreeElement.ondelete();
276 else if (isEnterKey(event)) 250 else if (isEnterKey(event))
277 handled = this.selectedTreeElement.onenter(); 251 handled = this.selectedTreeElement.onenter();
278 else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Space.code ) 252 else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Space.code )
279 handled = this.selectedTreeElement.onspace(); 253 handled = this.selectedTreeElement.onspace();
280 254
281 if (nextSelectedElement) {
282 nextSelectedElement.reveal();
283 nextSelectedElement.select(false, true);
284 }
285
286 if (handled) 255 if (handled)
287 event.consume(true); 256 event.consume(true);
288 }, 257 },
289 258
290 /** 259 /**
291 * @param {!TreeElement} treeElement 260 * @param {!TreeElement} treeElement
292 * @param {boolean} center 261 * @param {boolean} center
293 */ 262 */
294 _deferredScrollIntoView: function(treeElement, center) 263 _deferredScrollIntoView: function(treeElement, center)
295 { 264 {
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 maxDepth = 3; 875 maxDepth = 3;
907 876
908 while (item) { 877 while (item) {
909 if (depth < maxDepth) 878 if (depth < maxDepth)
910 item.expand(); 879 item.expand();
911 item = item.traverseNextTreeElement(false, this, (depth >= maxDepth) , info); 880 item = item.traverseNextTreeElement(false, this, (depth >= maxDepth) , info);
912 depth += info.depthChange; 881 depth += info.depthChange;
913 } 882 }
914 }, 883 },
915 884
885
886 /**
887 * @param {boolean} altKey
888 * @return {boolean}
889 */
890 collapseOrAscend: function(altKey)
dgozman 2016/10/31 21:36:31 Let's land changes to tree outline separately, wit
aboxhall 2016/10/31 22:45:15 Sounds good, will do.
891 {
892 if (this.expanded) {
893 if (altKey)
894 this.collapseRecursively();
895 else
896 this.collapse();
897 return true;
898 }
899
900 if (!this.parent || this.parent.root)
901 return false;
902
903 var handled = true;
904 var nextSelectedElement;
905 if (this.parent.selectable) {
906 nextSelectedElement = this.parent;
907 while (nextSelectedElement && !nextSelectedElement.selectable)
908 nextSelectedElement = nextSelectedElement.parent;
909 handled = nextSelectedElement ? true : false;
910 } else if (this.parent) {
911 this.parent.collapse();
912 }
913
914 if (nextSelectedElement) {
915 nextSelectedElement.reveal();
916 nextSelectedElement.select(false, true);
917 }
918
919 return handled;
920 },
921
922 /**
923 * @param {boolean} altKey
924 * @return {boolean}
925 */
926 descendOrExpand: function(altKey)
927 {
928 if (!this._expandable)
929 return false;
930
931 var handled = true;
932 var nextSelectedElement;
933 if (this.expanded) {
934 nextSelectedElement = this.firstChild();
935 while (nextSelectedElement && !nextSelectedElement.selectable)
936 nextSelectedElement = nextSelectedElement.nextSibling;
937 handled = nextSelectedElement ? true : false;
938 } else {
939 if (altKey)
940 this.expandRecursively();
941 else
942 this.expand();
943 }
944
945 if (nextSelectedElement) {
946 nextSelectedElement.reveal();
947 nextSelectedElement.select(false, true);
948 }
949
950 return handled;
951 },
952
916 /** 953 /**
917 * @param {boolean=} center 954 * @param {boolean=} center
918 */ 955 */
919 reveal: function(center) 956 reveal: function(center)
920 { 957 {
921 var currentAncestor = this.parent; 958 var currentAncestor = this.parent;
922 while (currentAncestor && !currentAncestor.root) { 959 while (currentAncestor && !currentAncestor.root) {
923 if (!currentAncestor.expanded) 960 if (!currentAncestor.expanded)
924 currentAncestor.expand(); 961 currentAncestor.expand();
925 currentAncestor = currentAncestor.parent; 962 currentAncestor = currentAncestor.parent;
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 isEventWithinDisclosureTriangle: function(event) 1188 isEventWithinDisclosureTriangle: function(event)
1152 { 1189 {
1153 // FIXME: We should not use getComputedStyle(). For that we need to get rid of using ::before for disclosure triangle. (http://webk.it/74446) 1190 // FIXME: We should not use getComputedStyle(). For that we need to get rid of using ::before for disclosure triangle. (http://webk.it/74446)
1154 var paddingLeftValue = window.getComputedStyle(this._listItemNode).paddi ngLeft; 1191 var paddingLeftValue = window.getComputedStyle(this._listItemNode).paddi ngLeft;
1155 console.assert(paddingLeftValue.endsWith("px")); 1192 console.assert(paddingLeftValue.endsWith("px"));
1156 var computedLeftPadding = parseFloat(paddingLeftValue); 1193 var computedLeftPadding = parseFloat(paddingLeftValue);
1157 var left = this._listItemNode.totalOffsetLeft() + computedLeftPadding; 1194 var left = this._listItemNode.totalOffsetLeft() + computedLeftPadding;
1158 return event.pageX >= left && event.pageX <= left + TreeElement._ArrowTo ggleWidth && this._expandable; 1195 return event.pageX >= left && event.pageX <= left + TreeElement._ArrowTo ggleWidth && this._expandable;
1159 } 1196 }
1160 }; 1197 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698