- Revision
- 98243
- Author
- [email protected]
- Date
- 2011-10-24 08:23:20 -0700 (Mon, 24 Oct 2011)
Log Message
Web Inspector: [Styles] Adding a new style rule breaks things
https://bugs.webkit.org/show_bug.cgi?id=70721
Reviewed by Pavel Feldman.
Source/WebCore:
We had used to swap BlankStylePropertiesSection prototype and recently got rid of this hack,
but still had dependencies on the old behavior.
* inspector/front-end/StylesSidebarPane.js:
(WebInspector.StylesSidebarPane.prototype._refreshStyleRules):
(WebInspector.ComputedStylePropertiesSection.prototype.rebuildComputedTrace):
(WebInspector.BlankStylePropertiesSection.prototype.get isBlank):
(WebInspector.BlankStylePropertiesSection.prototype.expand):
(WebInspector.BlankStylePropertiesSection.prototype.editingSelectorCommitted.successCallback):
(WebInspector.BlankStylePropertiesSection.prototype.editingSelectorCommitted):
(WebInspector.BlankStylePropertiesSection.prototype.editingSelectorCancelled):
(WebInspector.BlankStylePropertiesSection.prototype.makeNormal):
LayoutTests:
* inspector/styles/styles-add-new-rule-expected.txt:
* inspector/styles/styles-add-new-rule.html:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (98242 => 98243)
--- trunk/LayoutTests/ChangeLog 2011-10-24 15:20:38 UTC (rev 98242)
+++ trunk/LayoutTests/ChangeLog 2011-10-24 15:23:20 UTC (rev 98243)
@@ -1,3 +1,13 @@
+2011-10-24 Alexander Pavlov <[email protected]>
+
+ Web Inspector: [Styles] Adding a new style rule breaks things
+ https://bugs.webkit.org/show_bug.cgi?id=70721
+
+ Reviewed by Pavel Feldman.
+
+ * inspector/styles/styles-add-new-rule-expected.txt:
+ * inspector/styles/styles-add-new-rule.html:
+
2011-10-24 Pavel Feldman <[email protected]>
Web Inspector: do not force document loading on reload (should happen on demand).
Modified: trunk/LayoutTests/inspector/styles/styles-add-new-rule-expected.txt (98242 => 98243)
--- trunk/LayoutTests/inspector/styles/styles-add-new-rule-expected.txt 2011-10-24 15:20:38 UTC (rev 98242)
+++ trunk/LayoutTests/inspector/styles/styles-add-new-rule-expected.txt 2011-10-24 15:23:20 UTC (rev 98243)
@@ -1,4 +1,4 @@
-Tests that adding a new rule works after sitching nodes.
+Tests that adding a new rule works after switching nodes.
Text
After adding new rule (inspected):
@@ -7,6 +7,7 @@
======== Matched CSS Rules ========
[expanded] #inspected { (via inspector)
+color: maroon;
[expanded] div { (user agent stylesheet)
display: block;
Modified: trunk/LayoutTests/inspector/styles/styles-add-new-rule.html (98242 => 98243)
--- trunk/LayoutTests/inspector/styles/styles-add-new-rule.html 2011-10-24 15:20:38 UTC (rev 98242)
+++ trunk/LayoutTests/inspector/styles/styles-add-new-rule.html 2011-10-24 15:23:20 UTC (rev 98243)
@@ -13,25 +13,40 @@
function step1()
{
- // Click add new rule
+ // Click "Add new rule".
document.getElementById("add-style-button-test-id").click();
- InspectorTest.selectNodeAndWaitForStyles("other", step2);
+ var section = WebInspector.panels.elements.sidebarPanes.styles.sections[0][2];
+ section._selectorElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
+ InspectorTest.runAfterPendingDispatches(step2);
}
- function step2() {
- // Click add new rule
- document.getElementById("add-style-button-test-id").click();
- InspectorTest.selectNodeAndWaitForStyles("inspected", step3);
+ function step2()
+ {
+ var section = WebInspector.panels.elements.sidebarPanes.styles.sections[0][2];
+ var newProperty = section.addNewBlankProperty();
+ newProperty.startEditing();
+ newProperty.nameElement.textContent = "color";
+ newProperty.nameElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
+ newProperty.valueElement.textContent = "maroon";
+ newProperty.valueElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
+ InspectorTest.selectNodeAndWaitForStyles("other", step3);
}
function step3()
{
+ // Click "Add new rule".
+ document.getElementById("add-style-button-test-id").click();
+ InspectorTest.selectNodeAndWaitForStyles("inspected", step4);
+ }
+
+ function step4()
+ {
InspectorTest.addResult("After adding new rule (inspected):");
InspectorTest.dumpSelectedElementStyles(true, false, true);
- InspectorTest.selectNodeAndWaitForStyles("other", step4);
+ InspectorTest.selectNodeAndWaitForStyles("other", step5);
}
- function step4()
+ function step5()
{
InspectorTest.addResult("After adding new rule (other):");
InspectorTest.dumpSelectedElementStyles(true, false, true);
@@ -44,7 +59,7 @@
<body _onload_="runTest()">
<p>
-Tests that adding a new rule works after sitching nodes.
+Tests that adding a new rule works after switching nodes.
</p>
<div id="inspected" style="font-size: 12px">Text</div>
Modified: trunk/Source/WebCore/ChangeLog (98242 => 98243)
--- trunk/Source/WebCore/ChangeLog 2011-10-24 15:20:38 UTC (rev 98242)
+++ trunk/Source/WebCore/ChangeLog 2011-10-24 15:23:20 UTC (rev 98243)
@@ -1,3 +1,23 @@
+2011-10-24 Alexander Pavlov <[email protected]>
+
+ Web Inspector: [Styles] Adding a new style rule breaks things
+ https://bugs.webkit.org/show_bug.cgi?id=70721
+
+ Reviewed by Pavel Feldman.
+
+ We had used to swap BlankStylePropertiesSection prototype and recently got rid of this hack,
+ but still had dependencies on the old behavior.
+
+ * inspector/front-end/StylesSidebarPane.js:
+ (WebInspector.StylesSidebarPane.prototype._refreshStyleRules):
+ (WebInspector.ComputedStylePropertiesSection.prototype.rebuildComputedTrace):
+ (WebInspector.BlankStylePropertiesSection.prototype.get isBlank):
+ (WebInspector.BlankStylePropertiesSection.prototype.expand):
+ (WebInspector.BlankStylePropertiesSection.prototype.editingSelectorCommitted.successCallback):
+ (WebInspector.BlankStylePropertiesSection.prototype.editingSelectorCommitted):
+ (WebInspector.BlankStylePropertiesSection.prototype.editingSelectorCancelled):
+ (WebInspector.BlankStylePropertiesSection.prototype.makeNormal):
+
2011-10-24 Pavel Feldman <[email protected]>
Web Inspector: do not force document loading on reload (should happen on demand).
Modified: trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js (98242 => 98243)
--- trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js 2011-10-24 15:20:38 UTC (rev 98242)
+++ trunk/Source/WebCore/inspector/front-end/StylesSidebarPane.js 2011-10-24 15:23:20 UTC (rev 98243)
@@ -375,7 +375,7 @@
var styleRules = [];
for (var i = 0; sections && i < sections.length; ++i) {
var section = sections[i];
- if (section instanceof WebInspector.BlankStylePropertiesSection)
+ if (section.isBlank)
continue;
if (section.computedStyle)
section.styleRule.style = nodeComputedStyle;
@@ -1307,7 +1307,7 @@
{
for (var i = 0; i < sections.length; ++i) {
var section = sections[i];
- if (section.computedStyle || section instanceof WebInspector.BlankStylePropertiesSection)
+ if (section.computedStyle || section.isBlank)
continue;
for (var j = 0; j < section.uniqueProperties.length; ++j) {
@@ -1355,13 +1355,24 @@
}
WebInspector.BlankStylePropertiesSection.prototype = {
+ get isBlank()
+ {
+ return !this._normal;
+ },
+
expand: function()
{
- // Do nothing, blank sections are not expandable.
+ if (!this.isBlank)
+ WebInspector.StylePropertiesSection.prototype.expand.call(this);
},
- editingSelectorCommitted: function(element, newContent, oldContent, context)
+ editingSelectorCommitted: function(element, newContent, oldContent, context, moveDirection)
{
+ if (!this.isBlank) {
+ WebInspector.StylePropertiesSection.prototype.editingSelectorCommitted.call(this, element, newContent, oldContent, context, moveDirection);
+ return;
+ }
+
function successCallback(newRule, doesSelectorAffectSelectedNode)
{
var styleRule = { section: this, style: newRule.style, selectorText: newRule.selectorText, sourceURL: newRule.sourceURL, rule: newRule };
@@ -1374,8 +1385,8 @@
this.subtitleElement.textContent = WebInspector.UIString("via inspector");
this.expand();
- if (this.element.parentElement) // Might have been detached already.
- this.addNewBlankProperty().startEditing();
+ if (this.element.parentElement) // Might have been detached already.
+ this._moveEditorFromSelector(moveDirection);
}
WebInspector.cssModel.addRule(this.pane.node.id, newContent, successCallback.bind(this), this.editingSelectorCancelled.bind(this));
@@ -1383,6 +1394,11 @@
editingSelectorCancelled: function()
{
+ if (!this.isBlank) {
+ WebInspector.StylePropertiesSection.prototype.editingSelectorCancelled.call(this);
+ return;
+ }
+
this.pane.removeSection(this);
},
@@ -1392,6 +1408,9 @@
this.styleRule = styleRule;
this.rule = styleRule.rule;
this.identifier = styleRule.selectorText + ":via inspector";
+
+ // FIXME: replace this instance by a normal WebInspector.StylePropertiesSection.
+ this._normal = true;
}
}