Title: [147733] branches/chromium/1453
- Revision
- 147733
- Author
- apav...@chromium.org
- Date
- 2013-04-05 03:00:56 -0700 (Fri, 05 Apr 2013)
Log Message
Merge 147094 "Web Inspector: [REGRESSION] [Styles] Pasting a pro..."
> 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.
TBR=apav...@chromium.org
Review URL: https://codereview.chromium.org/13719002
Modified Paths
Added Paths
Diff
Copied: branches/chromium/1453/LayoutTests/inspector/styles/paste-property-expected.txt (from rev 147094, trunk/LayoutTests/inspector/styles/paste-property-expected.txt) (0 => 147733)
--- branches/chromium/1453/LayoutTests/inspector/styles/paste-property-expected.txt (rev 0)
+++ branches/chromium/1453/LayoutTests/inspector/styles/paste-property-expected.txt 2013-04-05 10:00:56 UTC (rev 147733)
@@ -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;
+
+
+
Copied: branches/chromium/1453/LayoutTests/inspector/styles/paste-property.html (from rev 147094, trunk/LayoutTests/inspector/styles/paste-property.html) (0 => 147733)
--- branches/chromium/1453/LayoutTests/inspector/styles/paste-property.html (rev 0)
+++ branches/chromium/1453/LayoutTests/inspector/styles/paste-property.html 2013-04-05 10:00:56 UTC (rev 147733)
@@ -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: branches/chromium/1453/Source/WebCore/inspector/front-end/StylesSidebarPane.js (147732 => 147733)
--- branches/chromium/1453/Source/WebCore/inspector/front-end/StylesSidebarPane.js 2013-04-05 09:28:35 UTC (rev 147732)
+++ branches/chromium/1453/Source/WebCore/inspector/front-end/StylesSidebarPane.js 2013-04-05 10:00:56 UTC (rev 147733)
@@ -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