<!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>[166860] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/166860">166860</a></dd>
<dt>Author</dt> <dd>darin@apple.com</dd>
<dt>Date</dt> <dd>2014-04-06 17:16:35 -0700 (Sun, 06 Apr 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Source/WebCore: Rework CSS calc logic, fixing some reference count mistakes in Length
https://bugs.webkit.org/show_bug.cgi?id=131280
rdar://problem/16400823

Reviewed by Andreas Kling.

New unit test in TestWebKitAPI.

Changed the classes related to CSS &quot;calc&quot; to make the code a bit easier to read by
moving code out of class definitions. Also used final some more, made more things private,
used references instead of pointers, and other such changes. Biggest change, though, is to
Length, which had a broken system for managing reference counted calculated objects.
There were multiple bugs including a basic design mistake of not having a reference count
and trying to use the reference count in the object itself. Fixed and covered by the unit
test now; test found multiple problems in both the old and new implementations.

* WebCore.exp.in: Updated exports, including symbols to make the unit test practical.

* WebCore.xcodeproj/project.pbxproj: Made CalculationValue.h a Private file so it can
be used in a unit test. Also let Xcode update the file type for a gperf file.

* css/CSSCalculationValue.cpp:
(WebCore::CSSCalcValue::equals): Updated since m_expression is a Ref now.
(WebCore::CSSCalcValue::clampToPermittedRange): Marked inline and updated for data member
name change.
(WebCore::isIntegerResult): Changed argument order to put the operator first and use
references instead of pointers. Also marked inline.
(WebCore::createBlendHalf): Added. Helper to make the other functions more readable.
(WebCore::createExpressionNode): Made non-member function private to this file. Also made
many small improvements.
(WebCore::CSSCalcValue::create): Updated so both of these call the same constructor.

* css/CSSCalculationValue.h: Cut down CSSCalcValue class by making more things private
and deleting unneeded things. Also use Ref instead of RefPtr.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::getPositionOffsetValue): Use isFixed function instead of type function.

* css/CSSGradientValue.cpp:
(WebCore::CSSGradientValue::addStops): Updated code since toCalcValue now returns PassRef
instead of PassRefPtr. Unfortunately the new code is a bit more verbose.
(WebCore::positionFromValue): Ditto.

* css/CSSParser.cpp:
(WebCore::CSSParser::parseCalculation):

* css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Updated to pass reference rather than pointer.
(WebCore::CSSPrimitiveValue::init): Ditto.

* css/CSSToStyleMap.h: Removed unneeded include of LengthBox.h.

* css/DeprecatedStyleBuilder.cpp:
(WebCore::ApplyPropertyLength::applyValue): Updated for function name change.
(WebCore::ApplyPropertyBorderRadius::applyValue): Removed extra parentheses.
(WebCore::ApplyPropertyFontSize::applyValue): Ditto. Also updated since toCalcValue returns Ref.

* css/LengthFunctions.cpp:
(WebCore::floatValueForLength): Updated to call value instead of getFloatValue; both are the same.

* css/StyleResolver.cpp:
(WebCore::addIntrinsicMargins): Updated for function name change.
(WebCore::createGridTrackBreadth): Ditto.

* platform/CalculationValue.cpp:
(WebCore::CalculationValue::create): Changed to return PassRef.
(WebCore::CalcExpressionNumber::evaluate): Moved this function out of the header, since it's
virtual and not really going to be inlined.
(WebCore::CalcExpressionNumber::operator==): Ditto.
(WebCore::CalculationValue::evaluate): Ditto.
(WebCore::CalcExpressionBinaryOperation::operator==): Ditto.
(WebCore::CalcExpressionLength::evaluate): Ditto.
(WebCore::CalcExpressionLength::operator==): Ditto.
(WebCore::CalcExpressionBlendLength::evaluate): Ditto.
(WebCore::CalcExpressionBlendLength::operator==): Ditto.

* platform/CalculationValue.h: Moved most functions out of the class bodies so the classes are
easier to see. Made all the == operator functions non-member ones except for the polymorphic
one from the base class. Changed the casting functions to work on references instead of pointers.
Tweaked name of some members.

* platform/Length.cpp: Reworked the CalculationValueMap (formerly CalculationValueHandleMap) to
use unsigned instead of int, and store reference counts in the map rather than trying to share the
reference count of the underlying CalculationValue object, which can lead to storage leaks where
handles end up in the map permanently.
(WebCore::calculationValues): Use NeverDestroyed instead of DEPRECATED_DEFINE_STATIC_LOCAL.
(WebCore::Length::Length): Updated some data member names.
(WebCore::Length::calculationValue): Updated to return a reference instead of a PassRefPtr.
(WebCore::Length::ref): Renamed and updated for new interface to the map.
(WebCore::Length::deref): Ditto.
(WebCore::Length::nonNanCalculatedValue): Updated to use a reference instead of a pointer.
(WebCore::Length::isCalculatedEqual): Updated since this is now only called if both objects are
known to be calculated values.

* platform/Length.h: Moved most functions out of the class definition to make the class definition
easier to read. Reworked the constructors and assignment operators to handle the reference counting
correctly. Added various FIXMEs and assertions. Removed some unused functions, made others private.

* platform/LengthBox.h: Renamed some one-letter arguments to use words instead.

* rendering/AutoTableLayout.cpp:
(WebCore::AutoTableLayout::recalcColumn): Updated for change to Length::setValue.
* rendering/FixedTableLayout.cpp:
(WebCore::FixedTableLayout::calcWidthArray): Ditto.

* rendering/style/FillLayer.h:
(WebCore::FillLayer::initialFillXPosition): Updated to not convert a double to a float at runtime.
(WebCore::FillLayer::initialFillYPosition): Ditto.

* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::setWordSpacing): Removed a bogus FALLTHROUGH that was clearly wrong, but
harmless. Updated for changes to Length.

* rendering/style/RenderStyle.h: Updated for name changes and to avoid converting doubles to floats
at runtime.

Tools: Rework CSS calc logic, fixing some reference count mistakes in Length
https://bugs.webkit.org/show_bug.cgi?id=131280

Reviewed by Andreas Kling.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Added CalculationValue.cpp.
* TestWebKitAPI/Tests/WebCore/CalculationValue.cpp: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorecssCSSCalculationValuecpp">trunk/Source/WebCore/css/CSSCalculationValue.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSCalculationValueh">trunk/Source/WebCore/css/CSSCalculationValue.h</a></li>
<li><a href="#trunkSourceWebCorecssCSSComputedStyleDeclarationcpp">trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSGradientValuecpp">trunk/Source/WebCore/css/CSSGradientValue.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSParsercpp">trunk/Source/WebCore/css/CSSParser.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSPrimitiveValuecpp">trunk/Source/WebCore/css/CSSPrimitiveValue.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSPrimitiveValueMappingsh">trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h</a></li>
<li><a href="#trunkSourceWebCorecssCSSToStyleMapcpp">trunk/Source/WebCore/css/CSSToStyleMap.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSToStyleMaph">trunk/Source/WebCore/css/CSSToStyleMap.h</a></li>
<li><a href="#trunkSourceWebCorecssDeprecatedStyleBuildercpp">trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp</a></li>
<li><a href="#trunkSourceWebCorecssLengthFunctionscpp">trunk/Source/WebCore/css/LengthFunctions.cpp</a></li>
<li><a href="#trunkSourceWebCorecssStyleResolvercpp">trunk/Source/WebCore/css/StyleResolver.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformCalculationValuecpp">trunk/Source/WebCore/platform/CalculationValue.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformCalculationValueh">trunk/Source/WebCore/platform/CalculationValue.h</a></li>
<li><a href="#trunkSourceWebCoreplatformLengthcpp">trunk/Source/WebCore/platform/Length.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformLengthh">trunk/Source/WebCore/platform/Length.h</a></li>
<li><a href="#trunkSourceWebCoreplatformLengthBoxh">trunk/Source/WebCore/platform/LengthBox.h</a></li>
<li><a href="#trunkSourceWebCorerenderingAutoTableLayoutcpp">trunk/Source/WebCore/rendering/AutoTableLayout.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingFixedTableLayoutcpp">trunk/Source/WebCore/rendering/FixedTableLayout.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleFillLayerh">trunk/Source/WebCore/rendering/style/FillLayer.h</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleRenderStylecpp">trunk/Source/WebCore/rendering/style/RenderStyle.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleRenderStyleh">trunk/Source/WebCore/rendering/style/RenderStyle.h</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebCoreCalculationValuecpp">trunk/Tools/TestWebKitAPI/Tests/WebCore/CalculationValue.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (166859 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-04-06 23:41:10 UTC (rev 166859)
+++ trunk/Source/WebCore/ChangeLog        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -1,3 +1,121 @@
</span><ins>+2014-04-06  Darin Adler  &lt;darin@apple.com&gt;
+
+        Rework CSS calc logic, fixing some reference count mistakes in Length
+        https://bugs.webkit.org/show_bug.cgi?id=131280
+        rdar://problem/16400823
+
+        Reviewed by Andreas Kling.
+
+        New unit test in TestWebKitAPI.
+
+        Changed the classes related to CSS &quot;calc&quot; to make the code a bit easier to read by
+        moving code out of class definitions. Also used final some more, made more things private,
+        used references instead of pointers, and other such changes. Biggest change, though, is to
+        Length, which had a broken system for managing reference counted calculated objects.
+        There were multiple bugs including a basic design mistake of not having a reference count
+        and trying to use the reference count in the object itself. Fixed and covered by the unit
+        test now; test found multiple problems in both the old and new implementations.
+
+        * WebCore.exp.in: Updated exports, including symbols to make the unit test practical.
+
+        * WebCore.xcodeproj/project.pbxproj: Made CalculationValue.h a Private file so it can
+        be used in a unit test. Also let Xcode update the file type for a gperf file.
+
+        * css/CSSCalculationValue.cpp:
+        (WebCore::CSSCalcValue::equals): Updated since m_expression is a Ref now.
+        (WebCore::CSSCalcValue::clampToPermittedRange): Marked inline and updated for data member
+        name change.
+        (WebCore::isIntegerResult): Changed argument order to put the operator first and use
+        references instead of pointers. Also marked inline.
+        (WebCore::createBlendHalf): Added. Helper to make the other functions more readable.
+        (WebCore::createExpressionNode): Made non-member function private to this file. Also made
+        many small improvements.
+        (WebCore::CSSCalcValue::create): Updated so both of these call the same constructor.
+
+        * css/CSSCalculationValue.h: Cut down CSSCalcValue class by making more things private
+        and deleting unneeded things. Also use Ref instead of RefPtr.
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::getPositionOffsetValue): Use isFixed function instead of type function.
+
+        * css/CSSGradientValue.cpp:
+        (WebCore::CSSGradientValue::addStops): Updated code since toCalcValue now returns PassRef
+        instead of PassRefPtr. Unfortunately the new code is a bit more verbose.
+        (WebCore::positionFromValue): Ditto.
+
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseCalculation):
+
+        * css/CSSPrimitiveValue.cpp:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Updated to pass reference rather than pointer.
+        (WebCore::CSSPrimitiveValue::init): Ditto.
+
+        * css/CSSToStyleMap.h: Removed unneeded include of LengthBox.h.
+
+        * css/DeprecatedStyleBuilder.cpp:
+        (WebCore::ApplyPropertyLength::applyValue): Updated for function name change.
+        (WebCore::ApplyPropertyBorderRadius::applyValue): Removed extra parentheses.
+        (WebCore::ApplyPropertyFontSize::applyValue): Ditto. Also updated since toCalcValue returns Ref.
+
+        * css/LengthFunctions.cpp:
+        (WebCore::floatValueForLength): Updated to call value instead of getFloatValue; both are the same.
+
+        * css/StyleResolver.cpp:
+        (WebCore::addIntrinsicMargins): Updated for function name change.
+        (WebCore::createGridTrackBreadth): Ditto.
+
+        * platform/CalculationValue.cpp:
+        (WebCore::CalculationValue::create): Changed to return PassRef.
+        (WebCore::CalcExpressionNumber::evaluate): Moved this function out of the header, since it's
+        virtual and not really going to be inlined.
+        (WebCore::CalcExpressionNumber::operator==): Ditto.
+        (WebCore::CalculationValue::evaluate): Ditto.
+        (WebCore::CalcExpressionBinaryOperation::operator==): Ditto.
+        (WebCore::CalcExpressionLength::evaluate): Ditto.
+        (WebCore::CalcExpressionLength::operator==): Ditto.
+        (WebCore::CalcExpressionBlendLength::evaluate): Ditto.
+        (WebCore::CalcExpressionBlendLength::operator==): Ditto.
+
+        * platform/CalculationValue.h: Moved most functions out of the class bodies so the classes are
+        easier to see. Made all the == operator functions non-member ones except for the polymorphic
+        one from the base class. Changed the casting functions to work on references instead of pointers.
+        Tweaked name of some members.
+
+        * platform/Length.cpp: Reworked the CalculationValueMap (formerly CalculationValueHandleMap) to
+        use unsigned instead of int, and store reference counts in the map rather than trying to share the
+        reference count of the underlying CalculationValue object, which can lead to storage leaks where
+        handles end up in the map permanently.
+        (WebCore::calculationValues): Use NeverDestroyed instead of DEPRECATED_DEFINE_STATIC_LOCAL.
+        (WebCore::Length::Length): Updated some data member names.
+        (WebCore::Length::calculationValue): Updated to return a reference instead of a PassRefPtr.
+        (WebCore::Length::ref): Renamed and updated for new interface to the map.
+        (WebCore::Length::deref): Ditto.
+        (WebCore::Length::nonNanCalculatedValue): Updated to use a reference instead of a pointer.
+        (WebCore::Length::isCalculatedEqual): Updated since this is now only called if both objects are
+        known to be calculated values.
+
+        * platform/Length.h: Moved most functions out of the class definition to make the class definition
+        easier to read. Reworked the constructors and assignment operators to handle the reference counting
+        correctly. Added various FIXMEs and assertions. Removed some unused functions, made others private.
+
+        * platform/LengthBox.h: Renamed some one-letter arguments to use words instead.
+
+        * rendering/AutoTableLayout.cpp:
+        (WebCore::AutoTableLayout::recalcColumn): Updated for change to Length::setValue.
+        * rendering/FixedTableLayout.cpp:
+        (WebCore::FixedTableLayout::calcWidthArray): Ditto.
+
+        * rendering/style/FillLayer.h:
+        (WebCore::FillLayer::initialFillXPosition): Updated to not convert a double to a float at runtime.
+        (WebCore::FillLayer::initialFillYPosition): Ditto.
+
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::setWordSpacing): Removed a bogus FALLTHROUGH that was clearly wrong, but
+        harmless. Updated for changes to Length.
+
+        * rendering/style/RenderStyle.h: Updated for name changes and to avoid converting doubles to floats
+        at runtime.
+
</ins><span class="cx"> 2014-04-06  Brent Fulgham  &lt;bfulgham@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Honor System-Level User Preferences for Caption Display
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (166859 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-04-06 23:41:10 UTC (rev 166859)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -649,6 +649,7 @@
</span><span class="cx"> __ZN7WebCore16ApplicationCache18diskUsageForOriginEPNS_14SecurityOriginE
</span><span class="cx"> __ZN7WebCore16ApplicationCache20deleteCacheForOriginEPNS_14SecurityOriginE
</span><span class="cx"> __ZN7WebCore16CSSParserContextC1ERNS_8DocumentERKNS_3URLERKN3WTF6StringE
</span><ins>+__ZN7WebCore16CalculationValue6createENSt3__110unique_ptrINS_18CalcExpressionNodeENS1_14default_deleteIS3_EEEENS_30CalculationPermittedValueRangeE
</ins><span class="cx"> __ZN7WebCore16DatabaseStrategy17getDatabaseServerEv
</span><span class="cx"> __ZN7WebCore16DatabaseStrategy23createIDBFactoryBackendERKN3WTF6StringE
</span><span class="cx"> __ZN7WebCore16DeviceMotionData12Acceleration6createEbdbdbd
</span><span class="lines">@@ -1172,6 +1173,7 @@
</span><span class="cx"> __ZN7WebCore6Editor7copyURLERKNS_3URLERKN3WTF6StringE
</span><span class="cx"> __ZN7WebCore6Editor7outdentEv
</span><span class="cx"> __ZN7WebCore6JSNode6s_infoE
</span><ins>+__ZN7WebCore6LengthC1EN3WTF7PassRefINS_16CalculationValueEEE
</ins><span class="cx"> __ZN7WebCore6Region21updateBoundsFromShapeEv
</span><span class="cx"> __ZN7WebCore6Region5uniteERKS0_
</span><span class="cx"> __ZN7WebCore6Region8subtractERKS0_
</span><span class="lines">@@ -1855,8 +1857,8 @@
</span><span class="cx"> __ZNK7WebCore6Editor7canEditEv
</span><span class="cx"> __ZNK7WebCore6Editor8canPasteEv
</span><span class="cx"> __ZNK7WebCore6Editor9canDeleteEv
</span><del>-__ZNK7WebCore6Length22decrementCalculatedRefEv
-__ZNK7WebCore6Length22incrementCalculatedRefEv
</del><ins>+__ZNK7WebCore6Length3refEv
+__ZNK7WebCore6Length5derefEv
</ins><span class="cx"> __ZNK7WebCore6Region5Shape7isValidEv
</span><span class="cx"> __ZNK7WebCore6Region5rectsEv
</span><span class="cx"> __ZNK7WebCore6Region8containsERKS0_
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (166859 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-04-06 23:41:10 UTC (rev 166859)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -1598,7 +1598,7 @@
</span><span class="cx">                 49AE2D8E134EE50C0072920A /* CSSCalculationValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49AE2D8C134EE50C0072920A /* CSSCalculationValue.cpp */; };
</span><span class="cx">                 49AE2D8F134EE50C0072920A /* CSSCalculationValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 49AE2D8D134EE50C0072920A /* CSSCalculationValue.h */; };
</span><span class="cx">                 49AE2D96134EE5F90072920A /* CalculationValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49AE2D94134EE5F90072920A /* CalculationValue.cpp */; };
</span><del>-                49AE2D97134EE5F90072920A /* CalculationValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 49AE2D95134EE5F90072920A /* CalculationValue.h */; };
</del><ins>+                49AE2D97134EE5F90072920A /* CalculationValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 49AE2D95134EE5F90072920A /* CalculationValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 49AF2D6914435D050016A784 /* DisplayRefreshMonitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 49AF2D6814435D050016A784 /* DisplayRefreshMonitor.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 49AF2D6C14435D210016A784 /* DisplayRefreshMonitorMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49AF2D6B14435D210016A784 /* DisplayRefreshMonitorMac.cpp */; };
</span><span class="cx">                 49B3760C15C6C6840059131D /* ArrayValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49B3760A15C6C6840059131D /* ArrayValue.cpp */; };
</span><span class="lines">@@ -8432,7 +8432,7 @@
</span><span class="cx">                 43A6266613B3D11000AC94B8 /* SVGAnimatedString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedString.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 43B85ED018CBEACE00E31AF4 /* makeSelectorPseudoClassAndCompatibilityElementMap.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = makeSelectorPseudoClassAndCompatibilityElementMap.py; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 43B85ED218CBEC5200E31AF4 /* SelectorPseudoClassAndCompatibilityElementMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SelectorPseudoClassAndCompatibilityElementMap.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                43B85ED318CBEC5200E31AF4 /* SelectorPseudoClassAndCompatibilityElementMap.gperf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file; path = SelectorPseudoClassAndCompatibilityElementMap.gperf; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><ins>+                43B85ED318CBEC5200E31AF4 /* SelectorPseudoClassAndCompatibilityElementMap.gperf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SelectorPseudoClassAndCompatibilityElementMap.gperf; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 43B85ED618CBEC9700E31AF4 /* SelectorPseudoClassAndCompatibilityElementMap.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SelectorPseudoClassAndCompatibilityElementMap.in; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 43B9336713B261B1004584BF /* SVGAnimatedPointList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPointList.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 43B9336813B261B1004584BF /* SVGAnimatedPointList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedPointList.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSCalculationValuecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSCalculationValue.cpp (166859 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSCalculationValue.cpp        2014-04-06 23:41:10 UTC (rev 166859)
+++ trunk/Source/WebCore/css/CSSCalculationValue.cpp        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -1,5 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
</span><ins>+ * Copyright (C) 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions are
</span><span class="lines">@@ -32,10 +33,7 @@
</span><span class="cx"> #include &quot;CSSCalculationValue.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CSSPrimitiveValueMappings.h&quot;
</span><del>-#include &quot;CSSValueList.h&quot;
-#include &quot;Length.h&quot;
</del><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><del>-
</del><span class="cx"> #include &lt;wtf/MathExtras.h&gt;
</span><span class="cx"> #include &lt;wtf/text/StringBuilder.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -49,6 +47,9 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+static PassRefPtr&lt;CSSCalcExpressionNode&gt; createCSS(const CalcExpressionNode&amp;, const RenderStyle&amp;);
+static PassRefPtr&lt;CSSCalcExpressionNode&gt; createCSS(const Length&amp;, const RenderStyle&amp;);
+
</ins><span class="cx"> static CalculationCategory unitCategory(CSSPrimitiveValue::UnitTypes type)
</span><span class="cx"> {
</span><span class="cx">     switch (type) {
</span><span class="lines">@@ -157,12 +158,12 @@
</span><span class="cx"> 
</span><span class="cx"> bool CSSCalcValue::equals(const CSSCalcValue&amp; other) const
</span><span class="cx"> {
</span><del>-    return compareCSSValuePtr(m_expression, other.m_expression);
</del><ins>+    return compareCSSValue(m_expression, other.m_expression);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-double CSSCalcValue::clampToPermittedRange(double value) const
</del><ins>+inline double CSSCalcValue::clampToPermittedRange(double value) const
</ins><span class="cx"> {
</span><del>-    return m_nonNegative &amp;&amp; value &lt; 0 ? 0 : value;
</del><ins>+    return m_shouldClampToNonNegative &amp;&amp; value &lt; 0 ? 0 : value;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> double CSSCalcValue::doubleValue() const
</span><span class="lines">@@ -175,39 +176,35 @@
</span><span class="cx">     return clampToPermittedRange(m_expression-&gt;computeLengthPx(currentStyle, rootStyle, multiplier, computingFontSize));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-CSSCalcExpressionNode::~CSSCalcExpressionNode()
-{
-}
-
-class CSSCalcPrimitiveValue : public CSSCalcExpressionNode {
</del><ins>+class CSSCalcPrimitiveValue final : public CSSCalcExpressionNode {
</ins><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><del>-
-    static PassRefPtr&lt;CSSCalcPrimitiveValue&gt; create(PassRefPtr&lt;CSSPrimitiveValue&gt; value, bool isInteger)
</del><ins>+    static PassRef&lt;CSSCalcPrimitiveValue&gt; create(PassRefPtr&lt;CSSPrimitiveValue&gt; value, bool isInteger)
</ins><span class="cx">     {
</span><del>-        return adoptRef(new CSSCalcPrimitiveValue(value, isInteger));
</del><ins>+        return adoptRef(*new CSSCalcPrimitiveValue(value, isInteger));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     static PassRefPtr&lt;CSSCalcPrimitiveValue&gt; create(double value, CSSPrimitiveValue::UnitTypes type, bool isInteger)
</span><span class="cx">     {
</span><span class="cx">         if (std::isnan(value) || std::isinf(value))
</span><del>-            return 0;
</del><ins>+            return nullptr;
</ins><span class="cx">         return adoptRef(new CSSCalcPrimitiveValue(CSSPrimitiveValue::create(value, type), isInteger));
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    virtual bool isZero() const
</del><ins>+private:
+    virtual bool isZero() const override
</ins><span class="cx">     {
</span><span class="cx">         return !m_value-&gt;getDoubleValue();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    virtual String customCSSText() const
</del><ins>+    virtual String customCSSText() const override
</ins><span class="cx">     {
</span><span class="cx">         return m_value-&gt;cssText();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    virtual std::unique_ptr&lt;CalcExpressionNode&gt; toCalcValue(const RenderStyle* style, const RenderStyle* rootStyle, double zoom) const
</del><ins>+    virtual std::unique_ptr&lt;CalcExpressionNode&gt; createCalcExpression(const RenderStyle* style, const RenderStyle* rootStyle, double zoom) const override
</ins><span class="cx">     {
</span><del>-        switch (m_category) {
</del><ins>+        switch (category()) {
</ins><span class="cx">         case CalcNumber:
</span><span class="cx">             return std::make_unique&lt;CalcExpressionNumber&gt;(m_value-&gt;getFloatValue());
</span><span class="cx">         case CalcLength:
</span><span class="lines">@@ -227,7 +224,7 @@
</span><span class="cx">         return nullptr;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    virtual double doubleValue() const
</del><ins>+    virtual double doubleValue() const override
</ins><span class="cx">     {
</span><span class="cx">         if (hasDoubleValue(primitiveType()))
</span><span class="cx">             return m_value-&gt;getDoubleValue();
</span><span class="lines">@@ -235,9 +232,9 @@
</span><span class="cx">         return 0;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    virtual double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
</del><ins>+    virtual double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const override
</ins><span class="cx">     {
</span><del>-        switch (m_category) {
</del><ins>+        switch (category()) {
</ins><span class="cx">         case CalcLength:
</span><span class="cx">             return m_value-&gt;computeLength&lt;double&gt;(currentStyle, rootStyle, multiplier, computingFontSize);
</span><span class="cx">         case CalcPercent:
</span><span class="lines">@@ -253,7 +250,7 @@
</span><span class="cx">         return 0;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    virtual bool equals(const CSSCalcExpressionNode&amp; other) const
</del><ins>+    virtual bool equals(const CSSCalcExpressionNode&amp; other) const override
</ins><span class="cx">     {
</span><span class="cx">         if (type() != other.type())
</span><span class="cx">             return false;
</span><span class="lines">@@ -261,8 +258,8 @@
</span><span class="cx">         return compareCSSValuePtr(m_value, static_cast&lt;const CSSCalcPrimitiveValue&amp;&gt;(other).m_value);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    virtual Type type() const { return CssCalcPrimitiveValue; }
-    virtual CSSPrimitiveValue::UnitTypes primitiveType() const
</del><ins>+    virtual Type type() const override { return CssCalcPrimitiveValue; }
+    virtual CSSPrimitiveValue::UnitTypes primitiveType() const override
</ins><span class="cx">     {
</span><span class="cx">         return CSSPrimitiveValue::UnitTypes(m_value-&gt;primitiveType());
</span><span class="cx">     }
</span><span class="lines">@@ -312,40 +309,40 @@
</span><span class="cx">     return CalcOther;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static bool isIntegerResult(const CSSCalcExpressionNode* leftSide, const CSSCalcExpressionNode* rightSide, CalcOperator op)
</del><ins>+static inline bool isIntegerResult(CalcOperator op, const CSSCalcExpressionNode&amp; leftSide, const CSSCalcExpressionNode&amp; rightSide)
</ins><span class="cx"> {
</span><span class="cx">     // Performs W3C spec's type checking for calc integers.
</span><span class="cx">     // http://www.w3.org/TR/css3-values/#calc-type-checking
</span><del>-    return op != CalcDivide &amp;&amp; leftSide-&gt;isInteger() &amp;&amp; rightSide-&gt;isInteger();
</del><ins>+    return op != CalcDivide &amp;&amp; leftSide.isInteger() &amp;&amp; rightSide.isInteger();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-class CSSCalcBinaryOperation : public CSSCalcExpressionNode {
-
</del><ins>+class CSSCalcBinaryOperation final : public CSSCalcExpressionNode {
+    WTF_MAKE_FAST_ALLOCATED;
</ins><span class="cx"> public:
</span><del>-    static PassRefPtr&lt;CSSCalcExpressionNode&gt; create(PassRefPtr&lt;CSSCalcExpressionNode&gt; leftSide, PassRefPtr&lt;CSSCalcExpressionNode&gt; rightSide, CalcOperator op)
</del><ins>+    static PassRefPtr&lt;CSSCalcBinaryOperation&gt; create(CalcOperator op, PassRefPtr&lt;CSSCalcExpressionNode&gt; leftSide, PassRefPtr&lt;CSSCalcExpressionNode&gt; rightSide)
</ins><span class="cx">     {
</span><span class="cx">         ASSERT(leftSide-&gt;category() != CalcOther &amp;&amp; rightSide-&gt;category() != CalcOther);
</span><span class="cx"> 
</span><span class="cx">         CalculationCategory newCategory = determineCategory(*leftSide, *rightSide, op);
</span><span class="cx"> 
</span><span class="cx">         if (newCategory == CalcOther)
</span><del>-            return 0;
</del><ins>+            return nullptr;
</ins><span class="cx"> 
</span><del>-        return adoptRef(new CSSCalcBinaryOperation(leftSide, rightSide, op, newCategory));
</del><ins>+        return adoptRef(new CSSCalcBinaryOperation(newCategory, op, leftSide, rightSide));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    static PassRefPtr&lt;CSSCalcExpressionNode&gt; createSimplified(PassRefPtr&lt;CSSCalcExpressionNode&gt; leftSide, PassRefPtr&lt;CSSCalcExpressionNode&gt; rightSide, CalcOperator op)
</del><ins>+    static PassRefPtr&lt;CSSCalcExpressionNode&gt; createSimplified(CalcOperator op, PassRefPtr&lt;CSSCalcExpressionNode&gt; leftSide, PassRefPtr&lt;CSSCalcExpressionNode&gt; rightSide)
</ins><span class="cx">     {
</span><span class="cx">         CalculationCategory leftCategory = leftSide-&gt;category();
</span><span class="cx">         CalculationCategory rightCategory = rightSide-&gt;category();
</span><span class="cx">         ASSERT(leftCategory != CalcOther &amp;&amp; rightCategory != CalcOther);
</span><span class="cx"> 
</span><del>-        bool isInteger = isIntegerResult(leftSide.get(), rightSide.get(), op);
</del><ins>+        bool isInteger = isIntegerResult(op, *leftSide, *rightSide);
</ins><span class="cx"> 
</span><span class="cx">         // Simplify numbers.
</span><span class="cx">         if (leftCategory == CalcNumber &amp;&amp; rightCategory == CalcNumber) {
</span><span class="cx">             CSSPrimitiveValue::UnitTypes evaluationType = isInteger ? CSSPrimitiveValue::CSS_PARSER_INTEGER : CSSPrimitiveValue::CSS_NUMBER;
</span><del>-            return CSSCalcPrimitiveValue::create(evaluateOperator(leftSide-&gt;doubleValue(), rightSide-&gt;doubleValue(), op), evaluationType, isInteger);
</del><ins>+            return CSSCalcPrimitiveValue::create(evaluateOperator(op, leftSide-&gt;doubleValue(), rightSide-&gt;doubleValue()), evaluationType, isInteger);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Simplify addition and subtraction between same types.
</span><span class="lines">@@ -355,14 +352,14 @@
</span><span class="cx">                 if (hasDoubleValue(leftType)) {
</span><span class="cx">                     CSSPrimitiveValue::UnitTypes rightType = rightSide-&gt;primitiveType();
</span><span class="cx">                     if (leftType == rightType)
</span><del>-                        return CSSCalcPrimitiveValue::create(evaluateOperator(leftSide-&gt;doubleValue(), rightSide-&gt;doubleValue(), op), leftType, isInteger);
</del><ins>+                        return CSSCalcPrimitiveValue::create(evaluateOperator(op, leftSide-&gt;doubleValue(), rightSide-&gt;doubleValue()), leftType, isInteger);
</ins><span class="cx">                     CSSPrimitiveValue::UnitCategory leftUnitCategory = CSSPrimitiveValue::unitCategory(leftType);
</span><span class="cx">                     if (leftUnitCategory != CSSPrimitiveValue::UOther &amp;&amp; leftUnitCategory == CSSPrimitiveValue::unitCategory(rightType)) {
</span><span class="cx">                         CSSPrimitiveValue::UnitTypes canonicalType = CSSPrimitiveValue::canonicalUnitTypeForCategory(leftUnitCategory);
</span><span class="cx">                         if (canonicalType != CSSPrimitiveValue::CSS_UNKNOWN) {
</span><span class="cx">                             double leftValue = leftSide-&gt;doubleValue() * CSSPrimitiveValue::conversionToCanonicalUnitsScaleFactor(leftType);
</span><span class="cx">                             double rightValue = rightSide-&gt;doubleValue() * CSSPrimitiveValue::conversionToCanonicalUnitsScaleFactor(rightType);
</span><del>-                            return CSSCalcPrimitiveValue::create(evaluateOperator(leftValue, rightValue, op), canonicalType, isInteger);
</del><ins>+                            return CSSCalcPrimitiveValue::create(evaluateOperator(op, leftValue, rightValue), canonicalType, isInteger);
</ins><span class="cx">                         }
</span><span class="cx">                     }
</span><span class="cx">                 }
</span><span class="lines">@@ -370,49 +367,50 @@
</span><span class="cx">         } else {
</span><span class="cx">             // Simplify multiplying or dividing by a number for simplifiable types.
</span><span class="cx">             ASSERT(op == CalcMultiply || op == CalcDivide);
</span><del>-            CSSCalcExpressionNode* numberSide = getNumberSide(leftSide.get(), rightSide.get());
</del><ins>+            CSSCalcExpressionNode* numberSide = getNumberSide(*leftSide, *rightSide);
</ins><span class="cx">             if (!numberSide)
</span><del>-                return create(leftSide, rightSide, op);
</del><ins>+                return create(op, leftSide, rightSide);
</ins><span class="cx">             if (numberSide == leftSide &amp;&amp; op == CalcDivide)
</span><del>-                return 0;
</del><ins>+                return nullptr;
</ins><span class="cx">             CSSCalcExpressionNode* otherSide = leftSide == numberSide ? rightSide.get() : leftSide.get();
</span><span class="cx"> 
</span><span class="cx">             double number = numberSide-&gt;doubleValue();
</span><span class="cx">             if (std::isnan(number) || std::isinf(number))
</span><del>-                return 0;
</del><ins>+                return nullptr;
</ins><span class="cx">             if (op == CalcDivide &amp;&amp; !number)
</span><del>-                return 0;
</del><ins>+                return nullptr;
</ins><span class="cx"> 
</span><span class="cx">             CSSPrimitiveValue::UnitTypes otherType = otherSide-&gt;primitiveType();
</span><span class="cx">             if (hasDoubleValue(otherType))
</span><del>-                return CSSCalcPrimitiveValue::create(evaluateOperator(otherSide-&gt;doubleValue(), number, op), otherType, isInteger);
</del><ins>+                return CSSCalcPrimitiveValue::create(evaluateOperator(op, otherSide-&gt;doubleValue(), number), otherType, isInteger);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        return create(leftSide, rightSide, op);
</del><ins>+        return create(op, leftSide, rightSide);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    virtual bool isZero() const
</del><ins>+private:
+    virtual bool isZero() const override
</ins><span class="cx">     {
</span><span class="cx">         return !doubleValue();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    virtual std::unique_ptr&lt;CalcExpressionNode&gt; toCalcValue(const RenderStyle* style, const RenderStyle* rootStyle, double zoom) const
</del><ins>+    virtual std::unique_ptr&lt;CalcExpressionNode&gt; createCalcExpression(const RenderStyle* style, const RenderStyle* rootStyle, double zoom) const override
</ins><span class="cx">     {
</span><del>-        std::unique_ptr&lt;CalcExpressionNode&gt; left(m_leftSide-&gt;toCalcValue(style, rootStyle, zoom));
</del><ins>+        std::unique_ptr&lt;CalcExpressionNode&gt; left(m_leftSide-&gt;createCalcExpression(style, rootStyle, zoom));
</ins><span class="cx">         if (!left)
</span><span class="cx">             return nullptr;
</span><del>-        std::unique_ptr&lt;CalcExpressionNode&gt; right(m_rightSide-&gt;toCalcValue(style, rootStyle, zoom));
</del><ins>+        std::unique_ptr&lt;CalcExpressionNode&gt; right(m_rightSide-&gt;createCalcExpression(style, rootStyle, zoom));
</ins><span class="cx">         if (!right)
</span><span class="cx">             return nullptr;
</span><span class="cx">         return std::make_unique&lt;CalcExpressionBinaryOperation&gt;(std::move(left), std::move(right), m_operator);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    virtual double doubleValue() const
</del><ins>+    virtual double doubleValue() const override
</ins><span class="cx">     {
</span><span class="cx">         return evaluate(m_leftSide-&gt;doubleValue(), m_rightSide-&gt;doubleValue());
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    virtual double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
</del><ins>+    virtual double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const override
</ins><span class="cx">     {
</span><span class="cx">         const double leftValue = m_leftSide-&gt;computeLengthPx(currentStyle, rootStyle, multiplier, computingFontSize);
</span><span class="cx">         const double rightValue = m_rightSide-&gt;computeLengthPx(currentStyle, rootStyle, multiplier, computingFontSize);
</span><span class="lines">@@ -433,13 +431,12 @@
</span><span class="cx">         return result.toString();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    virtual String customCSSText() const
</del><ins>+    virtual String customCSSText() const override
</ins><span class="cx">     {
</span><span class="cx">         return buildCssText(m_leftSide-&gt;customCSSText(), m_rightSide-&gt;customCSSText(), m_operator);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-
-    virtual bool equals(const CSSCalcExpressionNode&amp; exp) const
</del><ins>+    virtual bool equals(const CSSCalcExpressionNode&amp; exp) const override
</ins><span class="cx">     {
</span><span class="cx">         if (type() != exp.type())
</span><span class="cx">             return false;
</span><span class="lines">@@ -450,14 +447,14 @@
</span><span class="cx">             &amp;&amp; m_operator == other.m_operator;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    virtual Type type() const { return CssCalcBinaryOperation; }
</del><ins>+    virtual Type type() const override { return CssCalcBinaryOperation; }
</ins><span class="cx"> 
</span><del>-    virtual CSSPrimitiveValue::UnitTypes primitiveType() const
</del><ins>+    virtual CSSPrimitiveValue::UnitTypes primitiveType() const override
</ins><span class="cx">     {
</span><del>-        switch (m_category) {
</del><ins>+        switch (category()) {
</ins><span class="cx">         case CalcNumber:
</span><span class="cx">             ASSERT(m_leftSide-&gt;category() == CalcNumber &amp;&amp; m_rightSide-&gt;category() == CalcNumber);
</span><del>-            if (m_isInteger)
</del><ins>+            if (isInteger())
</ins><span class="cx">                 return CSSPrimitiveValue::CSS_PARSER_INTEGER;
</span><span class="cx">             return CSSPrimitiveValue::CSS_NUMBER;
</span><span class="cx">         case CalcLength:
</span><span class="lines">@@ -480,30 +477,29 @@
</span><span class="cx">         return CSSPrimitiveValue::CSS_UNKNOWN;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-private:
-    CSSCalcBinaryOperation(PassRefPtr&lt;CSSCalcExpressionNode&gt; leftSide, PassRefPtr&lt;CSSCalcExpressionNode&gt; rightSide, CalcOperator op, CalculationCategory category)
-        : CSSCalcExpressionNode(category, isIntegerResult(leftSide.get(), rightSide.get(), op))
</del><ins>+    CSSCalcBinaryOperation(CalculationCategory category, CalcOperator op, PassRefPtr&lt;CSSCalcExpressionNode&gt; leftSide, PassRefPtr&lt;CSSCalcExpressionNode&gt; rightSide)
+        : CSSCalcExpressionNode(category, isIntegerResult(op, *leftSide, *rightSide))
</ins><span class="cx">         , m_leftSide(leftSide)
</span><span class="cx">         , m_rightSide(rightSide)
</span><span class="cx">         , m_operator(op)
</span><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    static CSSCalcExpressionNode* getNumberSide(CSSCalcExpressionNode* leftSide, CSSCalcExpressionNode* rightSide)
</del><ins>+    static CSSCalcExpressionNode* getNumberSide(CSSCalcExpressionNode&amp; leftSide, CSSCalcExpressionNode&amp; rightSide)
</ins><span class="cx">     {
</span><del>-        if (leftSide-&gt;category() == CalcNumber)
-            return leftSide;
-        if (rightSide-&gt;category() == CalcNumber)
-            return rightSide;
-        return 0;
</del><ins>+        if (leftSide.category() == CalcNumber)
+            return &amp;leftSide;
+        if (rightSide.category() == CalcNumber)
+            return &amp;rightSide;
+        return nullptr;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     double evaluate(double leftSide, double rightSide) const
</span><span class="cx">     {
</span><del>-        return evaluateOperator(leftSide, rightSide, m_operator);
</del><ins>+        return evaluateOperator(m_operator, leftSide, rightSide);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    static double evaluateOperator(double leftValue, double rightValue, CalcOperator op)
</del><ins>+    static double evaluateOperator(CalcOperator op, double leftValue, double rightValue)
</ins><span class="cx">     {
</span><span class="cx">         switch (op) {
</span><span class="cx">         case CalcAdd:
</span><span class="lines">@@ -517,6 +513,7 @@
</span><span class="cx">                 return leftValue / rightValue;
</span><span class="cx">             return std::numeric_limits&lt;double&gt;::quiet_NaN();
</span><span class="cx">         }
</span><ins>+        ASSERT_NOT_REACHED();
</ins><span class="cx">         return 0;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -544,7 +541,7 @@
</span><span class="cx">         bool ok = parseValueExpression(tokens, 0, &amp;index, &amp;result);
</span><span class="cx">         ASSERT_WITH_SECURITY_IMPLICATION(index &lt;= tokens-&gt;size());
</span><span class="cx">         if (!ok || index != tokens-&gt;size())
</span><del>-            return 0;
</del><ins>+            return nullptr;
</ins><span class="cx">         return result.value;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -618,7 +615,7 @@
</span><span class="cx">             if (!parseValueTerm(tokens, depth, index, &amp;rhs))
</span><span class="cx">                 return false;
</span><span class="cx"> 
</span><del>-            result-&gt;value = CSSCalcBinaryOperation::createSimplified(result-&gt;value, rhs.value, static_cast&lt;CalcOperator&gt;(operatorCharacter));
</del><ins>+            result-&gt;value = CSSCalcBinaryOperation::createSimplified(static_cast&lt;CalcOperator&gt;(operatorCharacter), result-&gt;value, rhs.value);
</ins><span class="cx">             if (!result-&gt;value)
</span><span class="cx">                 return false;
</span><span class="cx">         }
</span><span class="lines">@@ -645,7 +642,7 @@
</span><span class="cx">             if (!parseValueMultiplicativeExpression(tokens, depth, index, &amp;rhs))
</span><span class="cx">                 return false;
</span><span class="cx"> 
</span><del>-            result-&gt;value = CSSCalcBinaryOperation::createSimplified(result-&gt;value, rhs.value, static_cast&lt;CalcOperator&gt;(operatorCharacter));
</del><ins>+            result-&gt;value = CSSCalcBinaryOperation::createSimplified(static_cast&lt;CalcOperator&gt;(operatorCharacter), result-&gt;value, rhs.value);
</ins><span class="cx">             if (!result-&gt;value)
</span><span class="cx">                 return false;
</span><span class="cx">         }
</span><span class="lines">@@ -660,54 +657,40 @@
</span><span class="cx">     }
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-PassRefPtr&lt;CSSCalcExpressionNode&gt; CSSCalcValue::createExpressionNode(PassRefPtr&lt;CSSPrimitiveValue&gt; value, bool isInteger)
</del><ins>+static inline PassRefPtr&lt;CSSCalcBinaryOperation&gt; createBlendHalf(const Length&amp; length, const RenderStyle&amp; style, float progress)
</ins><span class="cx"> {
</span><del>-    return CSSCalcPrimitiveValue::create(value, isInteger);
</del><ins>+    return CSSCalcBinaryOperation::create(CalcMultiply, createCSS(length, style),
+        CSSCalcPrimitiveValue::create(CSSPrimitiveValue::create(progress, CSSPrimitiveValue::CSS_NUMBER), !progress || progress == 1));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-PassRefPtr&lt;CSSCalcExpressionNode&gt; CSSCalcValue::createExpressionNode(PassRefPtr&lt;CSSCalcExpressionNode&gt; leftSide, PassRefPtr&lt;CSSCalcExpressionNode&gt; rightSide, CalcOperator op)
</del><ins>+static PassRefPtr&lt;CSSCalcExpressionNode&gt; createCSS(const CalcExpressionNode&amp; node, const RenderStyle&amp; style)
</ins><span class="cx"> {
</span><del>-    return CSSCalcBinaryOperation::create(leftSide, rightSide, op);
-}
-
-PassRefPtr&lt;CSSCalcExpressionNode&gt; CSSCalcValue::createExpressionNode(const CalcExpressionNode* node, const RenderStyle* style)
-{
-    switch (node-&gt;type()) {
</del><ins>+    switch (node.type()) {
</ins><span class="cx">     case CalcExpressionNodeNumber: {
</span><del>-        float value = toCalcExpressionNumber(node)-&gt;value();
-        return createExpressionNode(CSSPrimitiveValue::create(value, CSSPrimitiveValue::CSS_NUMBER), value == trunc(value));
</del><ins>+        float value = toCalcExpressionNumber(node).value();
+        return CSSCalcPrimitiveValue::create(CSSPrimitiveValue::create(value, CSSPrimitiveValue::CSS_NUMBER), value == truncf(value));
</ins><span class="cx">     }
</span><span class="cx">     case CalcExpressionNodeLength:
</span><del>-        return createExpressionNode(toCalcExpressionLength(node)-&gt;length(), style);
</del><ins>+        return createCSS(toCalcExpressionLength(node).length(), style);
</ins><span class="cx">     case CalcExpressionNodeBinaryOperation: {
</span><del>-        const CalcExpressionBinaryOperation* binaryNode = toCalcExpressionBinaryOperation(node);
-        return createExpressionNode(createExpressionNode(binaryNode-&gt;leftSide(), style), createExpressionNode(binaryNode-&gt;rightSide(), style), binaryNode-&gt;getOperator());
</del><ins>+        auto&amp; binaryNode = toCalcExpressionBinaryOperation(node);
+        return CSSCalcBinaryOperation::create(binaryNode.getOperator(), createCSS(binaryNode.leftSide(), style), createCSS(binaryNode.rightSide(), style));
</ins><span class="cx">     }
</span><span class="cx">     case CalcExpressionNodeBlendLength: {
</span><span class="cx">         // FIXME: (http://webkit.org/b/122036) Create a CSSCalcExpressionNode equivalent of CalcExpressionBlendLength.
</span><del>-        const CalcExpressionBlendLength* blendNode = toCalcExpressionBlendLength(node);
-        const double progress = blendNode-&gt;progress();
-        const bool isInteger = !progress || (progress == 1);
-        return createExpressionNode(
-            createExpressionNode(
-                createExpressionNode(blendNode-&gt;from(), style),
-                createExpressionNode(CSSPrimitiveValue::create(1 - progress, CSSPrimitiveValue::CSS_NUMBER), isInteger),
-                CalcMultiply),
-            createExpressionNode(
-                createExpressionNode(blendNode-&gt;to(), style),
-                createExpressionNode(CSSPrimitiveValue::create(progress, CSSPrimitiveValue::CSS_NUMBER), isInteger),
-                CalcMultiply),
-            CalcAdd);
</del><ins>+        auto&amp; blend = toCalcExpressionBlendLength(node);
+        float progress = blend.progress();
+        return CSSCalcBinaryOperation::create(CalcAdd, createBlendHalf(blend.from(), style, 1 - progress), createBlendHalf(blend.to(), style, progress));
</ins><span class="cx">     }
</span><span class="cx">     case CalcExpressionNodeUndefined:
</span><span class="cx">         ASSERT_NOT_REACHED();
</span><del>-        return 0;
</del><ins>+        return nullptr;
</ins><span class="cx">     }
</span><span class="cx">     ASSERT_NOT_REACHED();
</span><del>-    return 0;
</del><ins>+    return nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-PassRefPtr&lt;CSSCalcExpressionNode&gt; CSSCalcValue::createExpressionNode(const Length&amp; length, const RenderStyle* style)
</del><ins>+static PassRefPtr&lt;CSSCalcExpressionNode&gt; createCSS(const Length&amp; length, const RenderStyle&amp; style)
</ins><span class="cx"> {
</span><span class="cx">     switch (length.type()) {
</span><span class="cx">     case Percent:
</span><span class="lines">@@ -716,9 +699,9 @@
</span><span class="cx">     case ViewportPercentageMin:
</span><span class="cx">     case ViewportPercentageMax:
</span><span class="cx">     case Fixed:
</span><del>-        return createExpressionNode(CSSPrimitiveValue::create(length, style), length.value() == trunc(length.value()));
</del><ins>+        return CSSCalcPrimitiveValue::create(CSSPrimitiveValue::create(length, &amp;style), length.value() == trunc(length.value()));
</ins><span class="cx">     case Calculated:
</span><del>-        return createExpressionNode(length.calculationValue()-&gt;expression(), style);
</del><ins>+        return createCSS(length.calculationValue().expression(), style);
</ins><span class="cx">     case Auto:
</span><span class="cx">     case Intrinsic:
</span><span class="cx">     case MinIntrinsic:
</span><span class="lines">@@ -729,27 +712,30 @@
</span><span class="cx">     case Relative:
</span><span class="cx">     case Undefined:
</span><span class="cx">         ASSERT_NOT_REACHED();
</span><del>-        return 0;
</del><ins>+        return nullptr;
</ins><span class="cx">     }
</span><span class="cx">     ASSERT_NOT_REACHED();
</span><del>-    return 0;
</del><ins>+    return nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-PassRefPtr&lt;CSSCalcValue&gt; CSSCalcValue::create(CSSParserString name, CSSParserValueList* parserValueList, CalculationPermittedValueRange range)
</del><ins>+PassRefPtr&lt;CSSCalcValue&gt; CSSCalcValue::create(CSSParserString name, CSSParserValueList&amp; parserValueList, CalculationPermittedValueRange range)
</ins><span class="cx"> {
</span><span class="cx">     CSSCalcExpressionNodeParser parser;
</span><span class="cx">     RefPtr&lt;CSSCalcExpressionNode&gt; expression;
</span><span class="cx"> 
</span><span class="cx">     if (equalIgnoringCase(name, &quot;calc(&quot;) || equalIgnoringCase(name, &quot;-webkit-calc(&quot;))
</span><del>-        expression = parser.parseCalc(parserValueList);
</del><ins>+        expression = parser.parseCalc(&amp;parserValueList);
</ins><span class="cx">     // FIXME: calc (http://webkit.org/b/16662) Add parsing for min and max here
</span><span class="cx"> 
</span><del>-    return expression ? adoptRef(new CSSCalcValue(expression, range)) : 0;
</del><ins>+    return expression ? adoptRef(new CSSCalcValue(expression.releaseNonNull(), range != CalculationRangeAll)) : nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-PassRef&lt;CSSCalcValue&gt; CSSCalcValue::create(PassRefPtr&lt;CSSCalcExpressionNode&gt; expression, CalculationPermittedValueRange range)
</del><ins>+PassRefPtr&lt;CSSCalcValue&gt; CSSCalcValue::create(const CalculationValue&amp; value, const RenderStyle&amp; style)
</ins><span class="cx"> {
</span><del>-    return adoptRef(*new CSSCalcValue(expression, range));
</del><ins>+    RefPtr&lt;CSSCalcExpressionNode&gt; expression = createCSS(value.expression(), style);
+    if (!expression)
+        return nullptr;
+    return adoptRef(new CSSCalcValue(expression.releaseNonNull(), value.shouldClampToNonNegative()));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSCalculationValueh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSCalculationValue.h (166859 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSCalculationValue.h        2014-04-06 23:41:10 UTC (rev 166859)
+++ trunk/Source/WebCore/css/CSSCalculationValue.h        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -33,20 +33,11 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CSSParserValues.h&quot;
</span><span class="cx"> #include &quot;CSSPrimitiveValue.h&quot;
</span><del>-#include &quot;CSSValue.h&quot;
</del><span class="cx"> #include &quot;CalculationValue.h&quot;
</span><del>-#include &lt;memory&gt;
-#include &lt;wtf/RefCounted.h&gt;
-#include &lt;wtf/RefPtr.h&gt;
</del><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class CSSParserValueList;
-class CSSValueList;
-class CalculationValue;
-class CalcExpressionNode;
</del><span class="cx"> class RenderStyle;
</span><del>-struct Length;
</del><span class="cx"> 
</span><span class="cx"> enum CalculationCategory {
</span><span class="cx">     CalcNumber = 0,
</span><span class="lines">@@ -64,17 +55,17 @@
</span><span class="cx">         CssCalcBinaryOperation
</span><span class="cx">     };
</span><span class="cx"> 
</span><del>-    virtual ~CSSCalcExpressionNode() = 0;
</del><ins>+    virtual ~CSSCalcExpressionNode() { }
</ins><span class="cx">     virtual bool isZero() const = 0;
</span><del>-    virtual std::unique_ptr&lt;CalcExpressionNode&gt; toCalcValue(const RenderStyle*, const RenderStyle* rootStyle, double zoom = 1.0) const = 0;
</del><ins>+    virtual std::unique_ptr&lt;CalcExpressionNode&gt; createCalcExpression(const RenderStyle*, const RenderStyle* rootStyle, double zoom = 1.0) const = 0;
</ins><span class="cx">     virtual double doubleValue() const = 0;
</span><span class="cx">     virtual double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const = 0;
</span><span class="cx">     virtual String customCSSText() const = 0;
</span><span class="cx">     virtual bool equals(const CSSCalcExpressionNode&amp; other) const { return m_category == other.m_category &amp;&amp; m_isInteger == other.m_isInteger; }
</span><span class="cx">     virtual Type type() const = 0;
</span><ins>+    virtual CSSPrimitiveValue::UnitTypes primitiveType() const = 0;
</ins><span class="cx"> 
</span><span class="cx">     CalculationCategory category() const { return m_category; }
</span><del>-    virtual CSSPrimitiveValue::UnitTypes primitiveType() const = 0;
</del><span class="cx">     bool isInteger() const { return m_isInteger; }
</span><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="lines">@@ -84,56 +75,49 @@
</span><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+private:
</ins><span class="cx">     CalculationCategory m_category;
</span><span class="cx">     bool m_isInteger;
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> class CSSCalcValue : public CSSValue {
</span><span class="cx"> public:
</span><del>-    static PassRefPtr&lt;CSSCalcValue&gt; create(CSSParserString name, CSSParserValueList*, CalculationPermittedValueRange);
-    static PassRef&lt;CSSCalcValue&gt; create(PassRefPtr&lt;CSSCalcExpressionNode&gt;, CalculationPermittedValueRange = CalculationRangeAll);
-    static PassRef&lt;CSSCalcValue&gt; create(const CalculationValue* value, const RenderStyle* style) { return adoptRef(*new CSSCalcValue(value, style)); }
</del><ins>+    static PassRefPtr&lt;CSSCalcValue&gt; create(CSSParserString name, CSSParserValueList&amp; arguments, CalculationPermittedValueRange);
+    static PassRefPtr&lt;CSSCalcValue&gt; create(const CalculationValue&amp;, const RenderStyle&amp;);
</ins><span class="cx"> 
</span><del>-    static PassRefPtr&lt;CSSCalcExpressionNode&gt; createExpressionNode(PassRefPtr&lt;CSSPrimitiveValue&gt;, bool isInteger = false);
-    static PassRefPtr&lt;CSSCalcExpressionNode&gt; createExpressionNode(PassRefPtr&lt;CSSCalcExpressionNode&gt;, PassRefPtr&lt;CSSCalcExpressionNode&gt;, CalcOperator);
-    static PassRefPtr&lt;CSSCalcExpressionNode&gt; createExpressionNode(const CalcExpressionNode*, const RenderStyle*);
-    static PassRefPtr&lt;CSSCalcExpressionNode&gt; createExpressionNode(const Length&amp;, const RenderStyle*);
-
-    PassRefPtr&lt;CalculationValue&gt; toCalcValue(const RenderStyle* style, const RenderStyle* rootStyle, double zoom = 1.0) const
-    {
-        return CalculationValue::create(m_expression-&gt;toCalcValue(style, rootStyle, zoom), m_nonNegative ? CalculationRangeNonNegative : CalculationRangeAll);
-    }
</del><span class="cx">     CalculationCategory category() const { return m_expression-&gt;category(); }
</span><span class="cx">     bool isInt() const { return m_expression-&gt;isInteger(); }
</span><span class="cx">     double doubleValue() const;
</span><span class="cx">     bool isNegative() const { return m_expression-&gt;doubleValue() &lt; 0; }
</span><del>-    CalculationPermittedValueRange permittedValueRange() { return m_nonNegative ? CalculationRangeNonNegative : CalculationRangeAll; }
</del><span class="cx">     double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const;
</span><del>-    CSSCalcExpressionNode* expressionNode() const { return m_expression.get(); }
</del><span class="cx"> 
</span><ins>+    PassRef&lt;CalculationValue&gt; createCalculationValue(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double zoom = 1.0) const;
+
</ins><span class="cx">     String customCSSText() const;
</span><span class="cx">     bool equals(const CSSCalcValue&amp;) const;
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    CSSCalcValue(PassRefPtr&lt;CSSCalcExpressionNode&gt; expression, CalculationPermittedValueRange range)
-        : CSSValue(CalculationClass)
-        , m_expression(expression)
-        , m_nonNegative(range == CalculationRangeNonNegative)
-    {
-    }
-    CSSCalcValue(const CalculationValue* value, const RenderStyle* style)
-        : CSSValue(CalculationClass)
-        , m_expression(createExpressionNode(value-&gt;expression(), style))
-        , m_nonNegative(value-&gt;isNonNegative())
-    {
-    }
</del><ins>+    CSSCalcValue(PassRef&lt;CSSCalcExpressionNode&gt;, bool shouldClampToNonNegative);
</ins><span class="cx"> 
</span><span class="cx">     double clampToPermittedRange(double) const;
</span><span class="cx"> 
</span><del>-    const RefPtr&lt;CSSCalcExpressionNode&gt; m_expression;
-    const bool m_nonNegative;
</del><ins>+    const Ref&lt;CSSCalcExpressionNode&gt; m_expression;
+    const bool m_shouldClampToNonNegative;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><ins>+inline CSSCalcValue::CSSCalcValue(PassRef&lt;CSSCalcExpressionNode&gt; expression, bool shouldClampToNonNegative)
+    : CSSValue(CalculationClass)
+    , m_expression(std::move(expression))
+    , m_shouldClampToNonNegative(shouldClampToNonNegative)
+{
+}
+
+inline PassRef&lt;CalculationValue&gt; CSSCalcValue::createCalculationValue(const RenderStyle* style, const RenderStyle* rootStyle, double zoom) const
+{
+    return CalculationValue::create(m_expression-&gt;createCalcExpression(style, rootStyle, zoom),
+        m_shouldClampToNonNegative ? CalculationRangeNonNegative : CalculationRangeAll);
+}
+
</ins><span class="cx"> CSS_VALUE_TYPE_CASTS(CSSCalcValue, isCalcValue())
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSComputedStyleDeclarationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (166859 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp        2014-04-06 23:41:10 UTC (rev 166859)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -677,9 +677,9 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (style-&gt;hasOutOfFlowPosition()) {
</span><del>-        if (l.type() == WebCore::Fixed)
</del><ins>+        if (l.isFixed())
</ins><span class="cx">             return zoomAdjustedPixelValue(l.value(), style);
</span><del>-        else if (l.isViewportPercentage())
</del><ins>+        if (l.isViewportPercentage())
</ins><span class="cx">             return zoomAdjustedPixelValue(valueForLength(l, 0, renderView), style);
</span><span class="cx">         return cssValuePool().createValue(l);
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSGradientValuecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSGradientValue.cpp (166859 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSGradientValue.cpp        2014-04-06 23:41:10 UTC (rev 166859)
+++ trunk/Source/WebCore/css/CSSGradientValue.cpp        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -182,8 +182,10 @@
</span><span class="cx">                 float length;
</span><span class="cx">                 if (stop.m_position-&gt;isLength())
</span><span class="cx">                     length = stop.m_position-&gt;computeLength&lt;float&gt;(&amp;style, &amp;rootStyle, style.effectiveZoom());
</span><del>-                else 
-                    length = stop.m_position-&gt;cssCalcValue()-&gt;toCalcValue(&amp;style, &amp;rootStyle, style.effectiveZoom())-&gt;evaluate(gradientLength);
</del><ins>+                else {
+                    Ref&lt;CalculationValue&gt; calculationValue { stop.m_position-&gt;cssCalcValue()-&gt;createCalculationValue(&amp;style, &amp;rootStyle, style.effectiveZoom()) };
+                    length = calculationValue-&gt;evaluate(gradientLength);
+                }
</ins><span class="cx">                 stops[i].offset = (gradientLength &gt; 0) ? length / gradientLength : 0;
</span><span class="cx">             } else {
</span><span class="cx">                 ASSERT_NOT_REACHED();
</span><span class="lines">@@ -401,8 +403,10 @@
</span><span class="cx">     if (value-&gt;isPercentage())
</span><span class="cx">         return value-&gt;getFloatValue() / 100.f * edgeDistance;
</span><span class="cx"> 
</span><del>-    if (value-&gt;isCalculatedPercentageWithLength())
-        return value-&gt;cssCalcValue()-&gt;toCalcValue(&amp;style, &amp;rootStyle, style.effectiveZoom())-&gt;evaluate(edgeDistance);
</del><ins>+    if (value-&gt;isCalculatedPercentageWithLength()) {
+        Ref&lt;CalculationValue&gt; calculationValue { value-&gt;cssCalcValue()-&gt;createCalculationValue(&amp;style, &amp;rootStyle, style.effectiveZoom()) };
+        return calculationValue-&gt;evaluate(edgeDistance);
+    }
</ins><span class="cx"> 
</span><span class="cx">     switch (value-&gt;getValueID()) {
</span><span class="cx">     case CSSValueTop:
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSParser.cpp (166859 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSParser.cpp        2014-04-06 23:41:10 UTC (rev 166859)
+++ trunk/Source/WebCore/css/CSSParser.cpp        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -9569,7 +9569,7 @@
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     ASSERT(!m_parsedCalculation);
</span><del>-    m_parsedCalculation = CSSCalcValue::create(value-&gt;function-&gt;name, args, range);
</del><ins>+    m_parsedCalculation = CSSCalcValue::create(value-&gt;function-&gt;name, *args, range);
</ins><span class="cx">     
</span><span class="cx">     if (!m_parsedCalculation)
</span><span class="cx">         return false;
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSPrimitiveValuecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.cpp (166859 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSPrimitiveValue.cpp        2014-04-06 23:41:10 UTC (rev 166859)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.cpp        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -305,15 +305,16 @@
</span><span class="cx">         m_value.num = adjustFloatForAbsoluteZoom(length.value(), style);
</span><span class="cx">         return;
</span><span class="cx">     case Calculated: {
</span><del>-        RefPtr&lt;CSSCalcValue&gt; calcValue = CSSCalcValue::create(length.calculationValue().get(), style);
</del><ins>+        RefPtr&lt;CSSCalcValue&gt; calcValue = CSSCalcValue::create(length.calculationValue(), *style);
</ins><span class="cx">         init(calcValue.release());
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     case Relative:
</span><span class="cx">     case Undefined:
</span><span class="cx">         ASSERT_NOT_REACHED();
</span><del>-        break;
</del><ins>+        return;
</ins><span class="cx">     }
</span><ins>+    ASSERT_NOT_REACHED();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> CSSPrimitiveValue::CSSPrimitiveValue(const LengthSize&amp; lengthSize)
</span><span class="lines">@@ -328,62 +329,63 @@
</span><span class="cx">     case Auto:
</span><span class="cx">         m_primitiveUnitType = CSS_VALUE_ID;
</span><span class="cx">         m_value.valueID = CSSValueAuto;
</span><del>-        break;
</del><ins>+        return;
</ins><span class="cx">     case WebCore::Fixed:
</span><span class="cx">         m_primitiveUnitType = CSS_PX;
</span><span class="cx">         m_value.num = length.value();
</span><del>-        break;
</del><ins>+        return;
</ins><span class="cx">     case Intrinsic:
</span><span class="cx">         m_primitiveUnitType = CSS_VALUE_ID;
</span><span class="cx">         m_value.valueID = CSSValueIntrinsic;
</span><del>-        break;
</del><ins>+        return;
</ins><span class="cx">     case MinIntrinsic:
</span><span class="cx">         m_primitiveUnitType = CSS_VALUE_ID;
</span><span class="cx">         m_value.valueID = CSSValueMinIntrinsic;
</span><del>-        break;
</del><ins>+        return;
</ins><span class="cx">     case MinContent:
</span><span class="cx">         m_primitiveUnitType = CSS_VALUE_ID;
</span><span class="cx">         m_value.valueID = CSSValueWebkitMinContent;
</span><del>-        break;
</del><ins>+        return;
</ins><span class="cx">     case MaxContent:
</span><span class="cx">         m_primitiveUnitType = CSS_VALUE_ID;
</span><span class="cx">         m_value.valueID = CSSValueWebkitMaxContent;
</span><del>-        break;
</del><ins>+        return;
</ins><span class="cx">     case FillAvailable:
</span><span class="cx">         m_primitiveUnitType = CSS_VALUE_ID;
</span><span class="cx">         m_value.valueID = CSSValueWebkitFillAvailable;
</span><del>-        break;
</del><ins>+        return;
</ins><span class="cx">     case FitContent:
</span><span class="cx">         m_primitiveUnitType = CSS_VALUE_ID;
</span><span class="cx">         m_value.valueID = CSSValueWebkitFitContent;
</span><del>-        break;
</del><ins>+        return;
</ins><span class="cx">     case Percent:
</span><span class="cx">         m_primitiveUnitType = CSS_PERCENTAGE;
</span><span class="cx">         ASSERT(std::isfinite(length.percent()));
</span><span class="cx">         m_value.num = length.percent();
</span><del>-        break;
</del><ins>+        return;
</ins><span class="cx">     case ViewportPercentageWidth:
</span><span class="cx">         m_primitiveUnitType = CSS_VW;
</span><span class="cx">         m_value.num = length.viewportPercentageLength();
</span><del>-        break;
</del><ins>+        return;
</ins><span class="cx">     case ViewportPercentageHeight:
</span><span class="cx">         m_primitiveUnitType = CSS_VH;
</span><span class="cx">         m_value.num = length.viewportPercentageLength();
</span><del>-        break;
</del><ins>+        return;
</ins><span class="cx">     case ViewportPercentageMin:
</span><span class="cx">         m_primitiveUnitType = CSS_VMIN;
</span><span class="cx">         m_value.num = length.viewportPercentageLength();
</span><del>-        break;
</del><ins>+        return;
</ins><span class="cx">     case ViewportPercentageMax:
</span><span class="cx">         m_primitiveUnitType = CSS_VMAX;
</span><span class="cx">         m_value.num = length.viewportPercentageLength();
</span><del>-        break;
</del><ins>+        return;
</ins><span class="cx">     case Calculated:
</span><span class="cx">     case Relative:
</span><span class="cx">     case Undefined:
</span><span class="cx">         ASSERT_NOT_REACHED();
</span><del>-        break;
</del><ins>+        return;
</ins><span class="cx">     }
</span><ins>+    ASSERT_NOT_REACHED();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CSSPrimitiveValue::init(const LengthSize&amp; lengthSize)
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSPrimitiveValueMappingsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h (166859 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h        2014-04-06 23:41:10 UTC (rev 166859)
+++ trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -4646,7 +4646,7 @@
</span><span class="cx">     if ((supported &amp; AutoConversion) &amp;&amp; getValueID() == CSSValueAuto)
</span><span class="cx">         return Length(Auto);
</span><span class="cx">     if ((supported &amp; CalculatedConversion) &amp;&amp; isCalculated())
</span><del>-        return Length(cssCalcValue()-&gt;toCalcValue(style, rootStyle, multiplier));
</del><ins>+        return Length(cssCalcValue()-&gt;createCalculationValue(style, rootStyle, multiplier));
</ins><span class="cx">     if ((supported &amp; ViewportPercentageConversion) &amp;&amp; isViewportPercentageLength())
</span><span class="cx">         return viewportPercentageLength();
</span><span class="cx">     return Length(Undefined);
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSToStyleMapcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSToStyleMap.cpp (166859 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSToStyleMap.cpp        2014-04-06 23:41:10 UTC (rev 166859)
+++ trunk/Source/WebCore/css/CSSToStyleMap.cpp        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -251,7 +251,7 @@
</span><span class="cx">     else if (primitiveValue-&gt;isPercentage())
</span><span class="cx">         length = Length(primitiveValue-&gt;getDoubleValue(), Percent);
</span><span class="cx">     else if (primitiveValue-&gt;isCalculatedPercentageWithLength())
</span><del>-        length = Length(primitiveValue-&gt;cssCalcValue()-&gt;toCalcValue(style(), rootElementStyle(), zoomFactor));
</del><ins>+        length = Length(primitiveValue-&gt;cssCalcValue()-&gt;createCalculationValue(style(), rootElementStyle(), zoomFactor));
</ins><span class="cx">     else if (primitiveValue-&gt;isViewportPercentageLength())
</span><span class="cx">         length = primitiveValue-&gt;viewportPercentageLength();
</span><span class="cx">     else
</span><span class="lines">@@ -287,7 +287,7 @@
</span><span class="cx">     else if (primitiveValue-&gt;isPercentage())
</span><span class="cx">         length = Length(primitiveValue-&gt;getDoubleValue(), Percent);
</span><span class="cx">     else if (primitiveValue-&gt;isCalculatedPercentageWithLength())
</span><del>-        length = Length(primitiveValue-&gt;cssCalcValue()-&gt;toCalcValue(style(), rootElementStyle(), zoomFactor));
</del><ins>+        length = Length(primitiveValue-&gt;cssCalcValue()-&gt;createCalculationValue(style(), rootElementStyle(), zoomFactor));
</ins><span class="cx">     else if (primitiveValue-&gt;isViewportPercentageLength())
</span><span class="cx">         length = primitiveValue-&gt;viewportPercentageLength();
</span><span class="cx">     else
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSToStyleMaph"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSToStyleMap.h (166859 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSToStyleMap.h        2014-04-06 23:41:10 UTC (rev 166859)
+++ trunk/Source/WebCore/css/CSSToStyleMap.h        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -23,20 +23,21 @@
</span><span class="cx"> #define CSSToStyleMap_h
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CSSPropertyNames.h&quot;
</span><del>-#include &quot;LengthBox.h&quot;
</del><span class="cx"> #include &lt;wtf/FastMalloc.h&gt;
</span><span class="cx"> #include &lt;wtf/Noncopyable.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+class Animation;
+class CSSValue;
</ins><span class="cx"> class FillLayer;
</span><del>-class CSSValue;
-class Animation;
</del><span class="cx"> class RenderStyle;
</span><span class="cx"> class StyleImage;
</span><span class="cx"> class StyleResolver;
</span><span class="cx"> class NinePieceImage;
</span><span class="cx"> 
</span><ins>+struct LengthBox;
+
</ins><span class="cx"> class CSSToStyleMap {
</span><span class="cx">     WTF_MAKE_NONCOPYABLE(CSSToStyleMap);
</span><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span></span></pre></div>
<a id="trunkSourceWebCorecssDeprecatedStyleBuildercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp (166859 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp        2014-04-06 23:41:10 UTC (rev 166859)
+++ trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -388,12 +388,12 @@
</span><span class="cx">             setValue(styleResolver-&gt;style(), Length());
</span><span class="cx">         else if (primitiveValue-&gt;isLength()) {
</span><span class="cx">             Length length = primitiveValue-&gt;computeLength&lt;Length&gt;(styleResolver-&gt;style(), styleResolver-&gt;rootElementStyle(), styleResolver-&gt;style()-&gt;effectiveZoom());
</span><del>-            length.setQuirk(primitiveValue-&gt;isQuirkValue());
</del><ins>+            length.setHasQuirk(primitiveValue-&gt;isQuirkValue());
</ins><span class="cx">             setValue(styleResolver-&gt;style(), length);
</span><span class="cx">         } else if (primitiveValue-&gt;isPercentage())
</span><span class="cx">             setValue(styleResolver-&gt;style(), Length(primitiveValue-&gt;getDoubleValue(), Percent));
</span><span class="cx">         else if (primitiveValue-&gt;isCalculatedPercentageWithLength())
</span><del>-            setValue(styleResolver-&gt;style(), Length(primitiveValue-&gt;cssCalcValue()-&gt;toCalcValue(styleResolver-&gt;style(), styleResolver-&gt;rootElementStyle(), styleResolver-&gt;style()-&gt;effectiveZoom())));
</del><ins>+            setValue(styleResolver-&gt;style(), Length(primitiveValue-&gt;cssCalcValue()-&gt;createCalculationValue(styleResolver-&gt;style(), styleResolver-&gt;rootElementStyle(), styleResolver-&gt;style()-&gt;effectiveZoom())));
</ins><span class="cx">         else if (primitiveValue-&gt;isViewportPercentageLength())
</span><span class="cx">             setValue(styleResolver-&gt;style(), primitiveValue-&gt;viewportPercentageLength());
</span><span class="cx">     }
</span><span class="lines">@@ -449,7 +449,7 @@
</span><span class="cx">         else if (pair-&gt;first()-&gt;isViewportPercentageLength())
</span><span class="cx">             radiusWidth = Length(styleResolver-&gt;viewportPercentageValue(*pair-&gt;first(), pair-&gt;first()-&gt;getIntValue()), Fixed);
</span><span class="cx">         else if (pair-&gt;first()-&gt;isCalculatedPercentageWithLength())
</span><del>-            radiusWidth = Length((pair-&gt;first()-&gt;cssCalcValue()-&gt;toCalcValue(styleResolver-&gt;style(), styleResolver-&gt;rootElementStyle(), styleResolver-&gt;style()-&gt;effectiveZoom())));
</del><ins>+            radiusWidth = Length(pair-&gt;first()-&gt;cssCalcValue()-&gt;createCalculationValue(styleResolver-&gt;style(), styleResolver-&gt;rootElementStyle(), styleResolver-&gt;style()-&gt;effectiveZoom()));
</ins><span class="cx">         else
</span><span class="cx">             radiusWidth = pair-&gt;first()-&gt;computeLength&lt;Length&gt;(styleResolver-&gt;style(), styleResolver-&gt;rootElementStyle(), styleResolver-&gt;style()-&gt;effectiveZoom());
</span><span class="cx">         if (pair-&gt;second()-&gt;isPercentage())
</span><span class="lines">@@ -457,7 +457,7 @@
</span><span class="cx">         else if (pair-&gt;second()-&gt;isViewportPercentageLength())
</span><span class="cx">             radiusHeight = Length(styleResolver-&gt;viewportPercentageValue(*pair-&gt;second(), pair-&gt;second()-&gt;getIntValue()), Fixed);
</span><span class="cx">         else if (pair-&gt;second()-&gt;isCalculatedPercentageWithLength())
</span><del>-            radiusHeight = Length((pair-&gt;second()-&gt;cssCalcValue()-&gt;toCalcValue(styleResolver-&gt;style(), styleResolver-&gt;rootElementStyle(), styleResolver-&gt;style()-&gt;effectiveZoom())));
</del><ins>+            radiusHeight = Length(pair-&gt;second()-&gt;cssCalcValue()-&gt;createCalculationValue(styleResolver-&gt;style(), styleResolver-&gt;rootElementStyle(), styleResolver-&gt;style()-&gt;effectiveZoom()));
</ins><span class="cx">         else
</span><span class="cx">             radiusHeight = pair-&gt;second()-&gt;computeLength&lt;Length&gt;(styleResolver-&gt;style(), styleResolver-&gt;rootElementStyle(), styleResolver-&gt;style()-&gt;effectiveZoom());
</span><span class="cx">         int width = radiusWidth.value();
</span><span class="lines">@@ -883,9 +883,10 @@
</span><span class="cx">                 size = primitiveValue-&gt;computeLength&lt;float&gt;(styleResolver-&gt;parentStyle(), styleResolver-&gt;rootElementStyle(), 1.0, true);
</span><span class="cx">             else if (primitiveValue-&gt;isPercentage())
</span><span class="cx">                 size = (primitiveValue-&gt;getFloatValue() * parentSize) / 100.0f;
</span><del>-            else if (primitiveValue-&gt;isCalculatedPercentageWithLength())
-                size = primitiveValue-&gt;cssCalcValue()-&gt;toCalcValue(styleResolver-&gt;parentStyle(), styleResolver-&gt;rootElementStyle())-&gt;evaluate(parentSize);
-            else if (primitiveValue-&gt;isViewportPercentageLength())
</del><ins>+            else if (primitiveValue-&gt;isCalculatedPercentageWithLength()) {
+                Ref&lt;CalculationValue&gt; calculationValue { primitiveValue-&gt;cssCalcValue()-&gt;createCalculationValue(styleResolver-&gt;parentStyle(), styleResolver-&gt;rootElementStyle()) };
+                size = calculationValue-&gt;evaluate(parentSize);
+            } else if (primitiveValue-&gt;isViewportPercentageLength())
</ins><span class="cx">                 size = valueForLength(primitiveValue-&gt;viewportPercentageLength(), 0, styleResolver-&gt;document().renderView());
</span><span class="cx">             else
</span><span class="cx">                 return;
</span></span></pre></div>
<a id="trunkSourceWebCorecssLengthFunctionscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/LengthFunctions.cpp (166859 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/LengthFunctions.cpp        2014-04-06 23:41:10 UTC (rev 166859)
+++ trunk/Source/WebCore/css/LengthFunctions.cpp        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -122,7 +122,7 @@
</span><span class="cx"> {
</span><span class="cx">     switch (length.type()) {
</span><span class="cx">     case Fixed:
</span><del>-        return length.getFloatValue();
</del><ins>+        return length.value();
</ins><span class="cx">     case Percent:
</span><span class="cx">         return static_cast&lt;float&gt;(maximumValue * length.percent() / 100.0f);
</span><span class="cx">     case FillAvailable:
</span><span class="lines">@@ -168,7 +168,7 @@
</span><span class="cx"> {
</span><span class="cx">     switch (length.type()) {
</span><span class="cx">     case Fixed:
</span><del>-        return length.getFloatValue();
</del><ins>+        return length.value();
</ins><span class="cx">     case Percent:
</span><span class="cx">         return static_cast&lt;float&gt;(maximumValue * length.percent() / 100.0f);
</span><span class="cx">     case FillAvailable:
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleResolvercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleResolver.cpp (166859 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleResolver.cpp        2014-04-06 23:41:10 UTC (rev 166859)
+++ trunk/Source/WebCore/css/StyleResolver.cpp        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -1041,18 +1041,18 @@
</span><span class="cx">     const int intrinsicMargin = 2 * style.effectiveZoom();
</span><span class="cx"> 
</span><span class="cx">     // FIXME: Using width/height alone and not also dealing with min-width/max-width is flawed.
</span><del>-    // FIXME: Using &quot;quirk&quot; to decide the margin wasn't set is kind of lame.
</del><ins>+    // FIXME: Using &quot;hasQuirk&quot; to decide the margin wasn't set is kind of lame.
</ins><span class="cx">     if (style.width().isIntrinsicOrAuto()) {
</span><del>-        if (style.marginLeft().quirk())
</del><ins>+        if (style.marginLeft().hasQuirk())
</ins><span class="cx">             style.setMarginLeft(Length(intrinsicMargin, Fixed));
</span><del>-        if (style.marginRight().quirk())
</del><ins>+        if (style.marginRight().hasQuirk())
</ins><span class="cx">             style.setMarginRight(Length(intrinsicMargin, Fixed));
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (style.height().isAuto()) {
</span><del>-        if (style.marginTop().quirk())
</del><ins>+        if (style.marginTop().hasQuirk())
</ins><span class="cx">             style.setMarginTop(Length(intrinsicMargin, Fixed));
</span><del>-        if (style.marginBottom().quirk())
</del><ins>+        if (style.marginBottom().hasQuirk())
</ins><span class="cx">             style.setMarginBottom(Length(intrinsicMargin, Fixed));
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -1860,7 +1860,7 @@
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     if (primitiveValue-&gt;isLength())
</span><del>-        workingLength.length().setQuirk(primitiveValue-&gt;isQuirkValue());
</del><ins>+        workingLength.length().setHasQuirk(primitiveValue-&gt;isQuirkValue());
</ins><span class="cx"> 
</span><span class="cx">     return true;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformCalculationValuecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/CalculationValue.cpp (166859 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/CalculationValue.cpp        2014-04-06 23:41:10 UTC (rev 166859)
+++ trunk/Source/WebCore/platform/CalculationValue.cpp        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -1,5 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 2011 Google Inc. All rights reserved.
</span><ins>+ * Copyright (C) 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions are
</span><span class="lines">@@ -35,6 +36,31 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+PassRef&lt;CalculationValue&gt; CalculationValue::create(std::unique_ptr&lt;CalcExpressionNode&gt; value, CalculationPermittedValueRange range)
+{
+    return adoptRef(*new CalculationValue(std::move(value), range));
+}
+
+float CalcExpressionNumber::evaluate(float) const
+{
+    return m_value;
+}
+
+bool CalcExpressionNumber::operator==(const CalcExpressionNode&amp; other) const
+{
+    return other.type() == CalcExpressionNodeNumber &amp;&amp; *this == toCalcExpressionNumber(other);
+}
+
+float CalculationValue::evaluate(float maxValue) const
+{
+    float result = m_expression-&gt;evaluate(maxValue);
+    // FIXME: This test was originally needed when we did not detect division by zero at parse time.
+    // It's possible that this is now unneeded code and can be removed.
+    if (std::isnan(result))
+        return 0;
+    return m_shouldClampToNonNegative &amp;&amp; result &lt; 0 ? 0 : result;
+}
+
</ins><span class="cx"> float CalcExpressionBinaryOperation::evaluate(float maxValue) const
</span><span class="cx"> {
</span><span class="cx">     float left = m_leftSide-&gt;evaluate(maxValue);
</span><span class="lines">@@ -55,19 +81,29 @@
</span><span class="cx">     return std::numeric_limits&lt;float&gt;::quiet_NaN();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-PassRefPtr&lt;CalculationValue&gt; CalculationValue::create(std::unique_ptr&lt;CalcExpressionNode&gt; value, CalculationPermittedValueRange range)
</del><ins>+bool CalcExpressionBinaryOperation::operator==(const CalcExpressionNode&amp; other) const
</ins><span class="cx"> {
</span><del>-    return adoptRef(new CalculationValue(std::move(value), range));
</del><ins>+    return other.type() == CalcExpressionNodeBinaryOperation &amp;&amp; *this == toCalcExpressionBinaryOperation(other);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-float CalculationValue::evaluate(float maxValue) const
</del><ins>+float CalcExpressionLength::evaluate(float maxValue) const
</ins><span class="cx"> {
</span><del>-    float result = m_value-&gt;evaluate(maxValue);
-    // FIXME calc https://webkit.org/b/80411 : result is NaN when there is a division 
-    // by zero which isn't found at parse time. 
-    if (std::isnan(result))
-        return 0;
-    return m_isNonNegative &amp;&amp; result &lt; 0 ? 0 : result;
</del><ins>+    return floatValueForLength(m_length, maxValue);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool CalcExpressionLength::operator==(const CalcExpressionNode&amp; other) const
+{
+    return other.type() == CalcExpressionNodeLength &amp;&amp; *this == toCalcExpressionLength(other);
+}
+
+float CalcExpressionBlendLength::evaluate(float maxValue) const
+{
+    return (1.0f - m_progress) * floatValueForLength(m_from, maxValue) + m_progress * floatValueForLength(m_to, maxValue);
+}
+
+bool CalcExpressionBlendLength::operator==(const CalcExpressionNode&amp; other) const
+{
+    return other.type() == CalcExpressionNodeBlendLength &amp;&amp; *this == toCalcExpressionBlendLength(other);
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformCalculationValueh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/CalculationValue.h (166859 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/CalculationValue.h        2014-04-06 23:41:10 UTC (rev 166859)
+++ trunk/Source/WebCore/platform/CalculationValue.h        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -62,195 +62,179 @@
</span><span class="cx"> class CalcExpressionNode {
</span><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><del>-    CalcExpressionNode()
-        : m_type(CalcExpressionNodeUndefined)
-    {
-    }
</del><ins>+    explicit CalcExpressionNode(CalcExpressionNodeType = CalcExpressionNodeUndefined);
+    virtual ~CalcExpressionNode() { }
</ins><span class="cx"> 
</span><del>-    virtual ~CalcExpressionNode()
-    {
-    }
</del><ins>+    CalcExpressionNodeType type() const { return m_type; }
</ins><span class="cx"> 
</span><span class="cx">     virtual float evaluate(float maxValue) const = 0;
</span><span class="cx">     virtual bool operator==(const CalcExpressionNode&amp;) const = 0;
</span><span class="cx"> 
</span><del>-    CalcExpressionNodeType type() const { return m_type; }
-
-protected:
</del><ins>+private:
</ins><span class="cx">     CalcExpressionNodeType m_type;
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-class CalculationValue : public RefCounted&lt;CalculationValue&gt; {
</del><ins>+class CalcExpressionNumber final : public CalcExpressionNode {
</ins><span class="cx"> public:
</span><del>-    static PassRefPtr&lt;CalculationValue&gt; create(std::unique_ptr&lt;CalcExpressionNode&gt; value, CalculationPermittedValueRange);
-    float evaluate(float maxValue) const;
</del><ins>+    explicit CalcExpressionNumber(float);
</ins><span class="cx"> 
</span><del>-    bool operator==(const CalculationValue&amp; o) const
-    {
-        return *(m_value.get()) == *(o.m_value.get());
-    }
</del><ins>+    float value() const { return m_value; }
</ins><span class="cx"> 
</span><del>-    bool isNonNegative() const { return m_isNonNegative; }
-    const CalcExpressionNode* expression() const { return m_value.get(); }
-
</del><span class="cx"> private:
</span><del>-    CalculationValue(std::unique_ptr&lt;CalcExpressionNode&gt; value, CalculationPermittedValueRange range)
-        : m_value(std::move(value))
-        , m_isNonNegative(range == CalculationRangeNonNegative)
-    {
-    }
</del><ins>+    virtual float evaluate(float) const override;
+    virtual bool operator==(const CalcExpressionNode&amp;) const override;
</ins><span class="cx"> 
</span><del>-    std::unique_ptr&lt;CalcExpressionNode&gt; m_value;
-    bool m_isNonNegative;
</del><ins>+    float m_value;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><del>-class CalcExpressionNumber : public CalcExpressionNode {
</del><ins>+class CalcExpressionLength final : public CalcExpressionNode {
</ins><span class="cx"> public:
</span><del>-    explicit CalcExpressionNumber(float value)
-        : m_value(value)
-    {
-        m_type = CalcExpressionNodeNumber;
-    }
</del><ins>+    explicit CalcExpressionLength(Length);
</ins><span class="cx"> 
</span><del>-    bool operator==(const CalcExpressionNumber&amp; o) const
-    {
-        return m_value == o.m_value;
-    }
</del><ins>+    const Length&amp; length() const { return m_length; }
</ins><span class="cx"> 
</span><del>-    virtual bool operator==(const CalcExpressionNode&amp; o) const override
-    {
-        return type() == o.type() &amp;&amp; *this == static_cast&lt;const CalcExpressionNumber&amp;&gt;(o);
-    }
</del><ins>+private:
+    virtual float evaluate(float maxValue) const override;
+    virtual bool operator==(const CalcExpressionNode&amp;) const override;
</ins><span class="cx"> 
</span><del>-    virtual float evaluate(float) const override
-    {
-        return m_value;
-    }
</del><ins>+    Length m_length;
+};
</ins><span class="cx"> 
</span><del>-    float value() const { return m_value; }
</del><ins>+class CalcExpressionBinaryOperation final : public CalcExpressionNode {
+public:
+    CalcExpressionBinaryOperation(std::unique_ptr&lt;CalcExpressionNode&gt; leftSide, std::unique_ptr&lt;CalcExpressionNode&gt; rightSide, CalcOperator);
</ins><span class="cx"> 
</span><ins>+    const CalcExpressionNode&amp; leftSide() const { return *m_leftSide; }
+    const CalcExpressionNode&amp; rightSide() const { return *m_rightSide; }
+    CalcOperator getOperator() const { return m_operator; }
+
</ins><span class="cx"> private:
</span><del>-    float m_value;
</del><ins>+    virtual float evaluate(float maxValue) const override;
+    virtual bool operator==(const CalcExpressionNode&amp;) const override;
+
+    std::unique_ptr&lt;CalcExpressionNode&gt; m_leftSide;
+    std::unique_ptr&lt;CalcExpressionNode&gt; m_rightSide;
+    CalcOperator m_operator;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><del>-inline const CalcExpressionNumber* toCalcExpressionNumber(const CalcExpressionNode* value)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(!value || value-&gt;type() == CalcExpressionNodeNumber);
-    return static_cast&lt;const CalcExpressionNumber*&gt;(value);
-}
-
-class CalcExpressionLength : public CalcExpressionNode {
</del><ins>+class CalcExpressionBlendLength final : public CalcExpressionNode {
</ins><span class="cx"> public:
</span><del>-    explicit CalcExpressionLength(Length length)
-        : m_length(length)
-    {
-        m_type = CalcExpressionNodeLength;
-    }
</del><ins>+    CalcExpressionBlendLength(Length from, Length to, float progress);
</ins><span class="cx"> 
</span><del>-    bool operator==(const CalcExpressionLength&amp; o) const
-    {
-        return m_length == o.m_length;
-    }
</del><ins>+    const Length&amp; from() const { return m_from; }
+    const Length&amp; to() const { return m_to; }
+    float progress() const { return m_progress; }
</ins><span class="cx"> 
</span><del>-    virtual bool operator==(const CalcExpressionNode&amp; o) const override
-    {
-        return type() == o.type() &amp;&amp; *this == static_cast&lt;const CalcExpressionLength&amp;&gt;(o);
-    }
</del><ins>+private:
+    virtual float evaluate(float maxValue) const override;
+    virtual bool operator==(const CalcExpressionNode&amp;) const override;
</ins><span class="cx"> 
</span><del>-    virtual float evaluate(float maxValue) const override
-    {
-        return floatValueForLength(m_length, maxValue);
-    }
</del><ins>+    Length m_from;
+    Length m_to;
+    float m_progress;
+};
</ins><span class="cx"> 
</span><del>-    const Length&amp; length() const { return m_length; }
</del><ins>+class CalculationValue : public RefCounted&lt;CalculationValue&gt; {
+public:
+    static PassRef&lt;CalculationValue&gt; create(std::unique_ptr&lt;CalcExpressionNode&gt;, CalculationPermittedValueRange);
+    float evaluate(float maxValue) const;
</ins><span class="cx"> 
</span><ins>+    bool shouldClampToNonNegative() const { return m_shouldClampToNonNegative; }
+    const CalcExpressionNode&amp; expression() const { return *m_expression; }
+
</ins><span class="cx"> private:
</span><del>-    Length m_length;
</del><ins>+    CalculationValue(std::unique_ptr&lt;CalcExpressionNode&gt;, CalculationPermittedValueRange);
+
+    std::unique_ptr&lt;CalcExpressionNode&gt; m_expression;
+    bool m_shouldClampToNonNegative;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><del>-inline const CalcExpressionLength* toCalcExpressionLength(const CalcExpressionNode* value)
</del><ins>+inline CalcExpressionNode::CalcExpressionNode(CalcExpressionNodeType type)
+    : m_type(type)
</ins><span class="cx"> {
</span><del>-    ASSERT_WITH_SECURITY_IMPLICATION(!value || value-&gt;type() == CalcExpressionNodeLength);
-    return static_cast&lt;const CalcExpressionLength*&gt;(value);
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-class CalcExpressionBinaryOperation : public CalcExpressionNode {
-public:
-    CalcExpressionBinaryOperation(std::unique_ptr&lt;CalcExpressionNode&gt; leftSide, std::unique_ptr&lt;CalcExpressionNode&gt; rightSide, CalcOperator op)
-        : m_leftSide(std::move(leftSide))
-        , m_rightSide(std::move(rightSide))
-        , m_operator(op)
-    {
-        m_type = CalcExpressionNodeBinaryOperation;
-    }
</del><ins>+inline CalculationValue::CalculationValue(std::unique_ptr&lt;CalcExpressionNode&gt; expression, CalculationPermittedValueRange range)
+    : m_expression(std::move(expression))
+    , m_shouldClampToNonNegative(range == CalculationRangeNonNegative)
+{
+}
</ins><span class="cx"> 
</span><del>-    bool operator==(const CalcExpressionBinaryOperation&amp; o) const
-    {
-        return m_operator == o.m_operator &amp;&amp; *m_leftSide == *o.m_leftSide &amp;&amp; *m_rightSide == *o.m_rightSide;
-    }
</del><ins>+inline bool operator==(const CalculationValue&amp; a, const CalculationValue&amp; b)
+{
+    return a.expression() == b.expression();
+}
</ins><span class="cx"> 
</span><del>-    virtual bool operator==(const CalcExpressionNode&amp; o) const override
-    {
-        return type() == o.type() &amp;&amp; *this == static_cast&lt;const CalcExpressionBinaryOperation&amp;&gt;(o);
-    }
</del><ins>+inline CalcExpressionNumber::CalcExpressionNumber(float value)
+    : CalcExpressionNode(CalcExpressionNodeNumber)
+    , m_value(value)
+{
+}
</ins><span class="cx"> 
</span><del>-    virtual float evaluate(float) const override;
</del><ins>+inline bool operator==(const CalcExpressionNumber&amp; a, const CalcExpressionNumber&amp; b)
+{
+    return a.value() == b.value();
+}
</ins><span class="cx"> 
</span><del>-    const CalcExpressionNode* leftSide() const { return m_leftSide.get(); }
-    const CalcExpressionNode* rightSide() const { return m_rightSide.get(); }
-    CalcOperator getOperator() const { return m_operator; }
</del><ins>+inline const CalcExpressionNumber&amp; toCalcExpressionNumber(const CalcExpressionNode&amp; value)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(value.type() == CalcExpressionNodeNumber);
+    return static_cast&lt;const CalcExpressionNumber&amp;&gt;(value);
+}
</ins><span class="cx"> 
</span><del>-private:
-    std::unique_ptr&lt;CalcExpressionNode&gt; m_leftSide;
-    std::unique_ptr&lt;CalcExpressionNode&gt; m_rightSide;
-    CalcOperator m_operator;
-};
</del><ins>+inline CalcExpressionLength::CalcExpressionLength(Length length)
+    : CalcExpressionNode(CalcExpressionNodeLength)
+    , m_length(length)
+{
+}
</ins><span class="cx"> 
</span><del>-inline const CalcExpressionBinaryOperation* toCalcExpressionBinaryOperation(const CalcExpressionNode* value)
</del><ins>+inline bool operator==(const CalcExpressionLength&amp; a, const CalcExpressionLength&amp; b)
</ins><span class="cx"> {
</span><del>-    ASSERT_WITH_SECURITY_IMPLICATION(!value || value-&gt;type() == CalcExpressionNodeBinaryOperation);
-    return static_cast&lt;const CalcExpressionBinaryOperation*&gt;(value);
</del><ins>+    return a.length() == b.length();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-class CalcExpressionBlendLength : public CalcExpressionNode {
-public:
-    CalcExpressionBlendLength(Length from, Length to, float progress)
-        : m_from(from)
-        , m_to(to)
-        , m_progress(progress)
-    {
-        m_type = CalcExpressionNodeBlendLength;
-    }
</del><ins>+inline const CalcExpressionLength&amp; toCalcExpressionLength(const CalcExpressionNode&amp; value)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(value.type() == CalcExpressionNodeLength);
+    return static_cast&lt;const CalcExpressionLength&amp;&gt;(value);
+}
</ins><span class="cx"> 
</span><del>-    bool operator==(const CalcExpressionBlendLength&amp; o) const
-    {
-        return m_progress == o.m_progress &amp;&amp; m_from == o.m_from &amp;&amp; m_to == o.m_to;
-    }
</del><ins>+inline CalcExpressionBinaryOperation::CalcExpressionBinaryOperation(std::unique_ptr&lt;CalcExpressionNode&gt; leftSide, std::unique_ptr&lt;CalcExpressionNode&gt; rightSide, CalcOperator op)
+    : CalcExpressionNode(CalcExpressionNodeBinaryOperation)
+    , m_leftSide(std::move(leftSide))
+    , m_rightSide(std::move(rightSide))
+    , m_operator(op)
+{
+}
</ins><span class="cx"> 
</span><del>-    virtual bool operator==(const CalcExpressionNode&amp; o) const override
-    {
-        return type() == o.type() &amp;&amp; *this == static_cast&lt;const CalcExpressionBlendLength&amp;&gt;(o);
-    }
</del><ins>+inline bool operator==(const CalcExpressionBinaryOperation&amp; a, const CalcExpressionBinaryOperation&amp; b)
+{
+    return a.getOperator() == b.getOperator() &amp;&amp; a.leftSide() == b.leftSide() &amp;&amp; a.rightSide() == b.rightSide();
+}
</ins><span class="cx"> 
</span><del>-    virtual float evaluate(float maxValue) const override
-    {
-        return (1.0f - m_progress) * floatValueForLength(m_from, maxValue) + m_progress * floatValueForLength(m_to, maxValue);
-    }
</del><ins>+inline const CalcExpressionBinaryOperation&amp; toCalcExpressionBinaryOperation(const CalcExpressionNode&amp; value)
+{
+    ASSERT_WITH_SECURITY_IMPLICATION(value.type() == CalcExpressionNodeBinaryOperation);
+    return static_cast&lt;const CalcExpressionBinaryOperation&amp;&gt;(value);
+}
</ins><span class="cx"> 
</span><del>-    const Length&amp; from() const { return m_from; }
-    const Length&amp; to() const { return m_to; }
-    float progress() const { return m_progress; }
</del><ins>+inline CalcExpressionBlendLength::CalcExpressionBlendLength(Length from, Length to, float progress)
+    : CalcExpressionNode(CalcExpressionNodeBlendLength)
+    , m_from(from)
+    , m_to(to)
+    , m_progress(progress)
+{
+}
</ins><span class="cx"> 
</span><del>-private:
-    Length m_from;
-    Length m_to;
-    float m_progress;
-};
</del><ins>+inline bool operator==(const CalcExpressionBlendLength&amp; a, const CalcExpressionBlendLength&amp; b)
+{
+    return a.progress() == b.progress() &amp;&amp; a.from() == b.from() &amp;&amp; a.to() == b.to();
+}
</ins><span class="cx"> 
</span><del>-inline const CalcExpressionBlendLength* toCalcExpressionBlendLength(const CalcExpressionNode* value)
</del><ins>+inline const CalcExpressionBlendLength&amp; toCalcExpressionBlendLength(const CalcExpressionNode&amp; value)
</ins><span class="cx"> {
</span><del>-    ASSERT_WITH_SECURITY_IMPLICATION(!value || value-&gt;type() == CalcExpressionNodeBlendLength);
-    return static_cast&lt;const CalcExpressionBlendLength*&gt;(value);
</del><ins>+    ASSERT_WITH_SECURITY_IMPLICATION(value.type() == CalcExpressionNodeBlendLength);
+    return static_cast&lt;const CalcExpressionBlendLength&amp;&gt;(value);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformLengthcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/Length.cpp (166859 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/Length.cpp        2014-04-06 23:41:10 UTC (rev 166859)
+++ trunk/Source/WebCore/platform/Length.cpp        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx">  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
</span><span class="cx">  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
</span><span class="cx">  *           (C) 2001 Dirk Mueller ( mueller@kde.org )
</span><del>- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
</span><span class="cx">  *
</span><span class="cx">  * This library is free software; you can redistribute it and/or
</span><span class="lines">@@ -27,7 +27,8 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CalculationValue.h&quot;
</span><span class="cx"> #include &lt;wtf/ASCIICType.h&gt;
</span><del>-#include &lt;wtf/Assertions.h&gt;
</del><ins>+#include &lt;wtf/HashMap.h&gt;
+#include &lt;wtf/NeverDestroyed.h&gt;
</ins><span class="cx"> #include &lt;wtf/StdLibExtras.h&gt;
</span><span class="cx"> #include &lt;wtf/text/StringBuffer.h&gt;
</span><span class="cx"> #include &lt;wtf/text/StringView.h&gt;
</span><span class="lines">@@ -151,70 +152,102 @@
</span><span class="cx"> 
</span><span class="cx">     return r;
</span><span class="cx"> }
</span><del>-        
-class CalculationValueHandleMap {
-    WTF_MAKE_FAST_ALLOCATED;
</del><ins>+
+class CalculationValueMap {
</ins><span class="cx"> public:
</span><del>-    CalculationValueHandleMap() 
-        : m_index(1) 
-    {
-    }
</del><ins>+    CalculationValueMap();
+
+    unsigned insert(PassRef&lt;CalculationValue&gt;);
+    void ref(unsigned handle);
+    void deref(unsigned handle);
+
+    CalculationValue&amp; get(unsigned handle) const;
+
+private:
+    struct Entry {
+        uint64_t referenceCountMinusOne;
+        CalculationValue* value;
+        Entry();
+        Entry(CalculationValue&amp;);
+    };
+
+    unsigned m_nextAvailableHandle;
+    HashMap&lt;unsigned, Entry&gt; m_map;
+};
+
+inline CalculationValueMap::Entry::Entry()
+    : referenceCountMinusOne(0)
+    , value(nullptr)
+{
+}
+
+inline CalculationValueMap::Entry::Entry(CalculationValue&amp; value)
+    : referenceCountMinusOne(0)
+    , value(&amp;value)
+{
+}
+
+inline CalculationValueMap::CalculationValueMap()
+    : m_nextAvailableHandle(1)
+{
+}
</ins><span class="cx">     
</span><del>-    int insert(PassRefPtr&lt;CalculationValue&gt; calcValue)
-    {
-        ASSERT(m_index);
-        // FIXME calc(): https://bugs.webkit.org/show_bug.cgi?id=80489
-        // This monotonically increasing handle generation scheme is potentially wasteful
-        // of the handle space. Consider reusing empty handles.
-        while (m_map.contains(m_index))
-            m_index++;
-        
-        m_map.set(m_index, calcValue);       
-        
-        return m_index;
-    }
</del><ins>+inline unsigned CalculationValueMap::insert(PassRef&lt;CalculationValue&gt; value)
+{
+    ASSERT(m_nextAvailableHandle);
</ins><span class="cx"> 
</span><del>-    void remove(int index)
-    {
-        ASSERT(m_map.contains(index));
-        m_map.remove(index);
-    }
</del><ins>+    // The leakRef below is balanced by the deref in the deref member function.
+    Entry leakedValue = value.leakRef();
</ins><span class="cx"> 
</span><del>-    void remove(HashMap&lt;int, RefPtr&lt;CalculationValue&gt;&gt;::iterator it)
-    {
-        ASSERT(it != m_map.end());
-        m_map.remove(it);
-    }
</del><ins>+    // FIXME: This monotonically increasing handle generation scheme is potentially wasteful
+    // of the handle space. Consider reusing empty handles. https://bugs.webkit.org/show_bug.cgi?id=80489
+    while (!m_map.isValidKey(m_nextAvailableHandle) || !m_map.add(m_nextAvailableHandle, leakedValue).isNewEntry)
+        ++m_nextAvailableHandle;
</ins><span class="cx"> 
</span><del>-    PassRefPtr&lt;CalculationValue&gt; get(int index)
-    {
-        ASSERT(m_map.contains(index));
-        return m_map.get(index);
-    }
</del><ins>+    return m_nextAvailableHandle++;
+}
</ins><span class="cx"> 
</span><del>-    HashMap&lt;int, RefPtr&lt;CalculationValue&gt;&gt;::iterator find(int index)
-    {
-        ASSERT(m_map.contains(index));
-        return m_map.find(index);
</del><ins>+inline CalculationValue&amp; CalculationValueMap::get(unsigned handle) const
+{
+    ASSERT(m_map.contains(handle));
+
+    return *m_map.find(handle)-&gt;value.value;
+}
+
+inline void CalculationValueMap::ref(unsigned handle)
+{
+    ASSERT(m_map.contains(handle));
+
+    ++m_map.find(handle)-&gt;value.referenceCountMinusOne;
+}
+
+inline void CalculationValueMap::deref(unsigned handle)
+{
+    ASSERT(m_map.contains(handle));
+
+    auto it = m_map.find(handle);
+    if (it-&gt;value.referenceCountMinusOne) {
+        --it-&gt;value.referenceCountMinusOne;
+        return;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-private:        
-    int m_index;
-    HashMap&lt;int, RefPtr&lt;CalculationValue&gt;&gt; m_map;
-};
-    
-static CalculationValueHandleMap&amp; calcHandles()
</del><ins>+    // The deref below is balanced by the leakRef in the insert member function.
+    it-&gt;value.value-&gt;deref();
+    m_map.remove(it);
+}
+
+static CalculationValueMap&amp; calculationValues()
</ins><span class="cx"> {
</span><del>-    DEPRECATED_DEFINE_STATIC_LOCAL(CalculationValueHandleMap, handleMap, ());
-    return handleMap;
</del><ins>+    static NeverDestroyed&lt;CalculationValueMap&gt; map;
+    return map;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-Length::Length(PassRefPtr&lt;CalculationValue&gt; calc)
-    : m_quirk(false)
</del><ins>+Length::Length(PassRef&lt;CalculationValue&gt; value)
+    : m_hasQuirk(false)
</ins><span class="cx">     , m_type(Calculated)
</span><span class="cx">     , m_isFloat(false)
</span><span class="cx"> {
</span><del>-    m_intValue = calcHandles().insert(calc);
</del><ins>+    m_calculationValueHandle = calculationValues().insert(std::move(value));
</ins><span class="cx"> }
</span><span class="cx">         
</span><span class="cx"> Length Length::blendMixedTypes(const Length&amp; from, double progress) const
</span><span class="lines">@@ -228,39 +261,37 @@
</span><span class="cx">     auto blend = std::make_unique&lt;CalcExpressionBlendLength&gt;(from, *this, progress);
</span><span class="cx">     return Length(CalculationValue::create(std::move(blend), CalculationRangeAll));
</span><span class="cx"> }
</span><del>-          
-PassRefPtr&lt;CalculationValue&gt; Length::calculationValue() const
</del><ins>+
+CalculationValue&amp; Length::calculationValue() const
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(isCalculated());
</span><del>-    return calcHandles().get(calculationHandle());
</del><ins>+    return calculationValues().get(m_calculationValueHandle);
</ins><span class="cx"> }
</span><span class="cx">     
</span><del>-void Length::incrementCalculatedRef() const
</del><ins>+void Length::ref() const
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(isCalculated());
</span><del>-    calculationValue()-&gt;ref();
</del><ins>+    calculationValues().ref(m_calculationValueHandle);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Length::decrementCalculatedRef() const
</del><ins>+void Length::deref() const
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(isCalculated());
</span><del>-    auto it = calcHandles().find(calculationHandle());
-    if (it-&gt;value-&gt;hasOneRef())
-        calcHandles().remove(it);
</del><ins>+    calculationValues().deref(m_calculationValueHandle);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> float Length::nonNanCalculatedValue(int maxValue) const
</span><span class="cx"> {
</span><span class="cx">     ASSERT(isCalculated());
</span><del>-    float result = calculationValue()-&gt;evaluate(maxValue);
</del><ins>+    float result = calculationValue().evaluate(maxValue);
</ins><span class="cx">     if (std::isnan(result))
</span><span class="cx">         return 0;
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool Length::isCalculatedEqual(const Length&amp; o) const
</del><ins>+bool Length::isCalculatedEqual(const Length&amp; other) const
</ins><span class="cx"> {
</span><del>-    return isCalculated() &amp;&amp; (calculationValue() == o.calculationValue() || *calculationValue() == *o.calculationValue());
</del><ins>+    return calculationValue() == other.calculationValue();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> struct SameSizeAsLength {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformLengthh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/Length.h (166859 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/Length.h        2014-04-06 23:41:10 UTC (rev 166859)
+++ trunk/Source/WebCore/platform/Length.h        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx">     Copyright (C) 1999 Lars Knoll (knoll@kde.org)
</span><del>-    Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
</del><ins>+    Copyright (C) 2006, 2008, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">     Copyright (C) 2011 Rik Cabanier (cabanier@adobe.com)
</span><span class="cx">     Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
</span><span class="cx"> 
</span><span class="lines">@@ -29,8 +29,6 @@
</span><span class="cx"> #include &lt;wtf/Assertions.h&gt;
</span><span class="cx"> #include &lt;wtf/FastMalloc.h&gt;
</span><span class="cx"> #include &lt;wtf/Forward.h&gt;
</span><del>-#include &lt;wtf/HashMap.h&gt;
-#include &lt;wtf/MathExtras.h&gt;
</del><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -48,285 +46,394 @@
</span><span class="cx"> struct Length {
</span><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><del>-    Length()
-        :  m_intValue(0), m_quirk(false), m_type(Auto), m_isFloat(false)
-    {
-    }
</del><ins>+    Length(LengthType = Auto);
</ins><span class="cx"> 
</span><del>-    Length(LengthType t)
-        : m_intValue(0), m_quirk(false), m_type(t), m_isFloat(false)
-    {
-        ASSERT(t != Calculated);
-    }
</del><ins>+    Length(int value, LengthType, bool hasQuirk = false);
+    Length(LayoutUnit value, LengthType, bool hasQuirk = false);
+    Length(float value, LengthType, bool hasQuirk = false);
+    Length(double value, LengthType, bool hasQuirk = false);
</ins><span class="cx"> 
</span><del>-    Length(int v, LengthType t, bool q = false)
-        : m_intValue(v), m_quirk(q), m_type(t), m_isFloat(false)
-    {
-        ASSERT(t != Calculated);
-    }
</del><ins>+    explicit Length(PassRef&lt;CalculationValue&gt;);
+
+    Length(const Length&amp;);
+    Length(Length&amp;&amp;);
+    Length&amp; operator=(const Length&amp;);
+    Length&amp; operator=(Length&amp;&amp;);
+
+    ~Length();
+
+    void setValue(LengthType, int value);
+    void setValue(LengthType, float value);
+    void setValue(LengthType, LayoutUnit value);
+    Length&amp; operator*=(float);
+
+    void setHasQuirk(bool);
+
+    bool operator==(const Length&amp;) const;
+    bool operator!=(const Length&amp;) const;
+
+    float value() const;
+    int intValue() const;
+    float percent() const;
+    float viewportPercentageLength() const;
+    CalculationValue&amp; calculationValue() const;
+
+    LengthType type() const;
+
+    bool isAuto() const;
+    bool isFixed() const;
+    bool isMaxContent() const;
+    bool isMinContent() const;
+    bool isRelative() const;
+    bool isUndefined() const;
+
+    bool hasQuirk() const;
+
+    // FIXME calc: https://bugs.webkit.org/show_bug.cgi?id=80357. A calculated Length
+    // always contains a percentage, and without a maxValue passed to these functions
+    // it's impossible to determine the sign or zero-ness. The following three functions
+    // act as if all calculated values are positive.
+    bool isZero() const;
+    bool isPositive() const;
+    bool isNegative() const;
+
+    // Returns true for both Percent and Calculated.
+    // FIXME: Doesn't really seem OK to return true for Calculated given this function's name,
+    // even though all calculated values are treated as percentages. Callers can tell Percent
+    // from a Calculated already by looking at type, so this function only half-hides the distinction.
+    bool isPercent() const;
+
+    bool isIntrinsic() const;
+    bool isIntrinsicOrAuto() const;
+    bool isSpecified() const;
+    bool isSpecifiedOrIntrinsic() const;
+    bool isViewportPercentage() const;
+
+    // Blend two lengths to produce a new length that is in between them. Used for animation.
+    // FIXME: Why is this a member function?
+    Length blend(const Length&amp; from, double progress) const;
+
+    float nonNanCalculatedValue(int maxValue) const;
+
+private:
+    bool isCalculated() const;
+    bool isLegacyIntrinsic() const;
+
+    bool isCalculatedEqual(const Length&amp;) const;
+    Length blendMixedTypes(const Length&amp; from, double progress) const;
+
+    void ref() const;
+    void deref() const;
</ins><span class="cx">     
</span><del>-    Length(LayoutUnit v, LengthType t, bool q = false)
-        : m_floatValue(v.toFloat()), m_quirk(q), m_type(t), m_isFloat(true)
-    {
-        ASSERT(t != Calculated);
-    }
-    
-    Length(float v, LengthType t, bool q = false)
-        : m_floatValue(v), m_quirk(q), m_type(t), m_isFloat(true)
-    {
-        ASSERT(t != Calculated);
-    }
</del><ins>+    union {
+        int m_intValue;
+        float m_floatValue;
+        unsigned m_calculationValueHandle;
+    };
+    bool m_hasQuirk;
+    unsigned char m_type;
+    bool m_isFloat;
+};
</ins><span class="cx"> 
</span><del>-    Length(double v, LengthType t, bool q = false)
-        : m_quirk(q), m_type(t), m_isFloat(true)
-    {
-        m_floatValue = static_cast&lt;float&gt;(v);    
-    }
</del><ins>+std::unique_ptr&lt;Length[]&gt; newCoordsArray(const String&amp;, int&amp; length);
+std::unique_ptr&lt;Length[]&gt; newLengthArray(const String&amp;, int&amp; length);
</ins><span class="cx"> 
</span><del>-    explicit Length(PassRefPtr&lt;CalculationValue&gt;);
</del><ins>+inline Length::Length(LengthType type)
+    : m_intValue(0), m_hasQuirk(false), m_type(type), m_isFloat(false)
+{
+    ASSERT(type != Calculated);
+}
</ins><span class="cx"> 
</span><del>-    Length(const Length&amp; length)
-    {
-        initFromLength(length);
-    }
</del><ins>+inline Length::Length(int value, LengthType type, bool hasQuirk)
+    : m_intValue(value), m_hasQuirk(hasQuirk), m_type(type), m_isFloat(false)
+{
+    ASSERT(type != Calculated);
+}
</ins><span class="cx"> 
</span><del>-    Length(Length&amp;&amp; other)
-    {
-        moveFromLength(std::move(other));
-    }
</del><ins>+inline Length::Length(LayoutUnit value, LengthType type, bool hasQuirk)
+    : m_floatValue(value.toFloat()), m_hasQuirk(hasQuirk), m_type(type), m_isFloat(true)
+{
+    ASSERT(type != Calculated);
+}
</ins><span class="cx"> 
</span><del>-    Length&amp; operator=(const Length&amp; length)
-    {
-        initFromLength(length);
-        return *this;
-    }
</del><ins>+inline Length::Length(float value, LengthType type, bool hasQuirk)
+    : m_floatValue(value), m_hasQuirk(hasQuirk), m_type(type), m_isFloat(true)
+{
+    ASSERT(type != Calculated);
+}
</ins><span class="cx"> 
</span><del>-    Length&amp; operator=(Length&amp;&amp; other)
-    {
-        if (this != &amp;other)
-            moveFromLength(std::move(other));
</del><ins>+inline Length::Length(double value, LengthType type, bool hasQuirk)
+    : m_floatValue(static_cast&lt;float&gt;(value)), m_hasQuirk(hasQuirk), m_type(type), m_isFloat(true)
+{
+    ASSERT(type != Calculated);
+}
+
+inline Length::Length(const Length&amp; other)
+{
+    if (other.isCalculated())
+        other.ref();
+
+    memcpy(this, &amp;other, sizeof(Length));
+}
+
+inline Length::Length(Length&amp;&amp; other)
+{
+    memcpy(this, &amp;other, sizeof(Length));
+    other.m_type = Auto;
+}
+
+inline Length&amp; Length::operator=(const Length&amp; other)
+{
+    if (other.isCalculated())
+        other.ref();
+    if (isCalculated())
+        deref();
+
+    memcpy(this, &amp;other, sizeof(Length));
+    return *this;
+}
+
+inline Length&amp; Length::operator=(Length&amp;&amp; other)
+{
+    if (this == &amp;other)
</ins><span class="cx">         return *this;
</span><del>-    }
</del><span class="cx"> 
</span><del>-    ~Length()
-    {
-        if (isCalculated())
-            decrementCalculatedRef();
-    }  
-    
-    bool operator==(const Length&amp; o) const { return (m_type == o.m_type) &amp;&amp; (m_quirk == o.m_quirk) &amp;&amp; (isUndefined() || (getFloatValue() == o.getFloatValue()) || isCalculatedEqual(o)); }
-    bool operator!=(const Length&amp; o) const { return !(*this == o); }
</del><ins>+    if (isCalculated())
+        deref();
</ins><span class="cx"> 
</span><del>-    const Length&amp; operator*=(float v)
-    {       
-        if (isCalculated()) {
-            ASSERT_NOT_REACHED();
-            return *this;
-        }
-        
-        if (m_isFloat)
-            m_floatValue = static_cast&lt;float&gt;(m_floatValue * v);
-        else        
-            m_intValue = static_cast&lt;int&gt;(m_intValue * v);
-        
</del><ins>+    memcpy(this, &amp;other, sizeof(Length));
+    other.m_type = Auto;
+    return *this;
+}
+
+inline Length::~Length()
+{
+    if (isCalculated())
+        deref();
+}
+
+inline bool Length::operator==(const Length&amp; other) const
+{
+    // FIXME: This might be too long to be inline.
+    if (type() != other.type() || hasQuirk() != other.hasQuirk())
+        return false;
+    if (isUndefined())
+        return true;
+    if (isCalculated())
+        return isCalculatedEqual(other);
+    return value() == other.value();
+}
+
+inline bool Length::operator!=(const Length&amp; other) const
+{
+    return !(*this == other);
+}
+
+inline Length&amp; Length::operator*=(float value)
+{
+    ASSERT(!isCalculated());
+    if (isCalculated())
</ins><span class="cx">         return *this;
</span><del>-    }
-    
-    inline float value() const
-    {
-        return getFloatValue();
-    }
</del><span class="cx"> 
</span><del>-     int intValue() const
-     {
-        if (isCalculated()) {
-            ASSERT_NOT_REACHED();
-            return 0;
-        }
-        return getIntValue();
-    }
</del><ins>+    if (m_isFloat)
+        m_floatValue *= value;
+    else
+        m_intValue *= value;
</ins><span class="cx"> 
</span><del>-    float percent() const
-    {
-        ASSERT(isPercent());
-        return getFloatValue();
-    }
</del><ins>+    return *this;
+}
</ins><span class="cx"> 
</span><del>-    PassRefPtr&lt;CalculationValue&gt; calculationValue() const;
</del><ins>+inline float Length::value() const
+{
+    ASSERT(!isUndefined());
+    ASSERT(!isCalculated());
+    return m_isFloat ? m_floatValue : m_intValue;
+}
</ins><span class="cx"> 
</span><del>-    LengthType type() const { return static_cast&lt;LengthType&gt;(m_type); }
-    bool quirk() const { return m_quirk; }
</del><ins>+inline int Length::intValue() const
+{
+    ASSERT(!isUndefined());
+    ASSERT(!isCalculated());
+    // FIXME: Makes no sense to return 0 here but not in the value() function above.
+    if (isCalculated())
+        return 0;
+    return m_isFloat ? static_cast&lt;int&gt;(m_floatValue) : m_intValue;
+}
</ins><span class="cx"> 
</span><del>-    void setQuirk(bool quirk)
-    {
-        m_quirk = quirk;
-    }
</del><ins>+inline float Length::percent() const
+{
+    ASSERT(isPercent());
+    return value();
+}
</ins><span class="cx"> 
</span><del>-    void setValue(LengthType t, int value)
-    {
-        m_type = t;
-        m_intValue = value;
-        m_isFloat = false;
-    }
</del><ins>+inline float Length::viewportPercentageLength() const
+{
+    ASSERT(isViewportPercentage());
+    return value();
+}
</ins><span class="cx"> 
</span><del>-    void setValue(int value)
-    {
-        if (isCalculated()) {
-            ASSERT_NOT_REACHED();
-            return;
-        }
-        setValue(Fixed, value);
-    }
</del><ins>+inline LengthType Length::type() const
+{
+    return static_cast&lt;LengthType&gt;(m_type);
+}
</ins><span class="cx"> 
</span><del>-    void setValue(LengthType t, float value)
-    {
-        m_type = t;
-        m_floatValue = value;
-        m_isFloat = true;    
-    }
</del><ins>+inline bool Length::hasQuirk() const
+{
+    return m_hasQuirk;
+}
</ins><span class="cx"> 
</span><del>-    void setValue(LengthType t, LayoutUnit value)
-    {
-        m_type = t;
-        m_floatValue = value;
-        m_isFloat = true;    
-    }
</del><ins>+inline void Length::setHasQuirk(bool hasQuirk)
+{
+    m_hasQuirk = hasQuirk;
+}
</ins><span class="cx"> 
</span><del>-    void setValue(float value)
-    {
-        *this = Length(value, Fixed);
-    }
</del><ins>+inline void Length::setValue(LengthType type, int value)
+{
+    ASSERT(m_type != Calculated);
+    ASSERT(type != Calculated);
+    m_type = type;
+    m_intValue = value;
+    m_isFloat = false;
+}
</ins><span class="cx"> 
</span><del>-    bool isUndefined() const { return type() == Undefined; }
</del><ins>+inline void Length::setValue(LengthType type, float value)
+{
+    ASSERT(m_type != Calculated);
+    ASSERT(type != Calculated);
+    m_type = type;
+    m_floatValue = value;
+    m_isFloat = true;
+}
</ins><span class="cx"> 
</span><del>-    // FIXME calc: https://bugs.webkit.org/show_bug.cgi?id=80357. A calculated Length 
-    // always contains a percentage, and without a maxValue passed to these functions
-    // it's impossible to determine the sign or zero-ness. We assume all calc values
-    // are positive and non-zero for now.    
-    bool isZero() const 
-    {
-        ASSERT(!isUndefined());
-        if (isCalculated())
-            return false;
-            
-        return m_isFloat ? !m_floatValue : !m_intValue;
-    }
-    bool isPositive() const
-    {
-        if (isUndefined())
-            return false;
-        if (isCalculated())
-            return true;
-                
-        return getFloatValue() &gt; 0;
-    }
-    bool isNegative() const
-    {
-        if (isUndefined() || isCalculated())
-            return false;
-            
-        return getFloatValue() &lt; 0;
-    }
-    
-    bool isAuto() const { return type() == Auto; }
-    bool isRelative() const { return type() == Relative; }
-    bool isPercent() const { return type() == Percent || type() == Calculated; }
-    bool isFixed() const { return type() == Fixed; }
-    bool isIntrinsicOrAuto() const { return type() == Auto || isLegacyIntrinsic() || isIntrinsic(); }
-    bool isLegacyIntrinsic() const { return type() == Intrinsic || type() == MinIntrinsic; }
-    bool isIntrinsic() const { return type() == MinContent || type() == MaxContent || type() == FillAvailable || type() == FitContent; }
-    bool isSpecified() const { return type() == Fixed || type() == Percent || type() == Calculated || isViewportPercentage(); }
-    bool isSpecifiedOrIntrinsic() const { return isSpecified() || isIntrinsic(); }
-    bool isCalculated() const { return type() == Calculated; }
-    bool isCalculatedEqual(const Length&amp;) const;
-    bool isMinContent() const { return type() == MinContent; }
-    bool isMaxContent() const { return type() == MaxContent; }
</del><ins>+inline void Length::setValue(LengthType type, LayoutUnit value)
+{
+    ASSERT(m_type != Calculated);
+    ASSERT(type != Calculated);
+    m_type = type;
+    m_floatValue = value;
+    m_isFloat = true;
+}
</ins><span class="cx"> 
</span><del>-    Length blend(const Length&amp; from, double progress) const
-    {
-        // Blend two lengths to produce a new length that is in between them.  Used for animation.
-        if (from.type() == Calculated || type() == Calculated)
-            return blendMixedTypes(from, progress);
-        
-        if (!from.isZero() &amp;&amp; !isZero() &amp;&amp; from.type() != type())
-            return blendMixedTypes(from, progress);
</del><ins>+inline bool Length::isAuto() const
+{
+    return type() == Auto;
+}
</ins><span class="cx"> 
</span><del>-        if (from.isZero() &amp;&amp; isZero())
-            return *this;
-        
-        LengthType resultType = type();
-        if (isZero())
-            resultType = from.type();
-        
-        if (resultType == Percent) {
-            float fromPercent = from.isZero() ? 0 : from.percent();
-            float toPercent = isZero() ? 0 : percent();
-            return Length(WebCore::blend(fromPercent, toPercent, progress), Percent);
-        } 
</del><ins>+inline bool Length::isFixed() const
+{
+    return type() == Fixed;
+}
</ins><span class="cx"> 
</span><del>-        float fromValue = from.isZero() ? 0 : from.value();
-        float toValue = isZero() ? 0 : value();
-        return Length(WebCore::blend(fromValue, toValue, progress), resultType);
-    }
</del><ins>+inline bool Length::isMaxContent() const
+{
+    return type() == MaxContent;
+}
</ins><span class="cx"> 
</span><del>-    float getFloatValue() const
-    {
-        ASSERT(!isUndefined());
-        return m_isFloat ? m_floatValue : m_intValue;
-    }
-    float nonNanCalculatedValue(int maxValue) const;
</del><ins>+inline bool Length::isMinContent() const
+{
+    return type() == MinContent;
+}
</ins><span class="cx"> 
</span><del>-    bool isViewportPercentage() const
-    {
-        LengthType lengthType = type();
-        return lengthType &gt;= ViewportPercentageWidth &amp;&amp; lengthType &lt;= ViewportPercentageMax;
-    }
-    float viewportPercentageLength() const
-    {
-        ASSERT(isViewportPercentage());
-        return getFloatValue();
-    }
-private:
-    int getIntValue() const
-    {
-        ASSERT(!isUndefined());
-        return m_isFloat ? static_cast&lt;int&gt;(m_floatValue) : m_intValue;
-    }
-    void initFromLength(const Length&amp; length)
-    {
-        memcpy(this, &amp;length, sizeof(Length));
-        if (isCalculated())
-            incrementCalculatedRef();
-    }
</del><ins>+inline bool Length::isNegative() const
+{
+    if (isUndefined() || isCalculated())
+        return false;
+    return m_isFloat ? (m_floatValue &lt; 0) : (m_intValue &lt; 0);
+}
</ins><span class="cx"> 
</span><del>-    void moveFromLength(Length&amp;&amp; length)
-    {
-        ASSERT(this != &amp;length);
-        memcpy(this, &amp;length, sizeof(Length));
-        length.m_type = Auto;
-    }
</del><ins>+inline bool Length::isRelative() const
+{
+    return type() == Relative;
+}
</ins><span class="cx"> 
</span><del>-    Length blendMixedTypes(const Length&amp; from, double progress) const;
</del><ins>+inline bool Length::isUndefined() const
+{
+    return type() == Undefined;
+}
</ins><span class="cx"> 
</span><del>-    int calculationHandle() const
-    {
-        ASSERT(isCalculated());
-        return getIntValue();
</del><ins>+inline bool Length::isPercent() const
+{
+    return type() == Percent || isCalculated();
+}
+
+inline bool Length::isPositive() const
+{
+    if (isUndefined())
+        return false;
+    if (isCalculated())
+        return true;
+    return m_isFloat ? (m_floatValue &gt; 0) : (m_intValue &gt; 0);
+}
+
+inline bool Length::isZero() const
+{
+    ASSERT(!isUndefined());
+    if (isCalculated())
+        return false;
+    return m_isFloat ? !m_floatValue : !m_intValue;
+}
+
+inline bool Length::isCalculated() const
+{
+    return type() == Calculated;
+}
+
+inline bool Length::isLegacyIntrinsic() const
+{
+    return type() == Intrinsic || type() == MinIntrinsic;
+}
+
+inline bool Length::isIntrinsic() const
+{
+    return type() == MinContent || type() == MaxContent || type() == FillAvailable || type() == FitContent;
+}
+
+inline bool Length::isIntrinsicOrAuto() const
+{
+    return isAuto() || isIntrinsic() || isLegacyIntrinsic();
+}
+
+inline bool Length::isSpecified() const
+{
+    return isFixed() || type() == Percent || isCalculated() || isViewportPercentage();
+}
+
+inline bool Length::isSpecifiedOrIntrinsic() const
+{
+    return isSpecified() || isIntrinsic();
+}
+
+inline bool Length::isViewportPercentage() const
+{
+    return type() &gt;= ViewportPercentageWidth &amp;&amp; type() &lt;= ViewportPercentageMax;
+}
+
+// FIXME: Does this need to be in the header? Is it valuable to inline? Does it get inlined?
+inline Length Length::blend(const Length&amp; from, double progress) const
+{
+    if (from.type() == Calculated || type() == Calculated)
+        return blendMixedTypes(from, progress);
+
+    if (!from.isZero() &amp;&amp; !isZero() &amp;&amp; from.type() != type())
+        return blendMixedTypes(from, progress);
+
+    if (from.isZero() &amp;&amp; isZero())
+        return *this;
+
+    LengthType resultType = type();
+    if (isZero())
+        resultType = from.type();
+
+    if (resultType == Percent) {
+        float fromPercent = from.isZero() ? 0 : from.percent();
+        float toPercent = isZero() ? 0 : percent();
+        return Length(WebCore::blend(fromPercent, toPercent, progress), Percent);
</ins><span class="cx">     }
</span><del>-    void incrementCalculatedRef() const;
-    void decrementCalculatedRef() const;    
-    
-    union {
-        int m_intValue;
-        float m_floatValue;
-    };
-    bool m_quirk;
-    unsigned char m_type;
-    bool m_isFloat;
-};
</del><span class="cx"> 
</span><del>-std::unique_ptr&lt;Length[]&gt; newCoordsArray(const String&amp;, int&amp; len);
-std::unique_ptr&lt;Length[]&gt; newLengthArray(const String&amp;, int&amp; len);
</del><ins>+    float fromValue = from.isZero() ? 0 : from.value();
+    float toValue = isZero() ? 0 : value();
+    return Length(WebCore::blend(fromValue, toValue, progress), resultType);
+}
</ins><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformLengthBoxh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/LengthBox.h (166859 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/LengthBox.h        2014-04-06 23:41:10 UTC (rev 166859)
+++ trunk/Source/WebCore/platform/LengthBox.h        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -28,22 +28,20 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class RenderStyle;
-
</del><span class="cx"> struct LengthBox {
</span><span class="cx">     LengthBox()
</span><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    LengthBox(LengthType t)
-        : m_left(t)
-        , m_right(t)
-        , m_top(t)
-        , m_bottom(t)
</del><ins>+    explicit LengthBox(LengthType type)
+        : m_left(type)
+        , m_right(type)
+        , m_top(type)
+        , m_bottom(type)
</ins><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    LengthBox(int v)
</del><ins>+    explicit LengthBox(int v)
</ins><span class="cx">         : m_left(Length(v, Fixed))
</span><span class="cx">         , m_right(Length(v, Fixed))
</span><span class="cx">         , m_top(Length(v, Fixed))
</span><span class="lines">@@ -51,19 +49,19 @@
</span><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    LengthBox(Length t, Length r, Length b, Length l)
-        : m_left(std::move(l))
-        , m_right(std::move(r))
-        , m_top(std::move(t))
-        , m_bottom(std::move(b))
</del><ins>+    LengthBox(Length top, Length right, Length bottom, Length left)
+        : m_left(std::move(left))
+        , m_right(std::move(right))
+        , m_top(std::move(top))
+        , m_bottom(std::move(bottom))
</ins><span class="cx">     {
</span><span class="cx">     }
</span><del>-    
-    LengthBox(int t, int r, int b, int l)
-        : m_left(Length(l, Fixed))
-        , m_right(Length(r, Fixed))
-        , m_top(Length(t, Fixed))
-        , m_bottom(Length(b, Fixed))
</del><ins>+
+    LengthBox(int top, int right, int bottom, int left)
+        : m_left(Length(left, Fixed))
+        , m_right(Length(right, Fixed))
+        , m_top(Length(top, Fixed))
+        , m_bottom(Length(bottom, Fixed))
</ins><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -80,14 +78,14 @@
</span><span class="cx">     const Length&amp; start(WritingMode, TextDirection) const;
</span><span class="cx">     const Length&amp; end(WritingMode, TextDirection) const;
</span><span class="cx"> 
</span><del>-    bool operator==(const LengthBox&amp; o) const
</del><ins>+    bool operator==(const LengthBox&amp; other) const
</ins><span class="cx">     {
</span><del>-        return m_left == o.m_left &amp;&amp; m_right == o.m_right &amp;&amp; m_top == o.m_top &amp;&amp; m_bottom == o.m_bottom;
</del><ins>+        return m_left == other.m_left &amp;&amp; m_right == other.m_right &amp;&amp; m_top == other.m_top &amp;&amp; m_bottom == other.m_bottom;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    bool operator!=(const LengthBox&amp; o) const
</del><ins>+    bool operator!=(const LengthBox&amp; other) const
</ins><span class="cx">     {
</span><del>-        return !(*this == o);
</del><ins>+        return !(*this == other);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     bool nonZero() const
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingAutoTableLayoutcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/AutoTableLayout.cpp (166859 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/AutoTableLayout.cpp        2014-04-06 23:41:10 UTC (rev 166859)
+++ trunk/Source/WebCore/rendering/AutoTableLayout.cpp        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -85,9 +85,9 @@
</span><span class="cx">                     const int cCellMaxWidth = 32760;
</span><span class="cx">                     Length cellLogicalWidth = cell-&gt;styleOrColLogicalWidth();
</span><span class="cx">                     if (cellLogicalWidth.value() &gt; cCellMaxWidth)
</span><del>-                        cellLogicalWidth.setValue(cCellMaxWidth);
</del><ins>+                        cellLogicalWidth.setValue(Fixed, cCellMaxWidth);
</ins><span class="cx">                     if (cellLogicalWidth.isNegative())
</span><del>-                        cellLogicalWidth.setValue(0);
</del><ins>+                        cellLogicalWidth.setValue(Fixed, 0);
</ins><span class="cx">                     switch (cellLogicalWidth.type()) {
</span><span class="cx">                     case Fixed:
</span><span class="cx">                         // ignore width=0
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingFixedTableLayoutcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/FixedTableLayout.cpp (166859 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/FixedTableLayout.cpp        2014-04-06 23:41:10 UTC (rev 166859)
+++ trunk/Source/WebCore/rendering/FixedTableLayout.cpp        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -143,7 +143,7 @@
</span><span class="cx">         // RenderBox::computeLogicalWidthInRegionUsing to compute the width.
</span><span class="cx">         if (logicalWidth.isFixed() &amp;&amp; logicalWidth.isPositive()) {
</span><span class="cx">             fixedBorderBoxLogicalWidth = cell-&gt;adjustBorderBoxLogicalWidthForBoxSizing(logicalWidth.value());
</span><del>-            logicalWidth.setValue(fixedBorderBoxLogicalWidth);
</del><ins>+            logicalWidth.setValue(Fixed, fixedBorderBoxLogicalWidth);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         unsigned usedSpan = 0;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleFillLayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/FillLayer.h (166859 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/FillLayer.h        2014-04-06 23:41:10 UTC (rev 166859)
+++ trunk/Source/WebCore/rendering/style/FillLayer.h        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -187,8 +187,8 @@
</span><span class="cx">     static EFillSizeType initialFillSizeType(EFillLayerType) { return SizeNone; }
</span><span class="cx">     static LengthSize initialFillSizeLength(EFillLayerType) { return LengthSize(); }
</span><span class="cx">     static FillSize initialFillSize(EFillLayerType type) { return FillSize(initialFillSizeType(type), initialFillSizeLength(type)); }
</span><del>-    static Length initialFillXPosition(EFillLayerType) { return Length(0.0, Percent); }
-    static Length initialFillYPosition(EFillLayerType) { return Length(0.0, Percent); }
</del><ins>+    static Length initialFillXPosition(EFillLayerType) { return Length(0.0f, Percent); }
+    static Length initialFillYPosition(EFillLayerType) { return Length(0.0f, Percent); }
</ins><span class="cx">     static StyleImage* initialFillImage(EFillLayerType) { return 0; }
</span><span class="cx">     static EMaskSourceType initialMaskSourceType(EFillLayerType) { return MaskAlpha; }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleRenderStylecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (166859 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp        2014-04-06 23:41:10 UTC (rev 166859)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -1348,18 +1348,18 @@
</span><span class="cx">     return lh.value();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RenderStyle::setWordSpacing(Length v)
</del><ins>+void RenderStyle::setWordSpacing(Length value)
</ins><span class="cx"> {
</span><span class="cx">     float fontWordSpacing;
</span><del>-    switch (v.type()) {
</del><ins>+    switch (value.type()) {
</ins><span class="cx">     case Auto:
</span><span class="cx">         fontWordSpacing = 0;
</span><del>-        FALLTHROUGH;
</del><ins>+        break;
</ins><span class="cx">     case Percent:
</span><del>-        fontWordSpacing = v.getFloatValue() * font().spaceWidth() / 100;
</del><ins>+        fontWordSpacing = value.percent() * font().spaceWidth() / 100;
</ins><span class="cx">         break;
</span><span class="cx">     case Fixed:
</span><del>-        fontWordSpacing = v.getFloatValue();
</del><ins>+        fontWordSpacing = value.value();
</ins><span class="cx">         break;
</span><span class="cx">     default:
</span><span class="cx">         ASSERT_NOT_REACHED();
</span><span class="lines">@@ -1367,7 +1367,7 @@
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     inherited.access()-&gt;font.setWordSpacing(fontWordSpacing);
</span><del>-    rareInheritedData.access()-&gt;wordSpacing = std::move(v);
</del><ins>+    rareInheritedData.access()-&gt;wordSpacing = std::move(value);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RenderStyle::setLetterSpacing(float v) { inherited.access()-&gt;font.setLetterSpacing(v); }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleRenderStyleh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (166859 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/RenderStyle.h        2014-04-06 23:41:10 UTC (rev 166859)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -522,8 +522,8 @@
</span><span class="cx">     bool hasBorder() const { return surround-&gt;border.hasBorder(); }
</span><span class="cx">     bool hasPadding() const { return surround-&gt;padding.nonZero(); }
</span><span class="cx">     bool hasOffset() const { return surround-&gt;offset.nonZero(); }
</span><del>-    bool hasMarginBeforeQuirk() const { return marginBefore().quirk(); }
-    bool hasMarginAfterQuirk() const { return marginAfter().quirk(); }
</del><ins>+    bool hasMarginBeforeQuirk() const { return marginBefore().hasQuirk(); }
+    bool hasMarginAfterQuirk() const { return marginAfter().hasQuirk(); }
</ins><span class="cx"> 
</span><span class="cx">     bool hasBackgroundImage() const { return m_background-&gt;background().hasImage(); }
</span><span class="cx">     bool hasFixedBackgroundImage() const { return m_background-&gt;background().hasFixedImage(); }
</span><span class="lines">@@ -1775,9 +1775,9 @@
</span><span class="cx"> #endif
</span><span class="cx">     static short initialWidows() { return 2; }
</span><span class="cx">     static short initialOrphans() { return 2; }
</span><del>-    static Length initialLineHeight() { return Length(-100.0, Percent); }
</del><ins>+    static Length initialLineHeight() { return Length(-100.0f, Percent); }
</ins><span class="cx"> #if ENABLE(IOS_TEXT_AUTOSIZING)
</span><del>-    static Length initialSpecifiedLineHeight() { return Length(-100, Percent); }
</del><ins>+    static Length initialSpecifiedLineHeight() { return Length(-100.0f, Percent); }
</ins><span class="cx"> #endif
</span><span class="cx">     static ETextAlign initialTextAlign() { return TASTART; }
</span><span class="cx">     static TextDecoration initialTextDecoration() { return TextDecorationNone; }
</span><span class="lines">@@ -1846,15 +1846,15 @@
</span><span class="cx">     static ColumnFill initialColumnFill() { return ColumnFillBalance; }
</span><span class="cx">     static ColumnSpan initialColumnSpan() { return ColumnSpanNone; }
</span><span class="cx">     static const TransformOperations&amp; initialTransform() { DEPRECATED_DEFINE_STATIC_LOCAL(TransformOperations, ops, ()); return ops; }
</span><del>-    static Length initialTransformOriginX() { return Length(50.0, Percent); }
-    static Length initialTransformOriginY() { return Length(50.0, Percent); }
</del><ins>+    static Length initialTransformOriginX() { return Length(50.0f, Percent); }
+    static Length initialTransformOriginY() { return Length(50.0f, Percent); }
</ins><span class="cx">     static EPointerEvents initialPointerEvents() { return PE_AUTO; }
</span><span class="cx">     static float initialTransformOriginZ() { return 0; }
</span><span class="cx">     static ETransformStyle3D initialTransformStyle3D() { return TransformStyle3DFlat; }
</span><span class="cx">     static EBackfaceVisibility initialBackfaceVisibility() { return BackfaceVisibilityVisible; }
</span><span class="cx">     static float initialPerspective() { return 0; }
</span><del>-    static Length initialPerspectiveOriginX() { return Length(50.0, Percent); }
-    static Length initialPerspectiveOriginY() { return Length(50.0, Percent); }
</del><ins>+    static Length initialPerspectiveOriginX() { return Length(50.0f, Percent); }
+    static Length initialPerspectiveOriginY() { return Length(50.0f, Percent); }
</ins><span class="cx">     static Color initialBackgroundColor() { return Color::transparent; }
</span><span class="cx">     static Color initialTextEmphasisColor() { return TextEmphasisFillFilled; }
</span><span class="cx">     static TextEmphasisFill initialTextEmphasisFill() { return TextEmphasisFillFilled; }
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (166859 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2014-04-06 23:41:10 UTC (rev 166859)
+++ trunk/Tools/ChangeLog        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2014-04-06  Darin Adler  &lt;darin@apple.com&gt;
+
+        Rework CSS calc logic, fixing some reference count mistakes in Length
+        https://bugs.webkit.org/show_bug.cgi?id=131280
+
+        Reviewed by Andreas Kling.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Added CalculationValue.cpp.
+        * TestWebKitAPI/Tests/WebCore/CalculationValue.cpp: Added.
+
</ins><span class="cx"> 2014-04-04  Brian J. Burg  &lt;burg@cs.washington.edu&gt;
</span><span class="cx"> 
</span><span class="cx">         Enable WEB_REPLAY for PLATFORM(MAC)
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (166859 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2014-04-06 23:41:10 UTC (rev 166859)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -128,6 +128,7 @@
</span><span class="cx">                 939BFE3A18E5548900883275 /* StringTruncator.mm in Sources */ = {isa = PBXBuildFile; fileRef = 939BFE3918E5548900883275 /* StringTruncator.mm */; };
</span><span class="cx">                 93A427A9180D9B0700CD24D7 /* RefPtr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93A427A8180D9B0700CD24D7 /* RefPtr.cpp */; };
</span><span class="cx">                 93A427AB180DA26400CD24D7 /* Ref.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93A427AA180DA26400CD24D7 /* Ref.cpp */; };
</span><ins>+                93A720E618F1A0E800A848E1 /* CalculationValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93A720E518F1A0E800A848E1 /* CalculationValue.cpp */; };
</ins><span class="cx">                 93ABA80916DDAB91002DB2FA /* StringHasher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93ABA80816DDAB91002DB2FA /* StringHasher.cpp */; };
</span><span class="cx">                 93AF4ECE1506F064007FD57E /* NewFirstVisuallyNonEmptyLayoutForImages_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93AF4ECD1506F064007FD57E /* NewFirstVisuallyNonEmptyLayoutForImages_Bundle.cpp */; };
</span><span class="cx">                 93AF4ED01506F123007FD57E /* lots-of-images.html in Resources */ = {isa = PBXBuildFile; fileRef = 93AF4ECF1506F123007FD57E /* lots-of-images.html */; };
</span><span class="lines">@@ -458,6 +459,7 @@
</span><span class="cx">                 93A427AA180DA26400CD24D7 /* Ref.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Ref.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 93A427AC180DA60F00CD24D7 /* MoveOnly.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MoveOnly.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 93A427AD180DA60F00CD24D7 /* RefLogger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RefLogger.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                93A720E518F1A0E800A848E1 /* CalculationValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CalculationValue.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 93ABA80816DDAB91002DB2FA /* StringHasher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringHasher.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 93AF4ECA1506F035007FD57E /* NewFirstVisuallyNonEmptyLayoutForImages.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NewFirstVisuallyNonEmptyLayoutForImages.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 93AF4ECD1506F064007FD57E /* NewFirstVisuallyNonEmptyLayoutForImages_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NewFirstVisuallyNonEmptyLayoutForImages_Bundle.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -696,6 +698,7 @@
</span><span class="cx">                 440A1D3614A01000008A66F2 /* WebCore */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                93A720E518F1A0E800A848E1 /* CalculationValue.cpp */,
</ins><span class="cx">                                 CDC2C7141797089D00E627FB /* TimeRanges.cpp */,
</span><span class="cx">                                 440A1D3814A0103A008A66F2 /* URL.cpp */,
</span><span class="cx">                                 14464012167A8305000BD218 /* LayoutUnit.cpp */,
</span><span class="lines">@@ -1255,6 +1258,7 @@
</span><span class="cx">                                 3722C8691461E03E00C45D00 /* RenderedImageFromDOMRange.mm in Sources */,
</span><span class="cx">                                 C0BD669D131D3CF700E18F2A /* ResponsivenessTimerDoesntFireEarly.cpp in Sources */,
</span><span class="cx">                                 C0ADBE8312FCA6AA00D2C129 /* RestoreSessionStateContainingFormData.cpp in Sources */,
</span><ins>+                                93A720E618F1A0E800A848E1 /* CalculationValue.cpp in Sources */,
</ins><span class="cx">                                 1AEF994917A09F5400998EF0 /* GetPIDAfterAbortedProcessLaunch.cpp in Sources */,
</span><span class="cx">                                 BC029B181486AD6400817DA9 /* RetainPtr.cpp in Sources */,
</span><span class="cx">                                 BC029B1C1486B25900817DA9 /* RetainPtr.mm in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebCoreCalculationValuecpp"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebCore/CalculationValue.cpp (0 => 166860)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebCore/CalculationValue.cpp                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/CalculationValue.cpp        2014-04-07 00:16:35 UTC (rev 166860)
</span><span class="lines">@@ -0,0 +1,283 @@
</span><ins>+/*
+ * Copyright (C) 2014 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. AND ITS CONTRIBUTORS ``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 ITS 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 &lt;WebCore/CalculationValue.h&gt;
+
+namespace TestWebKitAPI {
+
+static unsigned deletionCount;
+
+class CalculationDeletionTestNode : public WebCore::CalcExpressionNode {
+public:
+    virtual ~CalculationDeletionTestNode()
+    {
+        ++deletionCount;
+    }
+
+    virtual float evaluate(float) const override { return 0; }
+    bool operator==(const CalcExpressionNode&amp;) const { ASSERT_NOT_REACHED(); return false; }
+};
+
+static PassRef&lt;WebCore::CalculationValue&gt; createTestValue()
+{
+    auto node = std::make_unique&lt;CalculationDeletionTestNode&gt;();
+    return WebCore::CalculationValue::create(std::move(node), WebCore::CalculationRangeAll);
+}
+
+TEST(CalculationValue, LengthConstruction)
+{
+    RefPtr&lt;WebCore::CalculationValue&gt; value = createTestValue();
+
+    EXPECT_EQ(1U, value-&gt;refCount());
+
+    {
+        WebCore::Length length(*value);
+        EXPECT_EQ(2U, value-&gt;refCount());
+    }
+
+    EXPECT_EQ(1U, value-&gt;refCount());
+
+    {
+        WebCore::Length lengthA(*value);
+        EXPECT_EQ(2U, value-&gt;refCount());
+        WebCore::Length lengthB(lengthA);
+        EXPECT_EQ(2U, value-&gt;refCount());
+    }
+
+    EXPECT_EQ(1U, value-&gt;refCount());
+
+    {
+        WebCore::Length lengthC(*value);
+        EXPECT_EQ(2U, value-&gt;refCount());
+        WebCore::Length lengthD(std::move(lengthC));
+        EXPECT_EQ(2U, value-&gt;refCount());
+    }
+
+    EXPECT_EQ(1U, value-&gt;refCount());
+
+    EXPECT_EQ(0U, deletionCount);
+    value = nullptr;
+    EXPECT_EQ(1U, deletionCount);
+    deletionCount = 0;
+}
+
+TEST(CalculationValue, LengthConstructionReleasedValue)
+{
+    RefPtr&lt;WebCore::CalculationValue&gt; value = createTestValue();
+
+    EXPECT_EQ(1U, value-&gt;refCount());
+
+    {
+        auto* rawValue = value.get();
+        WebCore::Length length(value.releaseNonNull());
+        EXPECT_EQ(1U, rawValue-&gt;refCount());
+
+        EXPECT_EQ(0U, deletionCount);
+    }
+
+    EXPECT_EQ(1U, deletionCount);
+    deletionCount = 0;
+
+    value = createTestValue();
+
+    {
+        auto* rawValue = value.get();
+        WebCore::Length lengthA(value.releaseNonNull());
+        EXPECT_EQ(1U, rawValue-&gt;refCount());
+        WebCore::Length lengthB(lengthA);
+        EXPECT_EQ(1U, rawValue-&gt;refCount());
+
+        EXPECT_EQ(0U, deletionCount);
+    }
+
+    EXPECT_EQ(1U, deletionCount);
+    deletionCount = 0;
+
+    value = createTestValue();
+
+    {
+        auto* rawValue = value.get();
+        WebCore::Length lengthC(value.releaseNonNull());
+        EXPECT_EQ(1U, rawValue-&gt;refCount());
+        WebCore::Length lengthD(std::move(lengthC));
+        EXPECT_EQ(1U, rawValue-&gt;refCount());
+
+        EXPECT_EQ(0U, deletionCount);
+    }
+
+    EXPECT_EQ(1U, deletionCount);
+    deletionCount = 0;
+}
+
+TEST(CalculationValue, LengthAssignment)
+{
+    RefPtr&lt;WebCore::CalculationValue&gt; value = createTestValue();
+
+    EXPECT_EQ(1U, value-&gt;refCount());
+
+    {
+        WebCore::Length lengthA(*value);
+        EXPECT_EQ(2U, value-&gt;refCount());
+        WebCore::Length lengthB;
+        lengthB = lengthA;
+        EXPECT_EQ(2U, value-&gt;refCount());
+    }
+
+    EXPECT_EQ(1U, value-&gt;refCount());
+
+    {
+        WebCore::Length lengthC(*value);
+        EXPECT_EQ(2U, value-&gt;refCount());
+        WebCore::Length lengthD;
+        lengthD = std::move(lengthC);
+        EXPECT_EQ(2U, value-&gt;refCount());
+    }
+
+    EXPECT_EQ(1U, value-&gt;refCount());
+
+    EXPECT_EQ(0U, deletionCount);
+    value = nullptr;
+    EXPECT_EQ(1U, deletionCount);
+    deletionCount = 0;
+
+    value = createTestValue();
+    RefPtr&lt;WebCore::CalculationValue&gt; value2 = createTestValue();
+
+    EXPECT_EQ(1U, value-&gt;refCount());
+    EXPECT_EQ(1U, value2-&gt;refCount());
+
+    {
+        WebCore::Length lengthE(*value);
+        EXPECT_EQ(2U, value-&gt;refCount());
+        WebCore::Length lengthF(*value2);
+        EXPECT_EQ(2U, value2-&gt;refCount());
+        lengthE = lengthF;
+        EXPECT_EQ(1U, value-&gt;refCount());
+        EXPECT_EQ(2U, value2-&gt;refCount());
+    }
+
+    EXPECT_EQ(1U, value-&gt;refCount());
+    EXPECT_EQ(1U, value2-&gt;refCount());
+
+    {
+        WebCore::Length lengthG(*value);
+        EXPECT_EQ(2U, value-&gt;refCount());
+        WebCore::Length lengthH(*value2);
+        EXPECT_EQ(2U, value2-&gt;refCount());
+        lengthG = std::move(lengthH);
+        EXPECT_EQ(1U, value-&gt;refCount());
+        EXPECT_EQ(2U, value2-&gt;refCount());
+    }
+
+    EXPECT_EQ(0U, deletionCount);
+    value = nullptr;
+    EXPECT_EQ(1U, deletionCount);
+    value2 = nullptr;
+    EXPECT_EQ(2U, deletionCount);
+    deletionCount = 0;
+}
+
+TEST(CalculationValue, LengthAssignmentReleasedValue)
+{
+    RefPtr&lt;WebCore::CalculationValue&gt; value = createTestValue();
+
+    {
+        auto* rawValue = value.get();
+        WebCore::Length lengthA(value.releaseNonNull());
+        EXPECT_EQ(1U, rawValue-&gt;refCount());
+        WebCore::Length lengthB;
+        lengthB = lengthA;
+        EXPECT_EQ(1U, rawValue-&gt;refCount());
+
+        EXPECT_EQ(0U, deletionCount);
+    }
+
+    EXPECT_EQ(1U, deletionCount);
+    deletionCount = 0;
+
+    value = createTestValue();
+
+    {
+        auto* rawValue = value.get();
+        WebCore::Length lengthC(value.releaseNonNull());
+        EXPECT_EQ(1U, rawValue-&gt;refCount());
+        WebCore::Length lengthD;
+        lengthD = std::move(lengthC);
+        EXPECT_EQ(1U, rawValue-&gt;refCount());
+
+        EXPECT_EQ(0U, deletionCount);
+    }
+
+    EXPECT_EQ(1U, deletionCount);
+    deletionCount = 0;
+
+    value = createTestValue();
+    RefPtr&lt;WebCore::CalculationValue&gt; value2 = createTestValue();
+
+    EXPECT_EQ(1U, value-&gt;refCount());
+    EXPECT_EQ(1U, value2-&gt;refCount());
+
+    {
+        auto* rawValue = value.get();
+        WebCore::Length lengthE(value.releaseNonNull());
+        EXPECT_EQ(1U, rawValue-&gt;refCount());
+        auto* rawValue2 = value2.get();
+        WebCore::Length lengthF(value2.releaseNonNull());
+        EXPECT_EQ(1U, rawValue2-&gt;refCount());
+
+        lengthE = lengthF;
+        EXPECT_EQ(1U, deletionCount);
+        EXPECT_EQ(1U, rawValue2-&gt;refCount());
+    }
+
+    EXPECT_EQ(2U, deletionCount);
+    deletionCount = 0;
+
+    value = createTestValue();
+    value2 = createTestValue();
+
+    EXPECT_EQ(1U, value-&gt;refCount());
+    EXPECT_EQ(1U, value2-&gt;refCount());
+
+    {
+        auto* rawValue = value.get();
+        WebCore::Length lengthG(value.releaseNonNull());
+        EXPECT_EQ(1U, rawValue-&gt;refCount());
+        auto* rawValue2 = value2.get();
+        WebCore::Length lengthH(value2.releaseNonNull());
+        EXPECT_EQ(1U, rawValue2-&gt;refCount());
+
+        lengthG = std::move(lengthH);
+        EXPECT_EQ(1U, deletionCount);
+        EXPECT_EQ(1U, rawValue2-&gt;refCount());
+    }
+
+    EXPECT_EQ(2U, deletionCount);
+    deletionCount = 0;
+}
+
+}
</ins><span class="cx">Property changes on: trunk/Tools/TestWebKitAPI/Tests/WebCore/CalculationValue.cpp
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
</div>

</body>
</html>