[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75

joepeck at webkit.org joepeck at webkit.org
Thu Oct 29 20:46:27 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit c44830e80b27325d93c76e839c0f36eef937fcdd
Author: joepeck at webkit.org <joepeck at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Oct 17 00:08:50 2009 +0000

    2009-10-15  Joseph Pecoraro  <joepeck at webkit.org>
    
            Reviewed by Timothy Hatcher.
    
            Web Inspector: Handle the Enter Key in the Elements Tree Hierarchy
            https://bugs.webkit.org/show_bug.cgi?id=30428
    
            TextNode => Edit Text Node
            Has Attributes => Edit First Attribute
            No Attributes => Start Editing New Attribute
    
            * inspector/front-end/ElementsTreeOutline.js:
            (WebInspector.ElementsTreeOutline.prototype.handleKeyEvent): handle the "Enter" key
            (WebInspector.ElementsTreeElement.prototype.set hovered): only add new attribute button on nodes with attributes
            (WebInspector.ElementsTreeElement.prototype._addNewAttribute): prevent moving backwards where there are no attributes
            (WebInspector.ElementsTreeElement.prototype._startEditingFromEvent): renamed to be clearer
            (WebInspector.ElementsTreeElement.prototype._startEditing): transition to the appropriate edit state for a tree element
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49709 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 3d9b3c8..0684128 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,21 @@
+2009-10-15  Joseph Pecoraro  <joepeck at webkit.org>
+
+        Reviewed by Timothy Hatcher.
+
+        Web Inspector: Handle the Enter Key in the Elements Tree Hierarchy
+        https://bugs.webkit.org/show_bug.cgi?id=30428
+
+        TextNode => Edit Text Node
+        Has Attributes => Edit First Attribute
+        No Attributes => Start Editing New Attribute
+
+        * inspector/front-end/ElementsTreeOutline.js:
+        (WebInspector.ElementsTreeOutline.prototype.handleKeyEvent): handle the "Enter" key
+        (WebInspector.ElementsTreeElement.prototype.set hovered): only add new attribute button on nodes with attributes
+        (WebInspector.ElementsTreeElement.prototype._addNewAttribute): prevent moving backwards where there are no attributes
+        (WebInspector.ElementsTreeElement.prototype._startEditingFromEvent): renamed to be clearer
+        (WebInspector.ElementsTreeElement.prototype._startEditing): transition to the appropriate edit state for a tree element
+
 2009-10-16  Adam Barth  <abarth at webkit.org>
 
         Reviewed by Eric Seidel.
diff --git a/WebCore/inspector/front-end/ElementsTreeOutline.js b/WebCore/inspector/front-end/ElementsTreeOutline.js
index ec1bbd0..c4bd372 100644
--- a/WebCore/inspector/front-end/ElementsTreeOutline.js
+++ b/WebCore/inspector/front-end/ElementsTreeOutline.js
@@ -188,16 +188,28 @@ WebInspector.ElementsTreeOutline.prototype = {
     handleKeyEvent: function(event)
     {
         var selectedElement = this.selectedTreeElement;
-
         if (!selectedElement)
             return;
-        
-        if (event.keyCode == 8 || event.keyCode == 46) {
-            // Delete or backspace pressed, delete the node.
+
+        // Delete or backspace pressed, delete the node.
+        if (event.keyCode === 8 || event.keyCode === 46) {
             selectedElement.remove();
             return;
         }
-        
+
+        // On Enter or Return start editing the first attribute
+        // or create a new attribute on the selected element.
+        if (event.keyIdentifier === "Enter") {
+            if (this._editing)
+                return;
+
+            selectedElement._startEditing();
+
+            // prevent a newline from being immediately inserted
+            event.preventDefault();
+            return;
+        }
+
         TreeOutline.prototype.handleKeyEvent.call(this, event);
     },
 
@@ -295,7 +307,8 @@ WebInspector.ElementsTreeElement.prototype = {
             if (x) {
                 this.updateSelection();
                 this.listItemElement.addStyleClass("hovered");
-                this._pendingToggleNewAttribute = setTimeout(this.toggleNewAttributeButton.bind(this, true), 500);
+                if (this._canAddAttributes)
+                    this._pendingToggleNewAttribute = setTimeout(this.toggleNewAttributeButton.bind(this, true), 500);
             } else {
                 this.listItemElement.removeStyleClass("hovered");
                 if (this._pendingToggleNewAttribute) {
@@ -506,7 +519,7 @@ WebInspector.ElementsTreeElement.prototype = {
         if (this._editing)
             return;
 
-        if (this._startEditing(event, treeElement))
+        if (this._startEditingFromEvent(event, treeElement))
             return;
 
         if (this.treeOutline.panel) {
@@ -531,7 +544,7 @@ WebInspector.ElementsTreeElement.prototype = {
         }
     },
 
-    _startEditing: function(event, treeElement)
+    _startEditingFromEvent: function(event, treeElement)
     {
         if (this.treeOutline.focusedDOMNode != this.representedObject)
             return;
@@ -554,6 +567,30 @@ WebInspector.ElementsTreeElement.prototype = {
         return false;
     },
 
+    _startEditing: function()
+    {
+        if (this.treeOutline.focusedDOMNode !== this.representedObject)
+            return;
+
+        var listItem = this._listItemNode;
+
+        if (this._canAddAttributes) {
+            this.toggleNewAttributeButton(false);
+            var attribute = listItem.getElementsByClassName("webkit-html-attribute")[0];
+            if (attribute)
+                return this._startEditingAttribute(attribute, attribute.getElementsByClassName("webkit-html-attribute-name")[0]);
+
+            return this._addNewAttribute(listItem);
+        }
+
+        if (this.representedObject.nodeType === Node.TEXT_NODE) {
+            var textNode = listItem.getElementsByClassName("webkit-html-text-node")[0];
+            if (textNode)
+                return this._startEditingTextNode(textNode);
+            return;
+        }
+    },
+
     _addNewAttribute: function(listItemElement)
     {
         var attr = document.createElement("span");
@@ -661,7 +698,7 @@ WebInspector.ElementsTreeElement.prototype = {
                 }
             }
 
-            if (!found && moveDirection === "backward")
+            if (!found && moveDirection === "backward" && attributes.length > 0)
                 moveToAttribute = attributes[attributes.length - 1].name;
             else if (!found && moveDirection === "forward" && !/^\s*$/.test(newText))
                 newAttribute = true;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list