Changeset 52099 in webkit


Ignore:
Timestamp:
Dec 14, 2009 10:01:08 AM (14 years ago)
Author:
pfeldman@chromium.org
Message:

2009-12-14 Pavel Feldman <pfeldman@chromium.org>

Reviewed by Timothy Hatcher.

Web Inspector: [regression] inspector deletes nodes when editing css.

Now all the treeoutlines are focusable, sections and their titles
are also focusable. Change contains couple of drive-by fixes such as
canceling of the attribute edit nuking attr info and maintaining proper
selection while deleting nodes.

https://bugs.webkit.org/show_bug.cgi?id=32460

  • inspector/front-end/CallStackSidebarPane.js: (WebInspector.CallStackSidebarPane.prototype.handleShortcut):
  • inspector/front-end/ConsoleView.js: (WebInspector.ConsoleView.prototype._promptKeyDown):
  • inspector/front-end/DataGrid.js: (WebInspector.DataGrid.prototype._keyDown):
  • inspector/front-end/DatabaseQueryView.js: (WebInspector.DatabaseQueryView): (WebInspector.DatabaseQueryView.prototype._promptKeyDown):
  • inspector/front-end/ElementsPanel.js: (WebInspector.ElementsPanel.this.treeOutline.focusedNodeChanged): (WebInspector.ElementsPanel.prototype.get defaultFocusedElement): (WebInspector.ElementsPanel.prototype.handleShortcut):
  • inspector/front-end/ElementsTreeOutline.js: (WebInspector.ElementsTreeOutline): (WebInspector.ElementsTreeOutline.prototype._keyDown): (WebInspector.ElementsTreeElement.prototype._textNodeEditingCommitted): (WebInspector.ElementsTreeElement.prototype._editingCancelled):
  • inspector/front-end/Panel.js: (WebInspector.Panel.prototype.show): (WebInspector.Panel.prototype.get defaultFocusedElement):
  • inspector/front-end/PropertiesSection.js: (WebInspector.PropertiesSection):
  • inspector/front-end/ScriptsPanel.js: (WebInspector.ScriptsPanel): (WebInspector.ScriptsPanel.prototype.get defaultFocusedElement): (WebInspector.ScriptsPanel.prototype.handleShortcut):
  • inspector/front-end/SidebarPane.js: (WebInspector.SidebarPane): (WebInspector.SidebarPane.prototype.toggleExpanded): (WebInspector.SidebarPane.prototype._onTitleKeyDown):
  • inspector/front-end/SourceFrame.js: (WebInspector.SourceFrame.prototype._loaded):
  • inspector/front-end/TextPrompt.js: (WebInspector.TextPrompt):
  • inspector/front-end/inspector.css:
  • inspector/front-end/inspector.html:
  • inspector/front-end/inspector.js: (WebInspector.loaded): (WebInspector.documentKeyDown): (WebInspector.documentCanCopy): (WebInspector.documentCopy): (WebInspector._searchFieldManualFocus): (WebInspector._searchKeyDown): (WebInspector.startEditing.cleanUpAfterEditing): (WebInspector.startEditing.keyDownEventListener): (WebInspector.startEditing):
  • inspector/front-end/treeoutline.js: (TreeOutline): (TreeOutline._removeChildAtIndex): (TreeOutline.prototype._treeKeyDown): (TreeElement.prototype.deselect):
  • inspector/front-end/utilities.js: ():
Location:
trunk/WebCore
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r52096 r52099  
     12009-12-14  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Reviewed by Timothy Hatcher.
     4
     5        Web Inspector: [regression] inspector deletes nodes when editing css.
     6
     7        Now all the treeoutlines are focusable, sections and their titles
     8        are also focusable. Change contains couple of drive-by fixes such as
     9        canceling of the attribute edit nuking attr info and maintaining proper
     10        selection while deleting nodes.
     11
     12        https://bugs.webkit.org/show_bug.cgi?id=32460
     13
     14        * inspector/front-end/CallStackSidebarPane.js:
     15        (WebInspector.CallStackSidebarPane.prototype.handleShortcut):
     16        * inspector/front-end/ConsoleView.js:
     17        (WebInspector.ConsoleView.prototype._promptKeyDown):
     18        * inspector/front-end/DataGrid.js:
     19        (WebInspector.DataGrid.prototype._keyDown):
     20        * inspector/front-end/DatabaseQueryView.js:
     21        (WebInspector.DatabaseQueryView):
     22        (WebInspector.DatabaseQueryView.prototype._promptKeyDown):
     23        * inspector/front-end/ElementsPanel.js:
     24        (WebInspector.ElementsPanel.this.treeOutline.focusedNodeChanged):
     25        (WebInspector.ElementsPanel.prototype.get defaultFocusedElement):
     26        (WebInspector.ElementsPanel.prototype.handleShortcut):
     27        * inspector/front-end/ElementsTreeOutline.js:
     28        (WebInspector.ElementsTreeOutline):
     29        (WebInspector.ElementsTreeOutline.prototype._keyDown):
     30        (WebInspector.ElementsTreeElement.prototype._textNodeEditingCommitted):
     31        (WebInspector.ElementsTreeElement.prototype._editingCancelled):
     32        * inspector/front-end/Panel.js:
     33        (WebInspector.Panel.prototype.show):
     34        (WebInspector.Panel.prototype.get defaultFocusedElement):
     35        * inspector/front-end/PropertiesSection.js:
     36        (WebInspector.PropertiesSection):
     37        * inspector/front-end/ScriptsPanel.js:
     38        (WebInspector.ScriptsPanel):
     39        (WebInspector.ScriptsPanel.prototype.get defaultFocusedElement):
     40        (WebInspector.ScriptsPanel.prototype.handleShortcut):
     41        * inspector/front-end/SidebarPane.js:
     42        (WebInspector.SidebarPane):
     43        (WebInspector.SidebarPane.prototype.toggleExpanded):
     44        (WebInspector.SidebarPane.prototype._onTitleKeyDown):
     45        * inspector/front-end/SourceFrame.js:
     46        (WebInspector.SourceFrame.prototype._loaded):
     47        * inspector/front-end/TextPrompt.js:
     48        (WebInspector.TextPrompt):
     49        * inspector/front-end/inspector.css:
     50        * inspector/front-end/inspector.html:
     51        * inspector/front-end/inspector.js:
     52        (WebInspector.loaded):
     53        (WebInspector.documentKeyDown):
     54        (WebInspector.documentCanCopy):
     55        (WebInspector.documentCopy):
     56        (WebInspector._searchFieldManualFocus):
     57        (WebInspector._searchKeyDown):
     58        (WebInspector.startEditing.cleanUpAfterEditing):
     59        (WebInspector.startEditing.keyDownEventListener):
     60        (WebInspector.startEditing):
     61        * inspector/front-end/treeoutline.js:
     62        (TreeOutline):
     63        (TreeOutline._removeChildAtIndex):
     64        (TreeOutline.prototype._treeKeyDown):
     65        (TreeElement.prototype.deselect):
     66        * inspector/front-end/utilities.js:
     67        ():
     68
    1692009-12-14  Dimitri Glazkov  <dglazkov@chromium.org>
    270
  • trunk/WebCore/inspector/front-end/CallStackSidebarPane.js

    r47703 r52099  
    110110    },
    111111
    112     handleKeyEvent: function(event)
     112    handleShortcut: function(event)
    113113    {
    114114        var shortcut = WebInspector.KeyboardShortcut.makeKeyFromEvent(event);
     
    116116        if (handler) {
    117117            handler(event);
    118             event.preventDefault();
    119118            event.handled = true;
    120119        }
  • trunk/WebCore/inspector/front-end/ConsoleView.js

    r51528 r52099  
    4646
    4747    this.promptElement = document.getElementById("console-prompt");
    48     this.promptElement.handleKeyEvent = this._promptKeyDown.bind(this);
     48    this.promptElement.addEventListener("keydown", this._promptKeyDown.bind(this), true);
    4949    this.prompt = new WebInspector.TextPrompt(this.promptElement, this.completions.bind(this), ExpressionStopCharacters + ".");
    5050
     
    408408        }
    409409
    410         if (isFnKey(event)) {
    411             if (WebInspector.currentPanel && WebInspector.currentPanel.handleKeyEvent) {
    412                 WebInspector.currentPanel.handleKeyEvent(event);
    413                 return;
    414             }
    415         }
    416 
    417410        var shortcut = WebInspector.KeyboardShortcut.makeKeyFromEvent(event);
    418411        var handler = this._shortcuts[shortcut];
     
    424417            }
    425418        }
    426 
    427         this.prompt.handleKeyEvent(event);
    428419    },
    429420
  • trunk/WebCore/inspector/front-end/DataGrid.js

    r51139 r52099  
    470470    },
    471471
    472     handleKeyEvent: function(event)
     472
     473    _keyDown: function(event)
    473474    {
    474475        if (!this.selectedNode || event.shiftKey || event.metaKey || event.ctrlKey || this._editing)
    475             return false;
     476            return;
    476477
    477478        var handled = false;
     
    541542            event.stopPropagation();
    542543        }
    543 
    544         return handled;
    545544    },
    546545
     
    571570        var rowElement = node.enclosingNodeOrSelfWithNodeName("tr");
    572571        return rowElement._dataGridNode;
    573     },
    574 
    575     _keyDown: function(event)
    576     {
    577         this.handleKeyEvent(event);
    578572    },
    579573
  • trunk/WebCore/inspector/front-end/DatabaseQueryView.js

    r50039 r52099  
    3939    this.promptElement.className = "database-query-prompt";
    4040    this.promptElement.appendChild(document.createElement("br"));
    41     this.promptElement.handleKeyEvent = this._promptKeyDown.bind(this);
     41    this.promptElement.addEventListener("keydown", this._promptKeyDown.bind(this), true);
    4242    this.element.appendChild(this.promptElement);
    4343
     
    9999            return;
    100100        }
    101 
    102         this.prompt.handleKeyEvent(event);
    103101    },
    104102
  • trunk/WebCore/inspector/front-end/ElementsPanel.js

    r51710 r52099  
    4747    {
    4848        if (this.panel.visible && WebInspector.currentFocusElement !== document.getElementById("search"))
    49             WebInspector.currentFocusElement = document.getElementById("main-panels");
     49            WebInspector.currentFocusElement = this.element;
    5050
    5151        this.panel.updateBreadcrumb(forceUpdate);
     
    128128    {
    129129        return [this.nodeSearchButton.element, this.crumbsElement];
     130    },
     131
     132    get defaultFocusedElement()
     133    {
     134        return this.treeOutline.element;
    130135    },
    131136
     
    10251030    },
    10261031
    1027     handleKeyEvent: function(event)
     1032    handleShortcut: function(event)
    10281033    {
    10291034        // Cmd/Control + Shift + C should be a shortcut to clicking the Node Search Button.
     
    10371042            if (isNodeSearchKey) {
    10381043                this._nodeSearchButtonClicked(event);
    1039                 event.preventDefault();
     1044                event.handled = true;
    10401045                return;
    10411046            }
    10421047        }
    1043        
    1044         this.treeOutline.handleKeyEvent(event);
    10451048    },
    10461049
  • trunk/WebCore/inspector/front-end/ElementsTreeOutline.js

    r51961 r52099  
    4444
    4545    this.element.addEventListener("contextmenu", this._contextMenuEventFired.bind(this), true);
     46    this.element.addEventListener("keydown", this._keyDown.bind(this), true);
    4647}
    4748
     
    192193    },
    193194   
    194     handleKeyEvent: function(event)
    195     {
     195    _keyDown: function(event)
     196    {
     197        if (event.target !== this.treeOutline.element)
     198            return;
     199
    196200        var selectedElement = this.selectedTreeElement;
    197201        if (!selectedElement)
     
    202206            selectedElement.remove();
    203207            event.preventDefault();
     208            event.stopPropagation();
    204209            return;
    205210        }
     
    207212        // On Enter or Return start editing the first attribute
    208213        // or create a new attribute on the selected element.
    209         if (event.keyIdentifier === "Enter") {
     214        if (isEnterKey(event)) {
    210215            if (this._editing)
    211216                return;
     
    215220            // prevent a newline from being immediately inserted
    216221            event.preventDefault();
    217             return;
    218         }
    219 
    220         TreeOutline.prototype.handleKeyEvent.call(this, event);
     222            event.stopPropagation();
     223            return;
     224        }
    221225    },
    222226
     
    830834        textNode.nodeValue = newText;
    831835
    832         // No need to call _updateTitle here, it will be called after the nodeValue is committed.
     836        // Need to restore attributes / node structure.
     837        this._updateTitle();
    833838    },
    834839
     
    837842        delete this._editing;
    838843
    839         // No need to call _updateTitle here, the editing code will revert to the original text.
     844        // Need to restore attributes structure.
     845        this._updateTitle();
    840846    },
    841847
  • trunk/WebCore/inspector/front-end/Panel.js

    r50635 r52099  
    8282            this._toolbarItem.addStyleClass("toggled-on");
    8383
    84         WebInspector.currentFocusElement = document.getElementById("main-panels");
     84        WebInspector.currentFocusElement = this.defaultFocusedElement;
    8585
    8686        this.updateSidebarWidth();
     
    9696        if ("_toolbarItem" in this)
    9797            this._toolbarItem.removeStyleClass("toggled-on");
     98    },
     99
     100    get defaultFocusedElement()
     101    {
     102        return this.sidebarTreeElement || this.element;
    98103    },
    99104
     
    275280    },
    276281
    277     handleKeyEvent: function(event)
    278     {
    279         this.handleSidebarKeyEvent(event);
    280     },
    281 
    282     handleSidebarKeyEvent: function(event)
    283     {
    284         if (this.hasSidebar && this.sidebarTree)
    285             this.sidebarTree.handleKeyEvent(event);
    286     },
    287 
    288282    createSidebar: function(parentElement, resizerParentElement)
    289283    {
  • trunk/WebCore/inspector/front-end/PropertiesSection.js

    r39537 r52099  
    4848    this.propertiesElement = document.createElement("ol");
    4949    this.propertiesElement.className = "properties";
     50    this.propertiesElement.tabIndex = 0;
    5051    this.propertiesTreeOutline = new TreeOutline(this.propertiesElement);
    5152    this.propertiesTreeOutline.section = this;
  • trunk/WebCore/inspector/front-end/ScriptsPanel.js

    r51528 r52099  
    5757    this.filesSelectElement.id = "scripts-files";
    5858    this.filesSelectElement.addEventListener("change", this._changeVisibleFile.bind(this), false);
    59     this.filesSelectElement.handleKeyEvent = this.handleKeyEvent.bind(this);
    6059    this.topStatusBar.appendChild(this.filesSelectElement);
    6160
     
    207206    {
    208207        return [this.enableToggleButton.element, this.pauseOnExceptionButton.element];
     208    },
     209
     210    get defaultFocusedElement()
     211    {
     212        return this.filesSelectElement;
    209213    },
    210214
     
    516520    },
    517521
    518     handleKeyEvent: function(event)
     522    handleShortcut: function(event)
    519523    {
    520524        var shortcut = WebInspector.KeyboardShortcut.makeKeyFromEvent(event);
     
    522526        if (handler) {
    523527            handler(event);
    524             event.preventDefault();
    525528            event.handled = true;
    526         } else {
    527             this.sidebarPanes.callstack.handleKeyEvent(event);
    528         }
     529        } else
     530            this.sidebarPanes.callstack.handleShortcut(event);
    529531    },
    530532
  • trunk/WebCore/inspector/front-end/SidebarPane.js

    r37289 r52099  
    3434    this.titleElement = document.createElement("div");
    3535    this.titleElement.className = "title";
     36    this.titleElement.tabIndex = 0;
    3637    this.titleElement.addEventListener("click", this.toggleExpanded.bind(this), false);
     38    this.titleElement.addEventListener("keydown", this._onTitleKeyDown.bind(this), false);
    3739
    3840    this.bodyElement = document.createElement("div");
     
    120122    {
    121123        this.expanded = !this.expanded;
     124    },
     125
     126    _onTitleKeyDown: function(event)
     127    {
     128        if (isEnterKey(event) || event.keyCode === WebInspector.KeyboardShortcut.KeyCodes.Space)
     129            this.toggleExpanded();
    122130    }
    123131}
  • trunk/WebCore/inspector/front-end/SourceFrame.js

    r51250 r52099  
    204204        this.element.contentDocument.addEventListener("mousedown", this._documentMouseDown.bind(this), true);
    205205        this.element.contentDocument.addEventListener("keydown", this._documentKeyDown.bind(this), true);
    206         this.element.contentDocument.addEventListener("keyup", WebInspector.documentKeyUp.bind(WebInspector), true);
    207206        this.element.contentDocument.addEventListener("webkitAnimationEnd", this._highlightLineEnds.bind(this), false);
    208207
  • trunk/WebCore/inspector/front-end/TextPrompt.js

    r51291 r52099  
    3434    this.history = [];
    3535    this.historyOffset = 0;
     36    this.element.addEventListener("keydown", this._onKeyDown.bind(this), true);
    3637}
    3738
     
    5455    },
    5556
    56     handleKeyEvent: function(event)
     57    _onKeyDown: function(event)
    5758    {
    5859        function defaultAction()
  • trunk/WebCore/inspector/front-end/inspector.css

    r51952 r52099  
    10481048}
    10491049
    1050 :focus .outline-disclosure li.selected .selection {
     1050.outline-disclosure ol:focus li.selected .selection {
    10511051    background-color: rgb(56, 121, 217);
    10521052}
     
    10761076}
    10771077
    1078 :focus .outline-disclosure li.selected {
     1078.outline-disclosure ol:focus li.selected {
    10791079    color: white;
    10801080}
    10811081
    1082 :focus .outline-disclosure li.selected * {
     1082.outline-disclosure ol:focus li.selected * {
    10831083    color: inherit;
    10841084}
     
    11051105}
    11061106
    1107 :focus .outline-disclosure li.parent.selected::before {
     1107.outline-disclosure ol:focus li.parent.selected::before {
    11081108    content: url(Images/treeRightTriangleWhite.png);
    11091109}
     
    11131113}
    11141114
    1115 :focus .outline-disclosure li.parent.expanded.selected::before {
     1115.outline-disclosure ol:focus li.parent.expanded.selected::before {
    11161116    content: url(Images/treeDownTriangleWhite.png);
    11171117}
  • trunk/WebCore/inspector/front-end/inspector.html

    r51839 r52099  
    113113    </div>
    114114    <div id="main">
    115         <div id="main-panels" tabindex="0" spellcheck="false"></div>
     115        <div id="main-panels" spellcheck="false"></div>
    116116        <div id="main-status-bar" class="status-bar"><div id="anchored-status-bar-items"><button id="dock-status-bar-item" class="status-bar-item"><div class="glyph"></div><div class="glyph shadow"></div></button><button id="console-status-bar-item" class="status-bar-item"><div class="glyph"></div><div class="glyph shadow"></div></button><button id="changes-status-bar-item" class="status-bar-item hidden"></button><div id="count-items"><div id="changes-count" class="hidden"></div><div id="error-warning-count" class="hidden"></div></div></div></div>
    117117    </div>
  • trunk/WebCore/inspector/front-end/inspector.js

    r51961 r52099  
    476476
    477477    document.addEventListener("focus", this.focusChanged.bind(this), true);
    478     document.addEventListener("keydown", this.documentKeyDown.bind(this), true);
    479     document.addEventListener("keyup", this.documentKeyUp.bind(this), true);
     478    document.addEventListener("keydown", this.documentKeyDown.bind(this), false);
    480479    document.addEventListener("beforecopy", this.documentCanCopy.bind(this), true);
    481480    document.addEventListener("copy", this.documentCopy.bind(this), true);
    482481    document.addEventListener("contextmenu", this.contextMenuEventFired.bind(this), true);
    483 
    484     var mainPanelsElement = document.getElementById("main-panels");
    485     mainPanelsElement.handleCopyEvent = this.mainCopy.bind(this);
    486 
    487     // Focus the mainPanelsElement in a timeout so it happens after the initial focus,
    488     // so it doesn't get reset to the first toolbar button. This initial focus happens
    489     // on Mac when the window is made key and the WebHTMLView becomes the first responder.
    490     setTimeout(function() { WebInspector.currentFocusElement = mainPanelsElement }, 0);
    491482
    492483    var dockToggleButton = document.getElementById("dock-status-bar-item");
     
    510501    var searchField = document.getElementById("search");
    511502    searchField.addEventListener("search", this.performSearch.bind(this), false); // when the search is emptied
    512     searchField.addEventListener("mousedown", this.searchFieldManualFocus.bind(this), false); // when the search field is manually selected
     503    searchField.addEventListener("mousedown", this._searchFieldManualFocus.bind(this), false); // when the search field is manually selected
     504    searchField.addEventListener("keydown", this._searchKeyDown.bind(this), true);
    513505
    514506    toolbarElement.addEventListener("mousedown", this.toolbarDragStart, true);
     
    639631WebInspector.documentKeyDown = function(event)
    640632{
    641     if (this.currentFocusElement) {
    642         if (this.currentFocusElement.handleKeyEvent)
    643             this.currentFocusElement.handleKeyEvent(event);
    644         else if (this.currentFocusElement.id && this.currentFocusElement.id.length && WebInspector[this.currentFocusElement.id + "KeyDown"])
    645             WebInspector[this.currentFocusElement.id + "KeyDown"](event);
    646         if (event.handled)
     633    if (this.currentPanel && this.currentPanel.handleShortcut) {
     634        this.currentPanel.handleShortcut(event);
     635        if (event.handled) {
     636            event.preventDefault();
    647637            return;
    648     }
    649 
    650     if (this.currentPanel && this.currentPanel.handleKeyEvent)
    651         this.currentPanel.handleKeyEvent(event);
    652 
    653     if (!event.handled) {
    654         var isMac = WebInspector.isMac();
    655 
    656         switch (event.keyIdentifier) {
    657             case "U+001B": // Escape key
     638        }
     639    }
     640
     641    var isMac = WebInspector.isMac();
     642
     643    switch (event.keyIdentifier) {
     644        case "U+001B": // Escape key
     645            event.preventDefault();
     646            if (this.drawer.fullPanel)
     647                return;
     648
     649            this.drawer.visible = !this.drawer.visible;
     650            break;
     651
     652        case "U+0046": // F key
     653            if (isMac)
     654                var isFindKey = event.metaKey && !event.ctrlKey && !event.altKey && !event.shiftKey;
     655            else
     656                var isFindKey = event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey;
     657
     658            if (isFindKey) {
     659                var searchField = document.getElementById("search");
     660                searchField.focus();
     661                searchField.select();
    658662                event.preventDefault();
    659                 if (this.drawer.fullPanel)
    660                     return;
    661 
    662                 this.drawer.visible = !this.drawer.visible;
    663                 break;
    664 
    665             case "U+0046": // F key
    666                 if (isMac)
    667                     var isFindKey = event.metaKey && !event.ctrlKey && !event.altKey && !event.shiftKey;
    668                 else
    669                     var isFindKey = event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey;
    670 
    671                 if (isFindKey) {
    672                     var searchField = document.getElementById("search");
    673                     searchField.focus();
    674                     searchField.select();
    675                     event.preventDefault();
    676                 }
    677 
    678                 break;
    679 
    680             case "U+0047": // G key
    681                 if (isMac)
    682                     var isFindAgainKey = event.metaKey && !event.ctrlKey && !event.altKey;
    683                 else
    684                     var isFindAgainKey = event.ctrlKey && !event.metaKey && !event.altKey;
    685 
    686                 if (isFindAgainKey) {
    687                     if (event.shiftKey) {
    688                         if (this.currentPanel.jumpToPreviousSearchResult)
    689                             this.currentPanel.jumpToPreviousSearchResult();
    690                     } else if (this.currentPanel.jumpToNextSearchResult)
    691                         this.currentPanel.jumpToNextSearchResult();
    692                     event.preventDefault();
    693                 }
    694 
    695                 break;
    696 
    697             // Windows and Mac have two different definitions of [, so accept both.
    698             case "U+005B":
    699             case "U+00DB": // [ key
    700                 if (isMac)
    701                     var isRotateLeft = event.metaKey && !event.shiftKey && !event.ctrlKey && !event.altKey;
    702                 else
    703                     var isRotateLeft = event.ctrlKey && !event.shiftKey && !event.metaKey && !event.altKey;
    704 
    705                 if (isRotateLeft) {
    706                     var index = this.panelOrder.indexOf(this.currentPanel);
    707                     index = (index === 0) ? this.panelOrder.length - 1 : index - 1;
    708                     this.panelOrder[index].toolbarItem.click();
    709                     event.preventDefault();
    710                 }
    711 
    712                 break;
    713 
    714             // Windows and Mac have two different definitions of ], so accept both.
    715             case "U+005D":
    716             case "U+00DD":  // ] key
    717                 if (isMac)
    718                     var isRotateRight = event.metaKey && !event.shiftKey && !event.ctrlKey && !event.altKey;
    719                 else
    720                     var isRotateRight = event.ctrlKey && !event.shiftKey && !event.metaKey && !event.altKey;
    721 
    722                 if (isRotateRight) {
    723                     var index = this.panelOrder.indexOf(this.currentPanel);
    724                     index = (index + 1) % this.panelOrder.length;
    725                     this.panelOrder[index].toolbarItem.click();
    726                     event.preventDefault();
    727                 }
    728 
    729                 break;
    730         }
    731     }
    732 }
    733 
    734 WebInspector.documentKeyUp = function(event)
    735 {
    736     if (this.currentFocusElement) {
    737         if (this.currentFocusElement.handleKeyUpEvent)
    738             this.currentFocusElement.handleKeyUpEvent(event);
    739         if (event.handled)
    740             return;
    741     }
    742 
    743     if (this.currentPanel && this.currentPanel.handleKeyUpEvent)
    744         this.currentPanel.handleKeyUpEvent(event);
     663            }
     664
     665            break;
     666
     667        case "U+0047": // G key
     668            if (isMac)
     669                var isFindAgainKey = event.metaKey && !event.ctrlKey && !event.altKey;
     670            else
     671                var isFindAgainKey = event.ctrlKey && !event.metaKey && !event.altKey;
     672
     673            if (isFindAgainKey) {
     674                if (event.shiftKey) {
     675                    if (this.currentPanel.jumpToPreviousSearchResult)
     676                        this.currentPanel.jumpToPreviousSearchResult();
     677                } else if (this.currentPanel.jumpToNextSearchResult)
     678                    this.currentPanel.jumpToNextSearchResult();
     679                event.preventDefault();
     680            }
     681
     682            break;
     683
     684        // Windows and Mac have two different definitions of [, so accept both.
     685        case "U+005B":
     686        case "U+00DB": // [ key
     687            if (isMac)
     688                var isRotateLeft = event.metaKey && !event.shiftKey && !event.ctrlKey && !event.altKey;
     689            else
     690                var isRotateLeft = event.ctrlKey && !event.shiftKey && !event.metaKey && !event.altKey;
     691
     692            if (isRotateLeft) {
     693                var index = this.panelOrder.indexOf(this.currentPanel);
     694                index = (index === 0) ? this.panelOrder.length - 1 : index - 1;
     695                this.panelOrder[index].toolbarItem.click();
     696                event.preventDefault();
     697            }
     698
     699            break;
     700
     701        // Windows and Mac have two different definitions of ], so accept both.
     702        case "U+005D":
     703        case "U+00DD":  // ] key
     704            if (isMac)
     705                var isRotateRight = event.metaKey && !event.shiftKey && !event.ctrlKey && !event.altKey;
     706            else
     707                var isRotateRight = event.ctrlKey && !event.shiftKey && !event.metaKey && !event.altKey;
     708
     709            if (isRotateRight) {
     710                var index = this.panelOrder.indexOf(this.currentPanel);
     711                index = (index + 1) % this.panelOrder.length;
     712                this.panelOrder[index].toolbarItem.click();
     713                event.preventDefault();
     714            }
     715
     716            break;
     717    }
    745718}
    746719
    747720WebInspector.documentCanCopy = function(event)
    748721{
    749     if (!this.currentFocusElement)
    750         return;
    751     // Calling preventDefault() will say "we support copying, so enable the Copy menu".
    752     if (this.currentFocusElement.handleCopyEvent)
    753         event.preventDefault();
    754     else if (this.currentFocusElement.id && this.currentFocusElement.id.length && WebInspector[this.currentFocusElement.id + "Copy"])
    755         event.preventDefault();
     722    return this.currentPanel && this.currentPanel.handleCopyEvent;
    756723}
    757724
    758725WebInspector.documentCopy = function(event)
    759726{
    760     if (!this.currentFocusElement)
    761         return;
    762     if (this.currentFocusElement.handleCopyEvent)
    763         this.currentFocusElement.handleCopyEvent(event);
    764     else if (this.currentFocusElement.id && this.currentFocusElement.id.length && WebInspector[this.currentFocusElement.id + "Copy"])
    765         WebInspector[this.currentFocusElement.id + "Copy"](event);
     727    if (this.currentPanel && this.currentPanel.handleCopyEvent)
     728        this.currentPanel.handleCopyEvent(event);
    766729}
    767730
     
    770733    if (event.handled || event.target.hasStyleClass("popup-glasspane"))
    771734        event.preventDefault();
    772 }
    773 
    774 WebInspector.mainCopy = function(event)
    775 {
    776     if (this.currentPanel && this.currentPanel.handleCopyEvent)
    777         this.currentPanel.handleCopyEvent(event);
    778735}
    779736
     
    15371494}
    15381495
    1539 WebInspector.searchFieldManualFocus = function(event)
     1496WebInspector._searchFieldManualFocus = function(event)
    15401497{
    15411498    this.currentFocusElement = event.target;
     
    15431500}
    15441501
    1545 WebInspector.searchKeyDown = function(event)
     1502WebInspector._searchKeyDown = function(event)
    15461503{
    15471504    // Escape Key will clear the field and clear the search results
    15481505    if (event.keyCode === WebInspector.KeyboardShortcut.KeyCodes.Esc) {
     1506        // If focus belongs here and text is empty - nothing to do, return unhandled.
     1507        if (event.target.value === "" && this.currentFocusElement === this.previousFocusElement)
     1508            return;
    15491509        event.preventDefault();
     1510        event.stopPropagation();
    15501511        // When search was selected manually and is currently blank, we'd like Esc stay unhandled
    15511512        // and hit console drawer handler.
    1552         event.handled = !(this.previousFocusElement === event.target && event.target.value === "");
    15531513        event.target.value = "";
    15541514
     
    15571517        if (this.currentFocusElement === event.target)
    15581518            this.currentFocusElement.select();
    1559         return false;
    1560     } else if (event.keyCode === WebInspector.KeyboardShortcut.KeyCodes.Backspace ||
    1561                event.keyCode === WebInspector.KeyboardShortcut.KeyCodes.Delete) {
    1562         event.handled = true;
    15631519        return false;
    15641520    }
     
    17051661
    17061662    var oldText = getContent(element);
    1707     var oldHandleKeyEvent = element.handleKeyEvent;
    17081663    var moveDirection = "";
    17091664
     
    17331688        this.scrollLeft = 0;
    17341689
    1735         this.handleKeyEvent = oldHandleKeyEvent;
    17361690        element.removeEventListener("blur", blurEventListener, false);
     1691        element.removeEventListener("keydown", keyDownEventListener, true);
    17371692
    17381693        if (element === WebInspector.currentFocusElement || element.isAncestor(WebInspector.currentFocusElement))
     
    17591714    }
    17601715
    1761     element.handleKeyEvent = function(event) {
    1762         if (oldHandleKeyEvent)
    1763             oldHandleKeyEvent(event);
    1764         if (event.handled)
    1765             return;
    1766 
     1716    function keyDownEventListener(event) {
    17671717        if (isEnterKey(event)) {
    17681718            editingCommitted.call(element);
    17691719            event.preventDefault();
    17701720            event.stopPropagation();
    1771             event.handled = true;
    1772         } else if (event.keyCode === 27) { // Escape key
     1721        } else if (event.keyCode === WebInspector.KeyboardShortcut.KeyCodes.Esc) {
    17731722            editingCancelled.call(element);
    17741723            event.preventDefault();
    1775             event.handled = true;
     1724            event.stopPropagation();
    17761725        } else if (event.keyIdentifier === "U+0009") // Tab key
    17771726            moveDirection = (event.shiftKey ? "backward" : "forward");
     
    17791728
    17801729    element.addEventListener("blur", blurEventListener, false);
     1730    element.addEventListener("keydown", keyDownEventListener, true);
    17811731
    17821732    WebInspector.currentFocusElement = element;
  • trunk/WebCore/inspector/front-end/treeoutline.js

    r51946 r52099  
    4141    this.selected = false;
    4242    this.treeOutline = this;
     43
     44    this._childrenListNode.tabIndex = 0;
     45    this._childrenListNode.addEventListener("keydown", this._treeKeyDown.bind(this), true);
    4346}
    4447
     
    142145    this.children.splice(childIndex, 1);
    143146
    144     child.deselect();
     147    var parent = child.parent;
     148    if (child.deselect()) {
     149        if (child.previousSibling)
     150            child.previousSibling.select();
     151        else if (child.nextSibling)
     152            child.nextSibling.select();
     153        else
     154            parent.select();
     155    }
    145156
    146157    if (child.previousSibling)
     
    328339}
    329340
    330 TreeOutline.prototype.handleKeyEvent = function(event)
    331 {
     341TreeOutline.prototype._treeKeyDown = function(event)
     342{
     343    if (event.target !== this._childrenListNode)
     344        return;
     345
    332346    if (!this.selectedTreeElement || event.shiftKey || event.metaKey || event.ctrlKey)
    333         return false;
     347        return;
    334348
    335349    var handled = false;
     
    387401        event.stopPropagation();
    388402    }
    389 
    390     return handled;
    391403}
    392404
     
    776788{
    777789    if (!this.treeOutline || this.treeOutline.selectedTreeElement !== this || !this.selected)
    778         return;
     790        return false;
    779791
    780792    this.selected = false;
     
    785797    if (this.ondeselect && !supressOnDeselect)
    786798        this.ondeselect(this);
     799    return true;
    787800}
    788801
  • trunk/WebCore/inspector/front-end/utilities.js

    r51506 r52099  
    834834    return event.keyCode !== 229 && event.keyIdentifier === "Enter";
    835835}
    836 
    837 function isFnKey(event) {
    838     return event.keyCode >= 112 && event.keyCode <= 123;
    839 }
Note: See TracChangeset for help on using the changeset viewer.