Title: [92288] branches/chromium/835
- Revision
- 92288
- Author
- [email protected]
- Date
- 2011-08-03 09:48:23 -0700 (Wed, 03 Aug 2011)
Log Message
Merge 92167 - 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.
[email protected]
BUG=91217
Review URL: http://codereview.chromium.org/7566008
Modified Paths
Added Paths
Diff
Copied: branches/chromium/835/LayoutTests/inspector/styles/styles-add-new-rule-expected.txt (from rev 92167, trunk/LayoutTests/inspector/styles/styles-add-new-rule-expected.txt) (0 => 92288)
--- branches/chromium/835/LayoutTests/inspector/styles/styles-add-new-rule-expected.txt (rev 0)
+++ branches/chromium/835/LayoutTests/inspector/styles/styles-add-new-rule-expected.txt 2011-08-03 16:48:23 UTC (rev 92288)
@@ -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;
+
+
+
Copied: branches/chromium/835/LayoutTests/inspector/styles/styles-add-new-rule.html (from rev 92167, trunk/LayoutTests/inspector/styles/styles-add-new-rule.html) (0 => 92288)
--- branches/chromium/835/LayoutTests/inspector/styles/styles-add-new-rule.html (rev 0)
+++ branches/chromium/835/LayoutTests/inspector/styles/styles-add-new-rule.html 2011-08-03 16:48:23 UTC (rev 92288)
@@ -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>
Modified: branches/chromium/835/Source/WebCore/inspector/front-end/StylesSidebarPane.js (92287 => 92288)
--- branches/chromium/835/Source/WebCore/inspector/front-end/StylesSidebarPane.js 2011-08-03 16:46:13 UTC (rev 92287)
+++ branches/chromium/835/Source/WebCore/inspector/front-end/StylesSidebarPane.js 2011-08-03 16:48:23 UTC (rev 92288)
@@ -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
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes