<!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>[175758] 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/175758">175758</a></dd>
<dt>Author</dt> <dd>joepeck@webkit.org</dd>
<dt>Date</dt> <dd>2014-11-07 12:29:49 -0800 (Fri, 07 Nov 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Web Inspector: Pseudo element matchedCSSRules do not include matching selector info
https://bugs.webkit.org/show_bug.cgi?id=138438
Reviewed by Benjamin Poulain.
Source/WebCore:
Test: inspector/css/psuedo-element-matches.html
Element::matches is not the correct API to use to check selectors with pseudo-elements.
Instead we should use the CSS Selector checking machinary which understands them.
* inspector/InspectorCSSAgent.cpp:
(WebCore::InspectorCSSAgent::getSupportedCSSProperties):
(WebCore::InspectorCSSAgent::buildArrayForRuleList):
(WebCore::InspectorCSSAgent::buildArrayForRegions):
(WebCore::InspectorCSSAgent::buildObjectForNamedFlow):
Some RefPtr release improvements.
(WebCore::InspectorCSSAgent::buildArrayForMatchedRuleList):
Use a SelectorChecker to check each Selector against the element.
This matches the SelectorChecker used when we collected the rules
for this element.
Source/WebInspectorUI:
* UserInterface/Base/Test.js:
(WebInspector.loaded):
Include a global setting for shadow dom used by DOM model classes.
Give it a "test" specific name to not override non-test setting values.
LayoutTests:
* inspector/css/pseudo-element-matches-expected.txt: Added.
* inspector/css/pseudo-element-matches.html: Added.
Add a test to ensure we get correct selector matches for a pseudo element
inside of an <audio> element. The test is heavily coupled to our UserAgent
stylesheet and Shadow DOM layout, so check for possible failures if
WebCore changes things.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorCSSAgentcpp">trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp</a></li>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceBaseTestjs">trunk/Source/WebInspectorUI/UserInterface/Base/Test.js</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsinspectorcsspseudoelementmatchesexpectedtxt">trunk/LayoutTests/inspector/css/pseudo-element-matches-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectorcsspseudoelementmatcheshtml">trunk/LayoutTests/inspector/css/pseudo-element-matches.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (175757 => 175758)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-11-07 20:25:17 UTC (rev 175757)
+++ trunk/LayoutTests/ChangeLog        2014-11-07 20:29:49 UTC (rev 175758)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2014-11-07 Joseph Pecoraro <pecoraro@apple.com>
+
+ Web Inspector: Pseudo element matchedCSSRules do not include matching selector info
+ https://bugs.webkit.org/show_bug.cgi?id=138438
+
+ Reviewed by Benjamin Poulain.
+
+ * inspector/css/pseudo-element-matches-expected.txt: Added.
+ * inspector/css/pseudo-element-matches.html: Added.
+ Add a test to ensure we get correct selector matches for a pseudo element
+ inside of an <audio> element. The test is heavily coupled to our UserAgent
+ stylesheet and Shadow DOM layout, so check for possible failures if
+ WebCore changes things.
+
</ins><span class="cx"> 2014-11-07 Bem Jones-Bey <bjonesbe@adobe.com>
</span><span class="cx">
</span><span class="cx"> [CSS Shapes] the sandbag JS utility code isn't producing the correct expected result in the shape-image gradient tests
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorcsspseudoelementmatchesexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/css/pseudo-element-matches-expected.txt (0 => 175758)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/css/pseudo-element-matches-expected.txt         (rev 0)
+++ trunk/LayoutTests/inspector/css/pseudo-element-matches-expected.txt        2014-11-07 20:29:49 UTC (rev 175758)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+Testing that psuedo element selectors correctly show matching selector information.
+
+
+video::-webkit-media-text-track-container
+audio::-webkit-media-text-track-container MATCHES
+
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectorcsspseudoelementmatcheshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/css/pseudo-element-matches.html (0 => 175758)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/css/pseudo-element-matches.html         (rev 0)
+++ trunk/LayoutTests/inspector/css/pseudo-element-matches.html        2014-11-07 20:29:49 UTC (rev 175758)
</span><span class="lines">@@ -0,0 +1,83 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script type="text/javascript" src="../../http/tests/inspector/inspector-test.js"></script>
+<script>
+function test() {
+ var nodeStyles;
+
+ function validateMatchedSelectors()
+ {
+ var found = false;
+
+ for (var i = 0; i < nodeStyles.matchedRules.length; ++i) {
+ var rule = nodeStyles.matchedRules[i];
+ if (rule.type !== WebInspector.CSSRule.Type.UserAgent)
+ continue;
+ if (rule.selectorText.indexOf("::-webkit-media-text-track-container") === -1)
+ continue;
+
+ found = true;
+ var index = 0;
+ for (var selector of rule.selectors) {
+ var matches = rule.matchedSelectorIndices.contains(index);
+ InspectorTest.log(selector.text + (matches ? " MATCHES" : ""));
+ index++;
+ }
+ break;
+ }
+
+ if (!found)
+ InspectorTest.log("Failed to find a ::-webkit-media-text-track-container UserAgent style. Test may need to change.");
+
+ InspectorTest.completeTest();
+ }
+
+ function onStylesRefreshed()
+ {
+ nodeStyles.removeEventListener(WebInspector.DOMNodeStyles.Event.Refreshed, onStylesRefreshed, this);
+ validateMatchedSelectors();
+ }
+
+ WebInspector.domTreeManager.requestDocument(function(documentNode) {
+ WebInspector.domTreeManager.querySelector(documentNode.id, "#node1", function(contentNodeId) {
+ try {
+ if (contentNodeId) {
+ var domNode = WebInspector.domTreeManager.nodeForId(contentNodeId);
+ domNode.getSubtree(1, function() {
+ var shadowRootDocument = domNode.children[0];
+ shadowRootDocument.getSubtree(2, function() {
+ var shadowRoot = shadowRootDocument.children[0];
+ for (var i = 0; i < shadowRoot.children.length; ++i) {
+ var shadowNode = shadowRoot.children[i];
+ if (shadowNode.getAttribute("pseudo") === "-webkit-media-text-track-container") {
+ nodeStyles = WebInspector.cssStyleManager.stylesForNode(shadowNode);
+ if (nodeStyles.needsRefresh)
+ nodeStyles.addEventListener(WebInspector.DOMNodeStyles.Event.Refreshed, onStylesRefreshed, this);
+ else
+ validateMatchedSelectors();
+ return;
+ }
+ }
+ });
+ });
+ } else {
+ InspectorTest.log("DOM node not found.");
+ InspectorTest.completeTest();
+ }
+ } catch (e) {
+ InspectorTest.log("Exception: " + e.message);
+ InspectorTest.log("Failed to find a ::-webkit-media-text-track-container shadow element under an <audio>. Test may need to change.");
+ InspectorTest.completeTest();
+ }
+ });
+ });
+}
+</script>
+</head>
+<body onload="runTest()">
+ <p>Testing that psuedo element selectors correctly show matching selector information.</p>
+
+ <audio id="node1" controls>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (175757 => 175758)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-11-07 20:25:17 UTC (rev 175757)
+++ trunk/Source/WebCore/ChangeLog        2014-11-07 20:29:49 UTC (rev 175758)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2014-11-07 Joseph Pecoraro <pecoraro@apple.com>
+
+ Web Inspector: Pseudo element matchedCSSRules do not include matching selector info
+ https://bugs.webkit.org/show_bug.cgi?id=138438
+
+ Reviewed by Benjamin Poulain.
+
+ Test: inspector/css/psuedo-element-matches.html
+
+ Element::matches is not the correct API to use to check selectors with pseudo-elements.
+ Instead we should use the CSS Selector checking machinary which understands them.
+
+ * inspector/InspectorCSSAgent.cpp:
+ (WebCore::InspectorCSSAgent::getSupportedCSSProperties):
+ (WebCore::InspectorCSSAgent::buildArrayForRuleList):
+ (WebCore::InspectorCSSAgent::buildArrayForRegions):
+ (WebCore::InspectorCSSAgent::buildObjectForNamedFlow):
+ Some RefPtr release improvements.
+
+ (WebCore::InspectorCSSAgent::buildArrayForMatchedRuleList):
+ Use a SelectorChecker to check each Selector against the element.
+ This matches the SelectorChecker used when we collected the rules
+ for this element.
+
</ins><span class="cx"> 2014-11-07 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><span class="cx"> Drop useless HTMLElement::isURLAttribute() override
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorCSSAgentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp (175757 => 175758)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp        2014-11-07 20:25:17 UTC (rev 175757)
+++ trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp        2014-11-07 20:29:49 UTC (rev 175758)
</span><span class="lines">@@ -49,6 +49,7 @@
</span><span class="cx"> #include "NodeList.h"
</span><span class="cx"> #include "RenderNamedFlowFragment.h"
</span><span class="cx"> #include "SVGStyleElement.h"
</span><ins>+#include "SelectorChecker.h"
</ins><span class="cx"> #include "StyleProperties.h"
</span><span class="cx"> #include "StylePropertyShorthand.h"
</span><span class="cx"> #include "StyleResolver.h"
</span><span class="lines">@@ -826,7 +827,7 @@
</span><span class="cx"> CSSPropertyID longhandID = shorthand.properties()[j];
</span><span class="cx"> longhands->addItem(getPropertyNameString(longhandID));
</span><span class="cx"> }
</span><del>- property->setLonghands(longhands);
</del><ins>+ property->setLonghands(longhands.release());
</ins><span class="cx"> properties->addItem(property.release());
</span><span class="cx"> }
</span><span class="cx"> cssProperties = properties.release();
</span><span class="lines">@@ -1047,7 +1048,7 @@
</span><span class="cx"> RefPtr<Inspector::Protocol::CSS::CSSRule> ruleObject = buildObjectForRule(rule);
</span><span class="cx"> if (!ruleObject)
</span><span class="cx"> continue;
</span><del>- result->addItem(ruleObject);
</del><ins>+ result->addItem(ruleObject.release());
</ins><span class="cx"> }
</span><span class="cx"> return result.release();
</span><span class="cx"> }
</span><span class="lines">@@ -1056,26 +1057,32 @@
</span><span class="cx"> {
</span><span class="cx"> RefPtr<Inspector::Protocol::Array<Inspector::Protocol::CSS::RuleMatch>> result = Inspector::Protocol::Array<Inspector::Protocol::CSS::RuleMatch>::create();
</span><span class="cx">
</span><ins>+ SelectorChecker::CheckingContext context(SelectorChecker::Mode::CollectingRules);
+ SelectorChecker selectorChecker(element->document());
+
</ins><span class="cx"> for (unsigned i = 0; i < matchedRules.size(); ++i) {
</span><span class="cx"> if (!matchedRules[i]->isStyleRule())
</span><span class="cx"> continue;
</span><ins>+
</ins><span class="cx"> StyleRule* matchedStyleRule = static_cast<StyleRule*>(matchedRules[i].get());
</span><span class="cx"> RefPtr<Inspector::Protocol::CSS::CSSRule> ruleObject = buildObjectForRule(matchedStyleRule, styleResolver);
</span><span class="cx"> if (!ruleObject)
</span><span class="cx"> continue;
</span><ins>+
</ins><span class="cx"> RefPtr<Inspector::Protocol::Array<int>> matchingSelectors = Inspector::Protocol::Array<int>::create();
</span><span class="cx"> const CSSSelectorList& selectorList = matchedStyleRule->selectorList();
</span><span class="cx"> long index = 0;
</span><span class="cx"> for (const CSSSelector* selector = selectorList.first(); selector; selector = CSSSelectorList::next(selector)) {
</span><del>- bool matched = element->matches(selector->selectorText(), IGNORE_EXCEPTION);
</del><ins>+ bool matched = selectorChecker.match(selector, element, context);
</ins><span class="cx"> if (matched)
</span><span class="cx"> matchingSelectors->addItem(index);
</span><span class="cx"> ++index;
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> RefPtr<Inspector::Protocol::CSS::RuleMatch> match = Inspector::Protocol::CSS::RuleMatch::create()
</span><del>- .setRule(ruleObject)
- .setMatchingSelectors(matchingSelectors);
- result->addItem(match);
</del><ins>+ .setRule(ruleObject.release())
+ .setMatchingSelectors(matchingSelectors.release());
+ result->addItem(match.release());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> return result.release();
</span><span class="lines">@@ -1128,7 +1135,7 @@
</span><span class="cx"> // documentNodeId was previously asserted
</span><span class="cx"> .setNodeId(m_domAgent->pushNodeToFrontend(errorString, documentNodeId, regionList->item(i)));
</span><span class="cx">
</span><del>- regions->addItem(region);
</del><ins>+ regions->addItem(region.release());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> return regions.release();
</span><span class="lines">@@ -1144,14 +1151,13 @@
</span><span class="cx"> content->addItem(m_domAgent->pushNodeToFrontend(errorString, documentNodeId, contentList->item(i)));
</span><span class="cx"> }
</span><span class="cx">
</span><del>- RefPtr<Inspector::Protocol::CSS::NamedFlow> namedFlow = Inspector::Protocol::CSS::NamedFlow::create()
</del><ins>+ return Inspector::Protocol::CSS::NamedFlow::create()
</ins><span class="cx"> .setDocumentNodeId(documentNodeId)
</span><span class="cx"> .setName(webkitNamedFlow->name().string())
</span><span class="cx"> .setOverset(webkitNamedFlow->overset())
</span><del>- .setContent(content)
- .setRegions(buildArrayForRegions(errorString, webkitNamedFlow->getRegions(), documentNodeId));
-
- return namedFlow.release();
</del><ins>+ .setContent(content.release())
+ .setRegions(buildArrayForRegions(errorString, webkitNamedFlow->getRegions(), documentNodeId))
+ .release();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void InspectorCSSAgent::didRemoveDocument(Document* document)
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (175757 => 175758)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog        2014-11-07 20:25:17 UTC (rev 175757)
+++ trunk/Source/WebInspectorUI/ChangeLog        2014-11-07 20:29:49 UTC (rev 175758)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2014-11-07 Joseph Pecoraro <pecoraro@apple.com>
+
+ Web Inspector: Pseudo element matchedCSSRules do not include matching selector info
+ https://bugs.webkit.org/show_bug.cgi?id=138438
+
+ Reviewed by Benjamin Poulain.
+
+ * UserInterface/Base/Test.js:
+ (WebInspector.loaded):
+ Include a global setting for shadow dom used by DOM model classes.
+ Give it a "test" specific name to not override non-test setting values.
+
</ins><span class="cx"> 2014-11-05 Commit Queue <commit-queue@webkit.org>
</span><span class="cx">
</span><span class="cx"> Unreviewed, rolling out r175628.
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceBaseTestjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Test.js (175757 => 175758)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Base/Test.js        2014-11-07 20:25:17 UTC (rev 175757)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Test.js        2014-11-07 20:29:49 UTC (rev 175758)
</span><span class="lines">@@ -63,6 +63,8 @@
</span><span class="cx">
</span><span class="cx"> // Perform one-time tasks.
</span><span class="cx"> WebInspector.CSSCompletions.requestCSSNameCompletions();
</span><ins>+
+ this.showShadowDOMSetting = new WebInspector.Setting("test-show-shadow-dom", true);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> WebInspector.contentLoaded = function()
</span></span></pre>
</div>
</div>
</body>
</html>