Title: [147094] trunk
Revision
147094
Author
apav...@chromium.org
Date
2013-03-28 05:02:15 -0700 (Thu, 28 Mar 2013)

Log Message

Web Inspector: [REGRESSION] [Styles] Pasting a property in the "name" field is broken
https://bugs.webkit.org/show_bug.cgi?id=113491

Reviewed by Pavel Feldman.

Source/WebCore:

Update the CSSProperty name and value upon pasting properties into the Styles pane.
Drive-by: start editing the next/new property name after pasting.

Test: inspector/styles/paste-property.html

* inspector/front-end/StylesSidebarPane.js:
(.selectElement):
(.moveDirection.alreadyNew):

LayoutTests:

* inspector/styles/paste-property-expected.txt: Added.
* inspector/styles/paste-property.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (147093 => 147094)


--- trunk/LayoutTests/ChangeLog	2013-03-28 10:54:58 UTC (rev 147093)
+++ trunk/LayoutTests/ChangeLog	2013-03-28 12:02:15 UTC (rev 147094)
@@ -1,3 +1,13 @@
+2013-03-28  Alexander Pavlov  <apav...@chromium.org>
+
+        Web Inspector: [REGRESSION] [Styles] Pasting a property in the "name" field is broken
+        https://bugs.webkit.org/show_bug.cgi?id=113491
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/styles/paste-property-expected.txt: Added.
+        * inspector/styles/paste-property.html: Added.
+
 2013-03-28  Zan Dobersek  <zdober...@igalia.com>
 
         Unreviewed GTK gardening.

Added: trunk/LayoutTests/inspector/styles/paste-property-expected.txt (0 => 147094)


--- trunk/LayoutTests/inspector/styles/paste-property-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/styles/paste-property-expected.txt	2013-03-28 12:02:15 UTC (rev 147094)
@@ -0,0 +1,56 @@
+Tests that splitting properties when pasting works.
+
+Text
+Before pasting:
+[expanded] 
+element.style  { ()
+font-size: 12px;
+
+======== Matched CSS Rules ========
+[expanded] 
+div  { (user agent stylesheet)
+display: block;
+
+
+After pasting 'margin-left: 1px':
+[expanded] 
+element.style  { ()
+margin-left: 1px;
+font-size: 12px;
+
+======== Matched CSS Rules ========
+[expanded] 
+div  { (user agent stylesheet)
+display: block;
+
+
+After pasting 'margin-top: 1px; color: red;':
+[expanded] 
+element.style  { ()
+margin-left: 1px;
+font-size: 12px;
+margin-top: 1px;
+color: red;
+
+======== Matched CSS Rules ========
+[expanded] 
+div  { (user agent stylesheet)
+display: block;
+
+
+After pasting 'foo: bar; moo: zoo' over 'margin-top':
+[expanded] 
+element.style  { ()
+margin-left: 1px;
+font-size: 12px;
+/-- overloaded --/ foo: bar;
+/-- overloaded --/ moo: zoo;
+color: red;
+
+======== Matched CSS Rules ========
+[expanded] 
+div  { (user agent stylesheet)
+display: block;
+
+
+

Added: trunk/LayoutTests/inspector/styles/paste-property.html (0 => 147094)


--- trunk/LayoutTests/inspector/styles/paste-property.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/styles/paste-property.html	2013-03-28 12:02:15 UTC (rev 147094)
@@ -0,0 +1,83 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+
+function test()
+{
+    WebInspector.showPanel("elements");
+    InspectorTest.selectNodeAndWaitForStyles("inspected", pasteFirstProperty);
+
+    function pasteFirstProperty()
+    {
+        InspectorTest.addResult("Before pasting:");
+        InspectorTest.dumpSelectedElementStyles(true);
+        var section = WebInspector.panels.elements.sidebarPanes.styles.sections[0][1];
+        section.expand();
+
+        var treeElement = section.addNewBlankProperty(0);
+        pasteProperty(treeElement, "margin-left: 1px", pasteTwoProperties);
+    }
+
+    function pasteTwoProperties()
+    {
+        InspectorTest.addResult("After pasting 'margin-left: 1px':");
+        InspectorTest.dumpSelectedElementStyles(true);
+
+        var treeElement = WebInspector.panels.elements.sidebarPanes.styles.sections[0][1].addNewBlankProperty(2);
+        pasteProperty(treeElement, "margin-top: 1px; color: red;", pasteOverExistingProperty);
+    }
+
+    function pasteOverExistingProperty()
+    {
+        InspectorTest.addResult("After pasting 'margin-top: 1px; color: red;':");
+        InspectorTest.dumpSelectedElementStyles(true);
+
+        var treeElement = InspectorTest.getElementStylePropertyTreeItem("margin-top");
+        pasteProperty(treeElement, "foo: bar; moo: zoo", dumpAndComplete);
+    }
+
+    function dumpAndComplete()
+    {
+        InspectorTest.addResult("After pasting 'foo: bar; moo: zoo' over 'margin-top':");
+        InspectorTest.dumpSelectedElementStyles(true);
+
+        InspectorTest.completeTest();
+    }
+
+    function pasteProperty(treeElement, propertyText, callback)
+    {
+        treeElement.nameElement.textContent = propertyText;
+        treeElement.startEditing();
+
+        document.execCommand("SelectAll");
+        document.execCommand("Copy");
+        document.execCommand("Paste");
+        InspectorTest.runAfterPendingDispatches(reloadStyles.bind(this, callback));
+    }
+
+    function reloadStyles(callback) {
+        InspectorTest.selectNodeWithId("other");
+        InspectorTest.runAfterPendingDispatches(otherCallback);
+
+        function otherCallback()
+        {
+            InspectorTest.selectNodeAndWaitForStyles("inspected", callback);
+        }
+    }
+}
+
+</script>
+</head>
+
+<body _onload_="runTest()">
+<p>
+Tests that splitting properties when pasting works.
+</p>
+
+<div id="inspected" style="font-size: 12px">Text</div>
+<div id="other"></div>
+
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (147093 => 147094)


--- trunk/Source/WebCore/ChangeLog	2013-03-28 10:54:58 UTC (rev 147093)
+++ trunk/Source/WebCore/ChangeLog	2013-03-28 12:02:15 UTC (rev 147094)
@@ -1,3 +1,19 @@
+2013-03-28  Alexander Pavlov  <apav...@chromium.org>
+
+        Web Inspector: [REGRESSION] [Styles] Pasting a property in the "name" field is broken
+        https://bugs.webkit.org/show_bug.cgi?id=113491
+
+        Reviewed by Pavel Feldman.
+
+        Update the CSSProperty name and value upon pasting properties into the Styles pane.
+        Drive-by: start editing the next/new property name after pasting.
+
+        Test: inspector/styles/paste-property.html
+
+        * inspector/front-end/StylesSidebarPane.js:
+        (.selectElement):
+        (.moveDirection.alreadyNew):
+
 2013-03-28  Alexei Filippov  <a...@chromium.org>
 
         Web Inspector: Auto expand retaining path until there are more than one retainer.

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


--- trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js	2013-03-28 10:54:58 UTC (rev 147093)
+++ trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js	2013-03-28 12:02:15 UTC (rev 147094)
@@ -2260,6 +2260,8 @@
                 context.originalName = this.nameElement.textContent;
                 context.originalValue = this.valueElement.textContent;
             }
+            this.property.name = name;
+            this.property.value = value;
             this.nameElement.textContent = name;
             this.valueElement.textContent = value;
             this.nameElement.normalize();
@@ -2444,10 +2446,13 @@
 
         // Determine where to move to before making changes
         var createNewProperty, moveToPropertyName, moveToSelector;
+        var isDataPasted = "originalName" in context;
+        var isDirtyViaPaste = isDataPasted && (this.nameElement.textContent !== context.originalName || this.valueElement.textContent !== context.originalValue);
+        var isPropertySplitPaste = isDataPasted && isEditingName && this.valueElement.textContent !== context.originalValue;
         var moveTo = this;
         var moveToOther = (isEditingName ^ (moveDirection === "forward"));
         var abandonNewProperty = this._newProperty && !userInput && (moveToOther || isEditingName);
-        if (moveDirection === "forward" && !isEditingName || moveDirection === "backward" && isEditingName) {
+        if (moveDirection === "forward" && (!isEditingName || isPropertySplitPaste) || moveDirection === "backward" && isEditingName) {
             moveTo = moveTo._findSibling(moveDirection);
             if (moveTo)
                 moveToPropertyName = moveTo.name;
@@ -2460,9 +2465,7 @@
         // Make the Changes and trigger the moveToNextCallback after updating.
         var moveToIndex = moveTo && this.treeOutline ? this.treeOutline.children.indexOf(moveTo) : -1;
         var blankInput = /^\s*$/.test(userInput);
-        var isDataPasted = "originalName" in context;
-        var isDirtyViaPaste = isDataPasted && (this.nameElement.textContent !== context.originalName || this.valueElement.textContent !== context.originalValue);
-        var shouldCommitNewProperty = this._newProperty && (moveToOther || (!moveDirection && !isEditingName) || (isEditingName && blankInput));
+        var shouldCommitNewProperty = this._newProperty && (isPropertySplitPaste || moveToOther || (!moveDirection && !isEditingName) || (isEditingName && blankInput));
         var section = this.section();
         if (((userInput !== previousContent || isDirtyViaPaste) && !this._newProperty) || shouldCommitNewProperty) {
             section._afterUpdate = moveToNextCallback.bind(this, this._newProperty, !blankInput, section);
@@ -2505,7 +2508,7 @@
                 else {
                     var treeElement = moveToIndex >= 0 ? propertyElements[moveToIndex] : null;
                     if (treeElement) {
-                        var elementToEdit = !isEditingName ? treeElement.nameElement : treeElement.valueElement;
+                        var elementToEdit = !isEditingName || isPropertySplitPaste ? treeElement.nameElement : treeElement.valueElement;
                         if (alreadyNew && blankInput)
                             elementToEdit = moveDirection === "forward" ? treeElement.nameElement : treeElement.valueElement;
                         treeElement.startEditing(elementToEdit);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to