Changeset 238858 in webkit


Ignore:
Timestamp:
Dec 4, 2018 10:14:28 AM (5 years ago)
Author:
Matt Baker
Message:

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.

Location:
trunk/Source/WebInspectorUI
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r238850 r238858  
     12018-12-04  Matt Baker  <mattbaker@apple.com>
     2
     3        Web Inspector: Elements: ⌘-A should select all visible nodes
     4        https://bugs.webkit.org/show_bug.cgi?id=192120
     5        <rdar://problem/46344435>
     6
     7        Reviewed by Devin Rousso.
     8
     9        * UserInterface/Views/TreeOutline.js:
     10        (WI.TreeOutline.prototype._treeKeyDown):
     11        Remove an early return, allowing `WI.SelectionController` to handle ⌘-A
     12        and select all items.
     13
    1142018-12-04  Devin Rousso  <drousso@apple.com>
    215
  • trunk/Source/WebInspectorUI/UserInterface/Views/TreeOutline.js

    r238825 r238858  
    546546            return;
    547547
    548         if (!this.selectedTreeElement || event.commandOrControlKey)
    549             return;
    550 
    551548        let isRTL = WI.resolvedLayoutDirection() === WI.LayoutDirection.RTL;
     549        let expandKeyIdentifier = isRTL ? "Left" : "Right";
     550        let collapseKeyIdentifier = isRTL ? "Right" : "Left";
    552551
    553552        var handled = false;
    554553        var nextSelectedElement;
    555554
    556         if ((!isRTL && event.keyIdentifier === "Left") || (isRTL && event.keyIdentifier === "Right")) {
    557             if (this.selectedTreeElement.expanded) {
    558                 if (event.altKey)
    559                     this.selectedTreeElement.collapseRecursively();
    560                 else
    561                     this.selectedTreeElement.collapse();
    562                 handled = true;
    563             } else if (this.selectedTreeElement.parent && !this.selectedTreeElement.parent.root) {
    564                 handled = true;
    565                 if (this.selectedTreeElement.parent.selectable) {
    566                     nextSelectedElement = this.selectedTreeElement.parent;
    567                     while (nextSelectedElement && !nextSelectedElement.selectable)
    568                         nextSelectedElement = nextSelectedElement.parent;
    569                     handled = nextSelectedElement ? true : false;
    570                 } else if (this.selectedTreeElement.parent)
    571                     this.selectedTreeElement.parent.collapse();
     555        if (this.selectedTreeElement) {
     556            if (event.keyIdentifier === collapseKeyIdentifier) {
     557                if (this.selectedTreeElement.expanded) {
     558                    if (event.altKey)
     559                        this.selectedTreeElement.collapseRecursively();
     560                    else
     561                        this.selectedTreeElement.collapse();
     562                    handled = true;
     563                } else if (this.selectedTreeElement.parent && !this.selectedTreeElement.parent.root) {
     564                    handled = true;
     565                    if (this.selectedTreeElement.parent.selectable) {
     566                        nextSelectedElement = this.selectedTreeElement.parent;
     567                        while (nextSelectedElement && !nextSelectedElement.selectable)
     568                            nextSelectedElement = nextSelectedElement.parent;
     569                        handled = nextSelectedElement ? true : false;
     570                    } else if (this.selectedTreeElement.parent)
     571                        this.selectedTreeElement.parent.collapse();
     572                }
     573            } else if (event.keyIdentifier === expandKeyIdentifier) {
     574                if (!this.selectedTreeElement.revealed()) {
     575                    this.selectedTreeElement.reveal();
     576                    handled = true;
     577                } else if (this.selectedTreeElement.hasChildren) {
     578                    handled = true;
     579                    if (this.selectedTreeElement.expanded) {
     580                        nextSelectedElement = this.selectedTreeElement.children[0];
     581                        while (nextSelectedElement && !nextSelectedElement.selectable)
     582                            nextSelectedElement = nextSelectedElement.nextSibling;
     583                        handled = nextSelectedElement ? true : false;
     584                    } else {
     585                        if (event.altKey)
     586                            this.selectedTreeElement.expandRecursively();
     587                        else
     588                            this.selectedTreeElement.expand();
     589                    }
     590                }
     591            } else if (event.keyCode === 8 /* Backspace */ || event.keyCode === 46 /* Delete */) {
     592                for (let treeElement of this.selectedTreeElements) {
     593                    if (treeElement.ondelete && treeElement.ondelete())
     594                        handled = true;
     595                }
     596                if (!handled && this.treeOutline.ondelete)
     597                    handled = this.treeOutline.ondelete(this.selectedTreeElement);
     598            } else if (isEnterKey(event)) {
     599                if (this.selectedTreeElement.onenter)
     600                    handled = this.selectedTreeElement.onenter();
     601                if (!handled && this.treeOutline.onenter)
     602                    handled = this.treeOutline.onenter(this.selectedTreeElement);
     603            } else if (event.keyIdentifier === "U+0020" /* Space */) {
     604                if (this.selectedTreeElement.onspace)
     605                    handled = this.selectedTreeElement.onspace();
     606                if (!handled && this.treeOutline.onspace)
     607                    handled = this.treeOutline.onspace(this.selectedTreeElement);
    572608            }
    573         } else if ((!isRTL && event.keyIdentifier === "Right") || (isRTL && event.keyIdentifier === "Left")) {
    574             if (!this.selectedTreeElement.revealed()) {
    575                 this.selectedTreeElement.reveal();
    576                 handled = true;
    577             } else if (this.selectedTreeElement.hasChildren) {
    578                 handled = true;
    579                 if (this.selectedTreeElement.expanded) {
    580                     nextSelectedElement = this.selectedTreeElement.children[0];
    581                     while (nextSelectedElement && !nextSelectedElement.selectable)
    582                         nextSelectedElement = nextSelectedElement.nextSibling;
    583                     handled = nextSelectedElement ? true : false;
    584                 } else {
    585                     if (event.altKey)
    586                         this.selectedTreeElement.expandRecursively();
    587                     else
    588                         this.selectedTreeElement.expand();
    589                 }
    590             }
    591         } else if (event.keyCode === 8 /* Backspace */ || event.keyCode === 46 /* Delete */) {
    592             for (let treeElement of this.selectedTreeElements) {
    593                 if (treeElement.ondelete && treeElement.ondelete())
    594                     handled = true;
    595             }
    596             if (!handled && this.treeOutline.ondelete)
    597                 handled = this.treeOutline.ondelete(this.selectedTreeElement);
    598         } else if (isEnterKey(event)) {
    599             if (this.selectedTreeElement.onenter)
    600                 handled = this.selectedTreeElement.onenter();
    601             if (!handled && this.treeOutline.onenter)
    602                 handled = this.treeOutline.onenter(this.selectedTreeElement);
    603         } else if (event.keyIdentifier === "U+0020" /* Space */) {
    604             if (this.selectedTreeElement.onspace)
    605                 handled = this.selectedTreeElement.onspace();
    606             if (!handled && this.treeOutline.onspace)
    607                 handled = this.treeOutline.onspace(this.selectedTreeElement);
    608609        }
    609610
Note: See TracChangeset for help on using the changeset viewer.