Fix various minor bugs with style editing in the Inspector.
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jul 2008 04:04:52 +0000 (04:04 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jul 2008 04:04:52 +0000 (04:04 +0000)
        - Restores the scroll position to 0,0 when finished editing a
        string that was longer than the editing input area.

        - Adjusts the margin of the list item to ensure the text does
        not shift when entering and exiting editing mode.

        - Reliably remembers if a shorthand has children when the
        children haven't been populated yet.

        - Reliably remembers if a shorthand was expanded, and expands
        if needed after editing finishes.

        - Hides color swatches when editing.

        https://bugs.webkit.org/show_bug.cgi?id=20238

        Reviewed by Adam Roben.

        * page/inspector/StylesSidebarPane.js:
        (WebInspector.StylePropertyTreeElement.prototype.startEditing):
        Store the expanded state and children state in wasExpanded and
        reallyHasChildren properties.
        (WebInspector.StylePropertyTreeElement.prototype.editingEnded):
        Removed the wasExpanded argument and use the reallyHasChildren and
        wasExpanded properties to restore state. Deletes the state properties.
        (WebInspector.StylePropertyTreeElement.prototype.editingCancelled):
        Removed the wasExpanded argument.
        (WebInspector.StylePropertyTreeElement.prototype.editingCommitted):
        Removed the wasExpanded argument.
        * page/inspector/inspector.css: Tweak the margin and hides the color
        swatches. ALso removes a rule that was not needed.
        * page/inspector/inspector.js:
        (WebInspector.startEditing): Restore the scrollLeft and scrollTop
        to zero when editing finishes.

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

WebCore/ChangeLog
WebCore/page/inspector/StylesSidebarPane.js
WebCore/page/inspector/inspector.css
WebCore/page/inspector/inspector.js

index 7c7898f..593a4c8 100644 (file)
@@ -1,3 +1,42 @@
+2008-07-30  Timothy Hatcher  <timothy@apple.com>
+
+        Fix various minor bugs with style editing in the Inspector.
+
+        - Restores the scroll position to 0,0 when finished editing a
+        string that was longer than the editing input area.
+
+        - Adjusts the margin of the list item to ensure the text does
+        not shift when entering and exiting editing mode.
+
+        - Reliably remembers if a shorthand has children when the
+        children haven't been populated yet.
+
+        - Reliably remembers if a shorthand was expanded, and expands
+        if needed after editing finishes.
+
+        - Hides color swatches when editing.
+
+        https://bugs.webkit.org/show_bug.cgi?id=20238
+
+        Reviewed by Adam Roben.
+
+        * page/inspector/StylesSidebarPane.js:
+        (WebInspector.StylePropertyTreeElement.prototype.startEditing):
+        Store the expanded state and children state in wasExpanded and
+        reallyHasChildren properties.
+        (WebInspector.StylePropertyTreeElement.prototype.editingEnded):
+        Removed the wasExpanded argument and use the reallyHasChildren and
+        wasExpanded properties to restore state. Deletes the state properties.
+        (WebInspector.StylePropertyTreeElement.prototype.editingCancelled):
+        Removed the wasExpanded argument.
+        (WebInspector.StylePropertyTreeElement.prototype.editingCommitted):
+        Removed the wasExpanded argument.
+        * page/inspector/inspector.css: Tweak the margin and hides the color
+        swatches. ALso removes a rule that was not needed.
+        * page/inspector/inspector.js:
+        (WebInspector.startEditing): Restore the scrollLeft and scrollTop
+        to zero when editing finishes.
+
 2008-07-30  Alice Liu  <alice.liu@apple.com>
 
         Implement userIdleTime() for Windows, and place a band-aid over other
index 87b8b21..ad4a226 100644 (file)
@@ -553,9 +553,9 @@ WebInspector.StylePropertyTreeElement.prototype = {
         if (WebInspector.isBeingEdited(this.listItemElement) || (this.treeOutline.section && !this.treeOutline.section.editable))
             return;
 
-        var wasExpanded = this.expanded;
-        this.collapse();
-        // Lie about out children to prevent toggling on click.
+        var context = { expanded: this.expanded, hasChildren: this.hasChildren };
+
+        // Lie about our children to prevent expanding on double click and to collapse shorthands.
         this.hasChildren = false;
 
         if (!selectElement)
@@ -563,25 +563,25 @@ WebInspector.StylePropertyTreeElement.prototype = {
 
         window.getSelection().setBaseAndExtent(selectElement, 0, selectElement, 1);
 
-        WebInspector.startEditing(this.listItemElement, this.editingCommitted.bind(this), this.editingCancelled.bind(this), wasExpanded);
+        WebInspector.startEditing(this.listItemElement, this.editingCommitted.bind(this), this.editingCancelled.bind(this), context);
     },
 
-    editingEnded: function(wasExpanded)
+    editingEnded: function(context)
     {
-        this.hasChildren = (this.children.length ? true : false);
-        if (wasExpanded)
+        this.hasChildren = context.hasChildren;
+        if (context.expanded)
             this.expand();
     },
 
-    editingCancelled: function(e, wasExpanded)
+    editingCancelled: function(element, context)
     {
-        this.editingEnded(wasExpanded);
+        this.editingEnded(context);
         this.updateTitle();
     },
 
-    editingCommitted: function(e, userInput, previousContent, wasExpanded)
+    editingCommitted: function(element, userInput, previousContent, context)
     {
-        this.editingEnded();
+        this.editingEnded(context);
 
         if (userInput === previousContent)
             return; // nothing changed, so do nothing else
index 5d59a94..525c059 100644 (file)
@@ -1167,11 +1167,11 @@ body.inactive .placard.selected {
 }
 
 .section .properties li.editing {
-    margin-left: 8px;
+    margin-left: 10px;
     text-overflow: clip;
 }
 
-.section .properties li.editing.parent::before {
+li.editing .swatch {
     display: none;
 }
 
index a392a1e..7cea17c 100644 (file)
@@ -1150,6 +1150,8 @@ WebInspector.startEditing = function(element, committedCallback, cancelledCallba
 
         this.removeStyleClass("editing");
         this.tabIndex = oldTabIndex;
+        this.scrollTop = 0;
+        this.scrollLeft = 0;
 
         this.handleKeyEvent = handleKeyEvent;
         element.removeEventListener("blur", blurEventListener, false);