<!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>[193559] branches/safari-601.1.46-branch</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/193559">193559</a></dd>
<dt>Author</dt> <dd>bshafiei@apple.com</dd>
<dt>Date</dt> <dd>2015-12-05 22:23:15 -0800 (Sat, 05 Dec 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/191128">r191128</a>.  rdar://problem/23221179</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari601146branchLayoutTestsChangeLog">branches/safari-601.1.46-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari601146branchLayoutTestsTestExpectations">branches/safari-601.1.46-branch/LayoutTests/TestExpectations</a></li>
<li><a href="#branchessafari601146branchSourceWebCoreCMakeListstxt">branches/safari-601.1.46-branch/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#branchessafari601146branchSourceWebCoreChangeLog">branches/safari-601.1.46-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari601146branchSourceWebCoreWebCorexcodeprojprojectpbxproj">branches/safari-601.1.46-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#branchessafari601146branchSourceWebCorecssCSSCalculationValuecpp">branches/safari-601.1.46-branch/Source/WebCore/css/CSSCalculationValue.cpp</a></li>
<li><a href="#branchessafari601146branchSourceWebCorecssCSSComputedStyleDeclarationcpp">branches/safari-601.1.46-branch/Source/WebCore/css/CSSComputedStyleDeclaration.cpp</a></li>
<li><a href="#branchessafari601146branchSourceWebCorecssCSSCustomPropertyValueh">branches/safari-601.1.46-branch/Source/WebCore/css/CSSCustomPropertyValue.h</a></li>
<li><a href="#branchessafari601146branchSourceWebCorecssCSSFunctionValuecpp">branches/safari-601.1.46-branch/Source/WebCore/css/CSSFunctionValue.cpp</a></li>
<li><a href="#branchessafari601146branchSourceWebCorecssCSSFunctionValueh">branches/safari-601.1.46-branch/Source/WebCore/css/CSSFunctionValue.h</a></li>
<li><a href="#branchessafari601146branchSourceWebCorecssCSSGrammaryin">branches/safari-601.1.46-branch/Source/WebCore/css/CSSGrammar.y.in</a></li>
<li><a href="#branchessafari601146branchSourceWebCorecssCSSParsercpp">branches/safari-601.1.46-branch/Source/WebCore/css/CSSParser.cpp</a></li>
<li><a href="#branchessafari601146branchSourceWebCorecssCSSParserh">branches/safari-601.1.46-branch/Source/WebCore/css/CSSParser.h</a></li>
<li><a href="#branchessafari601146branchSourceWebCorecssCSSParserValuescpp">branches/safari-601.1.46-branch/Source/WebCore/css/CSSParserValues.cpp</a></li>
<li><a href="#branchessafari601146branchSourceWebCorecssCSSParserValuesh">branches/safari-601.1.46-branch/Source/WebCore/css/CSSParserValues.h</a></li>
<li><a href="#branchessafari601146branchSourceWebCorecssCSSPrimitiveValuecpp">branches/safari-601.1.46-branch/Source/WebCore/css/CSSPrimitiveValue.cpp</a></li>
<li><a href="#branchessafari601146branchSourceWebCorecssCSSPrimitiveValueh">branches/safari-601.1.46-branch/Source/WebCore/css/CSSPrimitiveValue.h</a></li>
<li><a href="#branchessafari601146branchSourceWebCorecssCSSValuecpp">branches/safari-601.1.46-branch/Source/WebCore/css/CSSValue.cpp</a></li>
<li><a href="#branchessafari601146branchSourceWebCorecssCSSValueh">branches/safari-601.1.46-branch/Source/WebCore/css/CSSValue.h</a></li>
<li><a href="#branchessafari601146branchSourceWebCorecssCSSValueListcpp">branches/safari-601.1.46-branch/Source/WebCore/css/CSSValueList.cpp</a></li>
<li><a href="#branchessafari601146branchSourceWebCorecssCSSValueListh">branches/safari-601.1.46-branch/Source/WebCore/css/CSSValueList.h</a></li>
<li><a href="#branchessafari601146branchSourceWebCorecssStylePropertiescpp">branches/safari-601.1.46-branch/Source/WebCore/css/StyleProperties.cpp</a></li>
<li><a href="#branchessafari601146branchSourceWebCorecssStylePropertiesh">branches/safari-601.1.46-branch/Source/WebCore/css/StyleProperties.h</a></li>
<li><a href="#branchessafari601146branchSourceWebCorecssStyleResolvercpp">branches/safari-601.1.46-branch/Source/WebCore/css/StyleResolver.cpp</a></li>
<li><a href="#branchessafari601146branchSourceWebCorecssStyleResolverh">branches/safari-601.1.46-branch/Source/WebCore/css/StyleResolver.h</a></li>
<li><a href="#branchessafari601146branchSourceWebCorecssmakeproppl">branches/safari-601.1.46-branch/Source/WebCore/css/makeprop.pl</a></li>
<li><a href="#branchessafari601146branchSourceWebCorerenderingstyleRenderStylecpp">branches/safari-601.1.46-branch/Source/WebCore/rendering/style/RenderStyle.cpp</a></li>
<li><a href="#branchessafari601146branchSourceWebCorerenderingstyleRenderStyleh">branches/safari-601.1.46-branch/Source/WebCore/rendering/style/RenderStyle.h</a></li>
<li><a href="#branchessafari601146branchSourceWebCorerenderingstyleStyleCustomPropertyDatah">branches/safari-601.1.46-branch/Source/WebCore/rendering/style/StyleCustomPropertyData.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari601146branchLayoutTestsfastcsscustompropertiesinheritanceexpectedhtml">branches/safari-601.1.46-branch/LayoutTests/fast/css/custom-properties/inheritance-expected.html</a></li>
<li><a href="#branchessafari601146branchLayoutTestsfastcsscustompropertiesinheritancehtml">branches/safari-601.1.46-branch/LayoutTests/fast/css/custom-properties/inheritance.html</a></li>
<li>branches/safari-601.1.46-branch/LayoutTests/fast/css/variables/</li>
<li><a href="#branchessafari601146branchSourceWebCorecssCSSVariableDependentValuecpp">branches/safari-601.1.46-branch/Source/WebCore/css/CSSVariableDependentValue.cpp</a></li>
<li><a href="#branchessafari601146branchSourceWebCorecssCSSVariableDependentValueh">branches/safari-601.1.46-branch/Source/WebCore/css/CSSVariableDependentValue.h</a></li>
<li><a href="#branchessafari601146branchSourceWebCorecssCSSVariableValuecpp">branches/safari-601.1.46-branch/Source/WebCore/css/CSSVariableValue.cpp</a></li>
<li><a href="#branchessafari601146branchSourceWebCorecssCSSVariableValueh">branches/safari-601.1.46-branch/Source/WebCore/css/CSSVariableValue.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari601146branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/LayoutTests/ChangeLog (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/LayoutTests/ChangeLog        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/LayoutTests/ChangeLog        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -1,5 +1,36 @@
</span><span class="cx"> 2015-12-05  Babak Shafiei  &lt;bshafiei@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r191128.
+
+    2015-10-14  David Hyatt  &lt;hyatt@apple.com&gt;
+
+            Implement CSS Variables.
+            https://bugs.webkit.org/show_bug.cgi?id=19660
+
+            Reviewed by Dean Jackson.
+
+            * fast/css/custom-properties/inheritance-expected.html: Added.
+            * fast/css/custom-properties/inheritance.html: Added.
+            * fast/css/variables: Added.
+            * fast/css/variables/custom-property-computed-style-access-expected.html: Added.
+            * fast/css/variables/custom-property-computed-style-access.html: Added.
+            * fast/css/variables/custom-property-dynamic-update-expected.html: Added.
+            * fast/css/variables/custom-property-dynamic-update.html: Added.
+            * fast/css/variables/custom-property-simple-cycle-expected.html: Added.
+            * fast/css/variables/custom-property-simple-cycle.html: Added.
+            * fast/css/variables/inherited-fallback-expected.html: Added.
+            * fast/css/variables/inherited-fallback.html: Added.
+            * fast/css/variables/invalid-reference-expected.html: Added.
+            * fast/css/variables/invalid-reference.html: Added.
+            * fast/css/variables/rule-property-get-css-value-expected.html: Added.
+            * fast/css/variables/rule-property-get-css-value.html: Added.
+            * fast/css/variables/rule-property-get-expected.html: Added.
+            * fast/css/variables/rule-property-get.html: Added.
+            * fast/css/variables/rule-serialization-expected.html: Added.
+            * fast/css/variables/rule-serialization.html: Added.
+
+2015-12-05  Babak Shafiei  &lt;bshafiei@apple.com&gt;
+
</ins><span class="cx">         Merge r190209.
</span><span class="cx"> 
</span><span class="cx">     2015-09-24  David Hyatt  &lt;hyatt@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari601146branchLayoutTestsTestExpectations"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/LayoutTests/TestExpectations (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/LayoutTests/TestExpectations        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/LayoutTests/TestExpectations        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -550,3 +550,33 @@
</span><span class="cx"> js/arrowfunction-syntax-endings.html [ Skip ]
</span><span class="cx"> js/arrowfunction-syntax-errors.html [ Skip ]
</span><span class="cx"> js/arrowfunction-syntax.html [ Skip ]
</span><ins>+
+# Known failures on CSS Variables Test Suite
+webkit.org/b/150183 fast/css/variables/test-suite/failures/024.html [ ImageOnlyFailure ]
+webkit.org/b/150183 fast/css/variables/test-suite/failures/025.html [ ImageOnlyFailure ]
+webkit.org/b/150183 fast/css/variables/test-suite/failures/026.html [ ImageOnlyFailure ]
+webkit.org/b/150183 fast/css/variables/test-suite/failures/028.html [ ImageOnlyFailure ]
+webkit.org/b/150183 fast/css/variables/test-suite/failures/030.html [ ImageOnlyFailure ]
+webkit.org/b/150183 fast/css/variables/test-suite/failures/054.html [ ImageOnlyFailure ]
+webkit.org/b/150183 fast/css/variables/test-suite/failures/055.html [ ImageOnlyFailure ]
+webkit.org/b/150183 fast/css/variables/test-suite/failures/056.html [ ImageOnlyFailure ]
+webkit.org/b/150183 fast/css/variables/test-suite/failures/058.html [ ImageOnlyFailure ]
+webkit.org/b/150183 fast/css/variables/test-suite/failures/071.html [ ImageOnlyFailure ]
+webkit.org/b/150183 fast/css/variables/test-suite/failures/081.html [ ImageOnlyFailure ]
+webkit.org/b/150183 fast/css/variables/test-suite/failures/082.html [ ImageOnlyFailure ]
+webkit.org/b/150183 fast/css/variables/test-suite/failures/085.html [ ImageOnlyFailure ]
+webkit.org/b/150183 fast/css/variables/test-suite/failures/086.html [ ImageOnlyFailure ]
+webkit.org/b/150183 fast/css/variables/test-suite/failures/087.html [ ImageOnlyFailure ]
+webkit.org/b/150183 fast/css/variables/test-suite/failures/091.html [ ImageOnlyFailure ]
+webkit.org/b/150183 fast/css/variables/test-suite/failures/103.html [ ImageOnlyFailure ]
+webkit.org/b/150183 fast/css/variables/test-suite/failures/111.html [ ImageOnlyFailure ]
+webkit.org/b/150183 fast/css/variables/test-suite/failures/115.html [ ImageOnlyFailure ]
+webkit.org/b/150183 fast/css/variables/test-suite/failures/126.html [ ImageOnlyFailure ]
+webkit.org/b/150183 fast/css/variables/test-suite/failures/129.html [ ImageOnlyFailure ]
+webkit.org/b/150183 fast/css/variables/test-suite/failures/130.html [ ImageOnlyFailure ]
+webkit.org/b/150183 fast/css/variables/test-suite/failures/134.html [ ImageOnlyFailure ]
+webkit.org/b/150183 fast/css/variables/test-suite/failures/152.html [ ImageOnlyFailure ]
+webkit.org/b/150183 fast/css/variables/test-suite/failures/159.html [ ImageOnlyFailure ]
+webkit.org/b/150183 fast/css/variables/test-suite/failures/161.html [ ImageOnlyFailure ]
+webkit.org/b/150183 fast/css/variables/test-suite/failures/163.html [ ImageOnlyFailure ]
+webkit.org/b/150183 fast/css/variables/test-suite/failures/169.html [ ImageOnlyFailure ]
</ins></span></pre></div>
<a id="branchessafari601146branchLayoutTestsfastcsscustompropertiesinheritanceexpectedhtmlfromrev193503branchessafari601branchLayoutTestsfastcsscustompropertiesinheritanceexpectedhtml"></a>
<div class="copfile"><h4>Copied: branches/safari-601.1.46-branch/LayoutTests/fast/css/custom-properties/inheritance-expected.html (from rev 193503, branches/safari-601-branch/LayoutTests/fast/css/custom-properties/inheritance-expected.html) (0 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/LayoutTests/fast/css/custom-properties/inheritance-expected.html                                (rev 0)
+++ branches/safari-601.1.46-branch/LayoutTests/fast/css/custom-properties/inheritance-expected.html        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;body&gt;
+10px
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="branchessafari601146branchLayoutTestsfastcsscustompropertiesinheritancehtmlfromrev193503branchessafari601branchLayoutTestsfastcsscustompropertiesinheritancehtml"></a>
<div class="copfile"><h4>Copied: branches/safari-601.1.46-branch/LayoutTests/fast/css/custom-properties/inheritance.html (from rev 193503, branches/safari-601-branch/LayoutTests/fast/css/custom-properties/inheritance.html) (0 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/LayoutTests/fast/css/custom-properties/inheritance.html                                (rev 0)
+++ branches/safari-601.1.46-branch/LayoutTests/fast/css/custom-properties/inheritance.html        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;style&gt;
+html { --one: 10px; }
+body { --one: 50px; --one: inherit; }
+&lt;/style&gt;
+&lt;body&gt;
+&lt;script&gt;
+document.write(getComputedStyle(document.body).getPropertyValue(&quot;--one&quot;))
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="branchessafari601146branchSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/CMakeLists.txt (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/CMakeLists.txt        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/Source/WebCore/CMakeLists.txt        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -1316,6 +1316,8 @@
</span><span class="cx">     css/CSSValue.cpp
</span><span class="cx">     css/CSSValueList.cpp
</span><span class="cx">     css/CSSValuePool.cpp
</span><ins>+    css/CSSVariableDependentValue.cpp
+    css/CSSVariableValue.cpp
</ins><span class="cx">     css/DOMWindowCSS.cpp
</span><span class="cx">     css/DocumentRuleSets.cpp
</span><span class="cx">     css/ElementRuleCollector.cpp
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/ChangeLog (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/ChangeLog        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/Source/WebCore/ChangeLog        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -1,5 +1,226 @@
</span><span class="cx"> 2015-12-05  Babak Shafiei  &lt;bshafiei@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r191128.
+
+    2015-10-14  David Hyatt  &lt;hyatt@apple.com&gt;
+
+            Implement CSS Variables.
+            https://bugs.webkit.org/show_bug.cgi?id=19660
+
+            Reviewed by Dean Jackson.
+
+            Added new tests in fast/css/custom-properties and fast/css/variables.
+
+            * CMakeLists.txt:
+            * WebCore.xcodeproj/project.pbxproj:
+            Add CSSVariableValue.cpp and CSSVariableDependentValue.cpp to builds.
+
+            * css/CSSCalculationValue.cpp:
+            (WebCore::hasDoubleValue):
+            Handle the new CSS_PARSER_WHITESPACE value.
+
+            * css/CSSComputedStyleDeclaration.cpp:
+            (WebCore::ComputedStyleExtractor::customPropertyValue):
+            Patched to make sure style is updated so that dynamic changes to custom properties are reflected
+            immediately when querying values.
+
+            (WebCore::CSSComputedStyleDeclaration::length):
+            (WebCore::CSSComputedStyleDeclaration::item):
+            The custom properties table is a reference and not a pointer now.
+
+            * css/CSSCustomPropertyValue.h:
+            (WebCore::CSSCustomPropertyValue::create):
+            (WebCore::CSSCustomPropertyValue::createInvalid):
+            (WebCore::CSSCustomPropertyValue::customCSSText):
+            (WebCore::CSSCustomPropertyValue::equals):
+            (WebCore::CSSCustomPropertyValue::isInvalid):
+            (WebCore::CSSCustomPropertyValue::containsVariables):
+            (WebCore::CSSCustomPropertyValue::value):
+            (WebCore::CSSCustomPropertyValue::CSSCustomPropertyValue):
+            The CSSCustomPropertyValue represents a custom property/value pair in the back end. It holds on
+            to both the property name and a CSSValueList that has the original parser terms. This class also
+            doubles as the invalid-at-compute-time value for custom properties when they contain cycles, etc.
+
+            * css/CSSFunctionValue.cpp:
+            (WebCore::CSSFunctionValue::buildParserValueSubstitutingVariables):
+             * css/CSSFunctionValue.h:
+            (WebCore::CSSFunctionValue::buildParserValueSubstitutingVariables):
+            Hands back a CSSParserValue for a function with variables replaced with their real values (or fallback).
+
+            * css/CSSGrammar.y.in:
+            Many changes to support the var() syntax and to handle error conditions and cases.
+
+            * css/CSSParser.cpp:
+            (WebCore::filterProperties):
+            Null check the value here. Shouldn't happen, but being paranoid.
+
+            (WebCore::CSSParser::parseVariableDependentValue):
+            This function converts a CSSValueList back into a CSSParserValueList and then passes
+            it off to the parser. If the result parses, successfully, then the parsed CSSValue is handed back.
+
+            (WebCore::CSSParser::parseValue):
+            Detect when a property value contains variables and simply make a CSSVariableDependentValue to hold
+            a copy of the parser value list (as a CSSValueList). We defer parsing the list until compute-time
+            when we know the values of the variables to use.
+
+            (WebCore::CSSParser::parseCustomPropertyDeclaration):
+            Add support for inherit, initial and variable references in custom properties.
+
+            (WebCore::CSSParser::detectFunctionTypeToken):
+            Add support for detection of the &quot;var&quot; token.
+
+            (WebCore::CSSParser::realLex):
+            Fix the parsing of custom properties to allow &quot;--&quot; and to allow them to start with digits, e.g., &quot;--0&quot;.
+
+            * css/CSSParser.h:
+            Add parseVariableDependentValue function for handling variable substitution and subsequent parsing
+            of the resolved parser value list.
+
+            * css/CSSParserValues.cpp:
+            (WebCore::CSSParserValueList::containsVariables):
+            Get rid of the toString() function (no longer needed) and replace it with containsVariables(). This
+            check is used to figure out if a parser value list has variables and thus needs to defer parsing
+            until later.
+
+            (WebCore::CSSParserValue::createCSSValue):
+            Add support for the creation of values for variables, CSSVariableValues.
+
+            (WebCore::CSSParserValueList::toString): Deleted.
+            No longer needed.
+
+            * css/CSSParserValues.h:
+            Add CSSParserVariable as a new kind of parser value. This represents a var() that is encountered
+            during parsing. It is similar to a function except it has to hold both the reference (custom property name)
+            and fallback arguments.
+
+            * css/CSSPrimitiveValue.cpp:
+            (WebCore::isValidCSSUnitTypeForDoubleConversion):
+            (WebCore::CSSPrimitiveValue::cleanup):
+            (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText):
+            (WebCore::CSSPrimitiveValue::cloneForCSSOM):
+            (WebCore::CSSPrimitiveValue::equals):
+            Add support for CSS_PARSER_WHITESPACE as a way of preserving whitespace as a parsed item (variables can
+            be only whitespace, and this has to be retained).
+
+            (WebCore::CSSPrimitiveValue::buildParserValue):
+            Conversion from a CSSPrimitiveValue back into a parser value is handled by this function.
+
+            * css/CSSPrimitiveValue.h:
+            (WebCore::CSSPrimitiveValue::isParserOperator):
+            (WebCore::CSSPrimitiveValue::parserOperator):
+            Add ability to get parser operator info. Add the buildParserValue declaration.
+
+            * css/CSSValue.cpp:
+            (WebCore::CSSValue::equals):
+            (WebCore::CSSValue::cssText):
+            (WebCore::CSSValue::destroy):
+            (WebCore::CSSValue::cloneForCSSOM):
+            (WebCore::CSSValue::isInvalidCustomPropertyValue):
+            * css/CSSValue.h:
+            Add support for variable values and variable dependent values.
+
+            * css/CSSValueList.cpp:
+            (WebCore::CSSValueList::customCSSText):
+            Improve serialization to not output extra spaces when a comma operator is a value.
+
+            (WebCore::CSSValueList::containsVariables):
+            Whether or not a CSSVariableValue can be found somewhere within the list (or its descendants).
+
+            (WebCore::CSSValueList::checkVariablesForCycles):
+            Called to check variables for cycles.
+
+            (WebCore::CSSValueList::buildParserValueSubstitutingVariables):
+            (WebCore::CSSValueList::buildParserValueListSubstitutingVariables):
+            Functions that handle converting the value list to a parser value list while making
+            variable substitutions along the way.
+
+            * css/CSSValueList.h:
+            Add the new buildParserXXX functions.
+
+            * css/CSSVariableDependentValue.cpp: Added.
+            (WebCore::CSSVariableDependentValue::checkVariablesForCycles):
+            * css/CSSVariableDependentValue.h: Added.
+            (WebCore::CSSVariableDependentValue::create):
+            (WebCore::CSSVariableDependentValue::customCSSText):
+            (WebCore::CSSVariableDependentValue::equals):
+            (WebCore::CSSVariableDependentValue::propertyID):
+            (WebCore::CSSVariableDependentValue::valueList):
+            (WebCore::CSSVariableDependentValue::CSSVariableDependentValue):
+            This value represents a list of terms that have not had variables substituted yet. The list
+            is held by the value so that it can be converted back into a parser value list once the
+            variable values are known.
+
+            * css/CSSVariableValue.cpp: Added.
+            (WebCore::CSSVariableValue::CSSVariableValue):
+            (WebCore::CSSVariableValue::customCSSText):
+            (WebCore::CSSVariableValue::equals):
+            (WebCore::CSSVariableValue::buildParserValueListSubstitutingVariables):
+            * css/CSSVariableValue.h: Added.
+            (WebCore::CSSVariableValue::create):
+            (WebCore::CSSVariableValue::name):
+            (WebCore::CSSVariableValue::fallbackArguments):
+            This value represents a var() itself. It knows how to do the substitution of the variable
+            value and to apply fallback if that value is not present.
+
+            * css/StyleProperties.cpp:
+            (WebCore::StyleProperties::getPropertyValue):
+            (WebCore::StyleProperties::borderSpacingValue):
+            (WebCore::StyleProperties::getLayeredShorthandValue):
+            (WebCore::StyleProperties::getShorthandValue):
+            (WebCore::StyleProperties::getCommonValue):
+            (WebCore::StyleProperties::getPropertyCSSValue):
+            (WebCore::StyleProperties::getPropertyCSSValueInternal):
+            (WebCore::StyleProperties::asText):
+            (WebCore::StyleProperties::copyPropertiesInSet):
+            * css/StyleProperties.h:
+            Patched to factor property fetching into an internal method so that variables can work with shorthands
+            in the CSS OM.
+
+            * css/StyleResolver.cpp:
+            (WebCore::StyleResolver::applyProperty):
+            Resolve variable values at compute time. If they fail to resolve, use inherit or initial as the
+            value (depending on whether the property inherits by default).
+
+            (WebCore::StyleResolver::resolvedVariableValue):
+            Helper function that calls parseVariableDependentValue and gets the resolved result.
+
+            (WebCore::StyleResolver::applyCascadedProperties):
+            After custom properties have been collected, we check for cycles and perform variable substitutions.
+            This way we get all the variables replaced before we inherit down the style tree.
+
+            * css/StyleResolver.h:
+            Add resolvedVariableValue declaration.
+
+            * css/makeprop.pl:
+            Make sure custom properties are inherited by default.
+
+            * rendering/style/RenderStyle.cpp:
+            (WebCore::RenderStyle::checkVariablesInCustomProperties):
+            This function handles updating variables with cycles to be invalid in the RenderStyle. It then also
+            handles the replacement of variables found in custom properties with resolved values. All custom
+            properties are either invalid or are real non-variable-dependent value lists after this function
+            completes.
+
+            * rendering/style/RenderStyle.h:
+            Add checkVariablesInCustomProperties declaration.
+
+            * rendering/style/StyleCustomPropertyData.h:
+            (WebCore::StyleCustomPropertyData::create):
+            (WebCore::StyleCustomPropertyData::copy):
+            (WebCore::StyleCustomPropertyData::operator==):
+            (WebCore::StyleCustomPropertyData::operator!=):
+            (WebCore::StyleCustomPropertyData::setCustomPropertyValue):
+            (WebCore::StyleCustomPropertyData::getCustomPropertyValue):
+            (WebCore::StyleCustomPropertyData::values):
+            (WebCore::StyleCustomPropertyData::hasCustomProperty):
+            (WebCore::StyleCustomPropertyData::containsVariables):
+            (WebCore::StyleCustomPropertyData::setContainsVariables):
+            (WebCore::StyleCustomPropertyData::StyleCustomPropertyData):
+            Miscellaneous cleanup, and the addition of whether or not the properties still contain variable
+            dependent values that need to be resolved.
+
+2015-12-05  Babak Shafiei  &lt;bshafiei@apple.com&gt;
+
</ins><span class="cx">         Merge r190231.
</span><span class="cx"> 
</span><span class="cx">     2015-09-24  David Hyatt  &lt;hyatt@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -2548,6 +2548,8 @@
</span><span class="cx">                 7C48A6D1191C9D6500026674 /* WebKitNamespace.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C48A6CF191C9D6500026674 /* WebKitNamespace.h */; };
</span><span class="cx">                 7C4902A218B825F8007D9298 /* DOMWheelEventInternal.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 85989DCA0ACC8BBD00A0BC51 /* DOMWheelEventInternal.h */; };
</span><span class="cx">                 7C4C96DC1AD4483500365A50 /* JSReadableStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C4C96D81AD4483500365A50 /* JSReadableStream.cpp */; };
</span><ins>+                7C4C96DC1AD4483500365A51 /* ReadableStreamBuiltins.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C4C96D81AD4483500365A51 /* ReadableStreamBuiltins.cpp */; };
+                7C4C96DC1AD4483500365A52 /* CountQueuingStrategyBuiltins.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C4C96D81AD4483500365A52 /* CountQueuingStrategyBuiltins.cpp */; };
</ins><span class="cx">                 7C4C96DD1AD4483500365A50 /* JSReadableStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C4C96D91AD4483500365A50 /* JSReadableStream.h */; };
</span><span class="cx">                 7C4C96DE1AD4483500365A50 /* JSReadableStreamReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C4C96DA1AD4483500365A50 /* JSReadableStreamReader.cpp */; };
</span><span class="cx">                 7C4C96DF1AD4483500365A50 /* JSReadableStreamReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C4C96DB1AD4483500365A50 /* JSReadableStreamReader.h */; };
</span><span class="lines">@@ -5172,6 +5174,10 @@
</span><span class="cx">                 BC128B01137C8D4600CAC845 /* RenderGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC128B00137C8D4600CAC845 /* RenderGrid.cpp */; };
</span><span class="cx">                 BC14028A0E83680800319717 /* ScrollbarThemeComposite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC1402880E83680800319717 /* ScrollbarThemeComposite.cpp */; };
</span><span class="cx">                 BC14028B0E83680800319717 /* ScrollbarThemeComposite.h in Headers */ = {isa = PBXBuildFile; fileRef = BC1402890E83680800319717 /* ScrollbarThemeComposite.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                BC1790BB1BB5AB3F0006D13E /* CSSVariableDependentValue.h in Headers */ = {isa = PBXBuildFile; fileRef = BC1790BA1BB5AB3F0006D13E /* CSSVariableDependentValue.h */; settings = {ASSET_TAGS = (); }; };
+                BC1790BD1BBB36A80006D13E /* CSSVariableDependentValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC1790BC1BBB36A80006D13E /* CSSVariableDependentValue.cpp */; settings = {ASSET_TAGS = (); }; };
+                BC1790C01BBF2C430006D13E /* CSSVariableValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC1790BE1BBF2C430006D13E /* CSSVariableValue.cpp */; settings = {ASSET_TAGS = (); }; };
+                BC1790C11BBF2C430006D13E /* CSSVariableValue.h in Headers */ = {isa = PBXBuildFile; fileRef = BC1790BF1BBF2C430006D13E /* CSSVariableValue.h */; settings = {ASSET_TAGS = (); }; };
</ins><span class="cx">                 BC17F9660B64EBB8004A65CB /* JSHTMLSelectElementCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC17F9650B64EBB8004A65CB /* JSHTMLSelectElementCustom.cpp */; };
</span><span class="cx">                 BC1A37AD097C715F0019F3D8 /* DOM.h in Headers */ = {isa = PBXBuildFile; fileRef = BC1A3797097C715F0019F3D8 /* DOM.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 BC1A37AE097C715F0019F3D8 /* DOM.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC1A3798097C715F0019F3D8 /* DOM.mm */; };
</span><span class="lines">@@ -9870,6 +9876,8 @@
</span><span class="cx">                 7C48A6CF191C9D6500026674 /* WebKitNamespace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitNamespace.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7C48A6D2191C9D8E00026674 /* WebKitNamespace.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebKitNamespace.idl; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7C4C96D81AD4483500365A50 /* JSReadableStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSReadableStream.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                7C4C96D81AD4483500365A51 /* ReadableStreamBuiltins.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReadableStreamBuiltins.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                7C4C96D81AD4483500365A52 /* CountQueuingStrategyBuiltins.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CountQueuingStrategyBuiltins.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 7C4C96D91AD4483500365A50 /* JSReadableStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSReadableStream.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7C4C96DA1AD4483500365A50 /* JSReadableStreamReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSReadableStreamReader.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7C4C96DB1AD4483500365A50 /* JSReadableStreamReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSReadableStreamReader.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -12723,6 +12731,10 @@
</span><span class="cx">                 BC128B00137C8D4600CAC845 /* RenderGrid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderGrid.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 BC1402880E83680800319717 /* ScrollbarThemeComposite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollbarThemeComposite.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 BC1402890E83680800319717 /* ScrollbarThemeComposite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollbarThemeComposite.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                BC1790BA1BB5AB3F0006D13E /* CSSVariableDependentValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSVariableDependentValue.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                BC1790BC1BBB36A80006D13E /* CSSVariableDependentValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSVariableDependentValue.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                BC1790BE1BBF2C430006D13E /* CSSVariableValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSVariableValue.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                BC1790BF1BBF2C430006D13E /* CSSVariableValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSVariableValue.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 BC17F9650B64EBB8004A65CB /* JSHTMLSelectElementCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLSelectElementCustom.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 BC1A3797097C715F0019F3D8 /* DOM.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOM.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 BC1A3798097C715F0019F3D8 /* DOM.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DOM.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -22646,6 +22658,10 @@
</span><span class="cx">                                 A8D0651C0A23C1FE005E7203 /* CSSValueList.idl */,
</span><span class="cx">                                 E49BDA0A131FD3E5003C56F0 /* CSSValuePool.cpp */,
</span><span class="cx">                                 E49BD9F9131FD2ED003C56F0 /* CSSValuePool.h */,
</span><ins>+                                BC1790BC1BBB36A80006D13E /* CSSVariableDependentValue.cpp */,
+                                BC1790BA1BB5AB3F0006D13E /* CSSVariableDependentValue.h */,
+                                BC1790BE1BBF2C430006D13E /* CSSVariableValue.cpp */,
+                                BC1790BF1BBF2C430006D13E /* CSSVariableValue.h */,
</ins><span class="cx">                                 A80E6CE10A1989CA007FB8C5 /* DashboardRegion.h */,
</span><span class="cx">                                 4A4F48A716B0DFC000EDBB29 /* DocumentRuleSets.cpp */,
</span><span class="cx">                                 4A4F48A816B0DFC000EDBB29 /* DocumentRuleSets.h */,
</span><span class="lines">@@ -23878,6 +23894,7 @@
</span><span class="cx">                                 29A812410FBB9C1D00510293 /* AccessibilityTableColumn.h in Headers */,
</span><span class="cx">                                 29A8123F0FBB9C1D00510293 /* AccessibilityTableHeaderContainer.h in Headers */,
</span><span class="cx">                                 29A812310FBB9C1D00510293 /* AccessibilityTableRow.h in Headers */,
</span><ins>+                                BC1790C11BBF2C430006D13E /* CSSVariableValue.h in Headers */,
</ins><span class="cx">                                 B5D31DFB11CF610B009F22B4 /* ActiveDOMCallback.h in Headers */,
</span><span class="cx">                                 E1C4DE690EA75C1E0023CCD6 /* ActiveDOMObject.h in Headers */,
</span><span class="cx">                                 BCF7E491137CD7C7001DDAE7 /* AdjustViewSizeOrNot.h in Headers */,
</span><span class="lines">@@ -27014,6 +27031,7 @@
</span><span class="cx">                                 5D5975B319635F1100D00878 /* SystemVersion.h in Headers */,
</span><span class="cx">                                 A8CFF0510A154F09000A4234 /* TableLayout.h in Headers */,
</span><span class="cx">                                 BCE3BEC30D222B1D007E06E4 /* TagNodeList.h in Headers */,
</span><ins>+                                BC1790BB1BB5AB3F0006D13E /* CSSVariableDependentValue.h in Headers */,
</ins><span class="cx">                                 F55B3DD61251F12D003EF269 /* TelephoneInputType.h in Headers */,
</span><span class="cx">                                 7CC564B818BABEA6001B9652 /* TelephoneNumberDetector.h in Headers */,
</span><span class="cx">                                 C65046A9167BFB5500CC2A4D /* TemplateContentDocumentFragment.h in Headers */,
</span><span class="lines">@@ -27787,6 +27805,7 @@
</span><span class="cx">                                 AAA728F916D1D8BC00D3BBC6 /* AXObjectCacheIOS.mm in Sources */,
</span><span class="cx">                                 29A8124B0FBB9CA900510293 /* AXObjectCacheMac.mm in Sources */,
</span><span class="cx">                                 BCA8C81F11E3D36900812FB7 /* BackForwardController.cpp in Sources */,
</span><ins>+                                BC1790C01BBF2C430006D13E /* CSSVariableValue.cpp in Sources */,
</ins><span class="cx">                                 BCA8CA5F11E4E6D100812FB7 /* BackForwardList.cpp in Sources */,
</span><span class="cx">                                 BC124EE70C2641CD009E2349 /* BarProp.cpp in Sources */,
</span><span class="cx">                                 379E61C9126CA5C300B63E8D /* BaseButtonInputType.cpp in Sources */,
</span><span class="lines">@@ -30376,6 +30395,7 @@
</span><span class="cx">                                 E180811216FCF42F00B80D07 /* SynchronousLoaderClient.cpp in Sources */,
</span><span class="cx">                                 E180811616FCF9CB00B80D07 /* SynchronousLoaderClient.mm in Sources */,
</span><span class="cx">                                 442ABCD617D9262F00D30715 /* SynchronousLoaderClientCFNet.cpp in Sources */,
</span><ins>+                                BC1790BD1BBB36A80006D13E /* CSSVariableDependentValue.cpp in Sources */,
</ins><span class="cx">                                 26FAE4CE1852E3A5004C8C46 /* SynchronousResourceHandleCFURLConnectionDelegate.cpp in Sources */,
</span><span class="cx">                                 E45390AE0EAFF4B5003695C8 /* SystemMemoryIOS.cpp in Sources */,
</span><span class="cx">                                 CDA07FBD18E0A16A004699FA /* SystemSleepListener.cpp in Sources */,
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCorecssCSSCalculationValuecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/css/CSSCalculationValue.cpp (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/css/CSSCalculationValue.cpp        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/Source/WebCore/css/CSSCalculationValue.cpp        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -137,6 +137,7 @@
</span><span class="cx">     case CSSPrimitiveValue::CSS_PARSER_OPERATOR:
</span><span class="cx">     case CSSPrimitiveValue::CSS_PARSER_HEXCOLOR:
</span><span class="cx">     case CSSPrimitiveValue::CSS_PARSER_IDENTIFIER:
</span><ins>+    case CSSPrimitiveValue::CSS_PARSER_WHITESPACE:
</ins><span class="cx">     case CSSPrimitiveValue::CSS_COUNTER_NAME:
</span><span class="cx">     case CSSPrimitiveValue::CSS_SHAPE:
</span><span class="cx">     case CSSPrimitiveValue::CSS_QUAD:
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCorecssCSSComputedStyleDeclarationcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/css/CSSComputedStyleDeclaration.cpp        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/Source/WebCore/css/CSSComputedStyleDeclaration.cpp        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -1888,6 +1888,12 @@
</span><span class="cx">     Node* styledNode = this-&gt;styledNode();
</span><span class="cx">     if (!styledNode)
</span><span class="cx">         return nullptr;
</span><ins>+    
+    if (updateStyleIfNeededForNode(*styledNode)) {
+        // The style recalc could have caused the styled node to be discarded or replaced
+        // if it was a PseudoElement so we need to update it.
+        styledNode = this-&gt;styledNode();
+    }
</ins><span class="cx"> 
</span><span class="cx">     RefPtr&lt;RenderStyle&gt; style = computeRenderStyleForProperty(styledNode, m_pseudoElementSpecifier, CSSPropertyCustom);
</span><span class="cx">     if (!style || !style-&gt;hasCustomProperty(propertyName))
</span><span class="lines">@@ -3391,8 +3397,7 @@
</span><span class="cx">     if (!style)
</span><span class="cx">         return 0;
</span><span class="cx"> 
</span><del>-    const HashMap&lt;AtomicString, RefPtr&lt;CSSValue&gt;&gt;* customProperties = style-&gt;customProperties();
-    return numComputedProperties + (customProperties ? customProperties-&gt;size() : 0);
</del><ins>+    return numComputedProperties + style-&gt;customProperties().size();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> String CSSComputedStyleDeclaration::item(unsigned i) const
</span><span class="lines">@@ -3413,12 +3418,12 @@
</span><span class="cx">     
</span><span class="cx">     unsigned index = i - numComputedProperties;
</span><span class="cx">     
</span><del>-    const auto* customProperties = style-&gt;customProperties();
-    if (!customProperties || index &gt;= customProperties-&gt;size())
</del><ins>+    const auto&amp; customProperties = style-&gt;customProperties();
+    if (index &gt;= customProperties.size())
</ins><span class="cx">         return emptyString();
</span><span class="cx">     
</span><span class="cx">     Vector&lt;String, 4&gt; results;
</span><del>-    copyKeysToVector(*customProperties, results);
</del><ins>+    copyKeysToVector(customProperties, results);
</ins><span class="cx">     return results.at(index);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCorecssCSSCustomPropertyValueh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/css/CSSCustomPropertyValue.h (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/css/CSSCustomPropertyValue.h        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/Source/WebCore/css/CSSCustomPropertyValue.h        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -28,22 +28,28 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CSSParserValues.h&quot;
</span><span class="cx"> #include &quot;CSSValue.h&quot;
</span><ins>+#include &lt;wtf/RefPtr.h&gt;
</ins><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class CSSCustomPropertyValue : public CSSValue {
</span><span class="cx"> public:
</span><del>-    static Ref&lt;CSSCustomPropertyValue&gt; create(const AtomicString&amp; name, std::unique_ptr&lt;CSSParserValueList&gt;&amp; valueList)
</del><ins>+    static Ref&lt;CSSCustomPropertyValue&gt; create(const AtomicString&amp; name, RefPtr&lt;CSSValue&gt;&amp; value)
</ins><span class="cx">     {
</span><del>-        return adoptRef(*new CSSCustomPropertyValue(name, valueList));
</del><ins>+        return adoptRef(*new CSSCustomPropertyValue(name, value));
</ins><span class="cx">     }
</span><span class="cx">     
</span><ins>+    static Ref&lt;CSSCustomPropertyValue&gt; createInvalid()
+    {
+        return adoptRef(*new CSSCustomPropertyValue(emptyString(), emptyString()));
+    }
+    
</ins><span class="cx">     String customCSSText() const
</span><span class="cx">     {
</span><span class="cx">         if (!m_serialized) {
</span><span class="cx">             m_serialized = true;
</span><del>-            m_stringValue = m_parserValue ? m_parserValue-&gt;toString() : &quot;&quot;;
</del><ins>+            m_stringValue = m_value ? m_value-&gt;cssText() : emptyString();
</ins><span class="cx">         }
</span><span class="cx">         return m_stringValue;
</span><span class="cx">     }
</span><span class="lines">@@ -54,18 +60,33 @@
</span><span class="cx">     // is rarely used, so serialization to compare is probably fine.
</span><span class="cx">     bool equals(const CSSCustomPropertyValue&amp; other) const { return m_name == other.m_name &amp;&amp; customCSSText() == other.customCSSText(); }
</span><span class="cx"> 
</span><ins>+    bool isInvalid() const { return !m_value; }
+    bool containsVariables() const { return m_containsVariables; }
+
+    const RefPtr&lt;CSSValue&gt; value() const { return m_value.get(); }
+
</ins><span class="cx"> private:
</span><del>-    CSSCustomPropertyValue(const AtomicString&amp; name, std::unique_ptr&lt;CSSParserValueList&gt;&amp; valueList)
</del><ins>+    CSSCustomPropertyValue(const AtomicString&amp; name, RefPtr&lt;CSSValue&gt;&amp; value)
</ins><span class="cx">         : CSSValue(CustomPropertyClass)
</span><span class="cx">         , m_name(name)
</span><del>-        , m_parserValue(WTF::move(valueList))
-        , m_serialized(false)
</del><ins>+        , m_value(value)
+        , m_containsVariables(value &amp;&amp; value-&gt;isVariableDependentValue())
+        , m_serialized(!value)
</ins><span class="cx">     {
</span><span class="cx">     }
</span><ins>+    
+    CSSCustomPropertyValue(const AtomicString&amp; name, const String&amp; serializedValue)
+        : CSSValue(CustomPropertyClass)
+        , m_name(name)
+        , m_stringValue(serializedValue)
+        , m_serialized(true)
+    {
+    }
</ins><span class="cx"> 
</span><span class="cx">     const AtomicString m_name;
</span><del>-    std::unique_ptr&lt;CSSParserValueList&gt; m_parserValue;
</del><ins>+    RefPtr&lt;CSSValue&gt; m_value;
</ins><span class="cx">     mutable String m_stringValue;
</span><ins>+    bool m_containsVariables { false };
</ins><span class="cx">     mutable bool m_serialized;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCorecssCSSFunctionValuecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/css/CSSFunctionValue.cpp (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/css/CSSFunctionValue.cpp        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/Source/WebCore/css/CSSFunctionValue.cpp        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -62,4 +62,19 @@
</span><span class="cx">     return m_name == other.m_name &amp;&amp; compareCSSValuePtr(m_args, other.m_args);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool CSSFunctionValue::buildParserValueSubstitutingVariables(CSSParserValue* result, const CustomPropertyValueMap&amp; customProperties) const
+{
+    result-&gt;id = CSSValueInvalid;
+    result-&gt;unit = CSSParserValue::Function;
+    result-&gt;function = new CSSParserFunction;
+    result-&gt;function-&gt;name.init(m_name);
+    bool success = true;
+    if (m_args) {
+        CSSParserValueList* argList = new CSSParserValueList;
+        success = m_args-&gt;buildParserValueListSubstitutingVariables(argList, customProperties);
+        result-&gt;function-&gt;args.reset(argList);
+    }
+    return success;
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="branchessafari601146branchSourceWebCorecssCSSFunctionValueh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/css/CSSFunctionValue.h (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/css/CSSFunctionValue.h        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/Source/WebCore/css/CSSFunctionValue.h        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> 
</span><span class="cx"> class CSSValueList;
</span><span class="cx"> struct CSSParserFunction;
</span><ins>+struct CSSParserValue;
</ins><span class="cx"> 
</span><span class="cx"> class CSSFunctionValue : public CSSValue {
</span><span class="cx"> public:
</span><span class="lines">@@ -51,6 +52,8 @@
</span><span class="cx"> 
</span><span class="cx">     CSSValueList* arguments() const { return m_args.get(); }
</span><span class="cx"> 
</span><ins>+    bool buildParserValueSubstitutingVariables(CSSParserValue*, const CustomPropertyValueMap&amp; customProperties) const;
+    
</ins><span class="cx"> private:
</span><span class="cx">     explicit CSSFunctionValue(CSSParserFunction*);
</span><span class="cx">     CSSFunctionValue(const String&amp;, PassRefPtr&lt;CSSValueList&gt;);
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCorecssCSSGrammaryin"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/css/CSSGrammar.y.in (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/css/CSSGrammar.y.in        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/Source/WebCore/css/CSSGrammar.y.in        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -63,6 +63,7 @@
</span><span class="cx">     case NTHCHILDFUNCTIONS:
</span><span class="cx">     case NTHCHILDSELECTORSEPARATOR:
</span><span class="cx">     case LANGFUNCTION:
</span><ins>+    case VARFUNCTION:
</ins><span class="cx"> #if ENABLE_CSS_SELECTORS_LEVEL4
</span><span class="cx">     case DIRFUNCTION:
</span><span class="cx">     case ROLEFUNCTION:
</span><span class="lines">@@ -103,9 +104,9 @@
</span><span class="cx"> %}
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE_CSS_GRID_LAYOUT
</span><del>-%expect 32
</del><ins>+%expect 39
</ins><span class="cx"> #else
</span><del>-%expect 31
</del><ins>+%expect 37
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> %nonassoc LOWEST_PREC
</span><span class="lines">@@ -218,6 +219,7 @@
</span><span class="cx"> %token &lt;string&gt; MINFUNCTION
</span><span class="cx"> %token &lt;string&gt; NTHCHILDFUNCTIONS
</span><span class="cx"> %token &lt;string&gt; LANGFUNCTION
</span><ins>+%token &lt;string&gt; VARFUNCTION
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE_CSS_SELECTORS_LEVEL4
</span><span class="cx"> %token &lt;string&gt; DIRFUNCTION
</span><span class="lines">@@ -286,8 +288,8 @@
</span><span class="cx"> %type &lt;value&gt; calc_func_term key unary_term
</span><span class="cx"> 
</span><span class="cx"> // These parser values need to be destroyed because they might be functions.
</span><del>-%type &lt;value&gt; calc_function function min_or_max_function term
-%destructor { destroy($$); } calc_function function min_or_max_function term
</del><ins>+%type &lt;value&gt; calc_function function variable_function min_or_max_function term
+%destructor { destroy($$); } calc_function function variable_function min_or_max_function term
</ins><span class="cx"> 
</span><span class="cx"> %union { CSSPropertyID id; }
</span><span class="cx"> %type &lt;id&gt; property
</span><span class="lines">@@ -314,8 +316,8 @@
</span><span class="cx"> %type &lt;character&gt; operator calc_func_operator
</span><span class="cx"> 
</span><span class="cx"> %union { CSSParserValueList* valueList; }
</span><del>-%type &lt;valueList&gt; calc_func_expr calc_func_expr_list calc_func_paren_expr expr key_list maybe_media_value valid_calc_func_expr valid_expr
-%destructor { delete $$; } calc_func_expr calc_func_expr_list calc_func_paren_expr expr key_list maybe_media_value valid_calc_func_expr valid_expr
</del><ins>+%type &lt;valueList&gt; calc_func_expr calc_func_expr_list calc_func_paren_expr expr key_list maybe_media_value valid_calc_func_expr valid_expr whitespace_or_expr maybe_expr
+%destructor { delete $$; } calc_func_expr calc_func_expr_list calc_func_paren_expr expr key_list maybe_media_value valid_calc_func_expr valid_expr whitespace_or_expr maybe_expr
</ins><span class="cx"> 
</span><span class="cx"> %type &lt;string&gt; lang_range
</span><span class="cx"> %union { Vector&lt;CSSParserString&gt;* stringList; }
</span><span class="lines">@@ -771,6 +773,22 @@
</span><span class="cx">         }
</span><span class="cx">         p-&gt;markPropertyEnd($7, false);
</span><span class="cx">     }
</span><ins>+    |
+    '(' maybe_space CUSTOM_PROPERTY maybe_space ':' whitespace_or_expr priority ')' maybe_space {
+        $$ = false;
+        CSSParser* p = static_cast&lt;CSSParser*&gt;(parser);
+        std::unique_ptr&lt;CSSParserValueList&gt; propertyValue($6);
+        if (propertyValue) {
+            parser-&gt;m_valueList = WTF::move(propertyValue);
+            int oldParsedProperties = p-&gt;m_parsedProperties.size();
+            p-&gt;setCustomPropertyName($3);
+            $$ = p-&gt;parseValue(CSSPropertyCustom, $7);
+            if ($$)
+                p-&gt;rollbackLastProperties(p-&gt;m_parsedProperties.size() - oldParsedProperties);
+            p-&gt;m_valueList = nullptr;
+        }
+        p-&gt;markPropertyEnd($7, false);
+    }
</ins><span class="cx">     ;
</span><span class="cx"> 
</span><span class="cx"> before_keyframes_rule:
</span><span class="lines">@@ -1538,22 +1556,22 @@
</span><span class="cx">     ;
</span><span class="cx"> 
</span><span class="cx"> declaration:
</span><del>-    CUSTOM_PROPERTY maybe_space ':' maybe_space expr priority {
</del><ins>+    CUSTOM_PROPERTY maybe_space ':' whitespace_or_expr priority {
</ins><span class="cx">         $$ = false;
</span><span class="cx">         bool isPropertyParsed = false;
</span><del>-        std::unique_ptr&lt;CSSParserValueList&gt; propertyValue($5);
</del><ins>+        std::unique_ptr&lt;CSSParserValueList&gt; propertyValue($4);
</ins><span class="cx">         if (propertyValue) {
</span><span class="cx">             parser-&gt;m_valueList = WTF::move(propertyValue);
</span><span class="cx">             int oldParsedProperties = parser-&gt;m_parsedProperties.size();
</span><span class="cx">             parser-&gt;setCustomPropertyName($1);
</span><del>-            $$ = parser-&gt;parseValue(CSSPropertyCustom, $6);
</del><ins>+            $$ = parser-&gt;parseValue(CSSPropertyCustom, $5);
</ins><span class="cx">             if (!$$)
</span><span class="cx">                 parser-&gt;rollbackLastProperties(parser-&gt;m_parsedProperties.size() - oldParsedProperties);
</span><span class="cx">             else
</span><span class="cx">                 isPropertyParsed = true;
</span><span class="cx">             parser-&gt;m_valueList = nullptr;
</span><span class="cx">         }
</span><del>-        parser-&gt;markPropertyEnd($6, isPropertyParsed);
</del><ins>+        parser-&gt;markPropertyEnd($5, isPropertyParsed);
</ins><span class="cx">     }
</span><span class="cx">     | property ':' maybe_space expr priority {
</span><span class="cx">         $$ = false;
</span><span class="lines">@@ -1624,6 +1642,24 @@
</span><span class="cx"> 
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+whitespace_or_expr:
+    WHITESPACE maybe_expr {
+        if ($2)
+            $$ = $2;
+        else {
+            CSSParserValue val;
+            val.id = CSSValueInvalid;
+            val.unit = CSSPrimitiveValue::CSS_PARSER_WHITESPACE;
+            val.string.init(emptyString());
+            $$ = new CSSParserValueList;
+            $$-&gt;addValue(val);
+        }
+    }
+    | maybe_space expr { $$ = $2; }
+    ;
+
+maybe_expr: /* empty */ { $$ = nullptr; } | expr { $$ = $1; };
+
</ins><span class="cx"> expr: valid_expr | valid_expr expr_recovery { $$ = nullptr; delete $1; } ;
</span><span class="cx"> 
</span><span class="cx"> valid_expr:
</span><span class="lines">@@ -1667,6 +1703,7 @@
</span><span class="cx">   /* FIXME: according to the specs a function can have a unary_operator in front. I know no case where this makes sense */
</span><span class="cx">   | function maybe_space
</span><span class="cx">   | calc_function maybe_space
</span><ins>+  | variable_function maybe_space
</ins><span class="cx">   | min_or_max_function maybe_space
</span><span class="cx">   | '%' maybe_space { /* Handle width: %; */
</span><span class="cx">       $$.id = CSSValueInvalid; $$.unit = 0;
</span><span class="lines">@@ -1742,8 +1779,65 @@
</span><span class="cx">   }
</span><span class="cx">   ;
</span><span class="cx"> 
</span><ins>+variable_function:
+    VARFUNCTION maybe_space CUSTOM_PROPERTY maybe_space closing_parenthesis {
+        CSSParserVariable* var = new CSSParserVariable;
+        var-&gt;name = $3;
+        var-&gt;args = nullptr;
+        $$.id = CSSValueInvalid;
+        $$.unit = CSSParserValue::Variable;
+        $$.variable = var;
+    }
+    | VARFUNCTION maybe_space CUSTOM_PROPERTY maybe_space ',' maybe_space expr closing_parenthesis {
+        CSSParserVariable* var = new CSSParserVariable;
+        var-&gt;name = $3;
+        var-&gt;args = std::unique_ptr&lt;CSSParserValueList&gt;($7);
+        $$.id = CSSValueInvalid;
+        $$.unit = CSSParserValue::Variable;
+        $$.variable = var;
+    }
+    | VARFUNCTION maybe_space CUSTOM_PROPERTY maybe_space ',' maybe_space closing_parenthesis {
+        CSSParserVariable* var = new CSSParserVariable;
+        var-&gt;name = $3;
+        var-&gt;args = std::unique_ptr&lt;CSSParserValueList&gt;(new CSSParserValueList());
+        $$.id = CSSValueInvalid;
+        $$.unit = CSSParserValue::Variable;
+        $$.variable = var;
+    }
+    // Error handling cases
+    | VARFUNCTION maybe_space CUSTOM_PROPERTY maybe_space ',' closing_parenthesis {
+        $$.id = CSSValueInvalid;
+        $$.unit = 0;
+        YYERROR;
+    }
+    | VARFUNCTION maybe_space CUSTOM_PROPERTY maybe_space ',' maybe_space invalid_var_fallback maybe_space closing_parenthesis {
+        $$.id = CSSValueInvalid;
+        $$.unit = 0;
+        YYERROR;
+    }
+    | VARFUNCTION maybe_space CUSTOM_PROPERTY maybe_space ',' maybe_space priority closing_parenthesis {
+        $$.id = CSSValueInvalid;
+        $$.unit = 0;
+        YYERROR;
+    }
+    | VARFUNCTION maybe_space expr closing_parenthesis {
+        $$.id = CSSValueInvalid;
+        $$.unit = 0;
+        YYERROR;
+    }
+    | VARFUNCTION maybe_space expr_recovery closing_parenthesis {
+        $$.id = CSSValueInvalid;
+        $$.unit = 0;
+        YYERROR;
+    }
+    ;
+
+invalid_var_fallback:
+    '!' | ';';
+
</ins><span class="cx"> calc_func_term:
</span><span class="cx">   unary_term
</span><ins>+  | variable_function { $$ = $1; }
</ins><span class="cx">   | unary_operator unary_term { $$ = $2; $$.fValue *= $1; }
</span><span class="cx">   ;
</span><span class="cx"> 
</span><span class="lines">@@ -1893,7 +1987,7 @@
</span><span class="cx"> invalid_parentheses_block: opening_parenthesis error_recovery closing_parenthesis;
</span><span class="cx"> 
</span><span class="cx"> opening_parenthesis:
</span><del>-    '(' | FUNCTION | CALCFUNCTION | MATCHESFUNCTION | MAXFUNCTION | MINFUNCTION | ANYFUNCTION | NOTFUNCTION | LANGFUNCTION
</del><ins>+    '(' | FUNCTION | VARFUNCTION | CALCFUNCTION | MATCHESFUNCTION | MAXFUNCTION | MINFUNCTION | ANYFUNCTION | NOTFUNCTION | LANGFUNCTION
</ins><span class="cx"> #if ENABLE_CSS_SELECTORS_LEVEL4
</span><span class="cx">     | DIRFUNCTION | ROLEFUNCTION
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCorecssCSSParsercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/css/CSSParser.cpp (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/css/CSSParser.cpp        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/Source/WebCore/css/CSSParser.cpp        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -65,6 +65,7 @@
</span><span class="cx"> #include &quot;CSSValueKeywords.h&quot;
</span><span class="cx"> #include &quot;CSSValueList.h&quot;
</span><span class="cx"> #include &quot;CSSValuePool.h&quot;
</span><ins>+#include &quot;CSSVariableDependentValue.h&quot;
</ins><span class="cx"> #include &quot;Counter.h&quot;
</span><span class="cx"> #include &quot;Document.h&quot;
</span><span class="cx"> #include &quot;FloatConversion.h&quot;
</span><span class="lines">@@ -1591,11 +1592,13 @@
</span><span class="cx">             continue;
</span><span class="cx">         
</span><span class="cx">         if (property.id() == CSSPropertyCustom) {
</span><del>-            const AtomicString&amp; name = downcast&lt;CSSCustomPropertyValue&gt;(*property.value()).name();
-            if (seenCustomProperties.contains(name))
-                continue;
-            seenCustomProperties.add(name);
-            output[--unusedEntries] = property;
</del><ins>+            if (property.value()) {
+                const AtomicString&amp; name = downcast&lt;CSSCustomPropertyValue&gt;(*property.value()).name();
+                if (seenCustomProperties.contains(name))
+                    continue;
+                seenCustomProperties.add(name);
+                output[--unusedEntries] = property;
+            }
</ins><span class="cx">             continue;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -1897,20 +1900,38 @@
</span><span class="cx">         addProperty(longhands[i], value, important);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+RefPtr&lt;CSSValue&gt; CSSParser::parseVariableDependentValue(CSSPropertyID propID, const CSSVariableDependentValue&amp; dependentValue, const CustomPropertyValueMap&amp; customProperties)
+{
+    m_valueList.reset(new CSSParserValueList());
+    if (!dependentValue.valueList()-&gt;buildParserValueListSubstitutingVariables(m_valueList.get(), customProperties))
+        return nullptr;
+    bool parsed = parseValue(dependentValue.propertyID(), false);
+    if (!parsed)
+        return nullptr;
+    for (size_t i = 0; i &lt; m_parsedProperties.size(); ++i) {
+        if (m_parsedProperties[i].id() == propID)
+            return m_parsedProperties[i].value();
+    }
+    return nullptr;
+}
+
</ins><span class="cx"> bool CSSParser::parseValue(CSSPropertyID propId, bool important)
</span><span class="cx"> {
</span><span class="cx">     if (!m_valueList || !m_valueList-&gt;current())
</span><span class="cx">         return false;
</span><span class="cx">     
</span><del>-    if (propId == CSSPropertyCustom) {
-        // FIXME: For now put this ahead of inherit/initial processing.
-        // Eventually we want to support initial and inherit.
-        return parseCustomPropertyDeclaration(important);
-    }
-
</del><span class="cx">     ValueWithCalculation valueWithCalculation(*m_valueList-&gt;current());
</span><span class="cx">     CSSValueID id = valueWithCalculation.value().id;
</span><ins>+    
+    if (propId == CSSPropertyCustom)
+        return parseCustomPropertyDeclaration(important, id);
</ins><span class="cx"> 
</span><ins>+    if (m_valueList-&gt;containsVariables()) {
+        RefPtr&lt;CSSValueList&gt; valueList = CSSValueList::createFromParserValueList(*m_valueList);
+        addExpandedPropertyForValue(propId, CSSVariableDependentValue::create(valueList, propId), important);
+        return true;
+    }
+
</ins><span class="cx">     unsigned num = inShorthand() ? 1 : m_valueList-&gt;size();
</span><span class="cx"> 
</span><span class="cx">     if (id == CSSValueInherit) {
</span><span class="lines">@@ -4128,11 +4149,26 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool CSSParser::parseCustomPropertyDeclaration(bool important)
</del><ins>+bool CSSParser::parseCustomPropertyDeclaration(bool important, CSSValueID id)
</ins><span class="cx"> {
</span><span class="cx">     if (m_customPropertyName.isEmpty() || !m_valueList)
</span><span class="cx">         return false;
</span><del>-    addProperty(CSSPropertyCustom, CSSCustomPropertyValue::create(m_customPropertyName, m_valueList), important, false);
</del><ins>+    
+    auto&amp; cssValuePool = CSSValuePool::singleton();
+    RefPtr&lt;CSSValue&gt; value;
+    if (id == CSSValueInherit)
+        value = cssValuePool.createInheritedValue();
+    else if (id == CSSValueInitial)
+        value = cssValuePool.createExplicitInitialValue();
+    else {
+        RefPtr&lt;CSSValueList&gt; valueList = CSSValueList::createFromParserValueList(*m_valueList);
+        if (m_valueList-&gt;containsVariables())
+            value = CSSVariableDependentValue::create(valueList, CSSPropertyCustom);
+        else
+            value = valueList;
+    }
+
+    addProperty(CSSPropertyCustom, CSSCustomPropertyValue::create(m_customPropertyName, value), important, false);
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -11280,6 +11316,10 @@
</span><span class="cx">             m_token = URI;
</span><span class="cx">             return true;
</span><span class="cx">         }
</span><ins>+        if (isASCIIAlphaCaselessEqual(name[0], 'v') &amp;&amp; isASCIIAlphaCaselessEqual(name[1], 'a') &amp;&amp; isASCIIAlphaCaselessEqual(name[2], 'r')) {
+            m_token = VARFUNCTION;
+            return true;
+        }
</ins><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><span class="cx">         if (isASCIIAlphaCaselessEqual(name[0], 'c') &amp;&amp; isASCIIAlphaCaselessEqual(name[1], 'u') &amp;&amp; isASCIIAlphaCaselessEqual(name[2], 'e')) {
</span><span class="cx">             m_token = CUEFUNCTION;
</span><span class="lines">@@ -11968,14 +12008,14 @@
</span><span class="cx">             }
</span><span class="cx">             resultString.setLength(result - tokenStart&lt;SrcCharacterType&gt;());
</span><span class="cx">             yylval-&gt;string = resultString;
</span><del>-        } else if (currentCharacter&lt;SrcCharacterType&gt;()[0] == '-' &amp;&amp; isIdentifierStartAfterDash(currentCharacter&lt;SrcCharacterType&gt;() + 1)) {
</del><ins>+        } else if (currentCharacter&lt;SrcCharacterType&gt;()[0] == '-' &amp;&amp; currentCharacter&lt;SrcCharacterType&gt;()[1] == '&gt;') {
+            currentCharacter&lt;SrcCharacterType&gt;() += 2;
+            m_token = SGML_CD;
+        } else if (currentCharacter&lt;SrcCharacterType&gt;()[0] == '-') {
</ins><span class="cx">             --currentCharacter&lt;SrcCharacterType&gt;();
</span><span class="cx">             parseIdentifier(result, resultString, hasEscape);
</span><span class="cx">             m_token = CUSTOM_PROPERTY;
</span><span class="cx">             yylval-&gt;string = resultString;
</span><del>-        } else if (currentCharacter&lt;SrcCharacterType&gt;()[0] == '-' &amp;&amp; currentCharacter&lt;SrcCharacterType&gt;()[1] == '&gt;') {
-            currentCharacter&lt;SrcCharacterType&gt;() += 2;
-            m_token = SGML_CD;
</del><span class="cx">         } else if (UNLIKELY(m_parsingMode == NthChildMode)) {
</span><span class="cx">             // &quot;-[0-9]+n&quot; is always an NthChild.
</span><span class="cx">             if (parseNthChild&lt;SrcCharacterType&gt;()) {
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCorecssCSSParserh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/css/CSSParser.h (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/css/CSSParser.h        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/Source/WebCore/css/CSSParser.h        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -57,6 +57,7 @@
</span><span class="cx"> class CSSBasicShape;
</span><span class="cx"> class CSSBasicShapeInset;
</span><span class="cx"> class CSSGridLineNamesValue;
</span><ins>+class CSSVariableDependentValue;
</ins><span class="cx"> class Document;
</span><span class="cx"> class Element;
</span><span class="cx"> class ImmutableStyleProperties;
</span><span class="lines">@@ -144,7 +145,7 @@
</span><span class="cx">     bool parseQuotes(CSSPropertyID, bool important);
</span><span class="cx">     bool parseAlt(CSSPropertyID, bool important);
</span><span class="cx">     
</span><del>-    bool parseCustomPropertyDeclaration(bool important);
</del><ins>+    bool parseCustomPropertyDeclaration(bool important, CSSValueID);
</ins><span class="cx">     
</span><span class="cx">     PassRefPtr&lt;CSSValue&gt; parseAttr(CSSParserValueList&amp; args);
</span><span class="cx">     PassRefPtr&lt;CSSValue&gt; parseBackgroundColor();
</span><span class="lines">@@ -467,6 +468,8 @@
</span><span class="cx"> 
</span><span class="cx">     void setCustomPropertyName(const AtomicString&amp; propertyName) { m_customPropertyName = propertyName; }
</span><span class="cx"> 
</span><ins>+    RefPtr&lt;CSSValue&gt; parseVariableDependentValue(CSSPropertyID, const CSSVariableDependentValue&amp;, const CustomPropertyValueMap&amp; customProperties);
+
</ins><span class="cx"> private:
</span><span class="cx">     bool is8BitSource() { return m_is8BitSource; }
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCorecssCSSParserValuescpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/css/CSSParserValues.cpp (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/css/CSSParserValues.cpp        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/Source/WebCore/css/CSSParserValues.cpp        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -21,10 +21,12 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;CSSParserValues.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;CSSCustomPropertyValue.h&quot;
</ins><span class="cx"> #include &quot;CSSPrimitiveValue.h&quot;
</span><span class="cx"> #include &quot;CSSFunctionValue.h&quot;
</span><span class="cx"> #include &quot;CSSSelector.h&quot;
</span><span class="cx"> #include &quot;CSSSelectorList.h&quot;
</span><ins>+#include &quot;CSSVariableValue.h&quot;
</ins><span class="cx"> #include &quot;SelectorPseudoTypeMap.h&quot;
</span><span class="cx"> #include &lt;wtf/text/StringBuilder.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -67,22 +69,19 @@
</span><span class="cx">         m_values.append(*(valueList.valueAt(i)));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-String CSSParserValueList::toString()
</del><ins>+bool CSSParserValueList::containsVariables() const
</ins><span class="cx"> {
</span><del>-    // Build up a set of CSSValues and serialize them using cssText, separating multiple values
-    // with spaces.
-    // FIXME: Teach CSSParserValues how to serialize so that we don't have to create CSSValues
-    // just to perform this serialization.
-    StringBuilder builder;
</del><span class="cx">     for (unsigned i = 0; i &lt; size(); i++) {
</span><del>-        if (i)
-            builder.append(' ');
-        RefPtr&lt;CSSValue&gt; cssValue = valueAt(i)-&gt;createCSSValue();
-        if (!cssValue)
-            return &quot;&quot;;
-        builder.append(cssValue-&gt;cssText());
</del><ins>+        auto* parserValue = &amp;m_values[i];
+        if (parserValue-&gt;unit == CSSParserValue::Variable)
+            return true;
+        if (parserValue-&gt;unit == CSSParserValue::Function &amp;&amp; parserValue-&gt;function-&gt;args
+            &amp;&amp; parserValue-&gt;function-&gt;args-&gt;containsVariables())
+            return true;
+        if (parserValue-&gt;unit == CSSParserValue::ValueList &amp;&amp; parserValue-&gt;valueList-&gt;containsVariables())
+            return true;
</ins><span class="cx">     }
</span><del>-    return builder.toString().lower();
</del><ins>+    return false;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> PassRefPtr&lt;CSSValue&gt; CSSParserValue::createCSSValue()
</span><span class="lines">@@ -98,8 +97,11 @@
</span><span class="cx">     }
</span><span class="cx">     if (unit == CSSParserValue::Function)
</span><span class="cx">         return CSSFunctionValue::create(function);
</span><ins>+    if (unit == CSSParserValue::Variable)
+        return CSSVariableValue::create(variable);
</ins><span class="cx">     if (unit == CSSParserValue::ValueList)
</span><span class="cx">         return CSSValueList::createFromParserValueList(*valueList);
</span><ins>+
</ins><span class="cx">     if (unit &gt;= CSSParserValue::Q_EMS)
</span><span class="cx">         return CSSPrimitiveValue::createAllowingMarginQuirk(fValue, CSSPrimitiveValue::CSS_EMS);
</span><span class="cx"> 
</span><span class="lines">@@ -114,6 +116,9 @@
</span><span class="cx">     case CSSPrimitiveValue::CSS_STRING:
</span><span class="cx">     case CSSPrimitiveValue::CSS_URI:
</span><span class="cx">     case CSSPrimitiveValue::CSS_PARSER_HEXCOLOR:
</span><ins>+    case CSSPrimitiveValue::CSS_DIMENSION:
+    case CSSPrimitiveValue::CSS_UNICODE_RANGE:
+    case CSSPrimitiveValue::CSS_PARSER_WHITESPACE:
</ins><span class="cx">         return CSSPrimitiveValue::create(string, primitiveUnit);
</span><span class="cx">     case CSSPrimitiveValue::CSS_PERCENTAGE:
</span><span class="cx">     case CSSPrimitiveValue::CSS_EMS:
</span><span class="lines">@@ -141,7 +146,6 @@
</span><span class="cx">     case CSSPrimitiveValue::CSS_FR:
</span><span class="cx">         return CSSPrimitiveValue::create(fValue, primitiveUnit);
</span><span class="cx">     case CSSPrimitiveValue::CSS_UNKNOWN:
</span><del>-    case CSSPrimitiveValue::CSS_DIMENSION:
</del><span class="cx">     case CSSPrimitiveValue::CSS_ATTR:
</span><span class="cx">     case CSSPrimitiveValue::CSS_COUNTER:
</span><span class="cx">     case CSSPrimitiveValue::CSS_RECT:
</span><span class="lines">@@ -153,7 +157,6 @@
</span><span class="cx"> #if ENABLE(DASHBOARD_SUPPORT)
</span><span class="cx">     case CSSPrimitiveValue::CSS_DASHBOARD_REGION:
</span><span class="cx"> #endif
</span><del>-    case CSSPrimitiveValue::CSS_UNICODE_RANGE:
</del><span class="cx">     case CSSPrimitiveValue::CSS_PARSER_OPERATOR:
</span><span class="cx">     case CSSPrimitiveValue::CSS_PARSER_INTEGER:
</span><span class="cx">     case CSSPrimitiveValue::CSS_PARSER_IDENTIFIER:
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCorecssCSSParserValuesh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/css/CSSParserValues.h (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/css/CSSParserValues.h        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/Source/WebCore/css/CSSParserValues.h        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -25,6 +25,7 @@
</span><span class="cx"> #include &quot;CSSValueKeywords.h&quot;
</span><span class="cx"> #include &quot;CSSValueList.h&quot;
</span><span class="cx"> #include &lt;wtf/text/AtomicString.h&gt;
</span><ins>+#include &lt;wtf/text/AtomicStringHash.h&gt;
</ins><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -104,6 +105,7 @@
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> struct CSSParserFunction;
</span><ins>+struct CSSParserVariable;
</ins><span class="cx"> 
</span><span class="cx"> struct CSSParserValue {
</span><span class="cx">     CSSValueID id;
</span><span class="lines">@@ -113,6 +115,7 @@
</span><span class="cx">         int iValue;
</span><span class="cx">         CSSParserString string;
</span><span class="cx">         CSSParserFunction* function;
</span><ins>+        CSSParserVariable* variable;
</ins><span class="cx">         CSSParserValueList* valueList;
</span><span class="cx">     };
</span><span class="cx">     enum {
</span><span class="lines">@@ -120,6 +123,7 @@
</span><span class="cx">         Function  = 0x100001,
</span><span class="cx">         ValueList = 0x100002,
</span><span class="cx">         Q_EMS     = 0x100003,
</span><ins>+        Variable  = 0x100004
</ins><span class="cx">     };
</span><span class="cx">     int unit;
</span><span class="cx"> 
</span><span class="lines">@@ -167,6 +171,8 @@
</span><span class="cx">     void clear() { m_values.clear(); }
</span><span class="cx">     
</span><span class="cx">     String toString();
</span><ins>+    
+    bool containsVariables() const;
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     unsigned m_current;
</span><span class="lines">@@ -180,6 +186,13 @@
</span><span class="cx">     std::unique_ptr&lt;CSSParserValueList&gt; args;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+struct CSSParserVariable {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    CSSParserString name; // The custom property name
+    std::unique_ptr&lt;CSSParserValueList&gt; args; // The fallback args
+};
+
</ins><span class="cx"> enum class CSSParserSelectorCombinator {
</span><span class="cx">     Child,
</span><span class="cx">     DescendantSpace,
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCorecssCSSPrimitiveValuecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/css/CSSPrimitiveValue.cpp (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/css/CSSPrimitiveValue.cpp        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/Source/WebCore/css/CSSPrimitiveValue.cpp        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -117,6 +117,7 @@
</span><span class="cx">     case CSSPrimitiveValue::CSS_PARSER_IDENTIFIER:
</span><span class="cx">     case CSSPrimitiveValue::CSS_PARSER_INTEGER:
</span><span class="cx">     case CSSPrimitiveValue::CSS_PARSER_OPERATOR:
</span><ins>+    case CSSPrimitiveValue::CSS_PARSER_WHITESPACE:
</ins><span class="cx">     case CSSPrimitiveValue::CSS_RECT:
</span><span class="cx">     case CSSPrimitiveValue::CSS_QUAD:
</span><span class="cx"> #if ENABLE(CSS_SCROLL_SNAP)
</span><span class="lines">@@ -452,6 +453,7 @@
</span><span class="cx">     case CSS_ATTR:
</span><span class="cx">     case CSS_COUNTER_NAME:
</span><span class="cx">     case CSS_PARSER_HEXCOLOR:
</span><ins>+    case CSS_PARSER_WHITESPACE:
</ins><span class="cx">         if (m_value.string)
</span><span class="cx">             m_value.string-&gt;deref();
</span><span class="cx">         break;
</span><span class="lines">@@ -1169,7 +1171,9 @@
</span><span class="cx">         return String(&amp;c, 1U);
</span><span class="cx">     }
</span><span class="cx">     case CSS_PARSER_IDENTIFIER:
</span><del>-        return quoteCSSStringIfNeeded(m_value.string);
</del><ins>+        return m_value.string;
+    case CSS_PARSER_WHITESPACE:
+        return &quot; &quot;;
</ins><span class="cx">     case CSS_CALC:
</span><span class="cx">         return m_value.calc-&gt;cssText();
</span><span class="cx">     case CSS_SHAPE:
</span><span class="lines">@@ -1304,6 +1308,7 @@
</span><span class="cx">     case CSS_UNKNOWN:
</span><span class="cx">     case CSS_PARSER_OPERATOR:
</span><span class="cx">     case CSS_PARSER_IDENTIFIER:
</span><ins>+    case CSS_PARSER_WHITESPACE:
</ins><span class="cx">     case CSS_PARSER_HEXCOLOR:
</span><span class="cx">         ASSERT_NOT_REACHED();
</span><span class="cx">         break;
</span><span class="lines">@@ -1363,6 +1368,7 @@
</span><span class="cx">     case CSS_COUNTER_NAME:
</span><span class="cx">     case CSS_PARSER_IDENTIFIER:
</span><span class="cx">     case CSS_PARSER_HEXCOLOR:
</span><ins>+    case CSS_PARSER_WHITESPACE:
</ins><span class="cx">         return equal(m_value.string, other.m_value.string);
</span><span class="cx">     case CSS_COUNTER:
</span><span class="cx">         return m_value.counter &amp;&amp; other.m_value.counter &amp;&amp; m_value.counter-&gt;equals(*other.m_value.counter);
</span><span class="lines">@@ -1394,4 +1400,76 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool CSSPrimitiveValue::buildParserValue(CSSParserValue* result) const
+{
+    switch (m_primitiveUnitType) {
+    case CSS_VALUE_ID:
+        result-&gt;id = m_value.valueID;
+        result-&gt;unit = CSSPrimitiveValue::CSS_IDENT;
+        result-&gt;string.init(valueName(m_value.valueID));
+        break;
+    case CSS_PARSER_IDENTIFIER:
+        result-&gt;id = CSSValueInvalid;
+        result-&gt;unit = CSSPrimitiveValue::CSS_IDENT;
+        result-&gt;string.init(m_value.string);
+        break;
+    case CSS_NUMBER:
+    case CSS_PERCENTAGE:
+    case CSS_EMS:
+    case CSS_EXS:
+    case CSS_REMS:
+    case CSS_PX:
+    case CSS_CM:
+#if ENABLE(CSS_IMAGE_RESOLUTION) || ENABLE(RESOLUTION_MEDIA_QUERY)
+    case CSS_DPPX:
+    case CSS_DPI:
+    case CSS_DPCM:
+#endif
+    case CSS_MM:
+    case CSS_IN:
+    case CSS_PT:
+    case CSS_PC:
+    case CSS_DEG:
+    case CSS_RAD:
+    case CSS_GRAD:
+    case CSS_MS:
+    case CSS_S:
+    case CSS_HZ:
+    case CSS_KHZ:
+    case CSS_TURN:
+    case CSS_VW:
+    case CSS_VH:
+    case CSS_VMIN:
+    case CSS_DIMENSION:
+    case CSS_FR:
+        result-&gt;fValue = m_value.num;
+        result-&gt;unit = m_primitiveUnitType;
+        break;
+    case CSS_PARSER_INTEGER:
+        result-&gt;fValue = m_value.num;
+        result-&gt;unit = CSSPrimitiveValue::CSS_NUMBER;
+        result-&gt;isInt = true;
+        break;
+    case CSS_PARSER_OPERATOR:
+        result-&gt;iValue = m_value.parserOperator;
+        result-&gt;unit = CSSParserValue::Operator;
+        break;
+    case CSS_STRING:
+    case CSS_URI:
+    case CSS_ATTR:
+    case CSS_COUNTER_NAME:
+    case CSS_PARSER_HEXCOLOR:
+        result-&gt;string.init(m_value.string);
+        result-&gt;unit = m_primitiveUnitType;
+        break;
+    case CSS_PARSER_WHITESPACE:
+        return false;
+    default:
+        ASSERT_NOT_REACHED();
+        break;
+    }
+    
+    return true;
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCorecssCSSPrimitiveValueh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/css/CSSPrimitiveValue.h (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/css/CSSPrimitiveValue.h        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/Source/WebCore/css/CSSPrimitiveValue.h        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -44,6 +44,7 @@
</span><span class="cx"> class Rect;
</span><span class="cx"> class RenderStyle;
</span><span class="cx"> class CSSBasicShape;
</span><ins>+struct CSSParserValue;
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(CSS_SCROLL_SNAP)
</span><span class="cx"> class LengthRepeat;
</span><span class="lines">@@ -153,7 +154,10 @@
</span><span class="cx">         CSS_FONT_FAMILY = 116,
</span><span class="cx"> 
</span><span class="cx">         CSS_PROPERTY_ID = 117,
</span><del>-        CSS_VALUE_ID = 118
</del><ins>+        CSS_VALUE_ID = 118,
+        
+        // More internal parse stuff for CSS variables
+        CSS_PARSER_WHITESPACE = 119
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     // This enum follows the CSSParser::Units enum augmented with UNIT_FREQUENCY for frequencies.
</span><span class="lines">@@ -232,6 +236,9 @@
</span><span class="cx">     bool isViewportPercentageMin() const { return m_primitiveUnitType == CSS_VMIN; }
</span><span class="cx">     bool isValueID() const { return m_primitiveUnitType == CSS_VALUE_ID; }
</span><span class="cx">     bool isFlex() const { return primitiveType() == CSS_FR; }
</span><ins>+    
+    bool isParserOperator() const { return primitiveType() == CSS_PARSER_OPERATOR; }
+    int parserOperator() const { return isParserOperator() ? m_value.parserOperator : 0; }
</ins><span class="cx"> 
</span><span class="cx">     static Ref&lt;CSSPrimitiveValue&gt; createIdentifier(CSSValueID valueID) { return adoptRef(*new CSSPrimitiveValue(valueID)); }
</span><span class="cx">     static Ref&lt;CSSPrimitiveValue&gt; createIdentifier(CSSPropertyID propertyID) { return adoptRef(*new CSSPrimitiveValue(propertyID)); }
</span><span class="lines">@@ -266,7 +273,9 @@
</span><span class="cx">     unsigned short primitiveType() const;
</span><span class="cx"> 
</span><span class="cx">     double computeDegrees() const;
</span><del>-
</del><ins>+    
+    bool buildParserValue(CSSParserValue*) const;
+    
</ins><span class="cx">     enum TimeUnit { Seconds, Milliseconds };
</span><span class="cx">     template &lt;typename T, TimeUnit timeUnit&gt; T computeTime() const
</span><span class="cx">     {
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCorecssCSSValuecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/css/CSSValue.cpp (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/css/CSSValue.cpp        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/Source/WebCore/css/CSSValue.cpp        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -55,6 +55,8 @@
</span><span class="cx"> #include &quot;CSSTimingFunctionValue.h&quot;
</span><span class="cx"> #include &quot;CSSUnicodeRangeValue.h&quot;
</span><span class="cx"> #include &quot;CSSValueList.h&quot;
</span><ins>+#include &quot;CSSVariableDependentValue.h&quot;
+#include &quot;CSSVariableValue.h&quot;
</ins><span class="cx"> #include &quot;SVGColor.h&quot;
</span><span class="cx"> #include &quot;SVGPaint.h&quot;
</span><span class="cx"> #include &quot;WebKitCSSFilterValue.h&quot;
</span><span class="lines">@@ -239,7 +241,10 @@
</span><span class="cx">             return compareCSSValues&lt;CSSContentDistributionValue&gt;(*this, other);
</span><span class="cx">         case CustomPropertyClass:
</span><span class="cx">             return compareCSSValues&lt;CSSCustomPropertyValue&gt;(*this, other);
</span><del>-        
</del><ins>+        case VariableDependentClass:
+            return compareCSSValues&lt;CSSVariableDependentValue&gt;(*this, other);
+        case VariableClass:
+            return compareCSSValues&lt;CSSVariableValue&gt;(*this, other);
</ins><span class="cx">         default:
</span><span class="cx">             ASSERT_NOT_REACHED();
</span><span class="cx">             return false;
</span><span class="lines">@@ -336,6 +341,10 @@
</span><span class="cx">         return downcast&lt;CSSContentDistributionValue&gt;(*this).customCSSText();
</span><span class="cx">     case CustomPropertyClass:
</span><span class="cx">         return downcast&lt;CSSCustomPropertyValue&gt;(*this).customCSSText();
</span><ins>+    case VariableDependentClass:
+        return downcast&lt;CSSVariableDependentValue&gt;(*this).customCSSText();
+    case VariableClass:
+        return downcast&lt;CSSVariableValue&gt;(*this).customCSSText();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     ASSERT_NOT_REACHED();
</span><span class="lines">@@ -463,6 +472,12 @@
</span><span class="cx">     case CustomPropertyClass:
</span><span class="cx">         delete downcast&lt;CSSCustomPropertyValue&gt;(this);
</span><span class="cx">         return;
</span><ins>+    case VariableDependentClass:
+        delete downcast&lt;CSSVariableDependentValue&gt;(this);
+        return;
+    case VariableClass:
+        delete downcast&lt;CSSVariableValue&gt;(this);
+        return;
</ins><span class="cx">     }
</span><span class="cx">     ASSERT_NOT_REACHED();
</span><span class="cx"> }
</span><span class="lines">@@ -495,4 +510,9 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool CSSValue::isInvalidCustomPropertyValue() const
+{
+    return isCustomPropertyValue() &amp;&amp; downcast&lt;CSSCustomPropertyValue&gt;(*this).isInvalid();
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="branchessafari601146branchSourceWebCorecssCSSValueh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/css/CSSValue.h (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/css/CSSValue.h        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/Source/WebCore/css/CSSValue.h        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -60,6 +60,7 @@
</span><span class="cx">     Type cssValueType() const;
</span><span class="cx"> 
</span><span class="cx">     String cssText() const;
</span><ins>+
</ins><span class="cx">     void setCssText(const String&amp;, ExceptionCode&amp;) { } // FIXME: Not implemented.
</span><span class="cx"> 
</span><span class="cx">     bool isPrimitiveValue() const { return m_classType == PrimitiveClass; }
</span><span class="lines">@@ -74,6 +75,9 @@
</span><span class="cx">     bool isCrossfadeValue() const { return m_classType == CrossfadeClass; }
</span><span class="cx">     bool isCursorImageValue() const { return m_classType == CursorImageClass; }
</span><span class="cx">     bool isCustomPropertyValue() const { return m_classType == CustomPropertyClass; }
</span><ins>+    bool isInvalidCustomPropertyValue() const;
+    bool isVariableDependentValue() const { return m_classType == VariableDependentClass; }
+    bool isVariableValue() const { return m_classType == VariableClass; }
</ins><span class="cx">     bool isFunctionValue() const { return m_classType == FunctionClass; }
</span><span class="cx">     bool isFontFeatureValue() const { return m_classType == FontFeatureClass; }
</span><span class="cx">     bool isFontFaceSrcValue() const { return m_classType == FontFaceSrcClass; }
</span><span class="lines">@@ -178,7 +182,9 @@
</span><span class="cx"> 
</span><span class="cx">         CSSContentDistributionClass,
</span><span class="cx">         CustomPropertyClass,
</span><del>-        
</del><ins>+        VariableDependentClass,
+        VariableClass,
+
</ins><span class="cx">         // List class types must appear after ValueListClass.
</span><span class="cx">         ValueListClass,
</span><span class="cx"> #if ENABLE(CSS_IMAGE_SET)
</span><span class="lines">@@ -235,6 +241,8 @@
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     unsigned m_classType : ClassTypeBits; // ClassType
</span><ins>+    
+friend class CSSValueList;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> template&lt;typename CSSValueType&gt;
</span><span class="lines">@@ -266,6 +274,8 @@
</span><span class="cx">     return first.get().equals(second);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+typedef HashMap&lt;AtomicString, RefPtr&lt;CSSValue&gt;&gt; CustomPropertyValueMap;
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #define SPECIALIZE_TYPE_TRAITS_CSS_VALUE(ToValueTypeName, predicate) \
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCorecssCSSValueListcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/css/CSSValueList.cpp (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/css/CSSValueList.cpp        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/Source/WebCore/css/CSSValueList.cpp        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -21,7 +21,11 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;CSSValueList.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;CSSFunctionValue.h&quot;
</ins><span class="cx"> #include &quot;CSSParserValues.h&quot;
</span><ins>+#include &quot;CSSPrimitiveValue.h&quot;
+#include &quot;CSSVariableDependentValue.h&quot;
+#include &quot;CSSVariableValue.h&quot;
</ins><span class="cx"> #include &lt;wtf/text/StringBuilder.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -114,7 +118,13 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     for (auto&amp; value : m_values) {
</span><del>-        if (!result.isEmpty())
</del><ins>+        bool suppressSeparator = false;
+        if (m_valueListSeparator == SpaceSeparator &amp;&amp; value-&gt;isPrimitiveValue()) {
+            auto* primitiveValue = &amp;downcast&lt;CSSPrimitiveValue&gt;(*value.ptr());
+            if (primitiveValue-&gt;parserOperator() == ',')
+                suppressSeparator = true;
+        }
+        if (!suppressSeparator &amp;&amp; !result.isEmpty())
</ins><span class="cx">             result.append(separator);
</span><span class="cx">         result.append(value.get().cssText());
</span><span class="cx">     }
</span><span class="lines">@@ -174,4 +184,100 @@
</span><span class="cx">     return adoptRef(new CSSValueList(*this));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+
+bool CSSValueList::containsVariables() const
+{
+    for (unsigned i = 0; i &lt; m_values.size(); i++) {
+        if (m_values[i]-&gt;isVariableValue())
+            return true;
+        if (m_values[i]-&gt;isFunctionValue()) {
+            auto&amp; functionValue = downcast&lt;CSSFunctionValue&gt;(*item(i));
+            CSSValueList* args = functionValue.arguments();
+            if (args &amp;&amp; args-&gt;containsVariables())
+                return true;
+        } else if (m_values[i]-&gt;isValueList()) {
+            auto&amp; listValue = downcast&lt;CSSValueList&gt;(*item(i));
+            if (listValue.containsVariables())
+                return true;
+        }
+    }
+    return false;
+}
+
+bool CSSValueList::checkVariablesForCycles(CustomPropertyValueMap&amp; customProperties, HashSet&lt;AtomicString&gt;&amp; seenProperties, HashSet&lt;AtomicString&gt;&amp; invalidProperties) const
+{
+    for (unsigned i = 0; i &lt; m_values.size(); i++) {
+        auto* value = item(i);
+        if (value-&gt;isVariableValue()) {
+            auto&amp; variableValue = downcast&lt;CSSVariableValue&gt;(*value);
+            if (seenProperties.contains(variableValue.name()))
+                return false;
+            RefPtr&lt;CSSValue&gt; value = customProperties.get(variableValue.name());
+            if (value &amp;&amp; value-&gt;isVariableDependentValue() &amp;&amp; !downcast&lt;CSSVariableDependentValue&gt;(*value).checkVariablesForCycles(variableValue.name(), customProperties, seenProperties, invalidProperties))
+                return false;
+
+            // Have to check the fallback values.
+            auto* fallbackArgs = variableValue.fallbackArguments();
+            if (!fallbackArgs || !fallbackArgs-&gt;length())
+                continue;
+            
+            if (!fallbackArgs-&gt;checkVariablesForCycles(customProperties, seenProperties, invalidProperties))
+                return false;
+        } else if (value-&gt;isFunctionValue()) {
+            auto&amp; functionValue = downcast&lt;CSSFunctionValue&gt;(*value);
+            auto* args = functionValue.arguments();
+            if (args &amp;&amp; !args-&gt;checkVariablesForCycles(customProperties, seenProperties, invalidProperties))
+                return false;
+        } else if (value-&gt;isValueList()) {
+            auto&amp; listValue = downcast&lt;CSSValueList&gt;(*value);
+            if (!listValue.checkVariablesForCycles(customProperties, seenProperties, invalidProperties))
+                return false;
+        }
+    }
+    return true;
+}
+
+bool CSSValueList::buildParserValueSubstitutingVariables(CSSParserValue* result, const CustomPropertyValueMap&amp; customProperties) const
+{
+    result-&gt;id = CSSValueInvalid;
+    result-&gt;unit = CSSParserValue::ValueList;
+    result-&gt;valueList = new CSSParserValueList();
+    return buildParserValueListSubstitutingVariables(result-&gt;valueList, customProperties);
+}
+
+bool CSSValueList::buildParserValueListSubstitutingVariables(CSSParserValueList* parserList, const CustomPropertyValueMap&amp; customProperties) const
+{
+    for (unsigned i = 0; i &lt; m_values.size(); ++i) {
+        CSSParserValue result;
+        result.id = CSSValueInvalid;
+        switch (m_values[i]-&gt;classType()) {
+        case FunctionClass:
+            if (!downcast&lt;CSSFunctionValue&gt;(*m_values[i].ptr()).buildParserValueSubstitutingVariables(&amp;result, customProperties))
+                return false;
+            parserList-&gt;addValue(result);
+            break;
+        case ValueListClass:
+            if (!downcast&lt;CSSValueList&gt;(*m_values[i].ptr()).buildParserValueSubstitutingVariables(&amp;result, customProperties))
+                return false;
+            parserList-&gt;addValue(result);
+            break;
+        case VariableClass: {
+            if (!downcast&lt;CSSVariableValue&gt;(*m_values[i].ptr()).buildParserValueListSubstitutingVariables(parserList, customProperties))
+                return false;
+            break;
+        }
+        case PrimitiveClass:
+            // FIXME: Will have to change this if we start preserving invalid tokens.
+            if (downcast&lt;CSSPrimitiveValue&gt;(*m_values[i].ptr()).buildParserValue(&amp;result))
+                parserList-&gt;addValue(result);
+            break;
+        default:
+            ASSERT_NOT_REACHED();
+            break;
+            return false;
+        }
+    }
+    return true;
+}
+    
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCorecssCSSValueListh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/css/CSSValueList.h (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/css/CSSValueList.h        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/Source/WebCore/css/CSSValueList.h        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+struct CSSParserValue;
</ins><span class="cx"> class CSSParserValueList;
</span><span class="cx"> 
</span><span class="cx"> class CSSValueList : public CSSValue {
</span><span class="lines">@@ -78,6 +79,12 @@
</span><span class="cx">     
</span><span class="cx">     PassRefPtr&lt;CSSValueList&gt; cloneForCSSOM() const;
</span><span class="cx"> 
</span><ins>+    bool containsVariables() const;
+    bool checkVariablesForCycles(CustomPropertyValueMap&amp; customProperties, HashSet&lt;AtomicString&gt;&amp; seenProperties, HashSet&lt;AtomicString&gt;&amp; invalidProperties) const;
+    
+    bool buildParserValueListSubstitutingVariables(CSSParserValueList*, const CustomPropertyValueMap&amp; customProperties) const;
+    bool buildParserValueSubstitutingVariables(CSSParserValue*, const CustomPropertyValueMap&amp; customProperties) const;
+    
</ins><span class="cx"> protected:
</span><span class="cx">     CSSValueList(ClassType, ValueListSeparator);
</span><span class="cx">     CSSValueList(const CSSValueList&amp; cloneFrom);
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCorecssCSSVariableDependentValuecppfromrev193503branchessafari601branchSourceWebCorecssCSSVariableDependentValuecpp"></a>
<div class="copfile"><h4>Copied: branches/safari-601.1.46-branch/Source/WebCore/css/CSSVariableDependentValue.cpp (from rev 193503, branches/safari-601-branch/Source/WebCore/css/CSSVariableDependentValue.cpp) (0 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/css/CSSVariableDependentValue.cpp                                (rev 0)
+++ branches/safari-601.1.46-branch/Source/WebCore/css/CSSVariableDependentValue.cpp        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -0,0 +1,49 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;CSSVariableDependentValue.h&quot;
+
+#include &quot;CSSCustomPropertyValue.h&quot;
+#include &lt;wtf/text/AtomicStringHash.h&gt;
+
+namespace WebCore {
+
+bool CSSVariableDependentValue::checkVariablesForCycles(const AtomicString&amp; name, CustomPropertyValueMap&amp; customProperties, const HashSet&lt;AtomicString&gt;&amp; seenProperties, HashSet&lt;AtomicString&gt;&amp; invalidProperties)
+{
+    if (invalidProperties.contains(name))
+        return false;
+
+    HashSet&lt;AtomicString&gt; newSeenProperties = seenProperties;
+    newSeenProperties.add(name);
+    
+    bool valid = valueList()-&gt;checkVariablesForCycles(customProperties, newSeenProperties, invalidProperties);
+    if (!valid)
+        invalidProperties.add(name);
+
+    return valid;
+}
+
+}
</ins></span></pre></div>
<a id="branchessafari601146branchSourceWebCorecssCSSVariableDependentValuehfromrev193503branchessafari601branchSourceWebCorecssCSSVariableDependentValueh"></a>
<div class="copfile"><h4>Copied: branches/safari-601.1.46-branch/Source/WebCore/css/CSSVariableDependentValue.h (from rev 193503, branches/safari-601-branch/Source/WebCore/css/CSSVariableDependentValue.h) (0 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/css/CSSVariableDependentValue.h                                (rev 0)
+++ branches/safari-601.1.46-branch/Source/WebCore/css/CSSVariableDependentValue.h        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -0,0 +1,80 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CSSVariableDependentValue_h
+#define CSSVariableDependentValue_h
+
+#include &quot;CSSParserValues.h&quot;
+#include &quot;CSSPropertyNames.h&quot;
+#include &quot;CSSValueList.h&quot;
+#include &lt;wtf/RefPtr.h&gt;
+
+namespace WebCore {
+
+class CSSVariableDependentValue : public CSSValue {
+public:
+    static Ref&lt;CSSVariableDependentValue&gt; create(RefPtr&lt;CSSValueList&gt;&amp; valueList, CSSPropertyID propId)
+    {
+        return adoptRef(*new CSSVariableDependentValue(valueList, propId));
+    }
+    
+    String customCSSText() const
+    {
+        if (!m_serialized) {
+            m_serialized = true;
+            m_stringValue = m_valueList ? m_valueList-&gt;customCSSText() : emptyString();
+        }
+        return m_stringValue;
+    }
+    
+    // FIXME: Should arguably implement equals on all of the CSSParserValues, but CSSValue equivalence
+    // is rarely used, so serialization to compare is probably fine.
+    bool equals(const CSSVariableDependentValue&amp; other) const { return customCSSText() == other.customCSSText(); }
+    
+    CSSPropertyID propertyID() const { return m_propertyID; }
+    
+    CSSValueList* valueList() const { return m_valueList.get(); }
+
+    bool checkVariablesForCycles(const AtomicString&amp; name, CustomPropertyValueMap&amp; customProperties, const HashSet&lt;AtomicString&gt;&amp; seenProperties, HashSet&lt;AtomicString&gt;&amp; invalidProperties);
+
+private:
+    CSSVariableDependentValue(RefPtr&lt;CSSValueList&gt;&amp; valueList, CSSPropertyID propId)
+        : CSSValue(VariableDependentClass)
+        , m_valueList(valueList)
+        , m_propertyID(propId)
+    {
+    }
+
+    RefPtr&lt;CSSValueList&gt; m_valueList;
+    CSSPropertyID m_propertyID;
+    mutable String m_stringValue;
+    mutable bool m_serialized { false };
+};
+
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSVariableDependentValue, isVariableDependentValue())
+
+#endif // CSSCustomPropertyValue_h
</ins></span></pre></div>
<a id="branchessafari601146branchSourceWebCorecssCSSVariableValuecppfromrev193503branchessafari601branchSourceWebCorecssCSSVariableValuecpp"></a>
<div class="copfile"><h4>Copied: branches/safari-601.1.46-branch/Source/WebCore/css/CSSVariableValue.cpp (from rev 193503, branches/safari-601-branch/Source/WebCore/css/CSSVariableValue.cpp) (0 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/css/CSSVariableValue.cpp                                (rev 0)
+++ branches/safari-601.1.46-branch/Source/WebCore/css/CSSVariableValue.cpp        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -0,0 +1,90 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;CSSVariableValue.h&quot;
+
+#include &quot;CSSCustomPropertyValue.h&quot;
+#include &quot;CSSParserValues.h&quot;
+#include &quot;CSSValueList.h&quot;
+#include &quot;CSSVariableDependentValue.h&quot;
+#include &lt;wtf/text/StringBuilder.h&gt;
+
+namespace WebCore {
+
+CSSVariableValue::CSSVariableValue(CSSParserVariable* variable)
+    : CSSValue(VariableClass)
+    , m_name(variable-&gt;name)
+{
+    if (variable-&gt;args)
+        m_fallbackArguments = CSSValueList::createFromParserValueList(*variable-&gt;args);
+}
+
+CSSVariableValue::CSSVariableValue(const String&amp; name, PassRefPtr&lt;CSSValueList&gt; fallbackArgs)
+    : CSSValue(VariableClass)
+    , m_name(name)
+    , m_fallbackArguments(fallbackArgs)
+{
+}
+
+String CSSVariableValue::customCSSText() const
+{
+    StringBuilder result;
+    result.append(&quot;var(&quot;);
+    result.append(m_name);
+    if (m_fallbackArguments) {
+        result.append(&quot;, &quot;);
+        result.append(m_fallbackArguments-&gt;cssText());
+    }
+    result.append(&quot;)&quot;);
+    return result.toString();
+}
+
+bool CSSVariableValue::equals(const CSSVariableValue&amp; other) const
+{
+    return m_name == other.m_name &amp;&amp; compareCSSValuePtr(m_fallbackArguments, other.m_fallbackArguments);
+}
+
+bool CSSVariableValue::buildParserValueListSubstitutingVariables(CSSParserValueList* resultList, const CustomPropertyValueMap&amp; customProperties) const
+{
+    RefPtr&lt;CSSValue&gt; value = customProperties.get(m_name);
+    if (value &amp;&amp; value-&gt;isValueList()) {
+        auto&amp; variableList = downcast&lt;CSSValueList&gt;(*value);
+        return variableList.buildParserValueListSubstitutingVariables(resultList, customProperties);
+    }
+    
+    if (value &amp;&amp; value-&gt;isVariableDependentValue()) {
+        auto* variableList = downcast&lt;CSSVariableDependentValue&gt;(*value).valueList();
+        if (variableList)
+            return variableList-&gt;buildParserValueListSubstitutingVariables(resultList, customProperties);
+    }
+
+    // We failed to substitute the variable. If it has fallback arguments, use those instead.
+    if (!fallbackArguments() || !fallbackArguments()-&gt;length())
+        return false;
+    return fallbackArguments()-&gt;buildParserValueListSubstitutingVariables(resultList, customProperties);
+}
+
+}
</ins></span></pre></div>
<a id="branchessafari601146branchSourceWebCorecssCSSVariableValuehfromrev193503branchessafari601branchSourceWebCorecssCSSVariableValueh"></a>
<div class="copfile"><h4>Copied: branches/safari-601.1.46-branch/Source/WebCore/css/CSSVariableValue.h (from rev 193503, branches/safari-601-branch/Source/WebCore/css/CSSVariableValue.h) (0 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/css/CSSVariableValue.h                                (rev 0)
+++ branches/safari-601.1.46-branch/Source/WebCore/css/CSSVariableValue.h        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -0,0 +1,71 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CSSVariableValue_h
+#define CSSVariableValue_h
+
+#include &quot;CSSValue.h&quot;
+
+namespace WebCore {
+
+class CSSValueList;
+class CSSParserValueList;
+struct CSSParserVariable;
+
+class CSSVariableValue : public CSSValue {
+public:
+    static Ref&lt;CSSVariableValue&gt; create(CSSParserVariable* Variable)
+    {
+        return adoptRef(*new CSSVariableValue(Variable));
+    }
+
+    static Ref&lt;CSSVariableValue&gt; create(const String&amp; name, PassRefPtr&lt;CSSValueList&gt; fallbackArguments)
+    {
+        return adoptRef(*new CSSVariableValue(name, fallbackArguments));
+    }
+
+    String customCSSText() const;
+
+    bool equals(const CSSVariableValue&amp;) const;
+    
+    const String&amp; name() const { return m_name; }
+    CSSValueList* fallbackArguments() const { return m_fallbackArguments.get(); }
+
+    bool buildParserValueListSubstitutingVariables(CSSParserValueList*, const CustomPropertyValueMap&amp; customProperties) const;
+
+private:
+    explicit CSSVariableValue(CSSParserVariable*);
+    CSSVariableValue(const String&amp;, PassRefPtr&lt;CSSValueList&gt;);
+
+    String m_name;
+    RefPtr&lt;CSSValueList&gt; m_fallbackArguments;
+};
+
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSVariableValue, isVariableValue())
+
+#endif
+
</ins></span></pre></div>
<a id="branchessafari601146branchSourceWebCorecssStylePropertiescpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/css/StyleProperties.cpp (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/css/StyleProperties.cpp        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/Source/WebCore/css/StyleProperties.cpp        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #include &quot;CSSValueKeywords.h&quot;
</span><span class="cx"> #include &quot;CSSValueList.h&quot;
</span><span class="cx"> #include &quot;CSSValuePool.h&quot;
</span><ins>+#include &quot;CSSVariableDependentValue.h&quot;
</ins><span class="cx"> #include &quot;Document.h&quot;
</span><span class="cx"> #include &quot;PropertySetCSSStyleDeclaration.h&quot;
</span><span class="cx"> #include &quot;StylePropertyShorthand.h&quot;
</span><span class="lines">@@ -209,7 +210,7 @@
</span><span class="cx">     case CSSPropertyWebkitAnimation:
</span><span class="cx">         return getLayeredShorthandValue(webkitAnimationShorthand());
</span><span class="cx">     case CSSPropertyMarker: {
</span><del>-        RefPtr&lt;CSSValue&gt; value = getPropertyCSSValue(CSSPropertyMarkerStart);
</del><ins>+        RefPtr&lt;CSSValue&gt; value = getPropertyCSSValueInternal(CSSPropertyMarkerStart);
</ins><span class="cx">         if (value)
</span><span class="cx">             return value-&gt;cssText();
</span><span class="cx">         return String();
</span><span class="lines">@@ -231,8 +232,11 @@
</span><span class="cx"> 
</span><span class="cx"> String StyleProperties::borderSpacingValue(const StylePropertyShorthand&amp; shorthand) const
</span><span class="cx"> {
</span><del>-    RefPtr&lt;CSSValue&gt; horizontalValue = getPropertyCSSValue(shorthand.properties()[0]);
-    RefPtr&lt;CSSValue&gt; verticalValue = getPropertyCSSValue(shorthand.properties()[1]);
</del><ins>+    RefPtr&lt;CSSValue&gt; horizontalValue = getPropertyCSSValueInternal(shorthand.properties()[0]);
+    if (horizontalValue &amp;&amp; horizontalValue-&gt;isVariableDependentValue())
+        return horizontalValue-&gt;cssText();
+    
+    RefPtr&lt;CSSValue&gt; verticalValue = getPropertyCSSValueInternal(shorthand.properties()[1]);
</ins><span class="cx"> 
</span><span class="cx">     // While standard border-spacing property does not allow specifying border-spacing-vertical without
</span><span class="cx">     // specifying border-spacing-horizontal &lt;http://www.w3.org/TR/CSS21/tables.html#separated-borders&gt;,
</span><span class="lines">@@ -375,8 +379,10 @@
</span><span class="cx">     size_t numLayers = 0;
</span><span class="cx"> 
</span><span class="cx">     for (unsigned i = 0; i &lt; size; ++i) {
</span><del>-        values[i] = getPropertyCSSValue(shorthand.properties()[i]);
</del><ins>+        values[i] = getPropertyCSSValueInternal(shorthand.properties()[i]);
</ins><span class="cx">         if (values[i]) {
</span><ins>+            if (values[i]-&gt;isVariableDependentValue())
+                return values[i]-&gt;cssText();
</ins><span class="cx">             if (values[i]-&gt;isBaseValueList())
</span><span class="cx">                 numLayers = std::max(downcast&lt;CSSValueList&gt;(*values[i]).length(), numLayers);
</span><span class="cx">             else
</span><span class="lines">@@ -511,9 +517,11 @@
</span><span class="cx">     StringBuilder result;
</span><span class="cx">     for (unsigned i = 0; i &lt; shorthand.length(); ++i) {
</span><span class="cx">         if (!isPropertyImplicit(shorthand.properties()[i])) {
</span><del>-            RefPtr&lt;CSSValue&gt; value = getPropertyCSSValue(shorthand.properties()[i]);
</del><ins>+            RefPtr&lt;CSSValue&gt; value = getPropertyCSSValueInternal(shorthand.properties()[i]);
</ins><span class="cx">             if (!value)
</span><span class="cx">                 return String();
</span><ins>+            if (value-&gt;isVariableDependentValue())
+                return value-&gt;cssText();
</ins><span class="cx">             String valueText = value-&gt;cssText();
</span><span class="cx">             if (!i)
</span><span class="cx">                 commonValue = valueText;
</span><span class="lines">@@ -540,10 +548,12 @@
</span><span class="cx">     String res;
</span><span class="cx">     bool lastPropertyWasImportant = false;
</span><span class="cx">     for (unsigned i = 0; i &lt; shorthand.length(); ++i) {
</span><del>-        RefPtr&lt;CSSValue&gt; value = getPropertyCSSValue(shorthand.properties()[i]);
</del><ins>+        RefPtr&lt;CSSValue&gt; value = getPropertyCSSValueInternal(shorthand.properties()[i]);
</ins><span class="cx">         // FIXME: CSSInitialValue::cssText should generate the right value.
</span><span class="cx">         if (!value)
</span><span class="cx">             return String();
</span><ins>+        if (value-&gt;isVariableDependentValue())
+            return value-&gt;cssText();
</ins><span class="cx">         String text = value-&gt;cssText();
</span><span class="cx">         if (text.isNull())
</span><span class="cx">             return String();
</span><span class="lines">@@ -590,6 +600,17 @@
</span><span class="cx"> 
</span><span class="cx"> PassRefPtr&lt;CSSValue&gt; StyleProperties::getPropertyCSSValue(CSSPropertyID propertyID) const
</span><span class="cx"> {
</span><ins>+    PassRefPtr&lt;CSSValue&gt; value = getPropertyCSSValueInternal(propertyID);
+    if (value &amp;&amp; value-&gt;isVariableDependentValue()) {
+        auto&amp; dependentValue = downcast&lt;CSSVariableDependentValue&gt;(*value);
+        if (dependentValue.propertyID() != propertyID)
+            return CSSCustomPropertyValue::createInvalid(); // Have to return special &quot;pending-substitution&quot; value.
+    }
+    return value;
+}
+
+PassRefPtr&lt;CSSValue&gt; StyleProperties::getPropertyCSSValueInternal(CSSPropertyID propertyID) const
+{
</ins><span class="cx">     int foundPropertyIndex = findPropertyIndex(propertyID);
</span><span class="cx">     if (foundPropertyIndex == -1)
</span><span class="cx">         return 0;
</span><span class="lines">@@ -878,153 +899,159 @@
</span><span class="cx">         CSSPropertyID shorthandPropertyID = CSSPropertyInvalid;
</span><span class="cx">         CSSPropertyID borderFallbackShorthandProperty = CSSPropertyInvalid;
</span><span class="cx">         String value;
</span><ins>+        
+        if (property.value() &amp;&amp; property.value()-&gt;isVariableDependentValue()) {
+            auto&amp; dependentValue = downcast&lt;CSSVariableDependentValue&gt;(*property.value());
+            if (dependentValue.propertyID() != propertyID)
+                shorthandPropertyID = dependentValue.propertyID();
+        } else {
+            switch (propertyID) {
+            case CSSPropertyAnimationName:
+            case CSSPropertyAnimationDuration:
+            case CSSPropertyAnimationTimingFunction:
+            case CSSPropertyAnimationDelay:
+            case CSSPropertyAnimationIterationCount:
+            case CSSPropertyAnimationDirection:
+            case CSSPropertyAnimationFillMode:
+                shorthandPropertyID = CSSPropertyAnimation;
+                break;
+            case CSSPropertyBackgroundPositionX:
+                positionXPropertyIndex = n;
+                continue;
+            case CSSPropertyBackgroundPositionY:
+                positionYPropertyIndex = n;
+                continue;
+            case CSSPropertyBackgroundRepeatX:
+                repeatXPropertyIndex = n;
+                continue;
+            case CSSPropertyBackgroundRepeatY:
+                repeatYPropertyIndex = n;
+                continue;
+            case CSSPropertyBorderTopWidth:
+            case CSSPropertyBorderRightWidth:
+            case CSSPropertyBorderBottomWidth:
+            case CSSPropertyBorderLeftWidth:
+                if (!borderFallbackShorthandProperty)
+                    borderFallbackShorthandProperty = CSSPropertyBorderWidth;
+                FALLTHROUGH;
+            case CSSPropertyBorderTopStyle:
+            case CSSPropertyBorderRightStyle:
+            case CSSPropertyBorderBottomStyle:
+            case CSSPropertyBorderLeftStyle:
+                if (!borderFallbackShorthandProperty)
+                    borderFallbackShorthandProperty = CSSPropertyBorderStyle;
+                FALLTHROUGH;
+            case CSSPropertyBorderTopColor:
+            case CSSPropertyBorderRightColor:
+            case CSSPropertyBorderBottomColor:
+            case CSSPropertyBorderLeftColor:
+                if (!borderFallbackShorthandProperty)
+                    borderFallbackShorthandProperty = CSSPropertyBorderColor;
</ins><span class="cx"> 
</span><del>-        switch (propertyID) {
-        case CSSPropertyAnimationName:
-        case CSSPropertyAnimationDuration:
-        case CSSPropertyAnimationTimingFunction:
-        case CSSPropertyAnimationDelay:
-        case CSSPropertyAnimationIterationCount:
-        case CSSPropertyAnimationDirection:
-        case CSSPropertyAnimationFillMode:
-            shorthandPropertyID = CSSPropertyAnimation;
-            break;
-        case CSSPropertyBackgroundPositionX:
-            positionXPropertyIndex = n;
-            continue;
-        case CSSPropertyBackgroundPositionY:
-            positionYPropertyIndex = n;
-            continue;
-        case CSSPropertyBackgroundRepeatX:
-            repeatXPropertyIndex = n;
-            continue;
-        case CSSPropertyBackgroundRepeatY:
-            repeatYPropertyIndex = n;
-            continue;
-        case CSSPropertyBorderTopWidth:
-        case CSSPropertyBorderRightWidth:
-        case CSSPropertyBorderBottomWidth:
-        case CSSPropertyBorderLeftWidth:
-            if (!borderFallbackShorthandProperty)
-                borderFallbackShorthandProperty = CSSPropertyBorderWidth;
-            FALLTHROUGH;
-        case CSSPropertyBorderTopStyle:
-        case CSSPropertyBorderRightStyle:
-        case CSSPropertyBorderBottomStyle:
-        case CSSPropertyBorderLeftStyle:
-            if (!borderFallbackShorthandProperty)
-                borderFallbackShorthandProperty = CSSPropertyBorderStyle;
-            FALLTHROUGH;
-        case CSSPropertyBorderTopColor:
-        case CSSPropertyBorderRightColor:
-        case CSSPropertyBorderBottomColor:
-        case CSSPropertyBorderLeftColor:
-            if (!borderFallbackShorthandProperty)
-                borderFallbackShorthandProperty = CSSPropertyBorderColor;
-
-            // FIXME: Deal with cases where only some of border-(top|right|bottom|left) are specified.
-            ASSERT(CSSPropertyBorder - firstCSSProperty &lt; shorthandPropertyAppeared.size());
-            if (!shorthandPropertyAppeared[CSSPropertyBorder - firstCSSProperty]) {
-                value = borderPropertyValue(ReturnNullOnUncommonValues);
-                if (value.isNull())
-                    shorthandPropertyAppeared.set(CSSPropertyBorder - firstCSSProperty);
-                else
</del><ins>+                // FIXME: Deal with cases where only some of border-(top|right|bottom|left) are specified.
+                ASSERT(CSSPropertyBorder - firstCSSProperty &lt; shorthandPropertyAppeared.size());
+                if (!shorthandPropertyAppeared[CSSPropertyBorder - firstCSSProperty]) {
+                    value = borderPropertyValue(ReturnNullOnUncommonValues);
+                    if (value.isNull())
+                        shorthandPropertyAppeared.set(CSSPropertyBorder - firstCSSProperty);
+                    else
+                        shorthandPropertyID = CSSPropertyBorder;
+                } else if (shorthandPropertyUsed[CSSPropertyBorder - firstCSSProperty])
</ins><span class="cx">                     shorthandPropertyID = CSSPropertyBorder;
</span><del>-            } else if (shorthandPropertyUsed[CSSPropertyBorder - firstCSSProperty])
-                shorthandPropertyID = CSSPropertyBorder;
-            if (!shorthandPropertyID)
-                shorthandPropertyID = borderFallbackShorthandProperty;
-            break;
-        case CSSPropertyWebkitBorderHorizontalSpacing:
-        case CSSPropertyWebkitBorderVerticalSpacing:
-            shorthandPropertyID = CSSPropertyBorderSpacing;
-            break;
-        case CSSPropertyFontFamily:
-        case CSSPropertyLineHeight:
-        case CSSPropertyFontSize:
-        case CSSPropertyFontStyle:
-        case CSSPropertyFontVariant:
-        case CSSPropertyFontWeight:
-            // Don't use CSSPropertyFont because old UAs can't recognize them but are important for editing.
-            break;
-        case CSSPropertyListStyleType:
-        case CSSPropertyListStylePosition:
-        case CSSPropertyListStyleImage:
-            shorthandPropertyID = CSSPropertyListStyle;
-            break;
-        case CSSPropertyMarginTop:
-        case CSSPropertyMarginRight:
-        case CSSPropertyMarginBottom:
-        case CSSPropertyMarginLeft:
-            shorthandPropertyID = CSSPropertyMargin;
-            break;
-        case CSSPropertyOutlineWidth:
-        case CSSPropertyOutlineStyle:
-        case CSSPropertyOutlineColor:
-            shorthandPropertyID = CSSPropertyOutline;
-            break;
-        case CSSPropertyOverflowX:
-        case CSSPropertyOverflowY:
-            shorthandPropertyID = CSSPropertyOverflow;
-            break;
-        case CSSPropertyPaddingTop:
-        case CSSPropertyPaddingRight:
-        case CSSPropertyPaddingBottom:
-        case CSSPropertyPaddingLeft:
-            shorthandPropertyID = CSSPropertyPadding;
-            break;
-        case CSSPropertyTransitionProperty:
-        case CSSPropertyTransitionDuration:
-        case CSSPropertyTransitionTimingFunction:
-        case CSSPropertyTransitionDelay:
-            shorthandPropertyID = CSSPropertyTransition;
-            break;
-        case CSSPropertyWebkitAnimationName:
-        case CSSPropertyWebkitAnimationDuration:
-        case CSSPropertyWebkitAnimationTimingFunction:
-        case CSSPropertyWebkitAnimationDelay:
-        case CSSPropertyWebkitAnimationIterationCount:
-        case CSSPropertyWebkitAnimationDirection:
-        case CSSPropertyWebkitAnimationFillMode:
-            shorthandPropertyID = CSSPropertyWebkitAnimation;
-            break;
-        case CSSPropertyFlexDirection:
-        case CSSPropertyFlexWrap:
-            shorthandPropertyID = CSSPropertyFlexFlow;
-            break;
-        case CSSPropertyFlexBasis:
-        case CSSPropertyFlexGrow:
-        case CSSPropertyFlexShrink:
-            shorthandPropertyID = CSSPropertyFlex;
-            break;
-        case CSSPropertyWebkitMaskPositionX:
-        case CSSPropertyWebkitMaskPositionY:
-        case CSSPropertyWebkitMaskRepeatX:
-        case CSSPropertyWebkitMaskRepeatY:
-        case CSSPropertyWebkitMaskImage:
-        case CSSPropertyWebkitMaskRepeat:
-        case CSSPropertyWebkitMaskPosition:
-        case CSSPropertyWebkitMaskClip:
-        case CSSPropertyWebkitMaskOrigin:
-            shorthandPropertyID = CSSPropertyWebkitMask;
-            break;
-        case CSSPropertyPerspectiveOriginX:
-        case CSSPropertyPerspectiveOriginY:
-            shorthandPropertyID = CSSPropertyPerspectiveOrigin;
-            break;
-        case CSSPropertyTransformOriginX:
-        case CSSPropertyTransformOriginY:
-        case CSSPropertyTransformOriginZ:
-            shorthandPropertyID = CSSPropertyTransformOrigin;
-            break;
-        case CSSPropertyWebkitTransitionProperty:
-        case CSSPropertyWebkitTransitionDuration:
-        case CSSPropertyWebkitTransitionTimingFunction:
-        case CSSPropertyWebkitTransitionDelay:
-            shorthandPropertyID = CSSPropertyWebkitTransition;
-            break;
-        default:
-            break;
</del><ins>+                if (!shorthandPropertyID)
+                    shorthandPropertyID = borderFallbackShorthandProperty;
+                break;
+            case CSSPropertyWebkitBorderHorizontalSpacing:
+            case CSSPropertyWebkitBorderVerticalSpacing:
+                shorthandPropertyID = CSSPropertyBorderSpacing;
+                break;
+            case CSSPropertyFontFamily:
+            case CSSPropertyLineHeight:
+            case CSSPropertyFontSize:
+            case CSSPropertyFontStyle:
+            case CSSPropertyFontVariant:
+            case CSSPropertyFontWeight:
+                // Don't use CSSPropertyFont because old UAs can't recognize them but are important for editing.
+                break;
+            case CSSPropertyListStyleType:
+            case CSSPropertyListStylePosition:
+            case CSSPropertyListStyleImage:
+                shorthandPropertyID = CSSPropertyListStyle;
+                break;
+            case CSSPropertyMarginTop:
+            case CSSPropertyMarginRight:
+            case CSSPropertyMarginBottom:
+            case CSSPropertyMarginLeft:
+                shorthandPropertyID = CSSPropertyMargin;
+                break;
+            case CSSPropertyOutlineWidth:
+            case CSSPropertyOutlineStyle:
+            case CSSPropertyOutlineColor:
+                shorthandPropertyID = CSSPropertyOutline;
+                break;
+            case CSSPropertyOverflowX:
+            case CSSPropertyOverflowY:
+                shorthandPropertyID = CSSPropertyOverflow;
+                break;
+            case CSSPropertyPaddingTop:
+            case CSSPropertyPaddingRight:
+            case CSSPropertyPaddingBottom:
+            case CSSPropertyPaddingLeft:
+                shorthandPropertyID = CSSPropertyPadding;
+                break;
+            case CSSPropertyTransitionProperty:
+            case CSSPropertyTransitionDuration:
+            case CSSPropertyTransitionTimingFunction:
+            case CSSPropertyTransitionDelay:
+                shorthandPropertyID = CSSPropertyTransition;
+                break;
+            case CSSPropertyWebkitAnimationName:
+            case CSSPropertyWebkitAnimationDuration:
+            case CSSPropertyWebkitAnimationTimingFunction:
+            case CSSPropertyWebkitAnimationDelay:
+            case CSSPropertyWebkitAnimationIterationCount:
+            case CSSPropertyWebkitAnimationDirection:
+            case CSSPropertyWebkitAnimationFillMode:
+                shorthandPropertyID = CSSPropertyWebkitAnimation;
+                break;
+            case CSSPropertyFlexDirection:
+            case CSSPropertyFlexWrap:
+                shorthandPropertyID = CSSPropertyFlexFlow;
+                break;
+            case CSSPropertyFlexBasis:
+            case CSSPropertyFlexGrow:
+            case CSSPropertyFlexShrink:
+                shorthandPropertyID = CSSPropertyFlex;
+                break;
+            case CSSPropertyWebkitMaskPositionX:
+            case CSSPropertyWebkitMaskPositionY:
+            case CSSPropertyWebkitMaskRepeatX:
+            case CSSPropertyWebkitMaskRepeatY:
+            case CSSPropertyWebkitMaskImage:
+            case CSSPropertyWebkitMaskRepeat:
+            case CSSPropertyWebkitMaskPosition:
+            case CSSPropertyWebkitMaskClip:
+            case CSSPropertyWebkitMaskOrigin:
+                shorthandPropertyID = CSSPropertyWebkitMask;
+                break;
+            case CSSPropertyPerspectiveOriginX:
+            case CSSPropertyPerspectiveOriginY:
+                shorthandPropertyID = CSSPropertyPerspectiveOrigin;
+                break;
+            case CSSPropertyTransformOriginX:
+            case CSSPropertyTransformOriginY:
+            case CSSPropertyTransformOriginZ:
+                shorthandPropertyID = CSSPropertyTransformOrigin;
+                break;
+            case CSSPropertyWebkitTransitionProperty:
+            case CSSPropertyWebkitTransitionDuration:
+            case CSSPropertyWebkitTransitionTimingFunction:
+            case CSSPropertyWebkitTransitionDelay:
+                shorthandPropertyID = CSSPropertyWebkitTransition;
+                break;
+            default:
+                break;
+            }
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         unsigned shortPropertyIndex = shorthandPropertyID - firstCSSProperty;
</span><span class="lines">@@ -1318,7 +1345,7 @@
</span><span class="cx">     Vector&lt;CSSProperty, 256&gt; list;
</span><span class="cx">     list.reserveInitialCapacity(length);
</span><span class="cx">     for (unsigned i = 0; i &lt; length; ++i) {
</span><del>-        RefPtr&lt;CSSValue&gt; value = getPropertyCSSValue(set[i]);
</del><ins>+        RefPtr&lt;CSSValue&gt; value = getPropertyCSSValueInternal(set[i]);
</ins><span class="cx">         if (value)
</span><span class="cx">             list.append(CSSProperty(set[i], value.release(), false));
</span><span class="cx">     }
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCorecssStylePropertiesh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/css/StyleProperties.h (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/css/StyleProperties.h        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/Source/WebCore/css/StyleProperties.h        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -152,7 +152,9 @@
</span><span class="cx">     String borderSpacingValue(const StylePropertyShorthand&amp;) const;
</span><span class="cx">     String fontValue() const;
</span><span class="cx">     void appendFontLonghandValueIfExplicit(CSSPropertyID, StringBuilder&amp; result, String&amp; value) const;
</span><del>-
</del><ins>+    
+    PassRefPtr&lt;CSSValue&gt; getPropertyCSSValueInternal(CSSPropertyID) const;
+    
</ins><span class="cx">     friend class PropertySetCSSStyleDeclaration;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCorecssStyleResolvercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/css/StyleResolver.cpp (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/css/StyleResolver.cpp        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/Source/WebCore/css/StyleResolver.cpp        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -41,6 +41,8 @@
</span><span class="cx"> #include &quot;CSSFontSelector.h&quot;
</span><span class="cx"> #include &quot;CSSFontValue.h&quot;
</span><span class="cx"> #include &quot;CSSFunctionValue.h&quot;
</span><ins>+#include &quot;CSSInheritedValue.h&quot;
+#include &quot;CSSInitialValue.h&quot;
</ins><span class="cx"> #include &quot;CSSKeyframeRule.h&quot;
</span><span class="cx"> #include &quot;CSSKeyframesRule.h&quot;
</span><span class="cx"> #include &quot;CSSLineBoxContainValue.h&quot;
</span><span class="lines">@@ -56,6 +58,7 @@
</span><span class="cx"> #include &quot;CSSSupportsRule.h&quot;
</span><span class="cx"> #include &quot;CSSTimingFunctionValue.h&quot;
</span><span class="cx"> #include &quot;CSSValueList.h&quot;
</span><ins>+#include &quot;CSSVariableDependentValue.h&quot;
</ins><span class="cx"> #include &quot;CachedImage.h&quot;
</span><span class="cx"> #include &quot;CachedResourceLoader.h&quot;
</span><span class="cx"> #include &quot;CachedSVGDocument.h&quot;
</span><span class="lines">@@ -1903,15 +1906,32 @@
</span><span class="cx">     ASSERT_WITH_MESSAGE(!isShorthandCSSProperty(id), &quot;Shorthand property id = %d wasn't expanded at parsing time&quot;, id);
</span><span class="cx"> 
</span><span class="cx">     State&amp; state = m_state;
</span><ins>+    
+    RefPtr&lt;CSSValue&gt; valueToApply = value;
+    if (value-&gt;isVariableDependentValue()) {
+        valueToApply = resolvedVariableValue(id, *downcast&lt;CSSVariableDependentValue&gt;(value));
+        if (!valueToApply) {
+            if (CSSProperty::isInheritedProperty(id))
+                valueToApply = CSSInheritedValue::create();
+            else
+                valueToApply = CSSInitialValue::createExplicit();
+        }
+    }
</ins><span class="cx"> 
</span><span class="cx">     if (CSSProperty::isDirectionAwareProperty(id)) {
</span><span class="cx">         CSSPropertyID newId = CSSProperty::resolveDirectionAwareProperty(id, state.style()-&gt;direction(), state.style()-&gt;writingMode());
</span><span class="cx">         ASSERT(newId != id);
</span><del>-        return applyProperty(newId, value);
</del><ins>+        return applyProperty(newId, valueToApply.get());
</ins><span class="cx">     }
</span><ins>+    
+    CSSValue* valueToCheckForInheritInitial = valueToApply.get();
+    if (id == CSSPropertyCustom) {
+        CSSCustomPropertyValue* customProperty = &amp;downcast&lt;CSSCustomPropertyValue&gt;(*valueToApply);
+        valueToCheckForInheritInitial = customProperty-&gt;value().get();
+    }
</ins><span class="cx"> 
</span><del>-    bool isInherit = state.parentStyle() &amp;&amp; value-&gt;isInheritedValue();
-    bool isInitial = value-&gt;isInitialValue() || (!state.parentStyle() &amp;&amp; value-&gt;isInheritedValue());
</del><ins>+    bool isInherit = state.parentStyle() &amp;&amp; valueToCheckForInheritInitial-&gt;isInheritedValue();
+    bool isInitial = valueToCheckForInheritInitial-&gt;isInitialValue() || (!state.parentStyle() &amp;&amp; valueToCheckForInheritInitial-&gt;isInheritedValue());
</ins><span class="cx"> 
</span><span class="cx">     ASSERT(!isInherit || !isInitial); // isInherit -&gt; !isInitial &amp;&amp; isInitial -&gt; !isInherit
</span><span class="cx"> 
</span><span class="lines">@@ -1924,15 +1944,29 @@
</span><span class="cx">         state.parentStyle()-&gt;setHasExplicitlyInheritedProperties();
</span><span class="cx">     
</span><span class="cx">     if (id == CSSPropertyCustom) {
</span><del>-        CSSCustomPropertyValue* customProperty = &amp;downcast&lt;CSSCustomPropertyValue&gt;(*value);
-        state.style()-&gt;setCustomPropertyValue(customProperty-&gt;name(), value);
</del><ins>+        CSSCustomPropertyValue* customProperty = &amp;downcast&lt;CSSCustomPropertyValue&gt;(*valueToApply);
+        if (isInherit) {
+            RefPtr&lt;CSSValue&gt; customVal = state.parentStyle()-&gt;getCustomPropertyValue(customProperty-&gt;name());
+            if (!customVal)
+                customVal = CSSCustomPropertyValue::createInvalid();
+            state.style()-&gt;setCustomPropertyValue(customProperty-&gt;name(), customVal);
+        } else if (isInitial)
+            state.style()-&gt;setCustomPropertyValue(customProperty-&gt;name(), CSSCustomPropertyValue::createInvalid());
+        else
+            state.style()-&gt;setCustomPropertyValue(customProperty-&gt;name(), customProperty-&gt;value());
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Use the generated StyleBuilder.
</span><del>-    StyleBuilder::applyProperty(id, *this, *value, isInitial, isInherit);
</del><ins>+    StyleBuilder::applyProperty(id, *this, *valueToApply, isInitial, isInherit);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+RefPtr&lt;CSSValue&gt; StyleResolver::resolvedVariableValue(CSSPropertyID propID, const CSSVariableDependentValue&amp; value)
+{
+    CSSParser parser(m_state.document());
+    return parser.parseVariableDependentValue(propID, value, m_state.style()-&gt;customProperties());
+}
+
</ins><span class="cx"> PassRefPtr&lt;StyleImage&gt; StyleResolver::styleImage(CSSPropertyID property, CSSValue&amp; value)
</span><span class="cx"> {
</span><span class="cx">     if (is&lt;CSSImageValue&gt;(value))
</span><span class="lines">@@ -2697,6 +2731,9 @@
</span><span class="cx">         ASSERT(!shouldApplyPropertyInParseOrder(propertyID));
</span><span class="cx">         property.apply(*this);
</span><span class="cx">     }
</span><ins>+    
+    if (firstProperty == CSSPropertyCustom)
+        m_state.style()-&gt;checkVariablesInCustomProperties();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCorecssStyleResolverh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/css/StyleResolver.h (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/css/StyleResolver.h        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/Source/WebCore/css/StyleResolver.h        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -471,6 +471,7 @@
</span><span class="cx">     bool canShareStyleWithControl(StyledElement*) const;
</span><span class="cx"> 
</span><span class="cx">     void applyProperty(CSSPropertyID, CSSValue*);
</span><ins>+    RefPtr&lt;CSSValue&gt; resolvedVariableValue(CSSPropertyID, const CSSVariableDependentValue&amp;);
</ins><span class="cx"> 
</span><span class="cx">     void applySVGProperty(CSSPropertyID, CSSValue*);
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCorecssmakeproppl"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/css/makeprop.pl (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/css/makeprop.pl        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/Source/WebCore/css/makeprop.pl        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -236,7 +236,7 @@
</span><span class="cx"> 
</span><span class="cx"> static const bool isInheritedPropertyTable[numCSSProperties + $numPredefinedProperties] = {
</span><span class="cx">     false, // CSSPropertyInvalid
</span><del>-    false, // CSSPropertyCustom
</del><ins>+    true, // CSSPropertyCustom
</ins><span class="cx"> EOF
</span><span class="cx"> 
</span><span class="cx"> foreach my $name (@names) {
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCorerenderingstyleRenderStylecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/rendering/style/RenderStyle.cpp (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/rendering/style/RenderStyle.cpp        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/Source/WebCore/rendering/style/RenderStyle.cpp        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -24,8 +24,10 @@
</span><span class="cx"> #include &quot;RenderStyle.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;ContentData.h&quot;
</span><ins>+#include &quot;CSSCustomPropertyValue.h&quot;
+#include &quot;CSSPropertyNames.h&quot;
+#include &quot;CSSVariableDependentValue.h&quot;
</ins><span class="cx"> #include &quot;CursorList.h&quot;
</span><del>-#include &quot;CSSPropertyNames.h&quot;
</del><span class="cx"> #include &quot;FloatRoundedRect.h&quot;
</span><span class="cx"> #include &quot;FontCascade.h&quot;
</span><span class="cx"> #include &quot;FontSelector.h&quot;
</span><span class="lines">@@ -1981,4 +1983,54 @@
</span><span class="cx"> 
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+void RenderStyle::checkVariablesInCustomProperties()
+{
+    if (!rareInheritedData-&gt;m_customProperties-&gt;containsVariables())
+        return;
+    
+    // Our first pass checks the variables for validity and replaces any properties that became
+    // invalid with empty values.
+    auto&amp; customProperties = rareInheritedData.access()-&gt;m_customProperties.access()-&gt;values();
+    HashSet&lt;AtomicString&gt; invalidProperties;
+    for (auto entry : customProperties) {
+        if (!entry.value-&gt;isVariableDependentValue())
+            continue;
+        HashSet&lt;AtomicString&gt; seenProperties;
+        downcast&lt;CSSVariableDependentValue&gt;(*entry.value).checkVariablesForCycles(entry.key, customProperties, seenProperties, invalidProperties);
+    }
+    
+    // Now insert invalid values.
+    if (!invalidProperties.isEmpty()) {
+        RefPtr&lt;CSSValue&gt; invalidValue = CSSCustomPropertyValue::createInvalid();
+        for (auto&amp; property : invalidProperties)
+            customProperties.set(property, invalidValue);
+    }
+
+    // Now that all of the properties have been tested for validity and replaced with
+    // invalid values if they failed, we can perform variable substitution on the valid values.
+    Vector&lt;RefPtr&lt;CSSCustomPropertyValue&gt;&gt; resolvedValues;
+    for (auto entry : customProperties) {
+        if (!entry.value-&gt;isVariableDependentValue())
+            continue;
+        
+        CSSParserValueList parserList;
+        RefPtr&lt;CSSCustomPropertyValue&gt; result;
+        if (!downcast&lt;CSSVariableDependentValue&gt;(*entry.value).valueList()-&gt;buildParserValueListSubstitutingVariables(&amp;parserList, customProperties)) {
+            RefPtr&lt;CSSValue&gt; invalidResult = CSSCustomPropertyValue::createInvalid();
+            result = CSSCustomPropertyValue::create(entry.key, invalidResult);
+        } else {
+            RefPtr&lt;CSSValue&gt; newValueList = CSSValueList::createFromParserValueList(parserList);
+            result = CSSCustomPropertyValue::create(entry.key, newValueList);
+        }
+        resolvedValues.append(result);
+    }
+    
+    // With all results computed, we can now mutate our table to eliminate the variables and
+    // hold the final values. This way when we inherit, we don't end up resubstituting variables, etc.
+    for (auto&amp; resolvedValue : resolvedValues)
+        customProperties.set(resolvedValue-&gt;name(), resolvedValue-&gt;value());
+
+    rareInheritedData.access()-&gt;m_customProperties.access()-&gt;setContainsVariables(false);
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCorerenderingstyleRenderStyleh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/rendering/style/RenderStyle.h (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/rendering/style/RenderStyle.h        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/Source/WebCore/rendering/style/RenderStyle.h        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -516,7 +516,7 @@
</span><span class="cx">     void setCustomPropertyValue(const AtomicString&amp; name, const RefPtr&lt;CSSValue&gt;&amp; value) { rareInheritedData.access()-&gt;m_customProperties.access()-&gt;setCustomPropertyValue(name, value); }
</span><span class="cx">     RefPtr&lt;CSSValue&gt; getCustomPropertyValue(const AtomicString&amp; name) const { return rareInheritedData-&gt;m_customProperties-&gt;getCustomPropertyValue(name); }
</span><span class="cx">     bool hasCustomProperty(const AtomicString&amp; name) const { return rareInheritedData-&gt;m_customProperties-&gt;hasCustomProperty(name); }
</span><del>-    const HashMap&lt;AtomicString, RefPtr&lt;CSSValue&gt;&gt;* customProperties() const { return &amp;(rareInheritedData-&gt;m_customProperties-&gt;m_values); }
</del><ins>+    const CustomPropertyValueMap&amp; customProperties() const { return rareInheritedData-&gt;m_customProperties-&gt;m_values; }
</ins><span class="cx"> 
</span><span class="cx">     void setHasViewportUnits(bool hasViewportUnits = true) { noninherited_flags.setHasViewportUnits(hasViewportUnits); }
</span><span class="cx">     bool hasViewportUnits() const { return noninherited_flags.hasViewportUnits(); }
</span><span class="lines">@@ -1198,7 +1198,9 @@
</span><span class="cx"> #if ENABLE(CSS_TRAILING_WORD)
</span><span class="cx">     TrailingWord trailingWord() const { return static_cast&lt;TrailingWord&gt;(rareInheritedData-&gt;trailingWord); }
</span><span class="cx"> #endif
</span><del>-        
</del><ins>+    
+    void checkVariablesInCustomProperties();
+
</ins><span class="cx"> // attribute setter methods
</span><span class="cx"> 
</span><span class="cx">     void setDisplay(EDisplay v) { noninherited_flags.setEffectiveDisplay(v); }
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCorerenderingstyleStyleCustomPropertyDatah"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/rendering/style/StyleCustomPropertyData.h (193558 => 193559)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebCore/rendering/style/StyleCustomPropertyData.h        2015-12-06 06:21:00 UTC (rev 193558)
+++ branches/safari-601.1.46-branch/Source/WebCore/rendering/style/StyleCustomPropertyData.h        2015-12-06 06:23:15 UTC (rev 193559)
</span><span class="lines">@@ -22,6 +22,7 @@
</span><span class="cx"> #ifndef StyleCustomPropertyData_h
</span><span class="cx"> #define StyleCustomPropertyData_h
</span><span class="cx"> 
</span><ins>+#include &quot;CSSValue.h&quot;
</ins><span class="cx"> #include &lt;wtf/Forward.h&gt;
</span><span class="cx"> #include &lt;wtf/HashMap.h&gt;
</span><span class="cx"> #include &lt;wtf/RefCounted.h&gt;
</span><span class="lines">@@ -30,29 +31,55 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class CSSValue;
-
</del><span class="cx"> class StyleCustomPropertyData : public RefCounted&lt;StyleCustomPropertyData&gt; {
</span><span class="cx"> public:
</span><span class="cx">     static Ref&lt;StyleCustomPropertyData&gt; create() { return adoptRef(*new StyleCustomPropertyData); }
</span><span class="cx">     Ref&lt;StyleCustomPropertyData&gt; copy() const { return adoptRef(*new StyleCustomPropertyData(*this)); }
</span><span class="cx">     
</span><del>-    bool operator==(const StyleCustomPropertyData&amp; o) const { return m_values == o.m_values; }
</del><ins>+    bool operator==(const StyleCustomPropertyData&amp; o) const
+    {
+        if (m_containsVariables != o.m_containsVariables)
+            return false;
+        
+        if (m_values.size() != o.m_values.size())
+            return false;
+        
+        for (WTF::KeyValuePair&lt;AtomicString, RefPtr&lt;CSSValue&gt;&gt; entry : m_values) {
+            RefPtr&lt;CSSValue&gt; other = o.m_values.get(entry.key);
+            if (!other || !entry.value-&gt;equals(*other))
+                return false;
+        }
+        return true;
+    }
+
</ins><span class="cx">     bool operator!=(const StyleCustomPropertyData &amp;o) const { return !(*this == o); }
</span><span class="cx">     
</span><del>-    void setCustomPropertyValue(const AtomicString&amp; name, const RefPtr&lt;CSSValue&gt;&amp; value) { m_values.set(name, value); }
</del><ins>+    void setCustomPropertyValue(const AtomicString&amp; name, const RefPtr&lt;CSSValue&gt;&amp; value)
+    {
+        m_values.set(name, value);
+        if (value-&gt;isVariableDependentValue())
+            m_containsVariables = true;
+    }
+
</ins><span class="cx">     RefPtr&lt;CSSValue&gt; getCustomPropertyValue(const AtomicString&amp; name) const { return m_values.get(name); }
</span><ins>+    CustomPropertyValueMap&amp; values() { return m_values; }
+    
</ins><span class="cx">     bool hasCustomProperty(const AtomicString&amp; name) const { return m_values.contains(name); }
</span><ins>+    
+    bool containsVariables() const { return m_containsVariables; }
+    void setContainsVariables(bool containsVariables) { m_containsVariables = containsVariables; }
</ins><span class="cx"> 
</span><del>-    HashMap&lt;AtomicString, RefPtr&lt;CSSValue&gt;&gt; m_values;
-    
</del><ins>+    CustomPropertyValueMap m_values;
+    bool m_containsVariables { false };
+
</ins><span class="cx"> private:
</span><span class="cx">     explicit StyleCustomPropertyData()
</span><span class="cx">         : RefCounted&lt;StyleCustomPropertyData&gt;()
</span><span class="cx">     { }
</span><span class="cx">     StyleCustomPropertyData(const StyleCustomPropertyData&amp; other)
</span><span class="cx">         : RefCounted&lt;StyleCustomPropertyData&gt;()
</span><del>-        , m_values(HashMap&lt;AtomicString, RefPtr&lt;CSSValue&gt;&gt;(other.m_values))
</del><ins>+        , m_values(CustomPropertyValueMap(other.m_values))
+        , m_containsVariables(other.m_containsVariables)
</ins><span class="cx">     { }
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>