<!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>[198216] 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/198216">198216</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2016-03-15 10:26:50 -0700 (Tue, 15 Mar 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>
Source/WebCore:
REGRESSION (196383): Class change invalidation does not handle :not correctly
https://bugs.webkit.org/show_bug.cgi?id=155493
&lt;rdar://problem/24846762&gt;

Reviewed by Andreas Kling.

We fail to invalidate bar style in

    :not(.foo) bar { }

when class foo is added or removed.

There is a logic error in the invalidation code. It assumes that class addition can only make new selectors match
and removal make them not match. This is not true when :not is present.

* style/AttributeChangeInvalidation.h:
(WebCore::Style::AttributeChangeInvalidation::AttributeChangeInvalidation):
* style/ClassChangeInvalidation.cpp:
(WebCore::Style::ClassChangeInvalidation::invalidateStyle):

    Invalidate style and collect full set of rules that may affect descendant style.

(WebCore::Style::ClassChangeInvalidation::invalidateDescendantStyle):

    Invalidate with this set both before and after committing the changes.

(WebCore::Style::ClassChangeInvalidation::computeClassChange): Deleted.
* style/ClassChangeInvalidation.h:
(WebCore::Style::ClassChangeInvalidation::ClassChangeInvalidation):
(WebCore::Style::ClassChangeInvalidation::~ClassChangeInvalidation):

LayoutTests:
Class change invalidation does not handle :not correctly
https://bugs.webkit.org/show_bug.cgi?id=155493
&lt;rdar://problem/24846762&gt;

Reviewed by Andreas Kling.

* fast/css/style-invalidation-attribute-change-descendants-expected.txt:
* fast/css/style-invalidation-attribute-change-descendants.html:

    Also add :not case for attribute changes (which handles this correctly already).

* fast/css/style-invalidation-class-change-descendants-expected.txt:
* fast/css/style-invalidation-class-change-descendants.html:

    Add :not case.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastcssstyleinvalidationattributechangedescendantsexpectedtxt">trunk/LayoutTests/fast/css/style-invalidation-attribute-change-descendants-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcssstyleinvalidationattributechangedescendantshtml">trunk/LayoutTests/fast/css/style-invalidation-attribute-change-descendants.html</a></li>
<li><a href="#trunkLayoutTestsfastcssstyleinvalidationclasschangedescendantsexpectedtxt">trunk/LayoutTests/fast/css/style-invalidation-class-change-descendants-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcssstyleinvalidationclasschangedescendantshtml">trunk/LayoutTests/fast/css/style-invalidation-class-change-descendants.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorestyleAttributeChangeInvalidationh">trunk/Source/WebCore/style/AttributeChangeInvalidation.h</a></li>
<li><a href="#trunkSourceWebCorestyleClassChangeInvalidationcpp">trunk/Source/WebCore/style/ClassChangeInvalidation.cpp</a></li>
<li><a href="#trunkSourceWebCorestyleClassChangeInvalidationh">trunk/Source/WebCore/style/ClassChangeInvalidation.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (198215 => 198216)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-03-15 15:30:20 UTC (rev 198215)
+++ trunk/LayoutTests/ChangeLog        2016-03-15 17:26:50 UTC (rev 198216)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2016-03-15  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Class change invalidation does not handle :not correctly
+        https://bugs.webkit.org/show_bug.cgi?id=155493
+        &lt;rdar://problem/24846762&gt;
+
+        Reviewed by Andreas Kling.
+
+        * fast/css/style-invalidation-attribute-change-descendants-expected.txt:
+        * fast/css/style-invalidation-attribute-change-descendants.html:
+
+            Also add :not case for attribute changes (which handles this correctly already).
+
+        * fast/css/style-invalidation-class-change-descendants-expected.txt:
+        * fast/css/style-invalidation-class-change-descendants.html:
+
+            Add :not case.
+
</ins><span class="cx"> 2016-03-14  Jer Noble  &lt;jer.noble@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Video elements with autoplay do not begin playing when scrolling into view if InvisibleAutoplayNotPermitted is set.
</span></span></pre></div>
<a id="trunkLayoutTestsfastcssstyleinvalidationattributechangedescendantsexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/css/style-invalidation-attribute-change-descendants-expected.txt (198215 => 198216)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/style-invalidation-attribute-change-descendants-expected.txt        2016-03-15 15:30:20 UTC (rev 198215)
+++ trunk/LayoutTests/fast/css/style-invalidation-attribute-change-descendants-expected.txt        2016-03-15 17:26:50 UTC (rev 198216)
</span><span class="lines">@@ -3,6 +3,7 @@
</span><span class="cx"> On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+Setting attribute 'mynotattr' value ''
</ins><span class="cx"> PASS hasExpectedStyle is true
</span><span class="cx"> PASS testStyleChangeType(&quot;root&quot;, &quot;NoStyleChange&quot;) || testStyleChangeType(&quot;root&quot;, &quot;InlineStyleChange&quot;) is true
</span><span class="cx"> PASS testStyleChangeType(&quot;target&quot;, &quot;NoStyleChange&quot;) is true
</span><span class="lines">@@ -143,6 +144,16 @@
</span><span class="cx"> PASS testStyleChangeType(&quot;target&quot;, &quot;NoStyleChange&quot;) is true
</span><span class="cx"> PASS testStyleChangeType(&quot;inert&quot;, &quot;NoStyleChange&quot;) is true
</span><span class="cx"> PASS hasExpectedStyle is true
</span><ins>+Removing attribute 'mynotattr'
+PASS testStyleChangeType(&quot;root&quot;, &quot;NoStyleChange&quot;) || testStyleChangeType(&quot;root&quot;, &quot;InlineStyleChange&quot;) is true
+PASS testStyleChangeType(&quot;target&quot;, &quot;InlineStyleChange&quot;) is true
+PASS testStyleChangeType(&quot;inert&quot;, &quot;NoStyleChange&quot;) is true
+PASS hasExpectedStyle is true
+Setting attribute 'mynotattr' value 'value'
+PASS testStyleChangeType(&quot;root&quot;, &quot;NoStyleChange&quot;) || testStyleChangeType(&quot;root&quot;, &quot;InlineStyleChange&quot;) is true
+PASS testStyleChangeType(&quot;target&quot;, &quot;InlineStyleChange&quot;) is true
+PASS testStyleChangeType(&quot;inert&quot;, &quot;NoStyleChange&quot;) is true
+PASS hasExpectedStyle is true
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestsfastcssstyleinvalidationattributechangedescendantshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/css/style-invalidation-attribute-change-descendants.html (198215 => 198216)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/style-invalidation-attribute-change-descendants.html        2016-03-15 15:30:20 UTC (rev 198215)
+++ trunk/LayoutTests/fast/css/style-invalidation-attribute-change-descendants.html        2016-03-15 17:26:50 UTC (rev 198216)
</span><span class="lines">@@ -42,6 +42,10 @@
</span><span class="cx">     color: rgb(9, 0, 0);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+root:not([mynotattr]) target {
+    color: rgb(10, 0, 0);
+}
+
</ins><span class="cx"> &lt;/style&gt;
</span><span class="cx"> &lt;/head&gt;
</span><span class="cx"> &lt;body&gt;
</span><span class="lines">@@ -125,6 +129,8 @@
</span><span class="cx">     shouldBeTrue(&quot;hasExpectedStyle&quot;);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+setAttribute('mynotattr', '');
+
</ins><span class="cx"> checkStyle(0);
</span><span class="cx"> testStyleInvalidation(&quot;NoStyleChange&quot;);
</span><span class="cx"> checkStyle(0);
</span><span class="lines">@@ -237,6 +243,14 @@
</span><span class="cx"> testStyleInvalidation(&quot;NoStyleChange&quot;);
</span><span class="cx"> checkStyle(1);
</span><span class="cx"> 
</span><ins>+removeAttribute('mynotattr');
+testStyleInvalidation(&quot;InlineStyleChange&quot;);
+checkStyle(10);
+
+setAttribute('mynotattr', 'value');
+testStyleInvalidation(&quot;InlineStyleChange&quot;);
+checkStyle(1);
+
</ins><span class="cx"> &lt;/script&gt;
</span><span class="cx"> &lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
</span><span class="cx"> &lt;/html&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsfastcssstyleinvalidationclasschangedescendantsexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/css/style-invalidation-class-change-descendants-expected.txt (198215 => 198216)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/style-invalidation-class-change-descendants-expected.txt        2016-03-15 15:30:20 UTC (rev 198215)
+++ trunk/LayoutTests/fast/css/style-invalidation-class-change-descendants-expected.txt        2016-03-15 17:26:50 UTC (rev 198216)
</span><span class="lines">@@ -3,6 +3,7 @@
</span><span class="cx"> On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+Adding class style5
</ins><span class="cx"> PASS hasExpectedStyle is true
</span><span class="cx"> PASS testStyleChangeType(&quot;root&quot;, &quot;NoStyleChange&quot;) || testStyleChangeType(&quot;root&quot;, &quot;InlineStyleChange&quot;) is true
</span><span class="cx"> PASS testStyleChangeType(&quot;target&quot;, &quot;NoStyleChange&quot;) is true
</span><span class="lines">@@ -51,6 +52,16 @@
</span><span class="cx"> PASS testStyleChangeType(&quot;target&quot;, &quot;InlineStyleChange&quot;) is true
</span><span class="cx"> PASS testStyleChangeType(&quot;inert&quot;, &quot;NoStyleChange&quot;) is true
</span><span class="cx"> PASS hasExpectedStyle is true
</span><ins>+Removing class style5
+PASS testStyleChangeType(&quot;root&quot;, &quot;NoStyleChange&quot;) || testStyleChangeType(&quot;root&quot;, &quot;InlineStyleChange&quot;) is true
+PASS testStyleChangeType(&quot;target&quot;, &quot;InlineStyleChange&quot;) is true
+PASS testStyleChangeType(&quot;inert&quot;, &quot;NoStyleChange&quot;) is true
+PASS hasExpectedStyle is true
+Adding class style5
+PASS testStyleChangeType(&quot;root&quot;, &quot;NoStyleChange&quot;) || testStyleChangeType(&quot;root&quot;, &quot;InlineStyleChange&quot;) is true
+PASS testStyleChangeType(&quot;target&quot;, &quot;InlineStyleChange&quot;) is true
+PASS testStyleChangeType(&quot;inert&quot;, &quot;NoStyleChange&quot;) is true
+PASS hasExpectedStyle is true
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestsfastcssstyleinvalidationclasschangedescendantshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/css/style-invalidation-class-change-descendants.html (198215 => 198216)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/css/style-invalidation-class-change-descendants.html        2016-03-15 15:30:20 UTC (rev 198215)
+++ trunk/LayoutTests/fast/css/style-invalidation-class-change-descendants.html        2016-03-15 17:26:50 UTC (rev 198216)
</span><span class="lines">@@ -22,6 +22,10 @@
</span><span class="cx">     color: rgb(4, 4, 4);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+root:not(.style5) target {
+    color: rgb(5, 5, 5);
+}
+
</ins><span class="cx"> &lt;/style&gt;
</span><span class="cx"> &lt;/head&gt;
</span><span class="cx"> &lt;body&gt;
</span><span class="lines">@@ -105,6 +109,8 @@
</span><span class="cx">     shouldBeTrue(&quot;hasExpectedStyle&quot;);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+addClass('style5');
+
</ins><span class="cx"> checkStyle(0);
</span><span class="cx"> testStyleInvalidation(&quot;NoStyleChange&quot;);
</span><span class="cx"> checkStyle(0);
</span><span class="lines">@@ -143,6 +149,14 @@
</span><span class="cx"> testStyleInvalidation(&quot;InlineStyleChange&quot;);
</span><span class="cx"> checkStyle(0);
</span><span class="cx"> 
</span><ins>+removeClass('style5');
+testStyleInvalidation(&quot;InlineStyleChange&quot;);
+checkStyle(5);
+
+addClass('style5');
+testStyleInvalidation(&quot;InlineStyleChange&quot;);
+checkStyle(0);
+
</ins><span class="cx"> &lt;/script&gt;
</span><span class="cx"> &lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
</span><span class="cx"> &lt;/html&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (198215 => 198216)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-03-15 15:30:20 UTC (rev 198215)
+++ trunk/Source/WebCore/ChangeLog        2016-03-15 17:26:50 UTC (rev 198216)
</span><span class="lines">@@ -1,3 +1,36 @@
</span><ins>+2016-03-15  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        REGRESSION (196383): Class change invalidation does not handle :not correctly
+        https://bugs.webkit.org/show_bug.cgi?id=155493
+        &lt;rdar://problem/24846762&gt;
+
+        Reviewed by Andreas Kling.
+
+        We fail to invalidate bar style in
+
+            :not(.foo) bar { }
+
+        when class foo is added or removed.
+
+        There is a logic error in the invalidation code. It assumes that class addition can only make new selectors match
+        and removal make them not match. This is not true when :not is present.
+
+        * style/AttributeChangeInvalidation.h:
+        (WebCore::Style::AttributeChangeInvalidation::AttributeChangeInvalidation):
+        * style/ClassChangeInvalidation.cpp:
+        (WebCore::Style::ClassChangeInvalidation::invalidateStyle):
+
+            Invalidate style and collect full set of rules that may affect descendant style.
+
+        (WebCore::Style::ClassChangeInvalidation::invalidateDescendantStyle):
+
+            Invalidate with this set both before and after committing the changes.
+
+        (WebCore::Style::ClassChangeInvalidation::computeClassChange): Deleted.
+        * style/ClassChangeInvalidation.h:
+        (WebCore::Style::ClassChangeInvalidation::ClassChangeInvalidation):
+        (WebCore::Style::ClassChangeInvalidation::~ClassChangeInvalidation):
+
</ins><span class="cx"> 2016-03-14  Jer Noble  &lt;jer.noble@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Video elements with autoplay do not begin playing when scrolling into view if InvisibleAutoplayNotPermitted is set.
</span></span></pre></div>
<a id="trunkSourceWebCorestyleAttributeChangeInvalidationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/AttributeChangeInvalidation.h (198215 => 198216)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/AttributeChangeInvalidation.h        2016-03-15 15:30:20 UTC (rev 198215)
+++ trunk/Source/WebCore/style/AttributeChangeInvalidation.h        2016-03-15 17:26:50 UTC (rev 198216)
</span><span class="lines">@@ -46,7 +46,7 @@
</span><span class="cx">     const bool m_isEnabled;
</span><span class="cx">     Element&amp; m_element;
</span><span class="cx"> 
</span><del>-    RuleSet* m_descendantInvalidationRuleSet { nullptr };
</del><ins>+    const RuleSet* m_descendantInvalidationRuleSet { nullptr };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> inline AttributeChangeInvalidation::AttributeChangeInvalidation(Element&amp; element, const QualifiedName&amp; attributeName, const AtomicString&amp; oldValue, const AtomicString&amp; newValue)
</span></span></pre></div>
<a id="trunkSourceWebCorestyleClassChangeInvalidationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/ClassChangeInvalidation.cpp (198215 => 198216)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/ClassChangeInvalidation.cpp        2016-03-15 15:30:20 UTC (rev 198215)
+++ trunk/Source/WebCore/style/ClassChangeInvalidation.cpp        2016-03-15 17:26:50 UTC (rev 198216)
</span><span class="lines">@@ -34,7 +34,9 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> namespace Style {
</span><span class="cx"> 
</span><del>-auto ClassChangeInvalidation::collectClasses(const SpaceSplitString&amp; classes) -&gt; ClassChangeVector
</del><ins>+using ClassChangeVector = Vector&lt;AtomicStringImpl*, 4&gt;;
+
+static ClassChangeVector collectClasses(const SpaceSplitString&amp; classes)
</ins><span class="cx"> {
</span><span class="cx">     ClassChangeVector result;
</span><span class="cx">     result.reserveCapacity(classes.size());
</span><span class="lines">@@ -43,20 +45,18 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ClassChangeInvalidation::computeClassChange(const SpaceSplitString&amp; oldClasses, const SpaceSplitString&amp; newClasses)
</del><ins>+static ClassChangeVector computeClassChange(const SpaceSplitString&amp; oldClasses, const SpaceSplitString&amp; newClasses)
</ins><span class="cx"> {
</span><span class="cx">     unsigned oldSize = oldClasses.size();
</span><span class="cx">     unsigned newSize = newClasses.size();
</span><span class="cx"> 
</span><del>-    if (!oldSize) {
-        m_addedClasses = collectClasses(newClasses);
-        return;
-    }
-    if (!newSize) {
-        m_removedClasses = collectClasses(oldClasses);
-        return;
-    }
</del><ins>+    if (!oldSize)
+        return collectClasses(newClasses);
+    if (!newSize)
+        return collectClasses(oldClasses);
</ins><span class="cx"> 
</span><ins>+    ClassChangeVector changedClasses;
+
</ins><span class="cx">     BitVector remainingClassBits;
</span><span class="cx">     remainingClassBits.ensureSize(oldSize);
</span><span class="cx">     // Class vectors tend to be very short. This is faster than using a hash table.
</span><span class="lines">@@ -70,21 +70,25 @@
</span><span class="cx">         }
</span><span class="cx">         if (foundFromBoth)
</span><span class="cx">             continue;
</span><del>-        m_addedClasses.append(newClasses[i].impl());
</del><ins>+        changedClasses.append(newClasses[i].impl());
</ins><span class="cx">     }
</span><span class="cx">     for (unsigned i = 0; i &lt; oldSize; ++i) {
</span><span class="cx">         // If the bit is not set the the corresponding class has been removed.
</span><span class="cx">         if (remainingClassBits.quickGet(i))
</span><span class="cx">             continue;
</span><del>-        m_removedClasses.append(oldClasses[i].impl());
</del><ins>+        changedClasses.append(oldClasses[i].impl());
</ins><span class="cx">     }
</span><ins>+
+    return changedClasses;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ClassChangeInvalidation::invalidateStyle(const ClassChangeVector&amp; changedClasses)
</del><ins>+void ClassChangeInvalidation::invalidateStyle(const SpaceSplitString&amp; oldClasses, const SpaceSplitString&amp; newClasses)
</ins><span class="cx"> {
</span><ins>+    auto changedClasses = computeClassChange(oldClasses, newClasses);
+
</ins><span class="cx">     auto&amp; ruleSets = m_element.styleResolver().ruleSets();
</span><span class="cx"> 
</span><del>-    Vector&lt;AtomicStringImpl*, 4&gt; changedClassesAffectingStyle;
</del><ins>+    ClassChangeVector changedClassesAffectingStyle;
</ins><span class="cx">     for (auto* changedClass : changedClasses) {
</span><span class="cx">         if (ruleSets.features().classesInRules.contains(changedClass))
</span><span class="cx">             changedClassesAffectingStyle.append(changedClass);
</span><span class="lines">@@ -107,6 +111,13 @@
</span><span class="cx">         auto* ancestorClassRules = ruleSets.ancestorClassRules(changedClass);
</span><span class="cx">         if (!ancestorClassRules)
</span><span class="cx">             continue;
</span><ins>+        m_descendantInvalidationRuleSets.append(ancestorClassRules);
+    }
+}
+
+void ClassChangeInvalidation::invalidateDescendantStyle()
+{
+    for (auto* ancestorClassRules : m_descendantInvalidationRuleSets) {
</ins><span class="cx">         StyleInvalidationAnalysis invalidationAnalysis(*ancestorClassRules);
</span><span class="cx">         invalidationAnalysis.invalidateStyle(m_element);
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCorestyleClassChangeInvalidationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/ClassChangeInvalidation.h (198215 => 198216)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/ClassChangeInvalidation.h        2016-03-15 15:30:20 UTC (rev 198215)
+++ trunk/Source/WebCore/style/ClassChangeInvalidation.h        2016-03-15 17:26:50 UTC (rev 198216)
</span><span class="lines">@@ -44,18 +44,13 @@
</span><span class="cx">     ~ClassChangeInvalidation();
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    using ClassChangeVector = Vector&lt;AtomicStringImpl*, 4&gt;;
</del><ins>+    void invalidateStyle(const SpaceSplitString&amp; oldClasses, const SpaceSplitString&amp; newClasses);
+    void invalidateDescendantStyle();
</ins><span class="cx"> 
</span><del>-    void computeClassChange(const SpaceSplitString&amp; oldClasses, const SpaceSplitString&amp; newClasses);
-    void invalidateStyle(const ClassChangeVector&amp;);
-
-    static ClassChangeVector collectClasses(const SpaceSplitString&amp;);
-
</del><span class="cx">     const bool m_isEnabled;
</span><span class="cx">     Element&amp; m_element;
</span><span class="cx"> 
</span><del>-    ClassChangeVector m_addedClasses;
-    ClassChangeVector m_removedClasses;
</del><ins>+    Vector&lt;const RuleSet*, 4&gt; m_descendantInvalidationRuleSets;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> inline ClassChangeInvalidation::ClassChangeInvalidation(Element&amp; element, const SpaceSplitString&amp; oldClasses, const SpaceSplitString&amp; newClasses)
</span><span class="lines">@@ -65,15 +60,15 @@
</span><span class="cx"> {
</span><span class="cx">     if (!m_isEnabled)
</span><span class="cx">         return;
</span><del>-    computeClassChange(oldClasses, newClasses);
-    invalidateStyle(m_removedClasses);
</del><ins>+    invalidateStyle(oldClasses, newClasses);
+    invalidateDescendantStyle();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> inline ClassChangeInvalidation::~ClassChangeInvalidation()
</span><span class="cx"> {
</span><span class="cx">     if (!m_isEnabled)
</span><span class="cx">         return;
</span><del>-    invalidateStyle(m_addedClasses);
</del><ins>+    invalidateDescendantStyle();
</ins><span class="cx"> }
</span><span class="cx">     
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>