Diff
Modified: branches/safari-601-branch/LayoutTests/ChangeLog (193243 => 193244)
--- branches/safari-601-branch/LayoutTests/ChangeLog 2015-12-03 19:01:18 UTC (rev 193243)
+++ branches/safari-601-branch/LayoutTests/ChangeLog 2015-12-03 19:01:26 UTC (rev 193244)
@@ -1,5 +1,20 @@
2015-12-02 Timothy Hatcher <[email protected]>
+ Merge r190528. rdar://problem/23221163
+
+ 2015-10-02 Devin Rousso <[email protected]>
+
+ Web Inspector: Copying inline style text puts "undefined" in the pasteboard
+ https://bugs.webkit.org/show_bug.cgi?id=149155
+
+ Reviewed by Brian Burg.
+
+ Added test for generating CSS rule strings with default formatting.
+
+ * inspector/css/generate-css-rule-string.html:
+
+2015-12-02 Timothy Hatcher <[email protected]>
+
Merge r190184. rdar://problem/23221163
2015-09-23 Saam barati <[email protected]>
Added: branches/safari-601-branch/LayoutTests/inspector/css/generate-css-rule-string-expected.txt (0 => 193244)
--- branches/safari-601-branch/LayoutTests/inspector/css/generate-css-rule-string-expected.txt (rev 0)
+++ branches/safari-601-branch/LayoutTests/inspector/css/generate-css-rule-string-expected.txt 2015-12-03 19:01:26 UTC (rev 193244)
@@ -0,0 +1,27 @@
+Testing that generated CSS rule strings have proper formatting.
+
+== Running test suite: CSS.generateCSSRuleString
+-- Running test case: InlineStyleString
+#test-node {
+ background-color: red;
+}
+
+-- Running test case: CSSRuleString0
+@media only screen and (min-width: 0px) {
+ body > div {
+ display: block;
+ width: 100%;
+ text-align: center;
+ }
+}
+
+-- Running test case: CSSRuleString1
+* {
+ margin: 0;
+ padding: 0;
+}
+
+-- Running test case: CSSRuleString2
+address, article, aside, div, footer, header, hgroup, layer, main, nav, section {
+}
+
Added: branches/safari-601-branch/LayoutTests/inspector/css/generate-css-rule-string.html (0 => 193244)
--- branches/safari-601-branch/LayoutTests/inspector/css/generate-css-rule-string.html (rev 0)
+++ branches/safari-601-branch/LayoutTests/inspector/css/generate-css-rule-string.html 2015-12-03 19:01:26 UTC (rev 193244)
@@ -0,0 +1,70 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+* { margin: 0; padding: 0; }
+
+@media only screen and (min-width: 0px) {
+ body > div {
+ display: block;
+ width: 100%;
+ text-align: center;
+ }
+}
+</style>
+<script type="text/_javascript_" src=""
+<script>
+function test() {
+ let nodeStyles;
+ let suite = InspectorTest.createAsyncSuite("CSS.generateCSSRuleString");
+
+ function validateSelectors()
+ {
+ suite.addTestCase({
+ name: "InlineStyleString",
+ description: "Check the formatting of the generated inline style string.",
+ test: (resolve, reject) => {
+ InspectorTest.log(nodeStyles.inlineStyle.generateCSSRuleString());
+ resolve();
+ }
+ });
+
+ for (let i = 0; i < nodeStyles.matchedRules.length; ++i) {
+ let rule = nodeStyles.matchedRules[i];
+ suite.addTestCase({
+ name: "CSSRuleString" + i,
+ description: "Check the formatting of the generated string for the matched CSS rule.",
+ test: (resolve, reject) => {
+ InspectorTest.log(rule.style.generateCSSRuleString());
+ resolve();
+ }
+ });
+ }
+
+ suite.runTestCasesAndFinish();
+ }
+
+ WebInspector.domTreeManager.requestDocument(function(documentNode) {
+ WebInspector.domTreeManager.querySelector(documentNode.id, "#test-node", function(contentNodeId) {
+ if (contentNodeId) {
+ let domNode = WebInspector.domTreeManager.nodeForId(contentNodeId);
+ nodeStyles = WebInspector.cssStyleManager.stylesForNode(domNode);
+ if (nodeStyles.needsRefresh)
+ nodeStyles.singleFireEventListener(WebInspector.DOMNodeStyles.Event.Refreshed, validateSelectors, this);
+ else
+ validateSelectors();
+ } else {
+ InspectorTest.log("DOM node not found.");
+ InspectorTest.completeTest();
+ }
+ });
+ });
+}
+</script>
+</head>
+<body _onload_="runTest()">
+ <p>Testing that generated CSS rule strings have proper formatting.</p>
+
+ <div id="test-node" style="background-color: red;"></div>
+</body>
+</html>
Modified: branches/safari-601-branch/Source/WebInspectorUI/ChangeLog (193243 => 193244)
--- branches/safari-601-branch/Source/WebInspectorUI/ChangeLog 2015-12-03 19:01:18 UTC (rev 193243)
+++ branches/safari-601-branch/Source/WebInspectorUI/ChangeLog 2015-12-03 19:01:26 UTC (rev 193244)
@@ -1,5 +1,34 @@
2015-12-02 Timothy Hatcher <[email protected]>
+ Merge r190528. rdar://problem/23221163
+
+ 2015-10-02 Devin Rousso <[email protected]>
+
+ Web Inspector: Copying inline style text puts "undefined" in the pasteboard
+ https://bugs.webkit.org/show_bug.cgi?id=149155
+
+ Reviewed by Brian Burg.
+
+ CSSStyleDeclarations for inline styles do not have a owner CSSRule, which means
+ that they do not have a selector or media list. CSS strings must have a selector
+ and, for inline styles without an owner rule and selector, this was a problem.
+
+ * UserInterface/Models/CSSStyleDeclaration.js:
+ (WebInspector.CSSStyleDeclaration.prototype.get mediaList):
+ (WebInspector.CSSStyleDeclaration.prototype.get selectorText):
+ (WebInspector.CSSStyleDeclaration.prototype.generateCSSRuleString):
+ Added getters for the list of media queries and selector text with fallbacks
+ for CSSStyleDeclarations that do not have an owner CSSRule (inline styles).
+
+ * UserInterface/Test.html:
+ Added CSSMedia include for new inspector/css/generate-css-rule-string.html test.
+
+ * UserInterface/Views/VisualStyleSelectorTreeItem.js:
+ (WebInspector.VisualStyleSelectorTreeItem.prototype._handleContextMenuEvent):
+ Removed parameter that no longer exists.
+
+2015-12-02 Timothy Hatcher <[email protected]>
+
Merge r190521. rdar://problem/23221163
2015-10-02 Devin Rousso <[email protected]>
Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Models/CSSStyleDeclaration.js (193243 => 193244)
--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Models/CSSStyleDeclaration.js 2015-12-03 19:01:18 UTC (rev 193243)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Models/CSSStyleDeclaration.js 2015-12-03 19:01:26 UTC (rev 193244)
@@ -239,6 +239,20 @@
return this._styleSheetTextRange;
}
+ get mediaList()
+ {
+ if (this._ownerRule)
+ return this._ownerRule.mediaList;
+ return [];
+ }
+
+ get selectorText()
+ {
+ if (this._ownerRule)
+ return this._ownerRule.selectorText;
+ return this._node.appropriateSelectorFor(true);
+ }
+
propertyForName(name, dontCreateIfMissing)
{
console.assert(name);
@@ -288,26 +302,21 @@
generateCSSRuleString()
{
- if (!this._ownerRule)
- return;
-
+ // FIXME: <rdar://problem/10593948> Provide a way to change the tab width in the Web Inspector
+ var indentation = " ";
var styleText = "";
- var mediaQueriesCount = 0;
- var mediaList = this._ownerRule.mediaList;
- if (mediaList.length) {
- mediaQueriesCount = mediaList.length;
+ var mediaList = this.mediaList;
+ var mediaQueriesCount = mediaList.length;
+ for (var i = mediaQueriesCount - 1; i >= 0; --i)
+ styleText += indentation.repeat(mediaQueriesCount - i - 1) + "@media " + mediaList[i].text + " {\n";
- for (var i = mediaQueriesCount - 1; i >= 0; --i)
- styleText += " ".repeat(mediaQueriesCount - i - 1) + "@media " + mediaList[i].text + " {\n";
- }
+ styleText += indentation.repeat(mediaQueriesCount) + this.selectorText + " {\n";
- styleText += " ".repeat(mediaQueriesCount) + this._ownerRule.selectorText + " {\n";
-
for (var property of this._properties) {
if (property.anonymous)
continue;
- styleText += " ".repeat(mediaQueriesCount + 1) + property.text.trim();
+ styleText += indentation.repeat(mediaQueriesCount + 1) + property.text.trim();
if (!styleText.endsWith(";"))
styleText += ";";
@@ -316,7 +325,7 @@
}
for (var i = mediaQueriesCount; i > 0; --i)
- styleText += " ".repeat(i) + "}\n";
+ styleText += indentation.repeat(i) + "}\n";
styleText += "}";
Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Test.html (193243 => 193244)
--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Test.html 2015-12-03 19:01:18 UTC (rev 193243)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Test.html 2015-12-03 19:01:26 UTC (rev 193244)
@@ -71,6 +71,7 @@
<script src=""
<script src=""
<script src=""
+ <script src=""
<script src=""
<script src=""
<script src=""
Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/VisualStyleSelectorTreeItem.js (193243 => 193244)
--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/VisualStyleSelectorTreeItem.js 2015-12-03 19:01:18 UTC (rev 193243)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/VisualStyleSelectorTreeItem.js 2015-12-03 19:01:26 UTC (rev 193244)
@@ -144,8 +144,7 @@
}
contextMenu.appendItem(WebInspector.UIString("Copy Rule"), function() {
- var selectorText = !this.representedObject.ownerRule ? this.representedObject.node.appropriateSelectorFor(true) : null;
- InspectorFrontendHost.copyText(this.representedObject.generateCSSRuleString(selectorText));
+ InspectorFrontendHost.copyText(this.representedObject.generateCSSRuleString());
}.bind(this));
contextMenu.appendItem(WebInspector.UIString("Reset"), function() {