Title: [136488] trunk
Revision
136488
Author
[email protected]
Date
2012-12-04 01:18:20 -0800 (Tue, 04 Dec 2012)

Log Message

Web Inspector: [REGRESSION] [Styles] Rule disappears if edited selector does not affect selected node
https://bugs.webkit.org/show_bug.cgi?id=103059

Reviewed by Pavel Feldman.

Source/WebCore:

This change effectively turns WebInspector.cssModel.setRuleSelector() into a _userOperation
(in terms of StylesSidebarPane), which finishes upon the _finishOperationAndMoveEditor() invocation.

* inspector/front-end/CSSStyleModel.js:
(WebInspector.CSSRule): Fix selectorText now that r136370 has landed.
* inspector/front-end/StylesSidebarPane.js:
(WebInspector.StylePropertiesSection.prototype.update): Update the selector text from the model.
(WebInspector.StylePropertiesSection.prototype._markSelectorMatches): Set the "selector" className regardless of the matched selectors presence.
(WebInspector.StylePropertiesSection.prototype.successCallback): Make use of the _userOperation flag.
(WebInspector.StylePropertiesSection.prototype.finishOperationAndMoveEditor): Delete the _userOperation flag.
(WebInspector.StylePropertiesSection.prototype.editingSelectorCommitted): Make use of the _userOperation flag.
(WebInspector.BlankStylePropertiesSection.prototype.editingSelectorCommitted): Mark selector matches.
(WebInspector.BlankStylePropertiesSection.prototype.editingSelectorCancelled): Delete the _userOperation flag.

LayoutTests:

* http/tests/inspector/elements-test.js:
(initialize_ElementTest.InspectorTest.dumpSelectedElementStyles):
  Add dumping of the [no-affect] flag for rules not affecting the currently selected element.
* inspector/styles/commit-selector-expected.txt: Rebaseline.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (136487 => 136488)


--- trunk/LayoutTests/ChangeLog	2012-12-04 09:12:00 UTC (rev 136487)
+++ trunk/LayoutTests/ChangeLog	2012-12-04 09:18:20 UTC (rev 136488)
@@ -1,3 +1,15 @@
+2012-12-03  Alexander Pavlov  <[email protected]>
+
+        Web Inspector: [REGRESSION] [Styles] Rule disappears if edited selector does not affect selected node
+        https://bugs.webkit.org/show_bug.cgi?id=103059
+
+        Reviewed by Pavel Feldman.
+
+        * http/tests/inspector/elements-test.js:
+        (initialize_ElementTest.InspectorTest.dumpSelectedElementStyles):
+          Add dumping of the [no-affect] flag for rules not affecting the currently selected element.
+        * inspector/styles/commit-selector-expected.txt: Rebaseline.
+
 2012-12-04  Jussi Kukkonen  <[email protected]>
 
         Make svg/dom/viewspec-parser-*.html non-flaky

Modified: trunk/LayoutTests/http/tests/inspector/elements-test.js (136487 => 136488)


--- trunk/LayoutTests/http/tests/inspector/elements-test.js	2012-12-04 09:12:00 UTC (rev 136487)
+++ trunk/LayoutTests/http/tests/inspector/elements-test.js	2012-12-04 09:18:20 UTC (rev 136488)
@@ -153,7 +153,7 @@
                 continue;
             if (section.element.previousSibling && section.element.previousSibling.className === "sidebar-separator")
                 InspectorTest.addResult("======== " + section.element.previousSibling.textContent + " ========");
-            InspectorTest.addResult(section.expanded ? "[expanded] " : "[collapsed] ");
+            InspectorTest.addResult((section.expanded ? "[expanded] " : "[collapsed] ") + (section.noAffect ? "[no-affect] " : ""));
             var chainEntries = section.titleElement.children;
             for (var j = 0; j < chainEntries.length; ++j) {
                 var chainEntry = chainEntries[j];

Modified: trunk/LayoutTests/inspector/styles/commit-selector-expected.txt (136487 => 136488)


--- trunk/LayoutTests/inspector/styles/commit-selector-expected.txt	2012-12-04 09:12:00 UTC (rev 136487)
+++ trunk/LayoutTests/inspector/styles/commit-selector-expected.txt	2012-12-04 09:18:20 UTC (rev 136488)
@@ -37,6 +37,10 @@
 color: red;
 
 ======== Matched CSS Rules ========
+[expanded] [no-affect] 
+#inspectedChanged  { (commit-selector.html:4)
+color: green;
+
 [expanded] 
 div  { (user agent stylesheet)
 display: block;

Modified: trunk/Source/WebCore/ChangeLog (136487 => 136488)


--- trunk/Source/WebCore/ChangeLog	2012-12-04 09:12:00 UTC (rev 136487)
+++ trunk/Source/WebCore/ChangeLog	2012-12-04 09:18:20 UTC (rev 136488)
@@ -1,3 +1,24 @@
+2012-12-03  Alexander Pavlov  <[email protected]>
+
+        Web Inspector: [REGRESSION] [Styles] Rule disappears if edited selector does not affect selected node
+        https://bugs.webkit.org/show_bug.cgi?id=103059
+
+        Reviewed by Pavel Feldman.
+
+        This change effectively turns WebInspector.cssModel.setRuleSelector() into a _userOperation
+        (in terms of StylesSidebarPane), which finishes upon the _finishOperationAndMoveEditor() invocation.
+
+        * inspector/front-end/CSSStyleModel.js:
+        (WebInspector.CSSRule): Fix selectorText now that r136370 has landed.
+        * inspector/front-end/StylesSidebarPane.js:
+        (WebInspector.StylePropertiesSection.prototype.update): Update the selector text from the model.
+        (WebInspector.StylePropertiesSection.prototype._markSelectorMatches): Set the "selector" className regardless of the matched selectors presence.
+        (WebInspector.StylePropertiesSection.prototype.successCallback): Make use of the _userOperation flag.
+        (WebInspector.StylePropertiesSection.prototype.finishOperationAndMoveEditor): Delete the _userOperation flag.
+        (WebInspector.StylePropertiesSection.prototype.editingSelectorCommitted): Make use of the _userOperation flag.
+        (WebInspector.BlankStylePropertiesSection.prototype.editingSelectorCommitted): Mark selector matches.
+        (WebInspector.BlankStylePropertiesSection.prototype.editingSelectorCancelled): Delete the _userOperation flag.
+
 2012-12-04  Kondapally Kalyan  <[email protected]>
 
         [EFL][WK2][AC] USE_GRAPHICS_SURFACE should be enabled only if Xcomposite and Xrender extensions are found.

Modified: trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js (136487 => 136488)


--- trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js	2012-12-04 09:12:00 UTC (rev 136487)
+++ trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js	2012-12-04 09:18:20 UTC (rev 136488)
@@ -800,7 +800,7 @@
     if (matchingSelectors)
         this.matchingSelectors = matchingSelectors;
     this.selectors = payload.selectorList.selectors;
-    this.selectorText = payload.selectorList.text;
+    this.selectorText = this.selectors.join(", ");
     this.selectorRange = payload.selectorList.range;
     this.sourceLine = payload.sourceLine;
     this.sourceURL = payload.sourceURL;

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


--- trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js	2012-12-04 09:12:00 UTC (rev 136487)
+++ trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js	2012-12-04 09:18:20 UTC (rev 136488)
@@ -851,7 +851,6 @@
 
     var selectorContainer = document.createElement("div");
     this._selectorElement = document.createElement("span");
-    this._selectorElement.addStyleClass("selector-matches");
     this._selectorElement.textContent = styleRule.selectorText;
     selectorContainer.appendChild(this._selectorElement);
 
@@ -984,6 +983,8 @@
 
     update: function(full)
     {
+        if (this.styleRule.selectorText)
+            this._selectorElement.textContent = this.styleRule.selectorText;
         if (full) {
             this.propertiesTreeOutline.removeChildren();
             this.populated = false;
@@ -1088,11 +1089,14 @@
         if (!rule)
             return;
 
-        var selectors = rule.selectors;
         var matchingSelectors = rule.matchingSelectors;
+        // .selector is rendered as non-affecting selector by default.
+        if (this.noAffect || matchingSelectors)
+            this._selectorElement.className = "selector";
         if (!matchingSelectors)
             return;
 
+        var selectors = rule.selectors;
         var fragment = document.createDocumentFragment();
         var currentMatch = 0;
         for (var i = 0, lastSelectorIndex = selectors.length - 1; i <= lastSelectorIndex ; ++i) {
@@ -1111,7 +1115,6 @@
                 fragment.appendChild(document.createTextNode(", "));
         }
 
-        this._selectorElement.className = "selector";
         this._selectorElement.removeChildren();
         this._selectorElement.appendChild(fragment);
     },
@@ -1289,6 +1292,8 @@
             return this._moveEditorFromSelector(moveDirection);
         }
 
+        var selectedNode = this._parentPane.node;
+
         function successCallback(newRule, doesAffectSelectedNode)
         {
             if (!doesAffectSelectedNode) {
@@ -1302,13 +1307,20 @@
             this.rule = newRule;
             this.styleRule = { section: this, style: newRule.style, selectorText: newRule.selectorText, media: newRule.media, sourceURL: newRule.sourceURL, rule: newRule };
 
-            this._parentPane.update();
+            this._parentPane.update(selectedNode);
 
-            this._moveEditorFromSelector(moveDirection);
+            finishOperationAndMoveEditor.call(this, moveDirection);
         }
 
-        var selectedNode = this._parentPane.node;
-        WebInspector.cssModel.setRuleSelector(this.rule.id, selectedNode ? selectedNode.id : 0, newContent, successCallback.bind(this), this._moveEditorFromSelector.bind(this, moveDirection));
+        function finishOperationAndMoveEditor(direction)
+        {
+            delete this._parentPane._userOperation;
+            this._moveEditorFromSelector(direction);
+        }
+
+        // This gets deleted in finishOperationAndMoveEditor(), which is called both on success and failure.
+        this._parentPane._userOperation = true;
+        WebInspector.cssModel.setRuleSelector(this.rule.id, selectedNode ? selectedNode.id : 0, newContent, successCallback.bind(this), finishOperationAndMoveEditor.bind(this, moveDirection));
     },
 
     editingSelectorCancelled: function()
@@ -1489,15 +1501,19 @@
             if (this.element.parentElement) // Might have been detached already.
                 this._moveEditorFromSelector(moveDirection);
 
+            this._markSelectorMatches();
             delete this._parentPane._userOperation;
         }
 
+        if (newContent)
+            newContent = newContent.trim();
         this._parentPane._userOperation = true;
         WebInspector.cssModel.addRule(this.pane.node.id, newContent, successCallback.bind(this), this.editingSelectorCancelled.bind(this));
     },
 
     editingSelectorCancelled: function()
     {
+        delete this._parentPane._userOperation;
         if (!this.isBlank) {
             WebInspector.StylePropertiesSection.prototype.editingSelectorCancelled.call(this);
             return;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to