Title: [116933] trunk/Source/WebCore
Revision
116933
Author
[email protected]
Date
2012-05-14 04:42:09 -0700 (Mon, 14 May 2012)

Log Message

Web Inspector: Esc should revert the colorpicker-modifed color to the original
https://bugs.webkit.org/show_bug.cgi?id=86349

Reviewed by Vsevolod Vlasov.

A boolean parameter has been added to the Spectrum's hide() method to denote the picker cancellation,
which gets passed into the "Hidden" event listeners. StylesSidebarPane is made to remember the original property value
when the picker is opened, and restore it if the color picker is cancelled.

* inspector/front-end/Spectrum.js:
(WebInspector.Spectrum):
(WebInspector.Spectrum.prototype.toggle):
(WebInspector.Spectrum.prototype.show):
(WebInspector.Spectrum.prototype.hide):
(WebInspector.Spectrum.prototype._onKeyDown):
* inspector/front-end/StylesSidebarPane.js:
(WebInspector.StylesSidebarPane.prototype.update):
(WebInspector.StylesSidebarPane.prototype.willHide):
(WebInspector.StylePropertyTreeElement.prototype.updateTitle.):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (116932 => 116933)


--- trunk/Source/WebCore/ChangeLog	2012-05-14 11:08:53 UTC (rev 116932)
+++ trunk/Source/WebCore/ChangeLog	2012-05-14 11:42:09 UTC (rev 116933)
@@ -1,3 +1,25 @@
+2012-05-14  Alexander Pavlov  <[email protected]>
+
+        Web Inspector: Esc should revert the colorpicker-modifed color to the original
+        https://bugs.webkit.org/show_bug.cgi?id=86349
+
+        Reviewed by Vsevolod Vlasov.
+
+        A boolean parameter has been added to the Spectrum's hide() method to denote the picker cancellation,
+        which gets passed into the "Hidden" event listeners. StylesSidebarPane is made to remember the original property value
+        when the picker is opened, and restore it if the color picker is cancelled.
+
+        * inspector/front-end/Spectrum.js:
+        (WebInspector.Spectrum):
+        (WebInspector.Spectrum.prototype.toggle):
+        (WebInspector.Spectrum.prototype.show):
+        (WebInspector.Spectrum.prototype.hide):
+        (WebInspector.Spectrum.prototype._onKeyDown):
+        * inspector/front-end/StylesSidebarPane.js:
+        (WebInspector.StylesSidebarPane.prototype.update):
+        (WebInspector.StylesSidebarPane.prototype.willHide):
+        (WebInspector.StylePropertyTreeElement.prototype.updateTitle.):
+
 2012-05-14  Zeno Albisser  <[email protected]>
 
         [Qt] TextureMapperGL::drawTexture marked OVERRIDE but does not override any member function.

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


--- trunk/Source/WebCore/inspector/front-end/Spectrum.js	2012-05-14 11:08:53 UTC (rev 116932)
+++ trunk/Source/WebCore/inspector/front-end/Spectrum.js	2012-05-14 11:42:09 UTC (rev 116933)
@@ -94,7 +94,7 @@
         this._onchange();
     }
 
-    this._hideProxy = this.hide.bind(this);
+    this._hideProxy = this.hide.bind(this, true);
 };
 
 WebInspector.Spectrum.Events = {
@@ -364,7 +364,7 @@
     toggle: function(element, color, format)
     {
         if (this.visible)
-            this.hide();
+            this.hide(true);
         else
             this.show(element, color, format);
 
@@ -378,7 +378,7 @@
                 return false;
 
             // Reopen the picker for another anchor element.
-            this.hide();
+            this.hide(true);
         }
 
         this.reposition(element);
@@ -409,14 +409,17 @@
         WebInspector.setCurrentFocusElement(this._containerElement);
     },
 
-    hide: function()
+    /**
+     * @param {boolean} commitEdit
+     */
+    hide: function(commitEdit)
     {
         this._popover.hide();
 
         document.removeEventListener("mousedown", this._hideProxy, false);
         window.removeEventListener("blur", this._hideProxy, false);
 
-        this.dispatchEventToListeners(WebInspector.Spectrum.Events.Hidden);
+        this.dispatchEventToListeners(WebInspector.Spectrum.Events.Hidden, !!commitEdit);
 
         WebInspector.setCurrentFocusElement(this._previousFocusElement);
         delete this._previousFocusElement;
@@ -426,10 +429,15 @@
 
     _onKeyDown: function(event)
     {
-        if (event.keyIdentifier === "Enter" || event.keyIdentifier === "U+001B") { // Escape key
-            this.hide();
+        if (event.keyIdentifier === "Enter") {
+            this.hide(true);
             event.consume(true);
+            return;
         }
+        if (event.keyIdentifier === "U+001B") { // Escape key
+            this.hide(false);
+            event.consume(true);
+        }
     }
 }
 

Modified: trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js (116932 => 116933)


--- trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js	2012-05-14 11:08:53 UTC (rev 116932)
+++ trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js	2012-05-14 11:42:09 UTC (rev 116933)
@@ -217,7 +217,7 @@
     update: function(node, forceUpdate)
     {
         if (this._spectrum.visible)
-            this._spectrum.hide();
+            this._spectrum.hide(false);
 
         var refresh = false;
 
@@ -879,7 +879,7 @@
     willHide: function()
     {
         if (this._spectrum.visible)
-            this._spectrum.hide();
+            this._spectrum.hide(false);
     }
 }
 
@@ -1774,14 +1774,17 @@
                     self.applyStyleText(nameElement.textContent + ": " + valueElement.textContent, false, false, false);
                 }
 
-                function spectrumHidden()
+                function spectrumHidden(event)
                 {
                     scrollerElement.removeEventListener("scroll", repositionSpectrum, false);
-                    self.applyStyleText(nameElement.textContent + ": " + valueElement.textContent, true, true, false);
+                    var commitEdit = event.data;
+                    var propertyText = !commitEdit && self.originalPropertyText ? self.originalPropertyText : (nameElement.textContent + ": " + valueElement.textContent);
+                    self.applyStyleText(propertyText, true, true, false);
                     spectrum.removeEventListener(WebInspector.Spectrum.Events.ColorChanged, spectrumChanged);
                     spectrum.removeEventListener(WebInspector.Spectrum.Events.Hidden, spectrumHidden);
 
                     delete self._parentPane._isEditingStyle;
+                    delete self.originalPropertyText;
                 }
 
                 function repositionSpectrum()
@@ -1800,6 +1803,7 @@
 
                         if (visible) {
                             spectrum.displayText = color.toString(format);
+                            self.originalPropertyText = self.property.propertyText;
                             self._parentPane._isEditingStyle = true;
                             spectrum.addEventListener(WebInspector.Spectrum.Events.ColorChanged, spectrumChanged);
                             spectrum.addEventListener(WebInspector.Spectrum.Events.Hidden, spectrumHidden);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to