Title: [106550] trunk/Source/WebCore
Revision
106550
Author
[email protected]
Date
2012-02-02 06:25:15 -0800 (Thu, 02 Feb 2012)

Log Message

Web Inspector: add experiment for single click styles editing.
https://bugs.webkit.org/show_bug.cgi?id=77624

Reviewed by Vsevolod Vlasov.

* inspector/front-end/Settings.js:
(WebInspector.ExperimentsSettings):
* inspector/front-end/StylesSidebarPane.js:
(WebInspector.StylePropertiesSection):
(WebInspector.StylePropertyTreeElement.prototype.onattach):
(WebInspector.StylePropertyTreeElement.prototype._mouseDown):
(WebInspector.StylePropertyTreeElement.prototype._resetMouseDownElement):
(WebInspector.StylePropertyTreeElement.prototype):
(WebInspector.StylePropertyTreeElement.prototype.selectElement.context):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (106549 => 106550)


--- trunk/Source/WebCore/ChangeLog	2012-02-02 14:13:36 UTC (rev 106549)
+++ trunk/Source/WebCore/ChangeLog	2012-02-02 14:25:15 UTC (rev 106550)
@@ -1,3 +1,20 @@
+2012-02-02  Pavel Feldman  <[email protected]>
+
+        Web Inspector: add experiment for single click styles editing.
+        https://bugs.webkit.org/show_bug.cgi?id=77624
+
+        Reviewed by Vsevolod Vlasov.
+
+        * inspector/front-end/Settings.js:
+        (WebInspector.ExperimentsSettings):
+        * inspector/front-end/StylesSidebarPane.js:
+        (WebInspector.StylePropertiesSection):
+        (WebInspector.StylePropertyTreeElement.prototype.onattach):
+        (WebInspector.StylePropertyTreeElement.prototype._mouseDown):
+        (WebInspector.StylePropertyTreeElement.prototype._resetMouseDownElement):
+        (WebInspector.StylePropertyTreeElement.prototype):
+        (WebInspector.StylePropertyTreeElement.prototype.selectElement.context):
+
 2012-02-02  Kenneth Rohde Christiansen  <[email protected]>
 
         Make the tap highlighting work for all test cases

Modified: trunk/Source/WebCore/inspector/front-end/Settings.js (106549 => 106550)


--- trunk/Source/WebCore/inspector/front-end/Settings.js	2012-02-02 14:13:36 UTC (rev 106549)
+++ trunk/Source/WebCore/inspector/front-end/Settings.js	2012-02-02 14:25:15 UTC (rev 106550)
@@ -172,6 +172,7 @@
     this.sourceFrameAlwaysEditable = this._createExperiment("sourceFrameAlwaysEditable", "Make resources always editable");
     this.freeFlowDOMEditing = this._createExperiment("freeFlowDOMEditing", "Enable free flow DOM editing");
     this.showMemoryCounters = this._createExperiment("showMemoryCounters", "Show memory counters in Timeline panel");
+    this.singleClickEditing = this._createExperiment("singleClickEditing", "Single click CSS editing");
 
     this._cleanUpSetting();
 }

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


--- trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js	2012-02-02 14:13:36 UTC (rev 106549)
+++ trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js	2012-02-02 14:25:15 UTC (rev 106550)
@@ -899,8 +899,9 @@
     closeBrace.textContent = "}";
     this.element.appendChild(closeBrace);
 
-    this._selectorElement.addEventListener("dblclick", this._handleSelectorDoubleClick.bind(this), false);
-    this.element.addEventListener("dblclick", this._handleEmptySpaceDoubleClick.bind(this), false);
+    var eventName = WebInspector.experimentsSettings.singleClickEditing.isEnabled() ? "click" : "dblclick";
+    this._selectorElement.addEventListener(eventName, this._handleSelectorDoubleClick.bind(this), false);
+    this.element.addEventListener(eventName, this._handleEmptySpaceDoubleClick.bind(this), false);
 
     this._parentPane = parentPane;
     this.styleRule = styleRule;
@@ -1522,8 +1523,30 @@
     onattach: function()
     {
         this.updateTitle();
+        var eventName;
+        if (WebInspector.experimentsSettings.singleClickEditing.isEnabled()) {
+            this.listItemElement.addEventListener("mousedown", this._mouseDown.bind(this));
+            this.listItemElement.addEventListener("mouseup", this._resetMouseDownElement.bind(this));
+            eventName = "click";
+        } else
+            eventName = "dblclick";
+        this.listItemElement.addEventListener(eventName, this._startEditing.bind(this));
     },
 
+    _mouseDown: function(event)
+    {
+        this._parentPane._mouseDownTreeElement = this;
+        this._parentPane._mouseDownTreeElementIsName = this._isNameElement(event.target);
+        this._parentPane._mouseDownTreeElementIsValue = this._isValueElement(event.target);
+    },
+
+    _resetMouseDownElement: function()
+    {
+        delete this._parentPane._mouseDownTreeElement;
+        delete this._parentPane._mouseDownTreeElementIsName;
+        delete this._parentPane._mouseDownTreeElementIsValue;
+    },
+
     updateTitle: function()
     {
         var value = this.value;
@@ -1809,12 +1832,6 @@
         }
     },
 
-    ondblclick: function(event)
-    {
-        this.startEditing(event.target);
-        event.stopPropagation();
-    },
-
     restoreNameElement: function()
     {
         // Restore <span class="webkit-css-property"> if it doesn't yet exist or was accidentally deleted.
@@ -1827,6 +1844,22 @@
         this.listItemElement.insertBefore(this.nameElement, this.listItemElement.firstChild);
     },
 
+    _startEditing: function(event)
+    {
+        this.startEditing(event.target);
+        event.stopPropagation();
+    },
+
+    _isNameElement: function(element)
+    {
+        return element.enclosingNodeOrSelfWithClass("webkit-css-property") === this.nameElement;
+    },
+
+    _isValueElement: function(element)
+    {
+        return !!element.enclosingNodeOrSelfWithClass("value");
+    },
+
     startEditing: function(selectElement)
     {
         // FIXME: we don't allow editing of longhand properties under a shorthand right now.
@@ -1892,7 +1925,15 @@
 
         function blurListener(context, event)
         {
-            this.editingCommitted(null, event.target.textContent, context.previousContent, context, "");
+            var treeElement = this._parentPane._mouseDownTreeElement;
+            var moveDirection = "";
+            if (treeElement === this) {
+                if (isEditingName && this._parentPane._mouseDownTreeElementIsValue)
+                    moveDirection = "forward";
+                if (!isEditingName && this._parentPane._mouseDownTreeElementIsName)
+                    moveDirection = "backward";
+            }
+            this.editingCommitted(null, event.target.textContent, context.previousContent, context, moveDirection);
         }
 
         delete this.originalPropertyText;
@@ -2004,6 +2045,7 @@
 
     editingEnded: function(context)
     {
+        this._resetMouseDownElement();
         if (this._applyFreeFlowStyleTextEditTimer)
             clearTimeout(this._applyFreeFlowStyleTextEditTimer);
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to