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 fbfb9d23d7b0dab1751bd8c0bf949f6746f1ac01..31855cd1057d9259a219a71d30cd52a612f02095 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/ui/treeoutline.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/ui/treeoutline.js |
| @@ -237,39 +237,13 @@ TreeOutline.prototype = { |
| } 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); |
| } 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(); |
| @@ -278,11 +252,6 @@ TreeOutline.prototype = { |
| 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); |
| }, |
| @@ -913,6 +882,74 @@ TreeElement.prototype = { |
| } |
| }, |
| + |
| + /** |
| + * @param {boolean} altKey |
| + * @return {boolean} |
| + */ |
| + 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.
|
| + { |
| + 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: function(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 |
| */ |