Title: [94671] trunk
Revision
94671
Author
[email protected]
Date
2011-09-07 08:15:44 -0700 (Wed, 07 Sep 2011)

Log Message

Web Inspector: Implement circular tabbing through the Styles sidebar pane contents
https://bugs.webkit.org/show_bug.cgi?id=67127

Reviewed by Yury Semikhatsky.

Source/WebCore:

* inspector/front-end/Section.js:
(WebInspector.Section.prototype.get firstSibling):
(WebInspector.Section.prototype.get lastSibling):
* inspector/front-end/StylesSidebarPane.js:
(WebInspector.StylePropertiesSection.prototype.nextEditableSibling):
(WebInspector.StylePropertiesSection.prototype.previousEditableSibling):
(WebInspector.StylePropertiesSection.prototype.startEditingSelector):
(WebInspector.StylePropertiesSection.prototype._moveEditorFromSelector):
(WebInspector.StylePropertiesSection.prototype.editingSelectorCommitted.successCallback):
(WebInspector.StylePropertiesSection.prototype.editingSelectorCommitted):
(WebInspector.StylePropertyTreeElement.prototype):
(WebInspector.StylePropertyTreeElement.prototype.element.userInput.previousContent.context.moveDirection):

LayoutTests:

* inspector/styles/styles-commit-editing.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (94670 => 94671)


--- trunk/LayoutTests/ChangeLog	2011-09-07 15:09:44 UTC (rev 94670)
+++ trunk/LayoutTests/ChangeLog	2011-09-07 15:15:44 UTC (rev 94671)
@@ -1,3 +1,12 @@
+2011-09-07  Alexander Pavlov  <[email protected]>
+
+        Web Inspector: Implement circular tabbing through the Styles sidebar pane contents
+        https://bugs.webkit.org/show_bug.cgi?id=67127
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/styles/styles-commit-editing.html:
+
 2011-09-07  Andrey Kosyakov  <[email protected]>
 
         Unreviewed test fix (removed a call to console.trace() to avoid having platform-specific expectations).

Modified: trunk/LayoutTests/inspector/styles/styles-commit-editing.html (94670 => 94671)


--- trunk/LayoutTests/inspector/styles/styles-commit-editing.html	2011-09-07 15:09:44 UTC (rev 94670)
+++ trunk/LayoutTests/inspector/styles/styles-commit-editing.html	2011-09-07 15:15:44 UTC (rev 94671)
@@ -10,12 +10,14 @@
     InspectorTest.selectNodeAndWaitForStyles("inspected", step1);
 
     var treeElement;
+    var treeOutline;
     var section;
 
     function step1()
     {
         InspectorTest.dumpSelectedElementStyles(true);
         treeElement = InspectorTest.getElementStylePropertyTreeItem("color");
+        treeOutline = treeElement.treeOutline;
 
         treeElement.startEditing();
         treeElement.nameElement.textContent = "color";
@@ -34,10 +36,19 @@
 
     function step2()
     {
-        if (!WebInspector.isEditingAnyField()) {
+        var blankTreeElement = treeOutline.children[1];
+        if (!WebInspector.isBeingEdited(blankTreeElement.nameElement)) {
             InspectorTest.addResult("No new property editor active!");
             InspectorTest.completeTest();
         }
+
+        // Test Styles pane editor looping.
+        blankTreeElement.nameElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
+        if (!WebInspector.isBeingEdited(treeOutline.children[0].nameElement)) {
+            InspectorTest.addResult("Original property name editor not active!");
+            InspectorTest.completeTest();
+        }
+
         InspectorTest.selectNodeWithId("other");
         InspectorTest.runAfterPendingDispatches(step3);
     }

Modified: trunk/Source/WebCore/ChangeLog (94670 => 94671)


--- trunk/Source/WebCore/ChangeLog	2011-09-07 15:09:44 UTC (rev 94670)
+++ trunk/Source/WebCore/ChangeLog	2011-09-07 15:15:44 UTC (rev 94671)
@@ -1,3 +1,23 @@
+2011-09-07  Alexander Pavlov  <[email protected]>
+
+        Web Inspector: Implement circular tabbing through the Styles sidebar pane contents
+        https://bugs.webkit.org/show_bug.cgi?id=67127
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/front-end/Section.js:
+        (WebInspector.Section.prototype.get firstSibling):
+        (WebInspector.Section.prototype.get lastSibling):
+        * inspector/front-end/StylesSidebarPane.js:
+        (WebInspector.StylePropertiesSection.prototype.nextEditableSibling):
+        (WebInspector.StylePropertiesSection.prototype.previousEditableSibling):
+        (WebInspector.StylePropertiesSection.prototype.startEditingSelector):
+        (WebInspector.StylePropertiesSection.prototype._moveEditorFromSelector):
+        (WebInspector.StylePropertiesSection.prototype.editingSelectorCommitted.successCallback):
+        (WebInspector.StylePropertiesSection.prototype.editingSelectorCommitted):
+        (WebInspector.StylePropertyTreeElement.prototype):
+        (WebInspector.StylePropertyTreeElement.prototype.element.userInput.previousContent.context.moveDirection):
+
 2011-09-02  Andrey Kosyakov  <[email protected]>
 
         Web Inspector: [Extensions API] expose console API

Modified: trunk/Source/WebCore/inspector/front-end/Section.js (94670 => 94671)


--- trunk/Source/WebCore/inspector/front-end/Section.js	2011-09-07 15:09:44 UTC (rev 94670)
+++ trunk/Source/WebCore/inspector/front-end/Section.js	2011-09-07 15:15:44 UTC (rev 94671)
@@ -124,6 +124,38 @@
         }
     },
 
+    get firstSibling()
+    {
+        var parent = this.element.parentElement;
+        if (!parent)
+            return null;
+
+        var childElement = parent.firstChild;
+        while (childElement) {
+            if (childElement._section)
+                return childElement._section;
+            childElement = childElement.nextSibling;
+        }
+
+        return null;
+    },
+
+    get lastSibling()
+    {
+        var parent = this.element.parentElement;
+        if (!parent)
+            return null;
+
+        var childElement = parent.lastChild;
+        while (childElement) {
+            if (childElement._section)
+                return childElement._section;
+            childElement = childElement.previousSibling;
+        }
+
+        return null;
+    },
+
     get nextSibling()
     {
         var curElement = this.element;

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


--- trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js	2011-09-07 15:09:44 UTC (rev 94670)
+++ trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js	2011-09-07 15:15:44 UTC (rev 94671)
@@ -937,7 +937,13 @@
             curSection = curSection.nextSibling;
         } while (curSection && !curSection.editable);
 
-        return curSection;
+        if (!curSection) {
+            curSection = this.firstSibling;
+            while (curSection && !curSection.editable)
+                curSection = curSection.nextSibling;
+        }
+
+        return (curSection && curSection.editable) ? curSection : null;
     },
 
     previousEditableSibling: function()
@@ -947,7 +953,13 @@
             curSection = curSection.previousSibling;
         } while (curSection && !curSection.editable);
 
-        return curSection;
+        if (!curSection) {
+            curSection = this.lastSibling;
+            while (curSection && !curSection.editable)
+                curSection = curSection.previousSibling;
+        }
+
+        return (curSection && curSection.editable) ? curSection : null;
     },
 
     update: function(full)
@@ -1122,6 +1134,7 @@
         if (WebInspector.isBeingEdited(element))
             return;
 
+        this._selectorElement.scrollIntoViewIfNeeded(false);
         WebInspector.startEditing(this._selectorElement, {
             context: null,
             commitHandler: this.editingSelectorCommitted.bind(this),
@@ -1130,32 +1143,32 @@
         window.getSelection().setBaseAndExtent(element, 0, element, 1);
     },
 
-    editingSelectorCommitted: function(element, newContent, oldContent, context, moveDirection)
+    _moveEditorFromSelector: function(moveDirection)
     {
-        function moveToNextIfNeeded() {
-            if (!moveDirection)
+        if (!moveDirection)
+            return;
+
+        if (moveDirection === "forward") {
+            this.expand();
+            var firstChild = this.propertiesTreeOutline.children[0];
+            if (!firstChild)
+                this.addNewBlankProperty().startEditing();
+            else
+                firstChild.startEditing(firstChild.nameElement);
+        } else {
+            var previousSection = this.previousEditableSibling();
+            if (!previousSection)
                 return;
 
-            if (moveDirection === "forward") {
-                this.expand();
-                if (this.propertiesTreeOutline.children.length === 0)
-                    this.addNewBlankProperty().startEditing();
-                else {
-                    var item = this.propertiesTreeOutline.children[0]
-                    item.startEditing(item.nameElement);
-                }
-            } else {
-                var previousSection = this.previousEditableSibling();
-                if (!previousSection)
-                    return;
-
-                previousSection.expand();
-                previousSection.addNewBlankProperty().startEditing();
-            }
+            previousSection.expand();
+            previousSection.addNewBlankProperty().startEditing();
         }
+    },
 
+    editingSelectorCommitted: function(element, newContent, oldContent, context, moveDirection)
+    {
         if (newContent === oldContent)
-            return moveToNextIfNeeded.call(this);
+            return this._moveEditorFromSelector(moveDirection);
 
         var self = this;
 
@@ -1179,7 +1192,7 @@
 
             WebInspector.panels.elements.renameSelector(oldIdentifier, this.identifier, oldContent, newContent);
 
-            moveToNextIfNeeded.call(self);
+            self._moveEditorFromSelector(moveDirection);
         }
 
         var selectedNode = WebInspector.panels.elements.selectedDOMNode();
@@ -1839,6 +1852,8 @@
         delete this.originalPropertyText;
 
         this._parentPane._isEditingStyle = true;
+        if (selectElement.parentElement)
+            selectElement.parentElement.scrollIntoViewIfNeeded(false);
         WebInspector.startEditing(selectElement, {
             context: context,
             commitHandler: this.editingCommitted.bind(this),
@@ -1982,7 +1997,7 @@
             else
                 this.updateTitle();
         }
-    }, 
+    },
 
     editingCommitted: function(element, userInput, previousContent, context, moveDirection)
     {
@@ -2000,11 +2015,11 @@
                 moveTo = (moveDirection === "forward" ? moveTo.nextSibling : moveTo.previousSibling);
             } while(moveTo && !moveTo.selectable);
 
-           if (moveTo)
+            if (moveTo)
                 moveToPropertyName = moveTo.name;
             else if (moveDirection === "forward" && (!this._newProperty || userInput))
                 createNewProperty = true;
-            else if (moveDirection === "backward" && this.treeOutline.section.rule)
+            else if (moveDirection === "backward")
                 moveToSelector = true;
         }
 
@@ -2074,13 +2089,21 @@
 
             if (abandonNewProperty) {
                 var sectionToEdit = moveDirection === "backward" ? section : section.nextEditableSibling();
-                if (sectionToEdit && sectionToEdit.rule)
-                    sectionToEdit.startEditingSelector();
+                if (sectionToEdit) {
+                    if (sectionToEdit.rule)
+                        sectionToEdit.startEditingSelector();
+                    else
+                        sectionToEdit._moveEditorFromSelector(moveDirection);
+                }
                 return;
             }
 
-            if (moveToSelector)
-                section.startEditingSelector();
+            if (moveToSelector) {
+                if (section.rule)
+                    section.startEditingSelector();
+                else
+                    section._moveEditorFromSelector(moveDirection);
+            }
         }
     },
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to