Title: [92167] trunk
Revision
92167
Author
pfeld...@chromium.org
Date
2011-08-02 01:03:17 -0700 (Tue, 02 Aug 2011)

Log Message

Web Inspector: button + "New style rule"
https://bugs.webkit.org/show_bug.cgi?id=65409

Reviewed by Yury Semikhatsky.

Source/WebCore:

Test: inspector/styles/styles-add-new-rule.html

* inspector/front-end/StylesSidebarPane.js:
(WebInspector.StylesSidebarPane):
(WebInspector.BlankStylePropertiesSection.prototype.editingSelectorCommitted):

LayoutTests:

* inspector/styles/styles-add-new-rule-expected.txt: Added.
* inspector/styles/styles-add-new-rule.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (92166 => 92167)


--- trunk/LayoutTests/ChangeLog	2011-08-02 03:47:48 UTC (rev 92166)
+++ trunk/LayoutTests/ChangeLog	2011-08-02 08:03:17 UTC (rev 92167)
@@ -1,3 +1,13 @@
+2011-08-01  Pavel Feldman  <pfeld...@google.com>
+
+        Web Inspector: button + "New style rule"
+        https://bugs.webkit.org/show_bug.cgi?id=65409
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/styles/styles-add-new-rule-expected.txt: Added.
+        * inspector/styles/styles-add-new-rule.html: Added.
+
 2011-08-01  Anders Carlsson  <ander...@apple.com>
 
         Update Lion specific test results.

Added: trunk/LayoutTests/inspector/styles/styles-add-new-rule-expected.txt (0 => 92167)


--- trunk/LayoutTests/inspector/styles/styles-add-new-rule-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/styles/styles-add-new-rule-expected.txt	2011-08-02 08:03:17 UTC (rev 92167)
@@ -0,0 +1,26 @@
+Tests that adding a new rule works after sitching nodes.
+
+Text
+After adding new rule (inspected):
+[expanded] element.style { ()
+font-size: 12px;
+
+======== Matched CSS Rules ========
+[expanded] #inspected { (via inspector)
+
+[expanded] div { (user agent stylesheet)
+display: block;
+
+
+After adding new rule (other):
+[expanded] element.style { ()
+color: red;
+
+======== Matched CSS Rules ========
+[expanded] #other { (via inspector)
+
+[expanded] div { (user agent stylesheet)
+display: block;
+
+
+
Property changes on: trunk/LayoutTests/inspector/styles/styles-add-new-rule-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/inspector/styles/styles-add-new-rule.html (0 => 92167)


--- trunk/LayoutTests/inspector/styles/styles-add-new-rule.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/styles/styles-add-new-rule.html	2011-08-02 08:03:17 UTC (rev 92167)
@@ -0,0 +1,54 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+
+function test()
+{
+    WebInspector.showPanel("elements");
+    InspectorTest.selectNodeAndWaitForStyles("inspected", step1);
+
+    var treeElement;
+
+    function step1()
+    {
+        // Click add new rule
+        document.getElementById("add-style-button-test-id").click();
+        InspectorTest.selectNodeAndWaitForStyles("other", step2);
+    }
+
+    function step2() {
+        // Click add new rule
+        document.getElementById("add-style-button-test-id").click();
+        InspectorTest.selectNodeAndWaitForStyles("inspected", step3);
+    }
+
+    function step3()
+    {
+        InspectorTest.addResult("After adding new rule (inspected):");
+        InspectorTest.dumpSelectedElementStyles(true, false, true);
+        InspectorTest.selectNodeAndWaitForStyles("other", step4);
+    }
+
+    function step4()
+    {
+        InspectorTest.addResult("After adding new rule (other):");
+        InspectorTest.dumpSelectedElementStyles(true, false, true);
+        InspectorTest.completeTest();
+    }
+}
+
+</script>
+</head>
+
+<body _onload_="runTest()">
+<p>
+Tests that adding a new rule works after sitching nodes.
+</p>
+
+<div id="inspected" style="font-size: 12px">Text</div>
+<div id="other" style="color:red"></div>
+
+</body>
+</html>
Property changes on: trunk/LayoutTests/inspector/styles/styles-add-new-rule.html
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (92166 => 92167)


--- trunk/Source/WebCore/ChangeLog	2011-08-02 03:47:48 UTC (rev 92166)
+++ trunk/Source/WebCore/ChangeLog	2011-08-02 08:03:17 UTC (rev 92167)
@@ -1,3 +1,16 @@
+2011-08-01  Pavel Feldman  <pfeld...@google.com>
+
+        Web Inspector: button + "New style rule"
+        https://bugs.webkit.org/show_bug.cgi?id=65409
+
+        Reviewed by Yury Semikhatsky.
+
+        Test: inspector/styles/styles-add-new-rule.html
+
+        * inspector/front-end/StylesSidebarPane.js:
+        (WebInspector.StylesSidebarPane):
+        (WebInspector.BlankStylePropertiesSection.prototype.editingSelectorCommitted):
+
 2011-08-01  Luke Macpherson   <macpher...@chromium.org>
 
         Don't set m_fontDirty when setting zoom unless zoom has actually changed

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


--- trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js	2011-08-02 03:47:48 UTC (rev 92166)
+++ trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js	2011-08-02 08:03:17 UTC (rev 92167)
@@ -71,6 +71,7 @@
 
     var addButton = document.createElement("button");
     addButton.className = "pane-title-button add";
+    addButton.id = "add-style-button-test-id";
     addButton.title = WebInspector.UIString("New Style Rule");
     addButton.addEventListener("click", this._createNewRule.bind(this), false);
     this.titleElement.appendChild(addButton);
@@ -1285,24 +1286,23 @@
 
     editingSelectorCommitted: function(element, newContent, oldContent, context)
     {
-        var self = this;
         function successCallback(newRule, doesSelectorAffectSelectedNode)
         {
-            var styleRule = { section: self, style: newRule.style, selectorText: newRule.selectorText, sourceURL: newRule.sourceURL, rule: newRule };
-            self.makeNormal(styleRule);
+            var styleRule = { section: this, style: newRule.style, selectorText: newRule.selectorText, sourceURL: newRule.sourceURL, rule: newRule };
+            this.makeNormal(styleRule);
 
             if (!doesSelectorAffectSelectedNode) {
-                self.noAffect = true;
-                self.element.addStyleClass("no-affect");
+                this.noAffect = true;
+                this.element.addStyleClass("no-affect");
             }
 
-            self.subtitleElement.textContent = WebInspector.UIString("via inspector");
-            self.expand();
-
-            self.addNewBlankProperty().startEditing();
+            this.subtitleElement.textContent = WebInspector.UIString("via inspector");
+            this.expand();
+            if (this.element.parentElement)  // Might have been detached already.
+                this.addNewBlankProperty().startEditing();
         }
 
-        WebInspector.cssModel.addRule(this.pane.node.id, newContent, successCallback, this.editingSelectorCancelled.bind(this));
+        WebInspector.cssModel.addRule(this.pane.node.id, newContent, successCallback.bind(this), this.editingSelectorCancelled.bind(this));
     },
 
     editingSelectorCancelled: function()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to