<!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>[172024] 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/172024">172024</a></dd>
<dt>Author</dt> <dd>benjamin@webkit.org</dd>
<dt>Date</dt> <dd>2014-08-04 20:40:55 -0700 (Mon, 04 Aug 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Simplify the StyleInvalidation mode of rule collection
https://bugs.webkit.org/show_bug.cgi?id=135521

Reviewed by Antti Koivisto.


Source/WebCore: 
There are two branches where StyleInvalidation code is removed:
-Pseudo elements for shadow dom elements.
-Pseudo elements without dom tree counterpart.

The first can never be hit because StyleInvalidationAnalysis does a complete invalidation
when there is any shadow dom styling involved in the stylesheets.

Even if that branch was hit, not failing on custom pseudo elements would be equivalent
to ignoring those pseudo elements from the Selector. By doing so, we would match elements
that do not have shadow dom and invalidate pretty much everything.

Unlike pseudo elements without real elements, shadow dom elements are not matched separately with a different
context, thus we could generalize StyleInvalidationAnalysis to handle this case.


The second case handle pseudo elements that do not have a real element. That case no longer need to be handled
separately at the filter time, it has become a special case of SelectorChecker::match() after everything else
has matched.

The only condition for this to work is that the Context's pseudoId must be NOPSEUDO. This is the case
in practice since matching specific pseudo types would be a waste of time. ElementRuleCollector::collectMatchingRules()
has a new assertion to enforce that.

Test: fast/css/stylesheet-change-updates-pseudo-elements.html

* css/ElementRuleCollector.cpp:
(WebCore::ElementRuleCollector::collectMatchingRules):
* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::matchRecursively):
* cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateRequestedPseudoElementEqualsToSelectorPseudoElement):

LayoutTests: 
This test by:
1) Forcing the recalc of the user-agent stylesheet.
2) Wait for the page to finish loading.
3) Add a style changing only pseudo elements without corresponding shadow element.

* fast/css/stylesheet-change-updates-pseudo-elements-expected.html: Added.
* fast/css/stylesheet-change-updates-pseudo-elements.html: Added.</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="#trunkSourceWebCorecssElementRuleCollectorcpp">trunk/Source/WebCore/css/ElementRuleCollector.cpp</a></li>
<li><a href="#trunkSourceWebCorecssSelectorCheckercpp">trunk/Source/WebCore/css/SelectorChecker.cpp</a></li>
<li><a href="#trunkSourceWebCorecssjitSelectorCompilercpp">trunk/Source/WebCore/cssjit/SelectorCompiler.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastcssstylesheetchangeupdatespseudoelementsexpectedhtml">trunk/LayoutTests/fast/css/stylesheet-change-updates-pseudo-elements-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastcssstylesheetchangeupdatespseudoelementshtml">trunk/LayoutTests/fast/css/stylesheet-change-updates-pseudo-elements.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (172023 => 172024)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-08-05 03:25:52 UTC (rev 172023)
+++ trunk/LayoutTests/ChangeLog        2014-08-05 03:40:55 UTC (rev 172024)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2014-08-04  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
+
+        Simplify the StyleInvalidation mode of rule collection
+        https://bugs.webkit.org/show_bug.cgi?id=135521
+
+        Reviewed by Antti Koivisto.
+
+        This test by:
+        1) Forcing the recalc of the user-agent stylesheet.
+        2) Wait for the page to finish loading.
+        3) Add a style changing only pseudo elements without corresponding shadow element.
+
+        * fast/css/stylesheet-change-updates-pseudo-elements-expected.html: Added.
+        * fast/css/stylesheet-change-updates-pseudo-elements.html: Added.
+
</ins><span class="cx"> 2014-08-04  Carlos Alberto Lopez Perez  &lt;clopez@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GTK] Unreviewed GTK gardening.
</span></span></pre></div>
<a id="trunkLayoutTestsfastcssstylesheetchangeupdatespseudoelementsexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css/stylesheet-change-updates-pseudo-elements-expected.html (0 => 172024)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/stylesheet-change-updates-pseudo-elements-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/css/stylesheet-change-updates-pseudo-elements-expected.html        2014-08-05 03:40:55 UTC (rev 172024)
</span><span class="lines">@@ -0,0 +1,80 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;title&gt;Test if adding style dynamically after the document has loaded updates pseudo elements.&lt;/title&gt;
+    &lt;style&gt;
+        #target::before {
+            display: block;
+            width: 100px;
+            height: 100px;
+            background-color: green;
+            content: &quot;&quot;; }
+    &lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div id=&quot;target&quot;&gt;&lt;/div&gt;
+
+    &lt;!-- Some content to make the DOM non-trivial. --&gt;
+    &lt;div id=&quot;content&quot;&gt;
+        &lt;h2&gt;WebKit Project Goals&lt;/h2&gt;
+
+        &lt;p&gt;WebKit is an open source Web content engine for browsers and other applications. We value real-world web compatibility, standards compliance, stability, performance, security, portability, usability, and relative ease of understanding and modifying the code (hackability).
+
+        &lt;/p&gt;&lt;h3&gt;Goals&lt;/h3&gt;
+
+        &lt;dl&gt;
+            &lt;dt&gt;Web Content Engine&lt;/dt&gt;
+            &lt;dd&gt;The project's primary focus is content deployed on the World Wide Web, using standards-based technologies such as HTML, CSS, JavaScript and the DOM. However, we also want to make it possible to embed WebKit in other applications, and to use it as a general-purpose display and interaction engine.&lt;/dd&gt;
+
+            &lt;dt&gt;Open Source&lt;/dt&gt;
+            &lt;dd&gt;WebKit should remain freely usable for both open source and proprietary applications. To that end, we use BSD-style and LGPL licenses. Specifically, we aim for licensing compatible with LGPL 2.1+. We do not currently plan to move to LGPL 3. In addition, we strive to create a courteous, welcoming environment that feels approachable to newcomers. WebKit maintains a public IRC chat room and a public mailing list where the ideas of contributors both new and old are heard and discussed with equal weight.
+            &lt;/dd&gt;
+
+            &lt;dt&gt;Compatibility&lt;/dt&gt;
+            &lt;dd&gt;For users browsing the web, compatibility with their existing sites is essential. We strive to maintain and improve compatibility with existing web content, sometimes even at the expense of standards. We use regression testing to maintain our compatibility gains.&lt;/dd&gt;
+
+            &lt;dt&gt;Standards Compliance&lt;/dt&gt;
+            &lt;dd&gt;WebKit aims for compliance with relevant web standards, and support for new standards
+                In addition to improving compliance, we participate in the web standards community to bring new technologies into standards, and to make sure new standards are practical to implement in our engine. We use regression testing to maintain our standards compliance gains.&lt;/dd&gt;
+
+            &lt;dt&gt;Stability&lt;/dt&gt;
+            &lt;dd&gt;The main WebKit code base should always maintain a high degree of stability. This means that crashes, hangs and regressions should be dealt with promptly, rather than letting them pile up.&lt;/dd&gt;
+
+            &lt;dt&gt;Performance&lt;/dt&gt;
+            &lt;dd&gt; Maintaining and improving speed and memory use is an important goal. We never consider performance &quot;good enough&quot;, but strive to constantly improve. As web content becomes richer and more complex, and as web browsers run on more limited devices, performance gains continue to have value even if normal browsing seems fast enough.&lt;/dd&gt;
+
+            &lt;dt&gt;Security&lt;/dt&gt;
+            &lt;dd&gt;Protecting users from security violations is critical. We fix security issues promptly to protect users and maintain their trust.&lt;/dd&gt;
+
+            &lt;dt&gt;Portability&lt;/dt&gt;
+            &lt;dd&gt;The WebKit project seeks to address a variety of needs. We want to make it reasonable to port WebKit to a variety of desktop, mobile, embedded and other platforms. We will provide the infrastructure to do this with tight platform integration, reusing native platform services where appropriate and providing friendly embedding APIs.&lt;/dd&gt;
+
+            &lt;dt&gt;Usability&lt;/dt&gt;
+            &lt;dd&gt;To the extent that WebKit features affect the user experience, we want them to work in accordance with good human interface design principles, and to mesh well with platform-native HI conventions. Furthermore, we strive to integrate with platform accessibility features to allow access for all users, including those with disabilities.&lt;/dd&gt;
+
+            &lt;dt&gt;Hackability&lt;/dt&gt;
+            &lt;dd&gt;To make rapid progress possible, we try to keep the code relatively easy to understand, even though web technologies are often complex. We try to use straightforward algorithms and data structures when possible, we try to write clear, maintainable code, and we continue to improve names and code structure to aid understanding. When tricky &quot;rocket science&quot; code is truly needed to solve some problem, we try to keep it bottled up behind clean interfaces. In addition, we make heavy use of automated regression tests as a safety net, to allow aggressive changes with less risk of regressions.&lt;/dd&gt;
+        &lt;/dl&gt;
+
+        &lt;h3&gt;Non-Goals&lt;/h3&gt;
+
+        &lt;p&gt;The above goals are a lot to bite off, and there are a few points that arise occasionally which we consider out of scope for the project.
+
+        &lt;/p&gt;&lt;dl&gt;
+            &lt;dt&gt;WebKit is an engine, not a browser.&lt;/dt&gt;
+            &lt;dd&gt;We do not plan to develop or host a full-featured web browser
+                based on WebKit. Others are welcome to do so, of course.&lt;/dd&gt;
+
+            &lt;dt&gt;WebKit is an engineering project not a science project.&lt;/dt&gt;
+            &lt;dd&gt;For new features to be adopted into WebKit, we strongly prefer for the technology or at least the use case for it to be proven.&lt;/dd&gt;
+
+            &lt;dt&gt;WebKit is not a bundle of maximally general and reusable code.&lt;/dt&gt;
+            &lt;dd&gt;We build some general-purpose parts, but only to the degree needed to be a good web content engine.&lt;/dd&gt;
+
+            &lt;dt&gt;WebKit is not the solution to every problem.&lt;/dt&gt;
+            &lt;dd&gt;We focus on web content, not complete solutions to every imaginable technology need.&lt;/dd&gt;
+        &lt;/dl&gt;
+
+    &lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsfastcssstylesheetchangeupdatespseudoelementshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/css/stylesheet-change-updates-pseudo-elements.html (0 => 172024)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/stylesheet-change-updates-pseudo-elements.html                                (rev 0)
+++ trunk/LayoutTests/fast/css/stylesheet-change-updates-pseudo-elements.html        2014-08-05 03:40:55 UTC (rev 172024)
</span><span class="lines">@@ -0,0 +1,83 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;title&gt;Test if adding style dynamically after the document has loaded updates pseudo elements.&lt;/title&gt;
+    &lt;script&gt;
+        window.addEventListener(&quot;DOMContentLoaded&quot;, function() {
+            // Force a style recalc and layout to make sure the User-Agent stylesheet is already fully processed.
+            document.getElementById(&quot;content&quot;).offsetTop;
+        });
+        window.addEventListener(&quot;load&quot;, function() {
+            var newStyle = document.createElement(&quot;style&quot;);
+            newStyle.textContent = &quot;#target::before { display:block; width:100px; height:100px; background-color:green; content:\&quot;\&quot;; }&quot;
+            document.getElementsByTagName(&quot;head&quot;)[0].appendChild(newStyle);
+        });
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div id=&quot;target&quot;&gt;&lt;/div&gt;
+
+    &lt;!-- Some content to make the DOM non-trivial. --&gt;
+    &lt;div id=&quot;content&quot;&gt;
+        &lt;h2&gt;WebKit Project Goals&lt;/h2&gt;
+
+        &lt;p&gt;WebKit is an open source Web content engine for browsers and other applications. We value real-world web compatibility, standards compliance, stability, performance, security, portability, usability, and relative ease of understanding and modifying the code (hackability).
+
+        &lt;/p&gt;&lt;h3&gt;Goals&lt;/h3&gt;
+
+        &lt;dl&gt;
+            &lt;dt&gt;Web Content Engine&lt;/dt&gt;
+            &lt;dd&gt;The project's primary focus is content deployed on the World Wide Web, using standards-based technologies such as HTML, CSS, JavaScript and the DOM. However, we also want to make it possible to embed WebKit in other applications, and to use it as a general-purpose display and interaction engine.&lt;/dd&gt;
+
+            &lt;dt&gt;Open Source&lt;/dt&gt;
+            &lt;dd&gt;WebKit should remain freely usable for both open source and proprietary applications. To that end, we use BSD-style and LGPL licenses. Specifically, we aim for licensing compatible with LGPL 2.1+. We do not currently plan to move to LGPL 3. In addition, we strive to create a courteous, welcoming environment that feels approachable to newcomers. WebKit maintains a public IRC chat room and a public mailing list where the ideas of contributors both new and old are heard and discussed with equal weight.
+            &lt;/dd&gt;
+
+            &lt;dt&gt;Compatibility&lt;/dt&gt;
+            &lt;dd&gt;For users browsing the web, compatibility with their existing sites is essential. We strive to maintain and improve compatibility with existing web content, sometimes even at the expense of standards. We use regression testing to maintain our compatibility gains.&lt;/dd&gt;
+
+            &lt;dt&gt;Standards Compliance&lt;/dt&gt;
+            &lt;dd&gt;WebKit aims for compliance with relevant web standards, and support for new standards
+                In addition to improving compliance, we participate in the web standards community to bring new technologies into standards, and to make sure new standards are practical to implement in our engine. We use regression testing to maintain our standards compliance gains.&lt;/dd&gt;
+
+            &lt;dt&gt;Stability&lt;/dt&gt;
+            &lt;dd&gt;The main WebKit code base should always maintain a high degree of stability. This means that crashes, hangs and regressions should be dealt with promptly, rather than letting them pile up.&lt;/dd&gt;
+
+            &lt;dt&gt;Performance&lt;/dt&gt;
+            &lt;dd&gt; Maintaining and improving speed and memory use is an important goal. We never consider performance &quot;good enough&quot;, but strive to constantly improve. As web content becomes richer and more complex, and as web browsers run on more limited devices, performance gains continue to have value even if normal browsing seems fast enough.&lt;/dd&gt;
+
+            &lt;dt&gt;Security&lt;/dt&gt;
+            &lt;dd&gt;Protecting users from security violations is critical. We fix security issues promptly to protect users and maintain their trust.&lt;/dd&gt;
+
+            &lt;dt&gt;Portability&lt;/dt&gt;
+            &lt;dd&gt;The WebKit project seeks to address a variety of needs. We want to make it reasonable to port WebKit to a variety of desktop, mobile, embedded and other platforms. We will provide the infrastructure to do this with tight platform integration, reusing native platform services where appropriate and providing friendly embedding APIs.&lt;/dd&gt;
+
+            &lt;dt&gt;Usability&lt;/dt&gt;
+            &lt;dd&gt;To the extent that WebKit features affect the user experience, we want them to work in accordance with good human interface design principles, and to mesh well with platform-native HI conventions. Furthermore, we strive to integrate with platform accessibility features to allow access for all users, including those with disabilities.&lt;/dd&gt;
+
+            &lt;dt&gt;Hackability&lt;/dt&gt;
+            &lt;dd&gt;To make rapid progress possible, we try to keep the code relatively easy to understand, even though web technologies are often complex. We try to use straightforward algorithms and data structures when possible, we try to write clear, maintainable code, and we continue to improve names and code structure to aid understanding. When tricky &quot;rocket science&quot; code is truly needed to solve some problem, we try to keep it bottled up behind clean interfaces. In addition, we make heavy use of automated regression tests as a safety net, to allow aggressive changes with less risk of regressions.&lt;/dd&gt;
+        &lt;/dl&gt;
+
+        &lt;h3&gt;Non-Goals&lt;/h3&gt;
+
+        &lt;p&gt;The above goals are a lot to bite off, and there are a few points that arise occasionally which we consider out of scope for the project.
+
+        &lt;/p&gt;&lt;dl&gt;
+            &lt;dt&gt;WebKit is an engine, not a browser.&lt;/dt&gt;
+            &lt;dd&gt;We do not plan to develop or host a full-featured web browser
+                based on WebKit. Others are welcome to do so, of course.&lt;/dd&gt;
+
+            &lt;dt&gt;WebKit is an engineering project not a science project.&lt;/dt&gt;
+            &lt;dd&gt;For new features to be adopted into WebKit, we strongly prefer for the technology or at least the use case for it to be proven.&lt;/dd&gt;
+
+            &lt;dt&gt;WebKit is not a bundle of maximally general and reusable code.&lt;/dt&gt;
+            &lt;dd&gt;We build some general-purpose parts, but only to the degree needed to be a good web content engine.&lt;/dd&gt;
+
+            &lt;dt&gt;WebKit is not the solution to every problem.&lt;/dt&gt;
+            &lt;dd&gt;We focus on web content, not complete solutions to every imaginable technology need.&lt;/dd&gt;
+        &lt;/dl&gt;
+
+    &lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (172023 => 172024)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-08-05 03:25:52 UTC (rev 172023)
+++ trunk/Source/WebCore/ChangeLog        2014-08-05 03:40:55 UTC (rev 172024)
</span><span class="lines">@@ -1,5 +1,44 @@
</span><span class="cx"> 2014-08-04  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
</span><span class="cx"> 
</span><ins>+        Simplify the StyleInvalidation mode of rule collection
+        https://bugs.webkit.org/show_bug.cgi?id=135521
+
+        Reviewed by Antti Koivisto.
+
+        There are two branches where StyleInvalidation code is removed:
+        -Pseudo elements for shadow dom elements.
+        -Pseudo elements without dom tree counterpart.
+
+        The first can never be hit because StyleInvalidationAnalysis does a complete invalidation
+        when there is any shadow dom styling involved in the stylesheets.
+
+        Even if that branch was hit, not failing on custom pseudo elements would be equivalent
+        to ignoring those pseudo elements from the Selector. By doing so, we would match elements
+        that do not have shadow dom and invalidate pretty much everything.
+
+        Unlike pseudo elements without real elements, shadow dom elements are not matched separately with a different
+        context, thus we could generalize StyleInvalidationAnalysis to handle this case.
+
+
+        The second case handle pseudo elements that do not have a real element. That case no longer need to be handled
+        separately at the filter time, it has become a special case of SelectorChecker::match() after everything else
+        has matched.
+
+        The only condition for this to work is that the Context's pseudoId must be NOPSEUDO. This is the case
+        in practice since matching specific pseudo types would be a waste of time. ElementRuleCollector::collectMatchingRules()
+        has a new assertion to enforce that.
+
+        Test: fast/css/stylesheet-change-updates-pseudo-elements.html
+
+        * css/ElementRuleCollector.cpp:
+        (WebCore::ElementRuleCollector::collectMatchingRules):
+        * css/SelectorChecker.cpp:
+        (WebCore::SelectorChecker::matchRecursively):
+        * cssjit/SelectorCompiler.cpp:
+        (WebCore::SelectorCompiler::SelectorCodeGenerator::generateRequestedPseudoElementEqualsToSelectorPseudoElement):
+
+2014-08-04  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
+
</ins><span class="cx">         Add a flag for the CSS Selectors level 4 implementation
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=135535
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorecssElementRuleCollectorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/ElementRuleCollector.cpp (172023 => 172024)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/ElementRuleCollector.cpp        2014-08-05 03:25:52 UTC (rev 172023)
+++ trunk/Source/WebCore/css/ElementRuleCollector.cpp        2014-08-05 03:40:55 UTC (rev 172024)
</span><span class="lines">@@ -145,6 +145,7 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(matchRequest.ruleSet);
</span><span class="cx">     ASSERT_WITH_MESSAGE(!(m_mode == SelectorChecker::Mode::ResolvingStyle &amp;&amp; !m_style), &quot;When resolving style, the SelectorChecker must have a style to set the pseudo elements and/or to do marking. The SelectorCompiler also rely on that behavior.&quot;);
</span><ins>+    ASSERT_WITH_MESSAGE(!((m_mode == SelectorChecker::Mode::StyleInvalidation || m_mode == SelectorChecker::Mode::SharingRules) &amp;&amp; m_pseudoStyleRequest.pseudoId != NOPSEUDO), &quot;When in mode StyleInvalidation or SharingRules, SelectorChecker does not try to match the pseudo ID. While ElementRuleCollector supports matching a particular pseudoId in this case, this would indicate a error at the call site since matching a particular element should be unnecessary.&quot;);
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><span class="cx">     if (m_element.isWebVTTElement())
</span></span></pre></div>
<a id="trunkSourceWebCorecssSelectorCheckercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/SelectorChecker.cpp (172023 => 172024)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/SelectorChecker.cpp        2014-08-05 03:25:52 UTC (rev 172023)
+++ trunk/Source/WebCore/css/SelectorChecker.cpp        2014-08-05 03:40:55 UTC (rev 172024)
</span><span class="lines">@@ -180,14 +180,13 @@
</span><span class="cx"> 
</span><span class="cx">                 if (context.selector-&gt;pseudoElementType() == CSSSelector::PseudoElementWebKitCustom &amp;&amp; root-&gt;type() != ShadowRoot::UserAgentShadowRoot)
</span><span class="cx">                     return SelectorFailsLocally;
</span><del>-            } else if (m_mode != Mode::StyleInvalidation)
</del><ins>+            } else
</ins><span class="cx">                 return SelectorFailsLocally;
</span><span class="cx">         } else {
</span><span class="cx">             if ((!context.elementStyle &amp;&amp; m_mode == Mode::ResolvingStyle) || m_mode == Mode::QueryingRules)
</span><span class="cx">                 return SelectorFailsLocally;
</span><span class="cx"> 
</span><del>-            // When invalidating style all pseudo elements need to match.
-            PseudoId pseudoId = m_mode == Mode::StyleInvalidation ? NOPSEUDO : CSSSelector::pseudoId(context.selector-&gt;pseudoElementType());
</del><ins>+            PseudoId pseudoId = CSSSelector::pseudoId(context.selector-&gt;pseudoElementType());
</ins><span class="cx">             if (pseudoId != NOPSEUDO)
</span><span class="cx">                 dynamicPseudo = pseudoId;
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkSourceWebCorecssjitSelectorCompilercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/cssjit/SelectorCompiler.cpp (172023 => 172024)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/cssjit/SelectorCompiler.cpp        2014-08-05 03:25:52 UTC (rev 172023)
+++ trunk/Source/WebCore/cssjit/SelectorCompiler.cpp        2014-08-05 03:40:55 UTC (rev 172024)
</span><span class="lines">@@ -2855,11 +2855,6 @@
</span><span class="cx">             failureCases.append(m_assembler.branch8(Assembler::NotEqual, Assembler::Address(checkingContext, OBJECT_OFFSETOF(CheckingContext, pseudoId)), Assembler::TrustedImm32(NOPSEUDO)));
</span><span class="cx">         else {
</span><span class="cx">             Assembler::Jump skip = m_assembler.branch8(Assembler::Equal, Assembler::Address(checkingContext, OBJECT_OFFSETOF(CheckingContext, pseudoId)), Assembler::TrustedImm32(NOPSEUDO));
</span><del>-
-            // When mode is StyleInvalidation, the pseudo element of the rightmost fragment is treated as NOPSEUDO.
-            // Since the requested pseudoId is not NOPSEUDO here, it becomes failure.
-            failureCases.append(branchOnResolvingModeWithCheckingContext(Assembler::Equal, SelectorChecker::Mode::StyleInvalidation, checkingContext));
-
</del><span class="cx">             failureCases.append(m_assembler.branch8(Assembler::NotEqual, Assembler::Address(checkingContext, OBJECT_OFFSETOF(CheckingContext, pseudoId)), Assembler::TrustedImm32(CSSSelector::pseudoId(fragment.pseudoElementSelector-&gt;pseudoElementType()))));
</span><span class="cx">             skip.link(&amp;m_assembler);
</span><span class="cx">         }
</span></span></pre>
</div>
</div>

</body>
</html>