<!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>[175483] trunk</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/175483">175483</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2014-11-03 12:03:57 -0800 (Mon, 03 Nov 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Web Inspector: Show Selector's Specificity
https://bugs.webkit.org/show_bug.cgi?id=138189
Patch by Joseph Pecoraro <pecoraro@apple.com> on 2014-11-03
Reviewed by Timothy Hatcher.
Source/JavaScriptCore:
* inspector/protocol/CSS.json:
Create a new named type CSSSelector to include a selector's text and specificity.
The specificity tuple is optional as it may soon be made dynamic in some cases.
Source/WebCore:
Test: inspector/css/selector-specificity.html
* css/CSSSelector.h:
Remove very stale comment. '*' is a starAtom now instead of a special -1 tag.
Made the specificity masks public class constants.
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyle::buildArrayForComputedStyle):
(WebCore::InspectorStyle::styleWithProperties):
(WebCore::InspectorStyleSheet::buildObjectForStyleSheetInfo):
Drive by use release() in some cases to reduce ref count churn.
(WebCore::buildObjectForSelectorHelper):
(WebCore::selectorsFromSource):
(WebCore::InspectorStyleSheet::buildObjectForSelector):
(WebCore::InspectorStyleSheet::buildObjectForSelectorList):
Build CSSSelector objects for SelectorLists.
Source/WebInspectorUI:
* Localizations/en.lproj/localizedStrings.js:
* UserInterface/Main.html:
* UserInterface/Test.html:
Add new files and strings.
* UserInterface/Models/CSSMedia.js:
Constructor functions are not needed, remove unnecessary code.
* UserInterface/Models/CSSRule.js:
(WebInspector.CSSRule.prototype.set selectors): Deleted.
This was unused and is no longer correct.
(WebInspector.CSSRule.prototype.get matchedSelectorText):
Update now that selectors are a list of objects, not just strings.
* UserInterface/Models/CSSSelector.js:
(WebInspector.CSSSelector):
(WebInspector.CSSSelector.prototype.get specificity):
New model object for protocol type CSS.CSSSelector.
* UserInterface/Models/DOMNodeStyles.js:
(WebInspector.DOMNodeStyles.prototype._parseSelectorListPayload.return):
(WebInspector.DOMNodeStyles.prototype._parseSelectorListPayload):
(WebInspector.DOMNodeStyles.prototype._parseRulePayload):
Handle parsing old and new SelectorLists.
* UserInterface/Views/CSSStyleDeclarationSection.js:
(WebInspector.CSSStyleDeclarationSection.prototype.refresh.appendSelector):
(WebInspector.CSSStyleDeclarationSection.prototype.refresh.appendSelectorText):
(WebInspector.CSSStyleDeclarationSection.prototype.refresh):
Update the code now that the list of selectors are model objects instead
of just selector text strings.
LayoutTests:
* inspector/css/matched-style-properties.html:
* inspector/css/selector-specificity-expected.txt: Added.
* inspector/css/selector-specificity.html: Copied from LayoutTests/inspector/css/matched-style-properties.html.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsinspectorcssmatchedstylepropertieshtml">trunk/LayoutTests/inspector/css/matched-style-properties.html</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorprotocolCSSjson">trunk/Source/JavaScriptCore/inspector/protocol/CSS.json</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssCSSSelectorcpp">trunk/Source/WebCore/css/CSSSelector.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSSelectorh">trunk/Source/WebCore/css/CSSSelector.h</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorStyleSheetcpp">trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorStyleSheeth">trunk/Source/WebCore/inspector/InspectorStyleSheet.h</a></li>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUILocalizationsenlprojlocalizedStringsjs">trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceMainhtml">trunk/Source/WebInspectorUI/UserInterface/Main.html</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceModelsCSSMediajs">trunk/Source/WebInspectorUI/UserInterface/Models/CSSMedia.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceModelsCSSRulejs">trunk/Source/WebInspectorUI/UserInterface/Models/CSSRule.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceModelsDOMNodeStylesjs">trunk/Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceTesthtml">trunk/Source/WebInspectorUI/UserInterface/Test.html</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsCSSStyleDeclarationSectionjs">trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsinspectorcssselectorspecificityexpectedtxt">trunk/LayoutTests/inspector/css/selector-specificity-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectorcssselectorspecificityhtml">trunk/LayoutTests/inspector/css/selector-specificity.html</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceModelsCSSSelectorjs">trunk/Source/WebInspectorUI/UserInterface/Models/CSSSelector.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (175482 => 175483)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-11-03 19:59:44 UTC (rev 175482)
+++ trunk/LayoutTests/ChangeLog        2014-11-03 20:03:57 UTC (rev 175483)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2014-11-03 Joseph Pecoraro <pecoraro@apple.com>
+
+ Web Inspector: Show Selector's Specificity
+ https://bugs.webkit.org/show_bug.cgi?id=138189
+
+ Reviewed by Timothy Hatcher.
+
+ * inspector/css/matched-style-properties.html:
+ * inspector/css/selector-specificity-expected.txt: Added.
+ * inspector/css/selector-specificity.html: Copied from LayoutTests/inspector/css/matched-style-properties.html.
+
</ins><span class="cx"> 2014-11-03 Lorenzo Tilve <ltilve@igalia.com>
</span><span class="cx">
</span><span class="cx"> [GTK] Unreviewed gardening. Rebaseline after r175259.
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorcssmatchedstylepropertieshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/css/matched-style-properties.html (175482 => 175483)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/css/matched-style-properties.html        2014-11-03 19:59:44 UTC (rev 175482)
+++ trunk/LayoutTests/inspector/css/matched-style-properties.html        2014-11-03 20:03:57 UTC (rev 175483)
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx"> {
</span><span class="cx"> for (var i = 0; i < nodeStyles.matchedRules.length; ++i) {
</span><span class="cx"> var rule = nodeStyles.matchedRules[i];
</span><del>- if (rule.type != WebInspector.CSSRule.Type.Author)
</del><ins>+ if (rule.type !== WebInspector.CSSRule.Type.Author)
</ins><span class="cx"> continue;
</span><span class="cx">
</span><span class="cx"> for (var j = 0; j < rule.style.properties.length; ++j) {
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorcssselectorspecificityexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/css/selector-specificity-expected.txt (0 => 175483)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/css/selector-specificity-expected.txt         (rev 0)
+++ trunk/LayoutTests/inspector/css/selector-specificity-expected.txt        2014-11-03 20:03:57 UTC (rev 175483)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+Testing that selectors have expected specificity values.
+
+* (0, 0, 0)
+h1 (0, 0, 1)
+.class (0, 1, 0)
+#id (1, 0, 0)
+body h1.class-one.class-two (0, 2, 2)
+body #foo (1, 0, 1)
+body > #foo (1, 0, 1)
+body > #foo.a.b (1, 2, 1)
+h1::before (0, 1, 1)
+body h1::before (0, 1, 2)
+body.a h1.b::before (0, 3, 2)
+
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectorcssselectorspecificityhtmlfromrev175482trunkLayoutTestsinspectorcssmatchedstylepropertieshtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/inspector/css/selector-specificity.html (from rev 175482, trunk/LayoutTests/inspector/css/matched-style-properties.html) (0 => 175483)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/css/selector-specificity.html         (rev 0)
+++ trunk/LayoutTests/inspector/css/selector-specificity.html        2014-11-03 20:03:57 UTC (rev 175483)
</span><span class="lines">@@ -0,0 +1,68 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<style>
+*,
+h1,
+.class,
+#id,
+body h1.class-one.class-two,
+body #foo,
+body > #foo,
+body > #foo.a.b,
+h1::before,
+body h1::before,
+body.a h1.b::before {
+ color: green;
+}
+</style>
+<script type="text/javascript" src="../../http/tests/inspector/inspector-test.js"></script>
+<script>
+function test() {
+ var nodeStyles;
+
+ function validateSelectors()
+ {
+ for (var i = 0; i < nodeStyles.matchedRules.length; ++i) {
+ var rule = nodeStyles.matchedRules[i];
+ if (rule.type !== WebInspector.CSSRule.Type.Author)
+ continue;
+
+ for (var selector of rule.selectors)
+ InspectorTest.log(selector.text + " (" + selector.specificity.join(", ") + ")");
+ }
+
+ InspectorTest.completeTest();
+ }
+
+ function onStylesRefreshed()
+ {
+ nodeStyles.removeEventListener(WebInspector.DOMNodeStyles.Event.Refreshed, onStylesRefreshed, this);
+ validateSelectors();
+ }
+
+ WebInspector.domTreeManager.requestDocument(function(documentNode) {
+ WebInspector.domTreeManager.querySelector(documentNode.id, "#node1", function(contentNodeId) {
+ if (contentNodeId) {
+ var domNode = WebInspector.domTreeManager.nodeForId(contentNodeId);
+ nodeStyles = WebInspector.cssStyleManager.stylesForNode(domNode);
+
+ if (nodeStyles.needsRefresh)
+ nodeStyles.addEventListener(WebInspector.DOMNodeStyles.Event.Refreshed, onStylesRefreshed, this);
+ else
+ validateSelectors();
+ } else {
+ InspectorTest.log("DOM node not found.");
+ InspectorTest.completeTest();
+ }
+ });
+ });
+}
+</script>
+</head>
+<body onload="runTest()">
+ <p>Testing that selectors have expected specificity values.</p>
+
+ <div id="node1"></div>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (175482 => 175483)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2014-11-03 19:59:44 UTC (rev 175482)
+++ trunk/Source/JavaScriptCore/ChangeLog        2014-11-03 20:03:57 UTC (rev 175483)
</span><span class="lines">@@ -1,5 +1,16 @@
</span><span class="cx"> 2014-11-03 Joseph Pecoraro <pecoraro@apple.com>
</span><span class="cx">
</span><ins>+ Web Inspector: Show Selector's Specificity
+ https://bugs.webkit.org/show_bug.cgi?id=138189
+
+ Reviewed by Timothy Hatcher.
+
+ * inspector/protocol/CSS.json:
+ Create a new named type CSSSelector to include a selector's text and specificity.
+ The specificity tuple is optional as it may soon be made dynamic in some cases.
+
+2014-11-03 Joseph Pecoraro <pecoraro@apple.com>
+
</ins><span class="cx"> Web Inspector: ObjC Protocol Interfaces should throw exceptions for nil arguments
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=138221
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorprotocolCSSjson"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/protocol/CSS.json (175482 => 175483)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/protocol/CSS.json        2014-11-03 19:59:44 UTC (rev 175482)
+++ trunk/Source/JavaScriptCore/inspector/protocol/CSS.json        2014-11-03 20:03:57 UTC (rev 175483)
</span><span class="lines">@@ -59,10 +59,19 @@
</span><span class="cx"> "description": "Match data for a CSS rule."
</span><span class="cx"> },
</span><span class="cx"> {
</span><ins>+ "id": "CSSSelector",
+ "type": "object",
+ "properties": [
+ { "name": "text", "type": "string", "description": "Canonicalized selector text." },
+ { "name": "specificity", "optional": true, "type": "array", "items": { "type": "integer" }, "description": "Specificity (a, b, c) tuple. If missing the specificity is not known statically and may be dynamic." }
+ ],
+ "description": "CSS selector."
+ },
+ {
</ins><span class="cx"> "id": "SelectorList",
</span><span class="cx"> "type": "object",
</span><span class="cx"> "properties": [
</span><del>- { "name": "selectors", "type": "array", "items": { "type": "string" }, "description": "Selectors in the list." },
</del><ins>+ { "name": "selectors", "type": "array", "items": { "$ref": "CSSSelector" }, "description": "Selectors in the list." },
</ins><span class="cx"> { "name": "text", "type": "string", "description": "Rule selector text." },
</span><span class="cx"> { "name": "range", "$ref": "SourceRange", "optional": true, "description": "Rule selector range in the underlying resource (if available)." }
</span><span class="cx"> ],
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (175482 => 175483)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-11-03 19:59:44 UTC (rev 175482)
+++ trunk/Source/WebCore/ChangeLog        2014-11-03 20:03:57 UTC (rev 175483)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2014-11-03 Joseph Pecoraro <pecoraro@apple.com>
+
+ Web Inspector: Show Selector's Specificity
+ https://bugs.webkit.org/show_bug.cgi?id=138189
+
+ Reviewed by Timothy Hatcher.
+
+ Test: inspector/css/selector-specificity.html
+
+ * css/CSSSelector.h:
+ Remove very stale comment. '*' is a starAtom now instead of a special -1 tag.
+ Made the specificity masks public class constants.
+
+ * inspector/InspectorStyleSheet.h:
+ * inspector/InspectorStyleSheet.cpp:
+ (WebCore::InspectorStyle::buildArrayForComputedStyle):
+ (WebCore::InspectorStyle::styleWithProperties):
+ (WebCore::InspectorStyleSheet::buildObjectForStyleSheetInfo):
+ Drive by use release() in some cases to reduce ref count churn.
+
+ (WebCore::buildObjectForSelectorHelper):
+ (WebCore::selectorsFromSource):
+ (WebCore::InspectorStyleSheet::buildObjectForSelector):
+ (WebCore::InspectorStyleSheet::buildObjectForSelectorList):
+ Build CSSSelector objects for SelectorLists.
+
</ins><span class="cx"> 2014-11-03 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><span class="cx"> Move -webkit-shape-outside to the new StyleBuilder
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSSelectorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSSelector.cpp (175482 => 175483)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSSelector.cpp        2014-11-03 19:59:44 UTC (rev 175482)
+++ trunk/Source/WebCore/css/CSSSelector.cpp        2014-11-03 20:03:57 UTC (rev 175483)
</span><span class="lines">@@ -61,12 +61,6 @@
</span><span class="cx">
</span><span class="cx"> unsigned CSSSelector::specificity() const
</span><span class="cx"> {
</span><del>- // make sure the result doesn't overflow
- static const unsigned maxValueMask = 0xffffff;
- static const unsigned idMask = 0xff0000;
- static const unsigned classMask = 0xff00;
- static const unsigned elementMask = 0xff;
-
</del><span class="cx"> if (isForPage())
</span><span class="cx"> return specificityForPage() & maxValueMask;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSSelectorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSSelector.h (175482 => 175483)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSSelector.h        2014-11-03 19:59:44 UTC (rev 175482)
+++ trunk/Source/WebCore/css/CSSSelector.h        2014-11-03 20:03:57 UTC (rev 175483)
</span><span class="lines">@@ -47,7 +47,10 @@
</span><span class="cx"> // checks if the 2 selectors (including sub selectors) agree.
</span><span class="cx"> bool operator==(const CSSSelector&) const;
</span><span class="cx">
</span><del>- // tag == -1 means apply to all elements (Selector = *)
</del><ins>+ static const unsigned maxValueMask = 0xffffff;
+ static const unsigned idMask = 0xff0000;
+ static const unsigned classMask = 0xff00;
+ static const unsigned elementMask = 0xff;
</ins><span class="cx">
</span><span class="cx"> unsigned specificity() const;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorStyleSheetcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp (175482 => 175483)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp        2014-11-03 19:59:44 UTC (rev 175482)
+++ trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp        2014-11-03 20:03:57 UTC (rev 175483)
</span><span class="lines">@@ -151,12 +151,12 @@
</span><span class="cx"> TextPosition start = ContentSearchUtilities::textPositionFromOffset(range.start, *lineEndings);
</span><span class="cx"> TextPosition end = ContentSearchUtilities::textPositionFromOffset(range.end, *lineEndings);
</span><span class="cx">
</span><del>- RefPtr<Inspector::Protocol::CSS::SourceRange> result = Inspector::Protocol::CSS::SourceRange::create()
</del><ins>+ return Inspector::Protocol::CSS::SourceRange::create()
</ins><span class="cx"> .setStartLine(start.m_line.zeroBasedInt())
</span><span class="cx"> .setStartColumn(start.m_column.zeroBasedInt())
</span><span class="cx"> .setEndLine(end.m_line.zeroBasedInt())
</span><del>- .setEndColumn(end.m_column.zeroBasedInt());
- return result.release();
</del><ins>+ .setEndColumn(end.m_column.zeroBasedInt())
+ .release();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static PassRefPtr<Inspector::Protocol::CSS::CSSMedia> buildMediaObject(const MediaList* media, MediaListSource mediaListSource, const String& sourceURL)
</span><span class="lines">@@ -327,7 +327,7 @@
</span><span class="cx"> RefPtr<Inspector::Protocol::CSS::CSSComputedStyleProperty> entry = Inspector::Protocol::CSS::CSSComputedStyleProperty::create()
</span><span class="cx"> .setName(propertyEntry.name)
</span><span class="cx"> .setValue(propertyEntry.value);
</span><del>- result->addItem(entry);
</del><ins>+ result->addItem(entry.release());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> return result.release();
</span><span class="lines">@@ -603,7 +603,7 @@
</span><span class="cx"> RefPtr<Inspector::Protocol::CSS::ShorthandEntry> entry = Inspector::Protocol::CSS::ShorthandEntry::create()
</span><span class="cx"> .setName(shorthand)
</span><span class="cx"> .setValue(shorthandValue(shorthand));
</span><del>- shorthandEntries->addItem(entry);
</del><ins>+ shorthandEntries->addItem(entry.release());
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -614,10 +614,10 @@
</span><span class="cx"> property->setStatus(status);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- RefPtr<Inspector::Protocol::CSS::CSSStyle> result = Inspector::Protocol::CSS::CSSStyle::create()
- .setCssProperties(propertiesObject)
- .setShorthandEntries(shorthandEntries);
- return result.release();
</del><ins>+ return Inspector::Protocol::CSS::CSSStyle::create()
+ .setCssProperties(propertiesObject.release())
+ .setShorthandEntries(shorthandEntries.release())
+ .release();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> PassRefPtr<CSSRuleSourceData> InspectorStyle::extractSourceData() const
</span><span class="lines">@@ -981,53 +981,75 @@
</span><span class="cx">
</span><span class="cx"> Document* document = styleSheet->ownerDocument();
</span><span class="cx"> Frame* frame = document ? document->frame() : nullptr;
</span><del>- RefPtr<Inspector::Protocol::CSS::CSSStyleSheetHeader> result = Inspector::Protocol::CSS::CSSStyleSheetHeader::create()
</del><ins>+ return Inspector::Protocol::CSS::CSSStyleSheetHeader::create()
</ins><span class="cx"> .setStyleSheetId(id())
</span><span class="cx"> .setOrigin(m_origin)
</span><span class="cx"> .setDisabled(styleSheet->disabled())
</span><span class="cx"> .setSourceURL(finalURL())
</span><span class="cx"> .setTitle(styleSheet->title())
</span><del>- .setFrameId(m_pageAgent->frameId(frame));
</del><ins>+ .setFrameId(m_pageAgent->frameId(frame))
+ .release();
+}
</ins><span class="cx">
</span><del>- return result.release();
</del><ins>+static PassRefPtr<Inspector::Protocol::CSS::CSSSelector> buildObjectForSelectorHelper(const String& selectorText, unsigned specificity)
+{
+ RefPtr<Inspector::Protocol::CSS::CSSSelector> selector = Inspector::Protocol::CSS::CSSSelector::create()
+ .setText(selectorText);
+
+ RefPtr<Inspector::Protocol::Array<int>> tuple = Inspector::Protocol::Array<int>::create();
+ tuple->addItem(static_cast<int>((specificity & CSSSelector::idMask) >> 16));
+ tuple->addItem(static_cast<int>((specificity & CSSSelector::classMask) >> 8));
+ tuple->addItem(static_cast<int>(specificity & CSSSelector::elementMask));
+ selector->setSpecificity(tuple.release());
+
+ return selector.release();
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-static PassRefPtr<Inspector::Protocol::Array<String>> selectorsFromSource(const CSSRuleSourceData* sourceData, const String& sheetText)
</del><ins>+static PassRefPtr<Inspector::Protocol::Array<Inspector::Protocol::CSS::CSSSelector>> selectorsFromSource(const CSSRuleSourceData* sourceData, const String& sheetText, const CSSSelectorList& selectorList)
</ins><span class="cx"> {
</span><span class="cx"> DEPRECATED_DEFINE_STATIC_LOCAL(JSC::Yarr::RegularExpression, comment, ("/\\*[^]*?\\*/", TextCaseSensitive, JSC::Yarr::MultilineEnabled));
</span><del>- RefPtr<Inspector::Protocol::Array<String>> result = Inspector::Protocol::Array<String>::create();
</del><ins>+
+ RefPtr<Inspector::Protocol::Array<Inspector::Protocol::CSS::CSSSelector>> result = Inspector::Protocol::Array<Inspector::Protocol::CSS::CSSSelector>::create();
</ins><span class="cx"> const SelectorRangeList& ranges = sourceData->selectorRanges;
</span><ins>+ const CSSSelector* selector = selectorList.first();
</ins><span class="cx"> for (size_t i = 0, size = ranges.size(); i < size; ++i) {
</span><span class="cx"> const SourceRange& range = ranges.at(i);
</span><del>- String selector = sheetText.substring(range.start, range.length());
</del><ins>+ String selectorText = sheetText.substring(range.start, range.length());
</ins><span class="cx">
</span><span class="cx"> // We don't want to see any comments in the selector components, only the meaningful parts.
</span><del>- replace(selector, comment, "");
- result->addItem(selector.stripWhiteSpace());
</del><ins>+ replace(selectorText, comment, String());
+ result->addItem(buildObjectForSelectorHelper(selectorText.stripWhiteSpace(), selector->specificity()));
+
+ selector = CSSSelectorList::next(selector);
</ins><span class="cx"> }
</span><span class="cx"> return result.release();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+PassRefPtr<Inspector::Protocol::CSS::CSSSelector> InspectorStyleSheet::buildObjectForSelector(const CSSSelector* selector)
+{
+ return buildObjectForSelectorHelper(selector->selectorText(), selector->specificity());
+}
+
</ins><span class="cx"> PassRefPtr<Inspector::Protocol::CSS::SelectorList> InspectorStyleSheet::buildObjectForSelectorList(CSSStyleRule* rule)
</span><span class="cx"> {
</span><span class="cx"> RefPtr<CSSRuleSourceData> sourceData;
</span><span class="cx"> if (ensureParsedDataReady())
</span><span class="cx"> sourceData = ruleSourceDataFor(&rule->style());
</span><del>- RefPtr<Inspector::Protocol::Array<String>> selectors;
</del><ins>+ RefPtr<Inspector::Protocol::Array<Inspector::Protocol::CSS::CSSSelector>> selectors;
</ins><span class="cx">
</span><span class="cx"> // This intentionally does not rely on the source data to avoid catching the trailing comments (before the declaration starting '{').
</span><span class="cx"> String selectorText = rule->selectorText();
</span><span class="cx">
</span><span class="cx"> if (sourceData)
</span><del>- selectors = selectorsFromSource(sourceData.get(), m_parsedStyleSheet->text());
</del><ins>+ selectors = selectorsFromSource(sourceData.get(), m_parsedStyleSheet->text(), rule->styleRule()->selectorList());
</ins><span class="cx"> else {
</span><del>- selectors = Inspector::Protocol::Array<String>::create();
</del><ins>+ selectors = Inspector::Protocol::Array<Inspector::Protocol::CSS::CSSSelector>::create();
</ins><span class="cx"> const CSSSelectorList& selectorList = rule->styleRule()->selectorList();
</span><span class="cx"> for (const CSSSelector* selector = selectorList.first(); selector; selector = CSSSelectorList::next(selector))
</span><del>- selectors->addItem(selector->selectorText());
</del><ins>+ selectors->addItem(buildObjectForSelector(selector));
</ins><span class="cx"> }
</span><span class="cx"> RefPtr<Inspector::Protocol::CSS::SelectorList> result = Inspector::Protocol::CSS::SelectorList::create()
</span><del>- .setSelectors(selectors)
</del><ins>+ .setSelectors(selectors.release())
</ins><span class="cx"> .setText(selectorText)
</span><span class="cx"> .release();
</span><span class="cx"> if (sourceData)
</span><span class="lines">@@ -1074,10 +1096,10 @@
</span><span class="cx">
</span><span class="cx"> InspectorCSSId id = ruleOrStyleId(style);
</span><span class="cx"> if (id.isEmpty()) {
</span><del>- RefPtr<Inspector::Protocol::CSS::CSSStyle> bogusStyle = Inspector::Protocol::CSS::CSSStyle::create()
</del><ins>+ return Inspector::Protocol::CSS::CSSStyle::create()
</ins><span class="cx"> .setCssProperties(Array<Inspector::Protocol::CSS::CSSProperty>::create())
</span><del>- .setShorthandEntries(Array<Inspector::Protocol::CSS::ShorthandEntry>::create());
- return bogusStyle.release();
</del><ins>+ .setShorthandEntries(Array<Inspector::Protocol::CSS::ShorthandEntry>::create())
+ .release();
</ins><span class="cx"> }
</span><span class="cx"> RefPtr<InspectorStyle> inspectorStyle = inspectorStyleForId(id);
</span><span class="cx"> RefPtr<Inspector::Protocol::CSS::CSSStyle> result = inspectorStyle->buildObjectForStyle();
</span><span class="lines">@@ -1175,10 +1197,8 @@
</span><span class="cx"> return nullptr;
</span><span class="cx">
</span><span class="cx"> InspectorStyleMap::iterator it = m_inspectorStyles.find(style);
</span><del>- if (it == m_inspectorStyles.end()) {
- RefPtr<InspectorStyle> inspectorStyle = InspectorStyle::create(id, style, this);
- return inspectorStyle.release();
- }
</del><ins>+ if (it == m_inspectorStyles.end())
+ return InspectorStyle::create(id, style, this);
</ins><span class="cx"> return it->value;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorStyleSheeth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorStyleSheet.h (175482 => 175483)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorStyleSheet.h        2014-11-03 19:59:44 UTC (rev 175482)
+++ trunk/Source/WebCore/inspector/InspectorStyleSheet.h        2014-11-03 20:03:57 UTC (rev 175483)
</span><span class="lines">@@ -43,6 +43,7 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> class CSSRuleList;
</span><ins>+class CSSSelector;
</ins><span class="cx"> class CSSStyleDeclaration;
</span><span class="cx"> class CSSStyleRule;
</span><span class="cx"> class CSSStyleSheet;
</span><span class="lines">@@ -243,6 +244,7 @@
</span><span class="cx"> bool resourceStyleSheetText(String* result) const;
</span><span class="cx"> bool inlineStyleSheetText(String* result) const;
</span><span class="cx"> PassRefPtr<Inspector::Protocol::Array<Inspector::Protocol::CSS::CSSRule>> buildArrayForRuleList(CSSRuleList*);
</span><ins>+ PassRefPtr<Inspector::Protocol::CSS::CSSSelector> buildObjectForSelector(const CSSSelector*);
</ins><span class="cx"> PassRefPtr<Inspector::Protocol::CSS::SelectorList> buildObjectForSelectorList(CSSStyleRule*);
</span><span class="cx">
</span><span class="cx"> InspectorPageAgent* m_pageAgent;
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (175482 => 175483)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog        2014-11-03 19:59:44 UTC (rev 175482)
+++ trunk/Source/WebInspectorUI/ChangeLog        2014-11-03 20:03:57 UTC (rev 175483)
</span><span class="lines">@@ -1,5 +1,45 @@
</span><span class="cx"> 2014-11-03 Joseph Pecoraro <pecoraro@apple.com>
</span><span class="cx">
</span><ins>+ Web Inspector: Show Selector's Specificity
+ https://bugs.webkit.org/show_bug.cgi?id=138189
+
+ Reviewed by Timothy Hatcher.
+
+ * Localizations/en.lproj/localizedStrings.js:
+ * UserInterface/Main.html:
+ * UserInterface/Test.html:
+ Add new files and strings.
+
+ * UserInterface/Models/CSSMedia.js:
+ Constructor functions are not needed, remove unnecessary code.
+
+ * UserInterface/Models/CSSRule.js:
+ (WebInspector.CSSRule.prototype.set selectors): Deleted.
+ This was unused and is no longer correct.
+
+ (WebInspector.CSSRule.prototype.get matchedSelectorText):
+ Update now that selectors are a list of objects, not just strings.
+
+ * UserInterface/Models/CSSSelector.js:
+ (WebInspector.CSSSelector):
+ (WebInspector.CSSSelector.prototype.get specificity):
+ New model object for protocol type CSS.CSSSelector.
+
+ * UserInterface/Models/DOMNodeStyles.js:
+ (WebInspector.DOMNodeStyles.prototype._parseSelectorListPayload.return):
+ (WebInspector.DOMNodeStyles.prototype._parseSelectorListPayload):
+ (WebInspector.DOMNodeStyles.prototype._parseRulePayload):
+ Handle parsing old and new SelectorLists.
+
+ * UserInterface/Views/CSSStyleDeclarationSection.js:
+ (WebInspector.CSSStyleDeclarationSection.prototype.refresh.appendSelector):
+ (WebInspector.CSSStyleDeclarationSection.prototype.refresh.appendSelectorText):
+ (WebInspector.CSSStyleDeclarationSection.prototype.refresh):
+ Update the code now that the list of selectors are model objects instead
+ of just selector text strings.
+
+2014-11-03 Joseph Pecoraro <pecoraro@apple.com>
+
</ins><span class="cx"> Web Inspector: ALTERNATE_DISPATCHERS Let the frontend know about extra agents
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=138236
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebInspectorUILocalizationsenlprojlocalizedStringsjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (175482 => 175483)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js        2014-11-03 19:59:44 UTC (rev 175482)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js        2014-11-03 20:03:57 UTC (rev 175483)
</span><span class="lines">@@ -404,6 +404,7 @@
</span><span class="cx"> localizedStrings["Socket"] = "Socket";
</span><span class="cx"> localizedStrings["Sockets"] = "Sockets";
</span><span class="cx"> localizedStrings["Source Code"] = "Source Code";
</span><ins>+localizedStrings["Specificity: (%d, %d, %d) "H %d"] = "Specificity: (%d, %d, %d) "H %d";
</ins><span class="cx"> localizedStrings["Spelling"] = "Spelling";
</span><span class="cx"> localizedStrings["Start Playback"] = "Start Playback";
</span><span class="cx"> localizedStrings["Start Recording"] = "Start Recording";
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceMainhtml"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Main.html (175482 => 175483)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Main.html        2014-11-03 19:59:44 UTC (rev 175482)
+++ trunk/Source/WebInspectorUI/UserInterface/Main.html        2014-11-03 20:03:57 UTC (rev 175483)
</span><span class="lines">@@ -212,6 +212,7 @@
</span><span class="cx"> <script src="Models/CSSMedia.js"></script>
</span><span class="cx"> <script src="Models/CSSProperty.js"></script>
</span><span class="cx"> <script src="Models/CSSRule.js"></script>
</span><ins>+ <script src="Models/CSSSelector.js"></script>
</ins><span class="cx"> <script src="Models/CSSStyleDeclaration.js"></script>
</span><span class="cx"> <script src="Models/CSSStyleSheet.js"></script>
</span><span class="cx"> <script src="Models/CallFrame.js"></script>
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceModelsCSSMediajs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Models/CSSMedia.js (175482 => 175483)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Models/CSSMedia.js        2014-11-03 19:59:44 UTC (rev 175482)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/CSSMedia.js        2014-11-03 20:03:57 UTC (rev 175483)
</span><span class="lines">@@ -32,8 +32,6 @@
</span><span class="cx"> this._sourceCodeLocation = sourceCodeLocation || null;
</span><span class="cx"> };
</span><span class="cx">
</span><del>-WebInspector.Object.addConstructorFunctions(WebInspector.CSSMedia);
-
</del><span class="cx"> WebInspector.CSSMedia.Type = {
</span><span class="cx"> MediaRule: "css-media-type-media-rule",
</span><span class="cx"> ImportRule: "css-media-type-import-rule",
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceModelsCSSRulejs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Models/CSSRule.js (175482 => 175483)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Models/CSSRule.js        2014-11-03 19:59:44 UTC (rev 175482)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/CSSRule.js        2014-11-03 20:03:57 UTC (rev 175483)
</span><span class="lines">@@ -139,11 +139,6 @@
</span><span class="cx"> return this._selectors;
</span><span class="cx"> },
</span><span class="cx">
</span><del>- set selectors(selectors)
- {
- this.selectorText = (selectors || []).join(", ");
- },
-
</del><span class="cx"> get matchedSelectorIndices()
</span><span class="cx"> {
</span><span class="cx"> return this._matchedSelectorIndices;
</span><span class="lines">@@ -178,7 +173,7 @@
</span><span class="cx"> if ("_matchedSelectorText" in this)
</span><span class="cx"> return this._matchedSelectorText;
</span><span class="cx">
</span><del>- this._matchedSelectorText = this.matchedSelectors.join(", ");
</del><ins>+ this._matchedSelectorText = this.matchedSelectors.map(function(x) { return x.text; }).join(", ");
</ins><span class="cx">
</span><span class="cx"> return this._matchedSelectorText;
</span><span class="cx"> },
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceModelsCSSSelectorjsfromrev175482trunkSourceWebInspectorUIUserInterfaceModelsCSSMediajs"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebInspectorUI/UserInterface/Models/CSSSelector.js (from rev 175482, trunk/Source/WebInspectorUI/UserInterface/Models/CSSMedia.js) (0 => 175483)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Models/CSSSelector.js         (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/CSSSelector.js        2014-11-03 20:03:57 UTC (rev 175483)
</span><span class="lines">@@ -0,0 +1,51 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.CSSSelector = function(text, specificity)
+{
+ WebInspector.Object.call(this);
+
+ console.assert(text);
+
+ this._text = text;
+ this._specificity = specificity || null;
+};
+
+WebInspector.CSSSelector.prototype = {
+ constructor: WebInspector.CSSSelector,
+ __proto__: WebInspector.Object.prototype,
+
+ // Public
+
+ get text()
+ {
+ return this._text;
+ },
+
+ get specificity()
+ {
+ return this._specificity;
+ }
+};
</ins></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceModelsDOMNodeStylesjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js (175482 => 175483)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js        2014-11-03 19:59:44 UTC (rev 175482)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js        2014-11-03 20:03:57 UTC (rev 175483)
</span><span class="lines">@@ -745,6 +745,29 @@
</span><span class="cx"> return styleDeclaration;
</span><span class="cx"> },
</span><span class="cx">
</span><ins>+ _parseSelectorListPayload: function(selectorList)
+ {
+ // COMPATIBILITY (iOS 6): The payload did not have 'selectorList'.
+ if (!selectorList)
+ return [];
+
+ var selectors = selectorList.selectors;
+ if (!selectors.length)
+ return [];
+
+ // COMPATIBILITY (iOS 8): The selectorList payload was an array of selector text strings.
+ // Now they are CSSSelector objects with multiple properties.
+ if (typeof selectors[0] === "string") {
+ return selectors.map(function(selectorText) {
+ return new WebInspector.CSSSelector(selectorText);
+ });
+ }
+
+ return selectors.map(function(selectorPayload) {
+ return new WebInspector.CSSSelector(selectorPayload.text, selectorPayload.specificity);
+ });
+ },
+
</ins><span class="cx"> _parseRulePayload: function(payload, matchedSelectorIndices, node, inherited, ruleOccurrences)
</span><span class="cx"> {
</span><span class="cx"> if (!payload)
</span><span class="lines">@@ -791,7 +814,7 @@
</span><span class="cx"> // COMPATIBILITY (iOS 6): The payload had 'selectorText' as a property,
</span><span class="cx"> // now it has 'selectorList' with a 'text' property. Support both here.
</span><span class="cx"> var selectorText = payload.selectorList ? payload.selectorList.text : payload.selectorText;
</span><del>- var selectors = payload.selectorList ? payload.selectorList.selectors : [];
</del><ins>+ var selectors = this._parseSelectorListPayload(payload.selectorList);
</ins><span class="cx">
</span><span class="cx"> // COMPATIBILITY (iOS 6): The payload did not have 'selectorList'.
</span><span class="cx"> // Fallback to using 'sourceLine' without column information.
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceTesthtml"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Test.html (175482 => 175483)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Test.html        2014-11-03 19:59:44 UTC (rev 175482)
+++ trunk/Source/WebInspectorUI/UserInterface/Test.html        2014-11-03 20:03:57 UTC (rev 175483)
</span><span class="lines">@@ -74,6 +74,7 @@
</span><span class="cx"> <script src="Models/CSSKeywordCompletions.js"></script>
</span><span class="cx"> <script src="Models/CSSProperty.js"></script>
</span><span class="cx"> <script src="Models/CSSRule.js"></script>
</span><ins>+ <script src="Models/CSSSelector.js"></script>
</ins><span class="cx"> <script src="Models/CSSStyleDeclaration.js"></script>
</span><span class="cx"> <script src="Models/CSSStyleSheet.js"></script>
</span><span class="cx"> <script src="Models/DOMNode.js"></script>
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsCSSStyleDeclarationSectionjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js (175482 => 175483)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js        2014-11-03 19:59:44 UTC (rev 175482)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js        2014-11-03 20:03:57 UTC (rev 175483)
</span><span class="lines">@@ -168,12 +168,30 @@
</span><span class="cx">
</span><span class="cx"> this._originElement.appendChild(document.createTextNode(" \u2014 "));
</span><span class="cx">
</span><del>- function appendSelector(selectorText, matched)
</del><ins>+ function appendSelector(selector, matched)
</ins><span class="cx"> {
</span><ins>+ console.assert(selector instanceof WebInspector.CSSSelector);
+
</ins><span class="cx"> var selectorElement = document.createElement("span");
</span><ins>+ selectorElement.textContent = selector.text;
+
</ins><span class="cx"> if (matched)
</span><span class="cx"> selectorElement.className = WebInspector.CSSStyleDeclarationSection.MatchedSelectorElementStyleClassName;
</span><ins>+
+ var specificity = selector.specificity;
+ if (specificity) {
+ var approximatedSpecificity = (specificity[0] * 100) + (specificity[1] * 10) + specificity[2];
+ selectorElement.title = WebInspector.UIString("Specificity: (%d, %d, %d) ≈ %d").format(specificity[0], specificity[1], specificity[2], approximatedSpecificity);
+ }
+
+ this._selectorElement.appendChild(selectorElement);
+ }
+
+ function appendSelectorTextKnownToMatch(selectorText)
+ {
+ var selectorElement = document.createElement("span");
</ins><span class="cx"> selectorElement.textContent = selectorText;
</span><ins>+ selectorElement.className = WebInspector.CSSStyleDeclarationSection.MatchedSelectorElementStyleClassName;
</ins><span class="cx"> this._selectorElement.appendChild(selectorElement);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -190,7 +208,7 @@
</span><span class="cx"> this._selectorElement.appendChild(document.createTextNode(", "));
</span><span class="cx"> }
</span><span class="cx"> } else
</span><del>- appendSelector.call(this, this._style.ownerRule.selectorText, true);
</del><ins>+ appendSelectorTextKnownToMatch.call(this, this._style.ownerRule.selectorText);
</ins><span class="cx">
</span><span class="cx"> if (this._style.ownerRule.sourceCodeLocation) {
</span><span class="cx"> var sourceCodeLink = WebInspector.createSourceCodeLocationLink(this._style.ownerRule.sourceCodeLocation, true);
</span><span class="lines">@@ -223,12 +241,12 @@
</span><span class="cx"> break;
</span><span class="cx">
</span><span class="cx"> case WebInspector.CSSStyleDeclaration.Type.Inline:
</span><del>- appendSelector.call(this, WebInspector.displayNameForNode(this._style.node), true);
</del><ins>+ appendSelectorTextKnownToMatch.call(this, WebInspector.displayNameForNode(this._style.node));
</ins><span class="cx"> this._originElement.appendChild(document.createTextNode(WebInspector.UIString("Style Attribute")));
</span><span class="cx"> break;
</span><span class="cx">
</span><span class="cx"> case WebInspector.CSSStyleDeclaration.Type.Attribute:
</span><del>- appendSelector.call(this, WebInspector.displayNameForNode(this._style.node), true);
</del><ins>+ appendSelectorTextKnownToMatch.call(this, WebInspector.displayNameForNode(this._style.node));
</ins><span class="cx"> this._originElement.appendChild(document.createTextNode(WebInspector.UIString("HTML Attributes")));
</span><span class="cx"> break;
</span><span class="cx"> }
</span></span></pre>
</div>
</div>
</body>
</html>