<!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>[160852] trunk/Source/WebCore</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/160852">160852</a></dd>
<dt>Author</dt> <dd>akling@apple.com</dd>
<dt>Date</dt> <dd>2013-12-19 13:15:12 -0800 (Thu, 19 Dec 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Use CascadedProperties for page and keyframe style resolution as well.
&lt;https://webkit.org/b/125997&gt;

Port StyleResolver's styleForKeyframe() and styleForPage() over to
the new property cascading code. Neither of them care about !important
or matched properties caches, so the code is very simple.

Removed the old applyMatchedProperties and applyProperties code with
low/high priority passes.

Reviewed by Antti Koivisto.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssStyleResolvercpp">trunk/Source/WebCore/css/StyleResolver.cpp</a></li>
<li><a href="#trunkSourceWebCorecssStyleResolverh">trunk/Source/WebCore/css/StyleResolver.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (160851 => 160852)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2013-12-19 20:42:07 UTC (rev 160851)
+++ trunk/Source/WebCore/ChangeLog        2013-12-19 21:15:12 UTC (rev 160852)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2013-12-19  Andreas Kling  &lt;akling@apple.com&gt;
+
+        Use CascadedProperties for page and keyframe style resolution as well.
+        &lt;https://webkit.org/b/125997&gt;
+
+        Port StyleResolver's styleForKeyframe() and styleForPage() over to
+        the new property cascading code. Neither of them care about !important
+        or matched properties caches, so the code is very simple.
+
+        Removed the old applyMatchedProperties and applyProperties code with
+        low/high priority passes.
+
+        Reviewed by Antti Koivisto.
+
</ins><span class="cx"> 2013-12-19  Eric Carlson  &lt;eric.carlson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         tryAddEventListener uses local PassRefPtr&lt;&gt;
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleResolvercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleResolver.cpp (160851 => 160852)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleResolver.cpp        2013-12-19 20:42:07 UTC (rev 160851)
+++ trunk/Source/WebCore/css/StyleResolver.cpp        2013-12-19 21:15:12 UTC (rev 160852)
</span><span class="lines">@@ -205,7 +205,7 @@
</span><span class="cx"> 
</span><span class="cx">     bool hasProperty(CSSPropertyID id) const { return m_propertyIsPresent.test(id); }
</span><span class="cx">     Property&amp; property(CSSPropertyID);
</span><del>-    bool addMatches(const MatchResult&amp;, bool important, int startIndex, int endIndex, bool inheritedOnly);
</del><ins>+    bool addMatches(const MatchResult&amp;, bool important, int startIndex, int endIndex, bool inheritedOnly = false);
</ins><span class="cx"> 
</span><span class="cx">     void set(CSSPropertyID, CSSValue&amp;, unsigned linkMatchType);
</span><span class="cx">     void setDeferred(CSSPropertyID, CSSValue&amp;, unsigned linkMatchType);
</span><span class="lines">@@ -225,6 +225,8 @@
</span><span class="cx">     WritingMode m_writingMode;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+static void extractDirectionAndWritingMode(const RenderStyle&amp;, const StyleResolver::MatchResult&amp;, TextDirection&amp;, WritingMode&amp;);
+
</ins><span class="cx"> #define HANDLE_INHERIT(prop, Prop) \
</span><span class="cx"> if (isInherit) { \
</span><span class="cx">     m_state.style()-&gt;set##Prop(m_state.parentStyle()-&gt;prop()); \
</span><span class="lines">@@ -901,11 +903,17 @@
</span><span class="cx">     state.setStyle(RenderStyle::clone(elementStyle));
</span><span class="cx">     state.setLineHeightValue(0);
</span><span class="cx"> 
</span><ins>+    TextDirection direction;
+    WritingMode writingMode;
+    extractDirectionAndWritingMode(*state.style(), result, direction, writingMode);
+
</ins><span class="cx">     // We don't need to bother with !important. Since there is only ever one
</span><span class="cx">     // decl, there's nothing to override. So just add the first properties.
</span><del>-    bool inheritedOnly = false;
-    applyMatchedProperties&lt;HighPriorityProperties&gt;(result, false, 0, result.matchedProperties.size() - 1, inheritedOnly);
</del><ins>+    CascadedProperties cascade(direction, writingMode);
+    cascade.addMatches(result, false, 0, result.matchedProperties.size() - 1);
</ins><span class="cx"> 
</span><ins>+    applyCascadedProperties(cascade, firstCSSProperty, CSSPropertyLineHeight);
+
</ins><span class="cx">     // If our font got dirtied, go ahead and update it now.
</span><span class="cx">     updateFont();
</span><span class="cx"> 
</span><span class="lines">@@ -914,12 +922,14 @@
</span><span class="cx">         applyProperty(CSSPropertyLineHeight, state.lineHeightValue());
</span><span class="cx"> 
</span><span class="cx">     // Now do rest of the properties.
</span><del>-    applyMatchedProperties&lt;LowPriorityProperties&gt;(result, false, 0, result.matchedProperties.size() - 1, inheritedOnly);
</del><ins>+    applyCascadedProperties(cascade, CSSPropertyBackground, lastCSSProperty);
</ins><span class="cx"> 
</span><span class="cx">     // If our font got dirtied by one of the non-essential font props,
</span><span class="cx">     // go ahead and update it a second time.
</span><span class="cx">     updateFont();
</span><span class="cx"> 
</span><ins>+    cascade.applyDeferredProperties(*this);
+
</ins><span class="cx">     // Start loading resources referenced by this style.
</span><span class="cx">     loadPendingResources();
</span><span class="cx">     
</span><span class="lines">@@ -1064,11 +1074,18 @@
</span><span class="cx">     PageRuleCollector collector(m_state, m_ruleSets);
</span><span class="cx">     collector.matchAllPageRules(pageIndex);
</span><span class="cx">     m_state.setLineHeightValue(0);
</span><del>-    bool inheritedOnly = false;
</del><span class="cx"> 
</span><span class="cx">     MatchResult&amp; result = collector.matchedResult();
</span><del>-    applyMatchedProperties&lt;HighPriorityProperties&gt;(result, false, 0, result.matchedProperties.size() - 1, inheritedOnly);
</del><span class="cx"> 
</span><ins>+    TextDirection direction;
+    WritingMode writingMode;
+    extractDirectionAndWritingMode(*m_state.style(), result, direction, writingMode);
+
+    CascadedProperties cascade(direction, writingMode);
+    cascade.addMatches(result, false, 0, result.matchedProperties.size() - 1);
+
+    applyCascadedProperties(cascade, firstCSSProperty, CSSPropertyLineHeight);
+
</ins><span class="cx">     // If our font got dirtied, go ahead and update it now.
</span><span class="cx">     updateFont();
</span><span class="cx"> 
</span><span class="lines">@@ -1076,8 +1093,10 @@
</span><span class="cx">     if (m_state.lineHeightValue())
</span><span class="cx">         applyProperty(CSSPropertyLineHeight, m_state.lineHeightValue());
</span><span class="cx"> 
</span><del>-    applyMatchedProperties&lt;LowPriorityProperties&gt;(result, false, 0, result.matchedProperties.size() - 1, inheritedOnly);
</del><ins>+    applyCascadedProperties(cascade, CSSPropertyBackground, lastCSSProperty);
</ins><span class="cx"> 
</span><ins>+    cascade.applyDeferredProperties(*this);
+
</ins><span class="cx">     // Start loading resources referenced by this style.
</span><span class="cx">     loadPendingResources();
</span><span class="cx"> 
</span><span class="lines">@@ -1552,56 +1571,6 @@
</span><span class="cx">     return primitiveValue ? primitiveValue-&gt;convertToLength&lt;FixedFloatConversion | PercentConversion | CalculatedConversion | FractionConversion | ViewportPercentageConversion&gt;(style, rootStyle, multiplier) : Length(Undefined);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-template &lt;StyleResolver::StyleApplicationPass pass&gt;
-void StyleResolver::applyProperties(const StyleProperties* properties, StyleRule* rule, bool isImportant, bool inheritedOnly, PropertyWhitelistType propertyWhitelistType)
-{
-    ASSERT((propertyWhitelistType != PropertyWhitelistRegion) || m_state.regionForStyling());
-    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willProcessRule(&amp;document(), rule, *this);
-
-    unsigned propertyCount = properties-&gt;propertyCount();
-    for (unsigned i = 0; i &lt; propertyCount; ++i) {
-        StyleProperties::PropertyReference current = properties-&gt;propertyAt(i);
-        if (isImportant != current.isImportant())
-            continue;
-        if (inheritedOnly &amp;&amp; !current.isInherited()) {
-            // If the property value is explicitly inherited, we need to apply further non-inherited properties
-            // as they might override the value inherited here. For this reason we don't allow declarations with
-            // explicitly inherited properties to be cached.
-            ASSERT(!current.value()-&gt;isInheritedValue());
-            continue;
-        }
-        CSSPropertyID property = current.id();
-
-        if (propertyWhitelistType == PropertyWhitelistRegion &amp;&amp; !StyleResolver::isValidRegionStyleProperty(property))
-            continue;
-#if ENABLE(VIDEO_TRACK)
-        if (propertyWhitelistType == PropertyWhitelistCue &amp;&amp; !StyleResolver::isValidCueStyleProperty(property))
-            continue;
-#endif
-        switch (pass) {
-        case HighPriorityProperties:
-            COMPILE_ASSERT(firstCSSProperty == CSSPropertyColor, CSS_color_is_first_property);
-#if ENABLE(IOS_TEXT_AUTOSIZING)
-            COMPILE_ASSERT(CSSPropertyZoom == CSSPropertyColor + 18, CSS_zoom_is_end_of_first_prop_range);
-#else
-            COMPILE_ASSERT(CSSPropertyZoom == CSSPropertyColor + 17, CSS_zoom_is_end_of_first_prop_range);
-#endif
-            COMPILE_ASSERT(CSSPropertyLineHeight == CSSPropertyZoom + 1, CSS_line_height_is_after_zoom);
-            // give special priority to font-xxx, color properties, etc
-            if (property &lt; CSSPropertyLineHeight)
-                applyProperty(current.id(), current.value());
-            // we apply line-height later
-            else if (property == CSSPropertyLineHeight)
-                m_state.setLineHeightValue(current.value());
-            break;
-        case LowPriorityProperties:
-            if (property &gt; CSSPropertyLineHeight)
-                applyProperty(current.id(), current.value());
-        }
-    }
-    InspectorInstrumentation::didProcessRule(cookie);
-}
-
</del><span class="cx"> static bool shouldApplyPropertyInParseOrder(CSSPropertyID propertyID)
</span><span class="cx"> {
</span><span class="cx">     switch (propertyID) {
</span><span class="lines">@@ -1640,33 +1609,6 @@
</span><span class="cx">         || localName == HTMLNames::isindexTag;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-template &lt;StyleResolver::StyleApplicationPass pass&gt;
-void StyleResolver::applyMatchedProperties(const MatchResult&amp; matchResult, bool isImportant, int startIndex, int endIndex, bool inheritedOnly)
-{
-    if (startIndex == -1)
-        return;
-
-    State&amp; state = m_state;
-    if (state.style()-&gt;insideLink() != NotInsideLink) {
-        for (int i = startIndex; i &lt;= endIndex; ++i) {
-            const MatchedProperties&amp; matchedProperties = matchResult.matchedProperties[i];
-            unsigned linkMatchType = matchedProperties.linkMatchType;
-            // FIXME: It would be nicer to pass these as arguments but that requires changes in many places.
-            state.setApplyPropertyToRegularStyle(linkMatchType &amp; SelectorChecker::MatchLink);
-            state.setApplyPropertyToVisitedLinkStyle(linkMatchType &amp; SelectorChecker::MatchVisited);
-
-            applyProperties&lt;pass&gt;(matchedProperties.properties.get(), matchResult.matchedRules[i], isImportant, inheritedOnly, static_cast&lt;PropertyWhitelistType&gt;(matchedProperties.whitelistType));
-        }
-        state.setApplyPropertyToRegularStyle(true);
-        state.setApplyPropertyToVisitedLinkStyle(false);
-        return;
-    }
-    for (int i = startIndex; i &lt;= endIndex; ++i) {
-        const MatchedProperties&amp; matchedProperties = matchResult.matchedProperties[i];
-        applyProperties&lt;pass&gt;(matchedProperties.properties.get(), matchResult.matchedRules[i], isImportant, inheritedOnly, static_cast&lt;PropertyWhitelistType&gt;(matchedProperties.whitelistType));
-    }
-}
-
</del><span class="cx"> unsigned StyleResolver::computeMatchedPropertiesHash(const MatchedProperties* properties, unsigned size)
</span><span class="cx"> {
</span><span class="cx">     return StringHasher::hashMemory(properties, sizeof(MatchedProperties) * size);
</span><span class="lines">@@ -1762,7 +1704,7 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void extractDirectionAndWritingMode(const RenderStyle&amp; style, const StyleResolver::MatchResult&amp; matchResult, TextDirection&amp; direction, WritingMode&amp; writingMode)
</del><ins>+void extractDirectionAndWritingMode(const RenderStyle&amp; style, const StyleResolver::MatchResult&amp; matchResult, TextDirection&amp; direction, WritingMode&amp; writingMode)
</ins><span class="cx"> {
</span><span class="cx">     direction = style.direction();
</span><span class="cx">     writingMode = style.writingMode();
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleResolverh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleResolver.h (160851 => 160852)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleResolver.h        2013-12-19 20:42:07 UTC (rev 160851)
+++ trunk/Source/WebCore/css/StyleResolver.h        2013-12-19 21:15:12 UTC (rev 160852)
</span><span class="lines">@@ -353,20 +353,11 @@
</span><span class="cx">     enum ShouldUseMatchedPropertiesCache { DoNotUseMatchedPropertiesCache = 0, UseMatchedPropertiesCache };
</span><span class="cx">     void applyMatchedProperties(const MatchResult&amp;, const Element*, ShouldUseMatchedPropertiesCache = UseMatchedPropertiesCache);
</span><span class="cx"> 
</span><del>-    enum StyleApplicationPass {
-        HighPriorityProperties,
-        LowPriorityProperties
-    };
-
</del><span class="cx">     class CascadedProperties;
</span><span class="cx"> 
</span><span class="cx">     void applyCascadedProperties(CascadedProperties&amp;, int firstProperty, int lastProperty);
</span><span class="cx">     void cascadeMatches(CascadedProperties&amp;, const MatchResult&amp;, bool important, int startIndex, int endIndex, bool inheritedOnly);
</span><span class="cx"> 
</span><del>-    template &lt;StyleApplicationPass pass&gt;
-    void applyMatchedProperties(const MatchResult&amp;, bool important, int startIndex, int endIndex, bool inheritedOnly);
-    template &lt;StyleApplicationPass pass&gt;
-    void applyProperties(const StyleProperties*, StyleRule*, bool isImportant, bool inheritedOnly, PropertyWhitelistType = PropertyWhitelistNone);
</del><span class="cx">     static bool isValidRegionStyleProperty(CSSPropertyID);
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><span class="cx">     static bool isValidCueStyleProperty(CSSPropertyID);
</span></span></pre>
</div>
</div>

</body>
</html>