Title: [109348] trunk/Source/WebCore
Revision
109348
Author
pfeld...@chromium.org
Date
2012-03-01 08:16:54 -0800 (Thu, 01 Mar 2012)

Log Message

Web Inspector: hide color picker on Esc and Enter.
https://bugs.webkit.org/show_bug.cgi?id=79915

Reviewed by Vsevolod Vlasov.

* inspector/front-end/Spectrum.js:
(WebInspector.Spectrum.prototype.reposition):
(WebInspector.Spectrum.prototype.hide):
(WebInspector.Spectrum.prototype._onKeyDown):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (109347 => 109348)


--- trunk/Source/WebCore/ChangeLog	2012-03-01 16:13:19 UTC (rev 109347)
+++ trunk/Source/WebCore/ChangeLog	2012-03-01 16:16:54 UTC (rev 109348)
@@ -1,3 +1,15 @@
+2012-03-01  Pavel Feldman  <pfeld...@google.com>
+
+        Web Inspector: hide color picker on Esc and Enter.
+        https://bugs.webkit.org/show_bug.cgi?id=79915
+
+        Reviewed by Vsevolod Vlasov.
+
+        * inspector/front-end/Spectrum.js:
+        (WebInspector.Spectrum.prototype.reposition):
+        (WebInspector.Spectrum.prototype.hide):
+        (WebInspector.Spectrum.prototype._onKeyDown):
+
 2012-03-01  Huang Dongsung  <luxte...@company100.net>
 
         [Qt] Fixed incorrect size pixmap creation for a new transparency layer.

Modified: trunk/Source/WebCore/inspector/front-end/PropertiesSection.js (109347 => 109348)


--- trunk/Source/WebCore/inspector/front-end/PropertiesSection.js	2012-03-01 16:13:19 UTC (rev 109347)
+++ trunk/Source/WebCore/inspector/front-end/PropertiesSection.js	2012-03-01 16:16:54 UTC (rev 109348)
@@ -39,8 +39,8 @@
     this.headerElement.addStyleClass("monospace");
     this.propertiesElement = document.createElement("ol");
     this.propertiesElement.className = "properties properties-tree monospace";
-    this.propertiesElement.tabIndex = 0;
-    this.propertiesTreeOutline = new TreeOutline(this.propertiesElement);
+    this.propertiesTreeOutline = new TreeOutline(this.propertiesElement, true);
+    this.propertiesTreeOutline.setFocusable(false);
     this.propertiesTreeOutline.section = this;
 
     this.element.appendChild(this.propertiesElement);

Modified: trunk/Source/WebCore/inspector/front-end/Spectrum.js (109347 => 109348)


--- trunk/Source/WebCore/inspector/front-end/Spectrum.js	2012-03-01 16:13:19 UTC (rev 109347)
+++ trunk/Source/WebCore/inspector/front-end/Spectrum.js	2012-03-01 16:16:54 UTC (rev 109348)
@@ -38,6 +38,8 @@
 
     this._containerElement = document.createElement('div');
     this._containerElement.className = "spectrum-container";
+    this._containerElement.tabIndex = 0;
+    this._containerElement.addEventListener("keydown", this._onKeyDown.bind(this), false);
 
     var topElement = this._containerElement.createChild("div", "spectrum-top");
     topElement.createChild("div", "spectrum-fill");
@@ -405,11 +407,16 @@
 
     reposition: function(element)
     {
+        if (!this._previousFocusElement)
+            this._previousFocusElement = WebInspector.currentFocusElement();
         this._popover.show(this._containerElement, element);
+        WebInspector.markBeingEdited(this._containerElement, true);    
+        WebInspector.setCurrentFocusElement(this._containerElement);
     },
 
     hide: function()
     {
+        WebInspector.markBeingEdited(this._containerElement, false);
         this._popover.hide();
 
         document.removeEventListener("mousedown", this._hideProxy, false);
@@ -417,8 +424,20 @@
 
         this.dispatchEventToListeners(WebInspector.Spectrum.Events.Hidden);
 
+        WebInspector.setCurrentFocusElement(this._previousFocusElement);
+        delete this._previousFocusElement;
+
         delete this.anchorElement;
+    },
+
+    _onKeyDown: function(event)
+    {
+        if (event.keyIdentifier === "Enter" || event.keyIdentifier === "U+001B") { // Escape key
+            this.hide();
+            event.stopPropagation();
+            event.preventDefault();
+        }
     }
-};
+}
 
 WebInspector.Spectrum.prototype.__proto__ = WebInspector.Object.prototype;

Modified: trunk/Source/WebCore/inspector/front-end/treeoutline.js (109347 => 109348)


--- trunk/Source/WebCore/inspector/front-end/treeoutline.js	2012-03-01 16:13:19 UTC (rev 109347)
+++ trunk/Source/WebCore/inspector/front-end/treeoutline.js	2012-03-01 16:16:54 UTC (rev 109348)
@@ -28,8 +28,9 @@
 
 /**
  * @constructor
+ * @param {boolean=} nonFocusable
  */
-function TreeOutline(listNode)
+function TreeOutline(listNode, nonFocusable)
 {
     /**
      * @type {Array.<TreeElement>}
@@ -48,7 +49,7 @@
     this.searchable = false;
     this.searchInputElement = null;
 
-    this._childrenListNode.tabIndex = 0;
+    this.setFocusable(!nonFocusable);
     this._childrenListNode.addEventListener("keydown", this._treeKeyDown.bind(this), true);
     this._childrenListNode.addEventListener("keypress", this._treeKeyPress.bind(this), true);
     
@@ -56,6 +57,14 @@
     this._expandedStateMap = new Map();
 }
 
+TreeOutline.prototype.setFocusable = function(focusable)
+{
+    if (focusable)
+        this._childrenListNode.setAttribute("tabIndex", 0);
+    else
+        this._childrenListNode.removeAttribute("tabIndex");
+}
+
 TreeOutline.prototype.appendChild = function(child)
 {
     var insertionIndex;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to