<!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>[163475] 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/163475">163475</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2014-02-05 13:50:55 -0800 (Wed, 05 Feb 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>ElementRuleCollector should not use StyleResolver::State
https://bugs.webkit.org/show_bug.cgi?id=128247

Source/WebCore: 

Reviewed by Andreas Kling.
        
Make ElementRuleCollector more reusable.

* css/ElementRuleCollector.cpp:
(WebCore::ElementRuleCollector::collectMatchingRules):
(WebCore::ElementRuleCollector::sortAndTransferMatchedRules):
(WebCore::ElementRuleCollector::matchAuthorRules):
(WebCore::ElementRuleCollector::matchUARules):
(WebCore::ElementRuleCollector::ruleMatches):
(WebCore::ElementRuleCollector::collectMatchingRulesForList):
(WebCore::ElementRuleCollector::matchAllRules):
* css/ElementRuleCollector.h:
(WebCore::ElementRuleCollector::ElementRuleCollector):
        
    Pass the objects that are actually needed rather than the entire State.

LayoutTests: 

Reviewed by Andreas Kling.

* platform/mac/fast/parser/xhtml-alternate-entities-expected.png:
* platform/mac/fast/parser/xhtml-alternate-entities-expected.txt: This is a progression.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformmacfastparserxhtmlalternateentitiesexpectedpng">trunk/LayoutTests/platform/mac/fast/parser/xhtml-alternate-entities-expected.png</a></li>
<li><a href="#trunkLayoutTestsplatformmacfastparserxhtmlalternateentitiesexpectedtxt">trunk/LayoutTests/platform/mac/fast/parser/xhtml-alternate-entities-expected.txt</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="#trunkSourceWebCorecssElementRuleCollectorh">trunk/Source/WebCore/css/ElementRuleCollector.h</a></li>
<li><a href="#trunkSourceWebCorecssStyleResolvercpp">trunk/Source/WebCore/css/StyleResolver.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (163474 => 163475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-02-05 21:44:26 UTC (rev 163474)
+++ trunk/LayoutTests/ChangeLog        2014-02-05 21:50:55 UTC (rev 163475)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2014-02-05  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        ElementRuleCollector should not use StyleResolver::State
+        https://bugs.webkit.org/show_bug.cgi?id=128247
+
+        Reviewed by Andreas Kling.
+
+        * platform/mac/fast/parser/xhtml-alternate-entities-expected.png:
+        * platform/mac/fast/parser/xhtml-alternate-entities-expected.txt: This is a progression.
+
</ins><span class="cx"> 2014-02-05  Yuki Sekiguchi  &lt;yuki.sekiguchi@access-company.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Ruby base oddly justify its text when the text is ideograph and it contains &lt;br&gt; on Mac.
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacfastparserxhtmlalternateentitiesexpectedpng"></a>
<div class="binary"><h4>Modified: trunk/LayoutTests/platform/mac/fast/parser/xhtml-alternate-entities-expected.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacfastparserxhtmlalternateentitiesexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/fast/parser/xhtml-alternate-entities-expected.txt (163474 => 163475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/fast/parser/xhtml-alternate-entities-expected.txt        2014-02-05 21:44:26 UTC (rev 163474)
+++ trunk/LayoutTests/platform/mac/fast/parser/xhtml-alternate-entities-expected.txt        2014-02-05 21:50:55 UTC (rev 163475)
</span><span class="lines">@@ -18,7 +18,7 @@
</span><span class="cx">         RenderText {#text} at (0,0) size 0x0
</span><span class="cx">       RenderText {#text} at (0,0) size 0x0
</span><span class="cx">       RenderText {#text} at (0,0) size 0x0
</span><del>-      RenderInline {p} at (0,0) size 489x18
</del><ins>+      RenderInline {p} at (0,0) size 489x18 [color=#FF0000]
</ins><span class="cx">         RenderInline {font} at (0,0) size 489x18
</span><span class="cx">           RenderText {#text} at (0,0) size 489x18
</span><span class="cx">             text run at (0,0) width 263: &quot;This should be the only line on this page. &quot;
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (163474 => 163475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-02-05 21:44:26 UTC (rev 163474)
+++ trunk/Source/WebCore/ChangeLog        2014-02-05 21:50:55 UTC (rev 163475)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2014-02-05  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        ElementRuleCollector should not use StyleResolver::State
+        https://bugs.webkit.org/show_bug.cgi?id=128247
+
+        Reviewed by Andreas Kling.
+        
+        Make ElementRuleCollector more reusable.
+
+        * css/ElementRuleCollector.cpp:
+        (WebCore::ElementRuleCollector::collectMatchingRules):
+        (WebCore::ElementRuleCollector::sortAndTransferMatchedRules):
+        (WebCore::ElementRuleCollector::matchAuthorRules):
+        (WebCore::ElementRuleCollector::matchUARules):
+        (WebCore::ElementRuleCollector::ruleMatches):
+        (WebCore::ElementRuleCollector::collectMatchingRulesForList):
+        (WebCore::ElementRuleCollector::matchAllRules):
+        * css/ElementRuleCollector.h:
+        (WebCore::ElementRuleCollector::ElementRuleCollector):
+        
+            Pass the objects that are actually needed rather than the entire State.
+
</ins><span class="cx"> 2014-02-05  Brent Fulgham  &lt;bfulgham@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Mac] Correct copy/paste error in scrolling code.
</span></span></pre></div>
<a id="trunkSourceWebCorecssElementRuleCollectorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/ElementRuleCollector.cpp (163474 => 163475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/ElementRuleCollector.cpp        2014-02-05 21:44:26 UTC (rev 163474)
+++ trunk/Source/WebCore/css/ElementRuleCollector.cpp        2014-02-05 21:50:55 UTC (rev 163475)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx">  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
</span><span class="cx">  *           (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
</span><span class="cx">  * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
</span><del>- * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  * Copyright (C) 2007 Alexey Proskuryakov &lt;ap@webkit.org&gt;
</span><span class="cx">  * Copyright (C) 2007, 2008 Eric Seidel &lt;eric@webkit.org&gt;
</span><span class="cx">  * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
</span><span class="lines">@@ -145,19 +145,13 @@
</span><span class="cx"> void ElementRuleCollector::collectMatchingRules(const MatchRequest&amp; matchRequest, StyleResolver::RuleRange&amp; ruleRange)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(matchRequest.ruleSet);
</span><del>-    ASSERT(m_state.element());
</del><span class="cx"> 
</span><del>-    const StyleResolver::State&amp; state = m_state;
-    Element* element = state.element();
-    const StyledElement* styledElement = state.styledElement();
-    const AtomicString&amp; pseudoId = element-&gt;shadowPseudoId();
-    if (!pseudoId.isEmpty()) {
-        ASSERT(styledElement);
</del><ins>+    const AtomicString&amp; pseudoId = m_element.shadowPseudoId();
+    if (!pseudoId.isEmpty())
</ins><span class="cx">         collectMatchingRulesForList(matchRequest.ruleSet-&gt;shadowPseudoElementRules(pseudoId.impl()), matchRequest, ruleRange);
</span><del>-    }
</del><span class="cx"> 
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><del>-    if (element-&gt;isWebVTTElement())
</del><ins>+    if (m_element.isWebVTTElement())
</ins><span class="cx">         collectMatchingRulesForList(matchRequest.ruleSet-&gt;cuePseudoRules(), matchRequest, ruleRange);
</span><span class="cx"> #endif
</span><span class="cx">     // Check whether other types of rules are applicable in the current tree scope. Criteria for this:
</span><span class="lines">@@ -165,23 +159,23 @@
</span><span class="cx">     // b) the tree scope allows author rules
</span><span class="cx">     // c) the rules comes from a scoped style sheet within the same tree scope
</span><span class="cx">     if (!MatchingUARulesScope::isMatchingUARules()
</span><del>-        &amp;&amp; !element-&gt;treeScope().applyAuthorStyles())
</del><ins>+        &amp;&amp; !m_element.treeScope().applyAuthorStyles())
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     // We need to collect the rules for id, class, tag, and everything else into a buffer and
</span><span class="cx">     // then sort the buffer.
</span><del>-    if (element-&gt;hasID())
-        collectMatchingRulesForList(matchRequest.ruleSet-&gt;idRules(element-&gt;idForStyleResolution().impl()), matchRequest, ruleRange);
-    if (styledElement &amp;&amp; styledElement-&gt;hasClass()) {
-        for (size_t i = 0; i &lt; styledElement-&gt;classNames().size(); ++i)
-            collectMatchingRulesForList(matchRequest.ruleSet-&gt;classRules(styledElement-&gt;classNames()[i].impl()), matchRequest, ruleRange);
</del><ins>+    if (m_element.hasID())
+        collectMatchingRulesForList(matchRequest.ruleSet-&gt;idRules(m_element.idForStyleResolution().impl()), matchRequest, ruleRange);
+    if (m_element.hasClass()) {
+        for (size_t i = 0; i &lt; m_element.classNames().size(); ++i)
+            collectMatchingRulesForList(matchRequest.ruleSet-&gt;classRules(m_element.classNames()[i].impl()), matchRequest, ruleRange);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (element-&gt;isLink())
</del><ins>+    if (m_element.isLink())
</ins><span class="cx">         collectMatchingRulesForList(matchRequest.ruleSet-&gt;linkPseudoClassRules(), matchRequest, ruleRange);
</span><del>-    if (SelectorChecker::matchesFocusPseudoClass(element))
</del><ins>+    if (SelectorChecker::matchesFocusPseudoClass(&amp;m_element))
</ins><span class="cx">         collectMatchingRulesForList(matchRequest.ruleSet-&gt;focusPseudoClassRules(), matchRequest, ruleRange);
</span><del>-    collectMatchingRulesForList(matchRequest.ruleSet-&gt;tagRules(element-&gt;localName().impl()), matchRequest, ruleRange);
</del><ins>+    collectMatchingRulesForList(matchRequest.ruleSet-&gt;tagRules(m_element.localName().impl()), matchRequest, ruleRange);
</ins><span class="cx">     collectMatchingRulesForList(matchRequest.ruleSet-&gt;universalRules(), matchRequest, ruleRange);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -203,8 +197,6 @@
</span><span class="cx"> 
</span><span class="cx"> void ElementRuleCollector::sortAndTransferMatchedRules()
</span><span class="cx"> {
</span><del>-    const StyleResolver::State&amp; state = m_state;
-
</del><span class="cx">     if (!m_matchedRules || m_matchedRules-&gt;isEmpty())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -219,8 +211,8 @@
</span><span class="cx"> 
</span><span class="cx">     // Now transfer the set of matched rules over to our list of declarations.
</span><span class="cx">     for (unsigned i = 0; i &lt; matchedRules.size(); i++) {
</span><del>-        if (state.style() &amp;&amp; matchedRules[i]-&gt;containsUncommonAttributeSelector())
-            state.style()-&gt;setUnique();
</del><ins>+        if (m_style &amp;&amp; matchedRules[i]-&gt;containsUncommonAttributeSelector())
+            m_style-&gt;setUnique();
</ins><span class="cx">         m_result.addMatchedProperties(matchedRules[i]-&gt;rule()-&gt;properties(), matchedRules[i]-&gt;rule(), matchedRules[i]-&gt;linkMatchType(), matchedRules[i]-&gt;propertyWhitelistType(MatchingUARulesScope::isMatchingUARules()));
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -230,9 +222,6 @@
</span><span class="cx">     clearMatchedRules();
</span><span class="cx">     m_result.ranges.lastAuthorRule = m_result.matchedProperties.size() - 1;
</span><span class="cx"> 
</span><del>-    if (!m_state.element())
-        return;
-
</del><span class="cx">     // Match global author rules.
</span><span class="cx">     MatchRequest matchRequest(m_ruleSets.authorStyle(), includeEmptyRules);
</span><span class="cx">     StyleResolver::RuleRange ruleRange = m_result.ranges.authorRuleRange();
</span><span class="lines">@@ -270,11 +259,11 @@
</span><span class="cx">     matchUARules(userAgentStyleSheet);
</span><span class="cx"> 
</span><span class="cx">     // In quirks mode, we match rules from the quirks user agent sheet.
</span><del>-    if (document().inQuirksMode())
</del><ins>+    if (m_element.document().inQuirksMode())
</ins><span class="cx">         matchUARules(CSSDefaultStyleSheets::defaultQuirksStyle);
</span><span class="cx"> 
</span><span class="cx">     // If document uses view source styles (in view source mode or in xml viewer mode), then we match rules from the view source style sheet.
</span><del>-    if (document().isViewSource())
</del><ins>+    if (m_element.document().isViewSource())
</ins><span class="cx">         matchUARules(CSSDefaultStyleSheets::viewSourceStyle());
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -291,8 +280,6 @@
</span><span class="cx"> 
</span><span class="cx"> inline bool ElementRuleCollector::ruleMatches(const RuleData&amp; ruleData, PseudoId&amp; dynamicPseudo)
</span><span class="cx"> {
</span><del>-    const StyleResolver::State&amp; state = m_state;
-
</del><span class="cx">     bool fastCheckableSelector = ruleData.hasFastCheckableSelector();
</span><span class="cx">     if (fastCheckableSelector) {
</span><span class="cx">         // We know this selector does not include any pseudo elements.
</span><span class="lines">@@ -300,7 +287,7 @@
</span><span class="cx">             return false;
</span><span class="cx">         // We know a sufficiently simple single part selector matches simply because we found it from the rule hash.
</span><span class="cx">         // This is limited to HTML only so we don't need to check the namespace.
</span><del>-        if (ruleData.hasRightmostSelectorMatchingHTMLBasedOnRuleHash() &amp;&amp; state.element()-&gt;isHTMLElement()) {
</del><ins>+        if (ruleData.hasRightmostSelectorMatchingHTMLBasedOnRuleHash() &amp;&amp; m_element.isHTMLElement()) {
</ins><span class="cx">             if (!ruleData.hasMultipartSelector())
</span><span class="cx">                 return true;
</span><span class="cx">         }
</span><span class="lines">@@ -309,7 +296,7 @@
</span><span class="cx"> #if ENABLE(CSS_SELECTOR_JIT)
</span><span class="cx">     void* compiledSelectorChecker = ruleData.compiledSelectorCodeRef().code().executableAddress();
</span><span class="cx">     if (!compiledSelectorChecker &amp;&amp; ruleData.compilationStatus() == SelectorCompilationStatus::NotCompiled) {
</span><del>-        JSC::VM* vm = document().scriptExecutionContext()-&gt;vm();
</del><ins>+        JSC::VM* vm = m_element.document().scriptExecutionContext()-&gt;vm();
</ins><span class="cx">         SelectorCompilationStatus compilationStatus;
</span><span class="cx">         JSC::MacroAssemblerCodeRef compiledSelectorCodeRef;
</span><span class="cx">         compilationStatus = SelectorCompiler::compileSelector(ruleData.selector(), vm, compiledSelectorCodeRef);
</span><span class="lines">@@ -323,22 +310,22 @@
</span><span class="cx"> 
</span><span class="cx">         if (ruleData.compilationStatus() == SelectorCompilationStatus::SimpleSelectorChecker) {
</span><span class="cx">             SelectorCompiler::SimpleSelectorChecker selectorChecker = SelectorCompiler::simpleSelectorCheckerFunction(compiledSelectorChecker, ruleData.compilationStatus());
</span><del>-            return selectorChecker(state.element());
</del><ins>+            return selectorChecker(&amp;m_element);
</ins><span class="cx">         }
</span><span class="cx">         ASSERT(ruleData.compilationStatus() == SelectorCompilationStatus::SelectorCheckerWithCheckingContext);
</span><span class="cx"> 
</span><span class="cx">         SelectorCompiler::SelectorCheckerWithCheckingContext selectorChecker = SelectorCompiler::selectorCheckerFunctionWithCheckingContext(compiledSelectorChecker, ruleData.compilationStatus());
</span><span class="cx">         SelectorCompiler::CheckingContext context;
</span><del>-        context.elementStyle = state.style();
</del><ins>+        context.elementStyle = m_style;
</ins><span class="cx">         context.resolvingMode = m_mode;
</span><del>-        return selectorChecker(state.element(), &amp;context);
</del><ins>+        return selectorChecker(&amp;m_element, &amp;context);
</ins><span class="cx">     }
</span><span class="cx"> #endif // ENABLE(CSS_SELECTOR_JIT)
</span><span class="cx"> 
</span><span class="cx">     if (fastCheckableSelector) {
</span><del>-        if (ruleData.selector()-&gt;m_match == CSSSelector::Tag &amp;&amp; !SelectorChecker::tagMatches(state.element(), ruleData.selector()-&gt;tagQName()))
</del><ins>+        if (ruleData.selector()-&gt;m_match == CSSSelector::Tag &amp;&amp; !SelectorChecker::tagMatches(&amp;m_element, ruleData.selector()-&gt;tagQName()))
</ins><span class="cx">             return false;
</span><del>-        SelectorCheckerFastPath selectorCheckerFastPath(ruleData.selector(), state.element());
</del><ins>+        SelectorCheckerFastPath selectorCheckerFastPath(ruleData.selector(), &amp;m_element);
</ins><span class="cx">         if (!selectorCheckerFastPath.matchesRightmostAttributeSelector())
</span><span class="cx">             return false;
</span><span class="cx"> 
</span><span class="lines">@@ -346,9 +333,9 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Slow path.
</span><del>-    SelectorChecker selectorChecker(document(), m_mode);
-    SelectorChecker::SelectorCheckingContext context(ruleData.selector(), state.element(), SelectorChecker::VisitedMatchEnabled);
-    context.elementStyle = state.style();
</del><ins>+    SelectorChecker selectorChecker(m_element.document(), m_mode);
+    SelectorChecker::SelectorCheckingContext context(ruleData.selector(), &amp;m_element, SelectorChecker::VisitedMatchEnabled);
+    context.elementStyle = m_style;
</ins><span class="cx">     context.pseudoId = m_pseudoStyleRequest.pseudoId;
</span><span class="cx">     context.scrollbar = m_pseudoStyleRequest.scrollbar;
</span><span class="cx">     context.scrollbarPart = m_pseudoStyleRequest.scrollbarPart;
</span><span class="lines">@@ -364,8 +351,6 @@
</span><span class="cx">     if (!rules)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    const StyleResolver::State&amp; state = m_state;
-
</del><span class="cx">     for (unsigned i = 0, size = rules-&gt;size(); i &lt; size; ++i) {
</span><span class="cx">         const RuleData&amp; ruleData = rules-&gt;data()[i];
</span><span class="cx">         if (m_canUseFastReject &amp;&amp; m_selectorFilter.fastRejectSelector&lt;RuleData::maximumIdentifierCount&gt;(ruleData.descendantSelectorIdentifierHashes()))
</span><span class="lines">@@ -392,8 +377,8 @@
</span><span class="cx">             if (dynamicPseudo != NOPSEUDO &amp;&amp; m_pseudoStyleRequest.pseudoId == NOPSEUDO) {
</span><span class="cx">                 if (m_mode == SelectorChecker::CollectingRules)
</span><span class="cx">                     continue;
</span><del>-                if (dynamicPseudo &lt; FIRST_INTERNAL_PSEUDOID)
-                    state.style()-&gt;setHasPseudoStyle(dynamicPseudo);
</del><ins>+                if (dynamicPseudo &lt; FIRST_INTERNAL_PSEUDOID &amp;&amp; m_style)
+                    m_style-&gt;setHasPseudoStyle(dynamicPseudo);
</ins><span class="cx">             } else {
</span><span class="cx">                 // Update our first/last rule indices in the matched rules array.
</span><span class="cx">                 ++ruleRange.lastRuleIndex;
</span><span class="lines">@@ -430,17 +415,18 @@
</span><span class="cx">         matchUserRules(false);
</span><span class="cx"> 
</span><span class="cx">     // Now check author rules, beginning first with presentational attributes mapped from HTML.
</span><del>-    if (m_state.styledElement()) {
-        addElementStyleProperties(m_state.styledElement()-&gt;presentationAttributeStyle());
</del><ins>+    if (m_element.isStyledElement()) {
+        StyledElement&amp; styledElement = toStyledElement(m_element);
+        addElementStyleProperties(styledElement.presentationAttributeStyle());
</ins><span class="cx"> 
</span><span class="cx">         // Now we check additional mapped declarations.
</span><span class="cx">         // Tables and table cells share an additional mapped rule that must be applied
</span><span class="cx">         // after all attributes, since their mapped style depends on the values of multiple attributes.
</span><del>-        addElementStyleProperties(m_state.styledElement()-&gt;additionalPresentationAttributeStyle());
</del><ins>+        addElementStyleProperties(styledElement.additionalPresentationAttributeStyle());
</ins><span class="cx"> 
</span><del>-        if (m_state.styledElement()-&gt;isHTMLElement()) {
</del><ins>+        if (styledElement.isHTMLElement()) {
</ins><span class="cx">             bool isAuto;
</span><del>-            TextDirection textDirection = toHTMLElement(m_state.styledElement())-&gt;directionalityIfhasDirAutoAttribute(isAuto);
</del><ins>+            TextDirection textDirection = toHTMLElement(styledElement).directionalityIfhasDirAutoAttribute(isAuto);
</ins><span class="cx">             if (isAuto)
</span><span class="cx">                 m_result.addMatchedProperties(textDirection == LTR ? leftToRightDeclaration() : rightToLeftDeclaration());
</span><span class="cx">         }
</span><span class="lines">@@ -450,18 +436,21 @@
</span><span class="cx">     if (matchAuthorAndUserStyles)
</span><span class="cx">         matchAuthorRules(false);
</span><span class="cx"> 
</span><del>-    // Now check our inline style attribute.
-    if (matchAuthorAndUserStyles &amp;&amp; m_state.styledElement() &amp;&amp; m_state.styledElement()-&gt;inlineStyle()) {
-        // Inline style is immutable as long as there is no CSSOM wrapper.
-        // FIXME: Media control shadow trees seem to have problems with caching.
-        bool isInlineStyleCacheable = !m_state.styledElement()-&gt;inlineStyle()-&gt;isMutable() &amp;&amp; !m_state.styledElement()-&gt;isInShadowTree();
-        // FIXME: Constify.
-        addElementStyleProperties(m_state.styledElement()-&gt;inlineStyle(), isInlineStyleCacheable);
-    }
</del><ins>+    if (matchAuthorAndUserStyles &amp;&amp; m_element.isStyledElement()) {
+        StyledElement&amp; styledElement = toStyledElement(m_element);
+        // Now check our inline style attribute.
+        if (styledElement.inlineStyle()) {
+            // Inline style is immutable as long as there is no CSSOM wrapper.
+            // FIXME: Media control shadow trees seem to have problems with caching.
+            bool isInlineStyleCacheable = !styledElement.inlineStyle()-&gt;isMutable() &amp;&amp; !styledElement.isInShadowTree();
+            // FIXME: Constify.
+            addElementStyleProperties(styledElement.inlineStyle(), isInlineStyleCacheable);
+        }
</ins><span class="cx"> 
</span><del>-    // Now check SMIL animation override style.
-    if (includeSMILProperties &amp;&amp; matchAuthorAndUserStyles &amp;&amp; m_state.styledElement() &amp;&amp; m_state.styledElement()-&gt;isSVGElement())
-        addElementStyleProperties(toSVGElement(m_state.styledElement())-&gt;animatedSMILStyleProperties(), false /* isCacheable */);
</del><ins>+        // Now check SMIL animation override style.
+        if (includeSMILProperties &amp;&amp; styledElement.isSVGElement())
+            addElementStyleProperties(toSVGElement(styledElement).animatedSMILStyleProperties(), false /* isCacheable */);
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool ElementRuleCollector::hasAnyMatchingRules(RuleSet* ruleSet)
</span></span></pre></div>
<a id="trunkSourceWebCorecssElementRuleCollectorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/ElementRuleCollector.h (163474 => 163475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/ElementRuleCollector.h        2014-02-05 21:44:26 UTC (rev 163474)
+++ trunk/Source/WebCore/css/ElementRuleCollector.h        2014-02-05 21:50:55 UTC (rev 163475)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
</span><del>- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * This library is free software; you can redistribute it and/or
</span><span class="cx">  * modify it under the terms of the GNU Library General Public
</span><span class="lines">@@ -40,16 +40,17 @@
</span><span class="cx"> 
</span><span class="cx"> class ElementRuleCollector {
</span><span class="cx"> public:
</span><del>-    ElementRuleCollector(StyleResolver* styleResolver, const StyleResolver::State&amp; state)
-        : m_state(state)
-        , m_ruleSets(styleResolver-&gt;ruleSets())
-        , m_selectorFilter(styleResolver-&gt;selectorFilter())
</del><ins>+    ElementRuleCollector(Element&amp; element, RenderStyle* style, const DocumentRuleSets&amp; ruleSets, const SelectorFilter&amp; selectorFilter)
+        : m_element(element)
+        , m_style(style)
+        , m_ruleSets(ruleSets)
+        , m_selectorFilter(selectorFilter)
</ins><span class="cx">         , m_isPrintStyle(false)
</span><span class="cx">         , m_regionForStyling(0)
</span><span class="cx">         , m_pseudoStyleRequest(NOPSEUDO)
</span><span class="cx">         , m_sameOriginOnly(false)
</span><span class="cx">         , m_mode(SelectorChecker::ResolvingStyle)
</span><del>-        , m_canUseFastReject(m_selectorFilter.parentStackIsConsistent(state.parentNode()))
</del><ins>+        , m_canUseFastReject(m_selectorFilter.parentStackIsConsistent(element.parentNode()))
</ins><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -70,7 +71,6 @@
</span><span class="cx">     const Vector&lt;RefPtr&lt;StyleRuleBase&gt;&gt;&amp; matchedRuleList() const;
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    Document&amp; document() { return m_state.document(); }
</del><span class="cx">     void addElementStyleProperties(const StyleProperties*, bool isCacheable = true);
</span><span class="cx"> 
</span><span class="cx">     void matchUARules(RuleSet*);
</span><span class="lines">@@ -86,9 +86,10 @@
</span><span class="cx">     void addMatchedRule(const RuleData*);
</span><span class="cx">     void clearMatchedRules();
</span><span class="cx"> 
</span><del>-    const StyleResolver::State&amp; m_state;
-    DocumentRuleSets&amp; m_ruleSets;
-    SelectorFilter&amp; m_selectorFilter;
</del><ins>+    Element&amp; m_element;
+    RenderStyle* m_style;
+    const DocumentRuleSets&amp; m_ruleSets;
+    const SelectorFilter&amp; m_selectorFilter;
</ins><span class="cx"> 
</span><span class="cx">     bool m_isPrintStyle;
</span><span class="cx">     RenderRegion* m_regionForStyling;
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleResolvercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleResolver.cpp (163474 => 163475)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleResolver.cpp        2014-02-05 21:44:26 UTC (rev 163474)
+++ trunk/Source/WebCore/css/StyleResolver.cpp        2014-02-05 21:50:55 UTC (rev 163475)
</span><span class="lines">@@ -486,7 +486,7 @@
</span><span class="cx">     if (!ruleSet)
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    ElementRuleCollector collector(this, m_state);
</del><ins>+    ElementRuleCollector collector(*m_state.element(), m_state.style(), m_ruleSets, m_selectorFilter);
</ins><span class="cx">     return collector.hasAnyMatchingRules(ruleSet);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -796,7 +796,7 @@
</span><span class="cx">     if (needsCollection)
</span><span class="cx">         m_ruleSets.collectFeatures(document().isViewSource());
</span><span class="cx"> 
</span><del>-    ElementRuleCollector collector(this, state);
</del><ins>+    ElementRuleCollector collector(*element, state.style(), m_ruleSets, m_selectorFilter);
</ins><span class="cx">     collector.setRegionForStyling(regionForStyling);
</span><span class="cx">     collector.setMedium(m_medium.get());
</span><span class="cx"> 
</span><span class="lines">@@ -939,17 +939,17 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-PassRefPtr&lt;RenderStyle&gt; StyleResolver::pseudoStyleForElement(Element* e, const PseudoStyleRequest&amp; pseudoStyleRequest, RenderStyle* parentStyle)
</del><ins>+PassRefPtr&lt;RenderStyle&gt; StyleResolver::pseudoStyleForElement(Element* element, const PseudoStyleRequest&amp; pseudoStyleRequest, RenderStyle* parentStyle)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(parentStyle);
</span><del>-    if (!e)
</del><ins>+    if (!element)
</ins><span class="cx">         return 0;
</span><span class="cx"> 
</span><span class="cx">     State&amp; state = m_state;
</span><span class="cx"> 
</span><del>-    initElement(e);
</del><ins>+    initElement(element);
</ins><span class="cx"> 
</span><del>-    state.initForStyleResolve(document(), e, parentStyle);
</del><ins>+    state.initForStyleResolve(document(), element, parentStyle);
</ins><span class="cx"> 
</span><span class="cx">     if (m_state.parentStyle()) {
</span><span class="cx">         state.setStyle(RenderStyle::create());
</span><span class="lines">@@ -963,7 +963,7 @@
</span><span class="cx">     // those rules.
</span><span class="cx"> 
</span><span class="cx">     // Check UA, user and author rules.
</span><del>-    ElementRuleCollector collector(this, state);
</del><ins>+    ElementRuleCollector collector(*element, m_state.style(), m_ruleSets, m_selectorFilter);
</ins><span class="cx">     collector.setPseudoStyleRequest(pseudoStyleRequest);
</span><span class="cx">     collector.setMedium(m_medium.get());
</span><span class="cx">     collector.matchUARules();
</span><span class="lines">@@ -978,7 +978,7 @@
</span><span class="cx"> 
</span><span class="cx">     state.style()-&gt;setStyleType(pseudoStyleRequest.pseudoId);
</span><span class="cx"> 
</span><del>-    applyMatchedProperties(collector.matchedResult(), e);
</del><ins>+    applyMatchedProperties(collector.matchedResult(), element);
</ins><span class="cx"> 
</span><span class="cx">     // Clean up our style object's display and text decorations (among other fixups).
</span><span class="cx">     adjustRenderStyle(*state.style(), *m_state.parentStyle(), 0);
</span><span class="lines">@@ -1452,15 +1452,15 @@
</span><span class="cx">     return pseudoStyleRulesForElement(e, NOPSEUDO, rulesToInclude);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Vector&lt;RefPtr&lt;StyleRuleBase&gt;&gt; StyleResolver::pseudoStyleRulesForElement(Element* e, PseudoId pseudoId, unsigned rulesToInclude)
</del><ins>+Vector&lt;RefPtr&lt;StyleRuleBase&gt;&gt; StyleResolver::pseudoStyleRulesForElement(Element* element, PseudoId pseudoId, unsigned rulesToInclude)
</ins><span class="cx"> {
</span><del>-    if (!e || !e-&gt;document().haveStylesheetsLoaded())
</del><ins>+    if (!element || !element-&gt;document().haveStylesheetsLoaded())
</ins><span class="cx">         return Vector&lt;RefPtr&lt;StyleRuleBase&gt;&gt;();
</span><span class="cx"> 
</span><del>-    initElement(e);
-    m_state.initForStyleResolve(document(), e, 0);
</del><ins>+    initElement(element);
+    m_state.initForStyleResolve(document(), element, 0);
</ins><span class="cx"> 
</span><del>-    ElementRuleCollector collector(this, m_state);
</del><ins>+    ElementRuleCollector collector(*element, m_state.style(), m_ruleSets, m_selectorFilter);
</ins><span class="cx">     collector.setMode(SelectorChecker::CollectingRules);
</span><span class="cx">     collector.setPseudoStyleRequest(PseudoStyleRequest(pseudoId));
</span><span class="cx">     collector.setMedium(m_medium.get());
</span></span></pre>
</div>
</div>

</body>
</html>