<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[193244] branches/safari-601-branch</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/193244">193244</a></dd>
<dt>Author</dt> <dd>timothy@apple.com</dd>
<dt>Date</dt> <dd>2015-12-03 11:01:26 -0800 (Thu, 03 Dec 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/190528">r190528</a>. rdar://problem/23221163</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari601branchLayoutTestsChangeLog">branches/safari-601-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari601branchSourceWebInspectorUIChangeLog">branches/safari-601-branch/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#branchessafari601branchSourceWebInspectorUIUserInterfaceModelsCSSStyleDeclarationjs">branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Models/CSSStyleDeclaration.js</a></li>
<li><a href="#branchessafari601branchSourceWebInspectorUIUserInterfaceTesthtml">branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Test.html</a></li>
<li><a href="#branchessafari601branchSourceWebInspectorUIUserInterfaceViewsVisualStyleSelectorTreeItemjs">branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/VisualStyleSelectorTreeItem.js</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari601branchLayoutTestsinspectorcssgeneratecssrulestringexpectedtxt">branches/safari-601-branch/LayoutTests/inspector/css/generate-css-rule-string-expected.txt</a></li>
<li><a href="#branchessafari601branchLayoutTestsinspectorcssgeneratecssrulestringhtml">branches/safari-601-branch/LayoutTests/inspector/css/generate-css-rule-string.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari601branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/LayoutTests/ChangeLog (193243 => 193244)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,5 +1,20 @@
</span><span class="cx"> 2015-12-02  Timothy Hatcher  &lt;timothy@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r190528. rdar://problem/23221163
+
+    2015-10-02  Devin Rousso  &lt;dcrousso+webkit@gmail.com&gt;
+
+            Web Inspector: Copying inline style text puts &quot;undefined&quot; 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  &lt;timothy@apple.com&gt;
+
</ins><span class="cx">         Merge r190184. rdar://problem/23221163
</span><span class="cx"> 
</span><span class="cx">     2015-09-23  Saam barati  &lt;sbarati@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari601branchLayoutTestsinspectorcssgeneratecssrulestringexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-601-branch/LayoutTests/inspector/css/generate-css-rule-string-expected.txt (0 => 193244)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,27 @@
</span><ins>+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 &gt; 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 {
+}
+
</ins></span></pre></div>
<a id="branchessafari601branchLayoutTestsinspectorcssgeneratecssrulestringhtml"></a>
<div class="addfile"><h4>Added: branches/safari-601-branch/LayoutTests/inspector/css/generate-css-rule-string.html (0 => 193244)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,70 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;style&gt;
+* { margin: 0; padding: 0; }
+
+@media only screen and (min-width: 0px) {
+    body &gt; div {
+        display: block;
+        width: 100%;
+        text-align: center;
+    }
+}
+&lt;/style&gt;
+&lt;script type=&quot;text/javascript&quot; src=&quot;../../http/tests/inspector/resources/inspector-test.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+function test() {
+    let nodeStyles;
+    let suite = InspectorTest.createAsyncSuite(&quot;CSS.generateCSSRuleString&quot;);
+
+    function validateSelectors()
+    {
+        suite.addTestCase({
+            name: &quot;InlineStyleString&quot;,
+            description: &quot;Check the formatting of the generated inline style string.&quot;,
+            test: (resolve, reject) =&gt; {
+                InspectorTest.log(nodeStyles.inlineStyle.generateCSSRuleString());
+                resolve();
+            }
+        });
+
+        for (let i = 0; i &lt; nodeStyles.matchedRules.length; ++i) {
+            let rule = nodeStyles.matchedRules[i];
+            suite.addTestCase({
+                name: &quot;CSSRuleString&quot; + i,
+                description: &quot;Check the formatting of the generated string for the matched CSS rule.&quot;,
+                test: (resolve, reject) =&gt; {
+                    InspectorTest.log(rule.style.generateCSSRuleString());
+                    resolve();
+                }
+            });
+        }
+
+        suite.runTestCasesAndFinish();
+    }
+
+    WebInspector.domTreeManager.requestDocument(function(documentNode) {
+        WebInspector.domTreeManager.querySelector(documentNode.id, &quot;#test-node&quot;, 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(&quot;DOM node not found.&quot;);
+                InspectorTest.completeTest();
+            }
+        });
+    });
+}
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body onload=&quot;runTest()&quot;&gt;
+    &lt;p&gt;Testing that generated CSS rule strings have proper formatting.&lt;/p&gt;
+
+    &lt;div id=&quot;test-node&quot; style=&quot;background-color: red;&quot;&gt;&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="branchessafari601branchSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebInspectorUI/ChangeLog (193243 => 193244)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,5 +1,34 @@
</span><span class="cx"> 2015-12-02  Timothy Hatcher  &lt;timothy@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r190528. rdar://problem/23221163
+
+    2015-10-02  Devin Rousso  &lt;dcrousso+webkit@gmail.com&gt;
+
+            Web Inspector: Copying inline style text puts &quot;undefined&quot; 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  &lt;timothy@apple.com&gt;
+
</ins><span class="cx">         Merge r190521. rdar://problem/23221163
</span><span class="cx"> 
</span><span class="cx">     2015-10-02  Devin Rousso  &lt;dcrousso+webkit@gmail.com&gt;
</span></span></pre></div>
<a id="branchessafari601branchSourceWebInspectorUIUserInterfaceModelsCSSStyleDeclarationjs"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Models/CSSStyleDeclaration.js (193243 => 193244)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -239,6 +239,20 @@
</span><span class="cx">         return this._styleSheetTextRange;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    get mediaList()
+    {
+        if (this._ownerRule)
+            return this._ownerRule.mediaList;
+        return [];
+    }
+
+    get selectorText()
+    {
+        if (this._ownerRule)
+            return this._ownerRule.selectorText;
+        return this._node.appropriateSelectorFor(true);
+    }
+
</ins><span class="cx">     propertyForName(name, dontCreateIfMissing)
</span><span class="cx">     {
</span><span class="cx">         console.assert(name);
</span><span class="lines">@@ -288,26 +302,21 @@
</span><span class="cx"> 
</span><span class="cx">     generateCSSRuleString()
</span><span class="cx">     {
</span><del>-        if (!this._ownerRule)
-            return;
-
</del><ins>+        // FIXME: &lt;rdar://problem/10593948&gt; Provide a way to change the tab width in the Web Inspector
+        var indentation = &quot;    &quot;;
</ins><span class="cx">         var styleText = &quot;&quot;;
</span><del>-        var mediaQueriesCount = 0;
-        var mediaList = this._ownerRule.mediaList;
-        if (mediaList.length) {
-            mediaQueriesCount = mediaList.length;
</del><ins>+        var mediaList = this.mediaList;
+        var mediaQueriesCount = mediaList.length;
+        for (var i = mediaQueriesCount - 1; i &gt;= 0; --i)
+            styleText += indentation.repeat(mediaQueriesCount - i - 1) + &quot;@media &quot; + mediaList[i].text + &quot; {\n&quot;;
</ins><span class="cx"> 
</span><del>-            for (var i = mediaQueriesCount - 1; i &gt;= 0; --i)
-                styleText += &quot;    &quot;.repeat(mediaQueriesCount - i - 1) + &quot;@media &quot; + mediaList[i].text + &quot; {\n&quot;;
-        }
</del><ins>+        styleText += indentation.repeat(mediaQueriesCount) + this.selectorText + &quot; {\n&quot;;
</ins><span class="cx"> 
</span><del>-        styleText += &quot;    &quot;.repeat(mediaQueriesCount) + this._ownerRule.selectorText + &quot; {\n&quot;;
-
</del><span class="cx">         for (var property of this._properties) {
</span><span class="cx">             if (property.anonymous)
</span><span class="cx">                 continue;
</span><span class="cx"> 
</span><del>-            styleText += &quot;    &quot;.repeat(mediaQueriesCount + 1) + property.text.trim();
</del><ins>+            styleText += indentation.repeat(mediaQueriesCount + 1) + property.text.trim();
</ins><span class="cx"> 
</span><span class="cx">             if (!styleText.endsWith(&quot;;&quot;))
</span><span class="cx">                 styleText += &quot;;&quot;;
</span><span class="lines">@@ -316,7 +325,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         for (var i = mediaQueriesCount; i &gt; 0; --i)
</span><del>-            styleText += &quot;    &quot;.repeat(i) + &quot;}\n&quot;;
</del><ins>+            styleText += indentation.repeat(i) + &quot;}\n&quot;;
</ins><span class="cx"> 
</span><span class="cx">         styleText += &quot;}&quot;;
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari601branchSourceWebInspectorUIUserInterfaceTesthtml"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Test.html (193243 => 193244)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -71,6 +71,7 @@
</span><span class="cx">     &lt;script src=&quot;Models/Breakpoint.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;Models/CSSCompletions.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;Models/CSSKeywordCompletions.js&quot;&gt;&lt;/script&gt;
</span><ins>+    &lt;script src=&quot;Models/CSSMedia.js&quot;&gt;&lt;/script&gt;
</ins><span class="cx">     &lt;script src=&quot;Models/CSSProperty.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;Models/CSSRule.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;Models/CSSSelector.js&quot;&gt;&lt;/script&gt;
</span></span></pre></div>
<a id="branchessafari601branchSourceWebInspectorUIUserInterfaceViewsVisualStyleSelectorTreeItemjs"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/VisualStyleSelectorTreeItem.js (193243 => 193244)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -144,8 +144,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         contextMenu.appendItem(WebInspector.UIString(&quot;Copy Rule&quot;), function() {
</span><del>-            var selectorText = !this.representedObject.ownerRule ? this.representedObject.node.appropriateSelectorFor(true) : null;
-            InspectorFrontendHost.copyText(this.representedObject.generateCSSRuleString(selectorText));
</del><ins>+            InspectorFrontendHost.copyText(this.representedObject.generateCSSRuleString());
</ins><span class="cx">         }.bind(this));
</span><span class="cx"> 
</span><span class="cx">         contextMenu.appendItem(WebInspector.UIString(&quot;Reset&quot;), function() {
</span></span></pre>
</div>
</div>

</body>
</html>