Web Inspector: enable editing of selected rows on single click in elements panel.
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Feb 2012 14:28:39 +0000 (14:28 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Feb 2012 14:28:39 +0000 (14:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=77627

Reviewed by Vsevolod Vlasov.

* inspector/front-end/ElementsTreeOutline.js:
(WebInspector.ElementsTreeElement.prototype.onattach):
(WebInspector.ElementsTreeElement.prototype.onselect):
(WebInspector.ElementsTreeElement.prototype._mouseDown):
* inspector/front-end/treeoutline.js:
(TreeElement.prototype.selectOnMouseDown):
(TreeElement.prototype.select):

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

Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/ElementsTreeOutline.js
Source/WebCore/inspector/front-end/treeoutline.js

index 791066b..c341d20 100644 (file)
@@ -1,3 +1,18 @@
+2012-02-02  Pavel Feldman  <pfeldman@google.com>
+
+        Web Inspector: enable editing of selected rows on single click in elements panel.
+        https://bugs.webkit.org/show_bug.cgi?id=77627
+
+        Reviewed by Vsevolod Vlasov.
+
+        * inspector/front-end/ElementsTreeOutline.js:
+        (WebInspector.ElementsTreeElement.prototype.onattach):
+        (WebInspector.ElementsTreeElement.prototype.onselect):
+        (WebInspector.ElementsTreeElement.prototype._mouseDown):
+        * inspector/front-end/treeoutline.js:
+        (TreeElement.prototype.selectOnMouseDown):
+        (TreeElement.prototype.select):
+
 2012-02-02  Philip Rogers  <pdr@google.com>
 
         Fix mirroring with SVG fonts
index a872183..96b864e 100644 (file)
@@ -721,6 +721,8 @@ WebInspector.ElementsTreeElement.prototype = {
         this.updateTitle();
         this._preventFollowingLinksOnDoubleClick();
         this.listItemElement.draggable = true;
+        this.listItemElement.addEventListener("click", this._mouseClick.bind(this));
+        this.listItemElement.addEventListener("mousedown", this._mouseDown.bind(this));
     },
 
     _preventFollowingLinksOnDoubleClick: function()
@@ -943,6 +945,7 @@ WebInspector.ElementsTreeElement.prototype = {
             WebInspector.domAgent.highlightDOMNode(this.representedObject.id);
         this.updateSelection();
         this.treeOutline.suppressRevealAndSelect = false;
+        return true;
     },
 
     ondelete: function()
@@ -994,6 +997,20 @@ WebInspector.ElementsTreeElement.prototype = {
             this.expand();
     },
 
+    _mouseClick: function(event)
+    {
+        if (this._isSingleClickCandidate)
+            this._startEditingTarget(event.target);
+        this._isSingleClickCandidate = false;
+    },
+
+    _mouseDown: function(event)
+    {
+        if (event.handled || event.which !== 1 || this._editing || this._elementCloseTag || !this.selected)
+            return;
+        this._isSingleClickCandidate = true;
+    },
+
     _insertInLastAttributePosition: function(tag, node)
     {
         if (tag.getElementsByClassName("webkit-html-attribute").length > 0)
index 3144ee4..015ffb3 100644 (file)
@@ -997,17 +997,22 @@ TreeElement.prototype.revealed = function()
 
 TreeElement.prototype.selectOnMouseDown = function(event)
 {
-    this.select(false, true);
+    if (this.select(false, true)) {
+        event.stopPropagation();
+        event.preventDefault();
+        event.handled = true;
+    }
 }
 
 /**
  * @param {boolean=} omitFocus
  * @param {boolean=} selectedByUser
+ * @return {boolean}
  */
 TreeElement.prototype.select = function(omitFocus, selectedByUser)
 {
     if (!this.treeOutline || !this.selectable || this.selected)
-        return;
+        return false;
 
     if (this.treeOutline.selectedTreeElement)
         this.treeOutline.selectedTreeElement.deselect();
@@ -1019,13 +1024,14 @@ TreeElement.prototype.select = function(omitFocus, selectedByUser)
 
     // Focusing on another node may detach "this" from tree.
     if (!this.treeOutline)
-        return;
+        return false;
     this.treeOutline.selectedTreeElement = this;
     if (this._listItemNode)
         this._listItemNode.classList.add("selected");
 
     if (this.onselect)
-        this.onselect(this, selectedByUser);
+        return this.onselect(this, selectedByUser);
+    return false;
 }
 
 /**