Web Inspector: delete key should work on multi-values visual sidebar grid sections
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Aug 2015 04:11:09 +0000 (04:11 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Aug 2015 04:11:09 +0000 (04:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=148110

Reviewed by Timothy Hatcher.

* UserInterface/Views/VisualStyleCommaSeparatedKeywordEditor.js:
(WebInspector.VisualStyleCommaSeparatedKeywordEditor):
(WebInspector.VisualStyleCommaSeparatedKeywordEditor.prototype._listElementKeyDown):
If the backspace/delete key is pressed when focus is within the list element, delete
the selected list item if it is not currently being edited (if it has an editor).

* UserInterface/Views/VisualStyleFontFamilyTreeElement.js:
(WebInspector.VisualStyleFontFamilyTreeElement.prototype.get currentlyEditing):

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/VisualStyleCommaSeparatedKeywordEditor.js
Source/WebInspectorUI/UserInterface/Views/VisualStyleFontFamilyTreeElement.js

index cb51a68..bf122b9 100644 (file)
@@ -1,5 +1,21 @@
 2015-08-17  Devin Rousso  <drousso@apple.com>
 
+        Web Inspector: delete key should work on multi-values visual sidebar grid sections
+        https://bugs.webkit.org/show_bug.cgi?id=148110
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Views/VisualStyleCommaSeparatedKeywordEditor.js:
+        (WebInspector.VisualStyleCommaSeparatedKeywordEditor):
+        (WebInspector.VisualStyleCommaSeparatedKeywordEditor.prototype._listElementKeyDown):
+        If the backspace/delete key is pressed when focus is within the list element, delete
+        the selected list item if it is not currently being edited (if it has an editor).
+
+        * UserInterface/Views/VisualStyleFontFamilyTreeElement.js:
+        (WebInspector.VisualStyleFontFamilyTreeElement.prototype.get currentlyEditing):
+
+2015-08-17  Devin Rousso  <drousso@apple.com>
+
         Web Inspector: web fonts or unknown fonts show up as Times in visual sidebar
         https://bugs.webkit.org/show_bug.cgi?id=148103
 
index 17ff933..56b6593 100644 (file)
@@ -33,6 +33,7 @@ WebInspector.VisualStyleCommaSeparatedKeywordEditor = class VisualStyleCommaSepa
 
         let listElement = document.createElement("ol");
         listElement.classList.add("visual-style-comma-separated-keyword-list");
+        listElement.addEventListener("keydown", this._listElementKeyDown.bind(this));
         this.contentElement.appendChild(listElement);
 
         this._commaSeparatedKeywords = new WebInspector.TreeOutline(listElement);
@@ -114,6 +115,22 @@ WebInspector.VisualStyleCommaSeparatedKeywordEditor = class VisualStyleCommaSepa
 
     // Private
 
+    _listElementKeyDown(event)
+    {
+        let selectedTreeElement = this._commaSeparatedKeywords.selectedTreeElement;
+        if (!selectedTreeElement)
+            return;
+
+        if (selectedTreeElement.currentlyEditing)
+            return;
+
+        let keyCode = event.keyCode;
+        let backspaceKeyCode = WebInspector.KeyboardShortcut.Key.Backspace.keyCode;
+        let deleteKeyCode = WebInspector.KeyboardShortcut.Key.Delete.keyCode;
+        if (keyCode === backspaceKeyCode || keyCode === deleteKeyCode)
+            this._removeSelectedCommaSeparatedKeyword();
+    }
+
     _treeElementSelected(item, selectedByUser)
     {
         this._removeEmptyCommaSeparatedKeywords();
index 37e2259..c438ecc 100644 (file)
@@ -62,6 +62,11 @@ WebInspector.VisualStyleFontFamilyTreeElement = class VisualStyleFontFamilyTreeE
         this.dispatchEventToListeners(WebInspector.VisualStyleFontFamilyTreeElement.Event.KeywordChanged);
     }
 
+    get currentlyEditing()
+    {
+        return !this.keywordEditorHidden;
+    }
+
     showKeywordEditor()
     {
         if (!this.keywordEditorHidden)