Web Inspector: Elements: ⌘-A should select all visible nodes
authormattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Dec 2018 18:14:28 +0000 (18:14 +0000)
committermattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Dec 2018 18:14:28 +0000 (18:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192120
<rdar://problem/46344435>

Reviewed by Devin Rousso.

* UserInterface/Views/TreeOutline.js:
(WI.TreeOutline.prototype._treeKeyDown):
Remove an early return, allowing `WI.SelectionController` to handle ⌘-A
and select all items.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238858 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/TreeOutline.js

index cac3a7d..ab9532a 100644 (file)
@@ -1,3 +1,16 @@
+2018-12-04  Matt Baker  <mattbaker@apple.com>
+
+        Web Inspector: Elements: ⌘-A should select all visible nodes
+        https://bugs.webkit.org/show_bug.cgi?id=192120
+        <rdar://problem/46344435>
+
+        Reviewed by Devin Rousso.
+
+        * UserInterface/Views/TreeOutline.js:
+        (WI.TreeOutline.prototype._treeKeyDown):
+        Remove an early return, allowing `WI.SelectionController` to handle ⌘-A
+        and select all items.
+
 2018-12-04  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: Audit: tests should support async operations
index a7511d6..e3a3fe4 100644 (file)
@@ -545,66 +545,67 @@ WI.TreeOutline = class TreeOutline extends WI.Object
         if (event.target !== this._childrenListNode)
             return;
 
-        if (!this.selectedTreeElement || event.commandOrControlKey)
-            return;
-
         let isRTL = WI.resolvedLayoutDirection() === WI.LayoutDirection.RTL;
+        let expandKeyIdentifier = isRTL ? "Left" : "Right";
+        let collapseKeyIdentifier = isRTL ? "Right" : "Left";
 
         var handled = false;
         var nextSelectedElement;
 
-        if ((!isRTL && event.keyIdentifier === "Left") || (isRTL && event.keyIdentifier === "Right")) {
-            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();
-            }
-        } else if ((!isRTL && event.keyIdentifier === "Right") || (isRTL && event.keyIdentifier === "Left")) {
-            if (!this.selectedTreeElement.revealed()) {
-                this.selectedTreeElement.reveal();
-                handled = true;
-            } else if (this.selectedTreeElement.hasChildren) {
-                handled = true;
+        if (this.selectedTreeElement) {
+            if (event.keyIdentifier === collapseKeyIdentifier) {
                 if (this.selectedTreeElement.expanded) {
-                    nextSelectedElement = this.selectedTreeElement.children[0];
-                    while (nextSelectedElement && !nextSelectedElement.selectable)
-                        nextSelectedElement = nextSelectedElement.nextSibling;
-                    handled = nextSelectedElement ? true : false;
-                } else {
                     if (event.altKey)
-                        this.selectedTreeElement.expandRecursively();
+                        this.selectedTreeElement.collapseRecursively();
                     else
-                        this.selectedTreeElement.expand();
+                        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();
                 }
-            }
-        } else if (event.keyCode === 8 /* Backspace */ || event.keyCode === 46 /* Delete */) {
-            for (let treeElement of this.selectedTreeElements) {
-                if (treeElement.ondelete && treeElement.ondelete())
+            } else if (event.keyIdentifier === expandKeyIdentifier) {
+                if (!this.selectedTreeElement.revealed()) {
+                    this.selectedTreeElement.reveal();
+                    handled = true;
+                } else if (this.selectedTreeElement.hasChildren) {
                     handled = true;
+                    if (this.selectedTreeElement.expanded) {
+                        nextSelectedElement = this.selectedTreeElement.children[0];
+                        while (nextSelectedElement && !nextSelectedElement.selectable)
+                            nextSelectedElement = nextSelectedElement.nextSibling;
+                        handled = nextSelectedElement ? true : false;
+                    } else {
+                        if (event.altKey)
+                            this.selectedTreeElement.expandRecursively();
+                        else
+                            this.selectedTreeElement.expand();
+                    }
+                }
+            } else if (event.keyCode === 8 /* Backspace */ || event.keyCode === 46 /* Delete */) {
+                for (let treeElement of this.selectedTreeElements) {
+                    if (treeElement.ondelete && treeElement.ondelete())
+                        handled = true;
+                }
+                if (!handled && this.treeOutline.ondelete)
+                    handled = this.treeOutline.ondelete(this.selectedTreeElement);
+            } else if (isEnterKey(event)) {
+                if (this.selectedTreeElement.onenter)
+                    handled = this.selectedTreeElement.onenter();
+                if (!handled && this.treeOutline.onenter)
+                    handled = this.treeOutline.onenter(this.selectedTreeElement);
+            } else if (event.keyIdentifier === "U+0020" /* Space */) {
+                if (this.selectedTreeElement.onspace)
+                    handled = this.selectedTreeElement.onspace();
+                if (!handled && this.treeOutline.onspace)
+                    handled = this.treeOutline.onspace(this.selectedTreeElement);
             }
-            if (!handled && this.treeOutline.ondelete)
-                handled = this.treeOutline.ondelete(this.selectedTreeElement);
-        } else if (isEnterKey(event)) {
-            if (this.selectedTreeElement.onenter)
-                handled = this.selectedTreeElement.onenter();
-            if (!handled && this.treeOutline.onenter)
-                handled = this.treeOutline.onenter(this.selectedTreeElement);
-        } else if (event.keyIdentifier === "U+0020" /* Space */) {
-            if (this.selectedTreeElement.onspace)
-                handled = this.selectedTreeElement.onspace();
-            if (!handled && this.treeOutline.onspace)
-                handled = this.treeOutline.onspace(this.selectedTreeElement);
         }
 
         if (!handled)