Title: [210615] trunk/Source/WebInspectorUI
Revision
210615
Author
commit-qu...@webkit.org
Date
2017-01-11 18:08:39 -0800 (Wed, 11 Jan 2017)

Log Message

Web Inspector: color, gradient, cubic-bezier, spring editors should be dismissable using ESC
https://bugs.webkit.org/show_bug.cgi?id=166934

Patch by Devin Rousso <dcrousso+web...@gmail.com> on 2017-01-11
Reviewed by Brian Burg.

* UserInterface/Views/Popover.js:
(WebInspector.Popover):
(WebInspector.Popover.prototype.dismiss):
(WebInspector.Popover.prototype.handleEvent):
(WebInspector.Popover.prototype._addListenersIfNeeded):
Adds a keydown listener while visible for the Escape key that dismisses the popover.

* UserInterface/Views/QuickConsole.js:
(WebInspector.QuickConsole.prototype.set keyboardShortcutDisabled):
Expose the ability to disable the global keyboard shortcut.  This allows the Popover to have
its own Escape keyboard shortcut to take precedence.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (210614 => 210615)


--- trunk/Source/WebInspectorUI/ChangeLog	2017-01-12 01:57:34 UTC (rev 210614)
+++ trunk/Source/WebInspectorUI/ChangeLog	2017-01-12 02:08:39 UTC (rev 210615)
@@ -1,5 +1,24 @@
 2017-01-11  Devin Rousso  <dcrousso+web...@gmail.com>
 
+        Web Inspector: color, gradient, cubic-bezier, spring editors should be dismissable using ESC
+        https://bugs.webkit.org/show_bug.cgi?id=166934
+
+        Reviewed by Brian Burg.
+
+        * UserInterface/Views/Popover.js:
+        (WebInspector.Popover):
+        (WebInspector.Popover.prototype.dismiss):
+        (WebInspector.Popover.prototype.handleEvent):
+        (WebInspector.Popover.prototype._addListenersIfNeeded):
+        Adds a keydown listener while visible for the Escape key that dismisses the popover.
+
+        * UserInterface/Views/QuickConsole.js:
+        (WebInspector.QuickConsole.prototype.set keyboardShortcutDisabled):
+        Expose the ability to disable the global keyboard shortcut.  This allows the Popover to have
+        its own Escape keyboard shortcut to take precedence.
+
+2017-01-11  Devin Rousso  <dcrousso+web...@gmail.com>
+
         Web Inspector: fix UIString for Print Styles button
         https://bugs.webkit.org/show_bug.cgi?id=166892
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/Popover.js (210614 => 210615)


--- trunk/Source/WebInspectorUI/UserInterface/Views/Popover.js	2017-01-12 01:57:34 UTC (rev 210614)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/Popover.js	2017-01-12 02:08:39 UTC (rev 210615)
@@ -41,9 +41,10 @@
         this._contentNeedsUpdate = false;
         this._dismissing = false;
 
+        this._canvasId = "popover-" + (WebInspector.Popover.canvasId++);
+
         this._element = document.createElement("div");
         this._element.className = "popover";
-        this._canvasId = "popover-" + (WebInspector.Popover.canvasId++);
         this._element.style.backgroundImage = "-webkit-canvas(" + this._canvasId + ")";
         this._element.addEventListener("transitionend", this, true);
 
@@ -147,10 +148,14 @@
 
         console.assert(this._isListeningForPopoverEvents);
         this._isListeningForPopoverEvents = false;
+
         window.removeEventListener("mousedown", this, true);
         window.removeEventListener("scroll", this, true);
         window.removeEventListener("resize", this, true);
+        window.removeEventListener("keypress", this, true);
 
+        WebInspector.quickConsole.keyboardShortcutDisabled = false;
+
         this._element.classList.add(WebInspector.Popover.FadeOutClassName);
 
         if (this.delegate && typeof this.delegate.willDismissPopover === "function")
@@ -169,6 +174,10 @@
             if (this._resizeHandler)
                 this._resizeHandler();
             break;
+        case "keypress":
+            if (event.keyCode === WebInspector.KeyboardShortcut.Key.Escape.keyCode)
+                this.dismiss();
+            break;
         case "transitionend":
             if (event.target === this._element) {
                 document.body.removeChild(this._element);
@@ -568,9 +577,13 @@
     {
         if (!this._isListeningForPopoverEvents) {
             this._isListeningForPopoverEvents = true;
+
             window.addEventListener("mousedown", this, true);
             window.addEventListener("scroll", this, true);
             window.addEventListener("resize", this, true);
+            window.addEventListener("keypress", this, true);
+
+            WebInspector.quickConsole.keyboardShortcutDisabled = true;
         }
     }
 };

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/QuickConsole.js (210614 => 210615)


--- trunk/Source/WebInspectorUI/UserInterface/Views/QuickConsole.js	2017-01-12 01:57:34 UTC (rev 210614)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/QuickConsole.js	2017-01-12 02:08:39 UTC (rev 210615)
@@ -105,6 +105,11 @@
         this.dispatchEventToListeners(WebInspector.QuickConsole.Event.DidResize);
     }
 
+    set keyboardShortcutDisabled(disabled)
+    {
+        this._toggleOrFocusKeyboardShortcut.disabled = disabled;
+    }
+
     // Protected
 
     layout()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to