Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/ui/treeoutline.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/ui/treeoutline.js b/third_party/WebKit/Source/devtools/front_end/ui/treeoutline.js |
| index e60dbf3dc7dcd9bf132aca609fa6c58dfda9a9dc..2dd6a8ace2d3f44e066936d4bd1dc45d19490d79 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/ui/treeoutline.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/ui/treeoutline.js |
| @@ -213,39 +213,13 @@ var TreeOutline = class extends WebInspector.Object { |
| } else if (event.key === 'ArrowDown' && !event.altKey) { |
| handled = this.selectNext(); |
| } else if (event.key === 'ArrowLeft') { |
| - if (this.selectedTreeElement.expanded) { |
| - if (event.altKey) |
| - this.selectedTreeElement.collapseRecursively(); |
| - else |
| - this.selectedTreeElement.collapse(); |
| - handled = true; |
| - } else if (this.selectedTreeElement.parent && !this.selectedTreeElement.parent.root) { |
| - handled = true; |
| - if (this.selectedTreeElement.parent.selectable) { |
| - nextSelectedElement = this.selectedTreeElement.parent; |
| - while (nextSelectedElement && !nextSelectedElement.selectable) |
| - nextSelectedElement = nextSelectedElement.parent; |
| - handled = nextSelectedElement ? true : false; |
| - } else if (this.selectedTreeElement.parent) |
| - this.selectedTreeElement.parent.collapse(); |
| - } |
| + 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.
|
| } else if (event.key === 'ArrowRight') { |
| if (!this.selectedTreeElement.revealed()) { |
| this.selectedTreeElement.reveal(); |
| handled = true; |
| - } else if (this.selectedTreeElement._expandable) { |
| - handled = true; |
| - if (this.selectedTreeElement.expanded) { |
| - nextSelectedElement = this.selectedTreeElement.firstChild(); |
| - while (nextSelectedElement && !nextSelectedElement.selectable) |
| - nextSelectedElement = nextSelectedElement.nextSibling; |
| - handled = nextSelectedElement ? true : false; |
| - } else { |
| - if (event.altKey) |
| - this.selectedTreeElement.expandRecursively(); |
| - else |
| - this.selectedTreeElement.expand(); |
| - } |
| + } else { |
| + handled = this.selectedTreeElement.descendOrExpand(event.altKey); |
| } |
| } else if (event.keyCode === 8 /* Backspace */ || event.keyCode === 46 /* Delete */) |
| handled = this.selectedTreeElement.ondelete(); |
| @@ -254,11 +228,6 @@ var TreeOutline = class extends WebInspector.Object { |
| else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Space.code) |
| handled = this.selectedTreeElement.onspace(); |
| - if (nextSelectedElement) { |
| - nextSelectedElement.reveal(); |
| - nextSelectedElement.select(false, true); |
| - } |
| - |
| if (handled) |
| event.consume(true); |
| } |
| @@ -858,6 +827,71 @@ var TreeElement = class { |
| } |
| /** |
| + * @param {boolean} altKey |
| + * @return {boolean} |
| + */ |
| + collapseOrAscend(altKey) { |
| + if (this.expanded) { |
| + if (altKey) |
| + this.collapseRecursively(); |
| + else |
| + this.collapse(); |
| + return true; |
| + } |
| + |
| + if (!this.parent || this.parent.root) |
| + return false; |
| + |
| + var handled = true; |
| + var nextSelectedElement; |
| + if (this.parent.selectable) { |
| + nextSelectedElement = this.parent; |
| + while (nextSelectedElement && !nextSelectedElement.selectable) |
| + nextSelectedElement = nextSelectedElement.parent; |
| + handled = nextSelectedElement ? true : false; |
| + } else if (this.parent) { |
| + this.parent.collapse(); |
| + } |
| + |
| + if (nextSelectedElement) { |
| + nextSelectedElement.reveal(); |
| + nextSelectedElement.select(false, true); |
| + } |
| + |
| + return handled; |
| + } |
| + |
| + /** |
| + * @param {boolean} altKey |
| + * @return {boolean} |
| + */ |
| + descendOrExpand(altKey) { |
| + if (!this._expandable) |
| + return false; |
| + |
| + var handled = true; |
| + var nextSelectedElement; |
| + if (this.expanded) { |
| + nextSelectedElement = this.firstChild(); |
| + while (nextSelectedElement && !nextSelectedElement.selectable) |
| + nextSelectedElement = nextSelectedElement.nextSibling; |
| + handled = nextSelectedElement ? true : false; |
| + } else { |
| + if (altKey) |
| + this.expandRecursively(); |
| + else |
| + this.expand(); |
| + } |
| + |
| + if (nextSelectedElement) { |
| + nextSelectedElement.reveal(); |
| + nextSelectedElement.select(false, true); |
| + } |
| + |
| + return handled; |
| + } |
| + |
| + /** |
| * @param {boolean=} center |
| */ |
| reveal(center) { |