Fix assertions triggered by CSS calc changes in r166860
https://bugs.webkit.org/show_bug.cgi?id=131346

Reviewed by Andrei Bucur.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::getBorderRadiusCornerValues): Use isPercentNotCalculated() instead of
type() == Percent; no behavior change.
(WebCore::getBorderRadiusCornerValue): Ditto.
(WebCore::lineHeightFromStyle): Use isPercentNotCalculated() before code
that calls percent(), which won't work for a calculated length.

* css/DeprecatedStyleBuilder.cpp:
(WebCore::ApplyPropertyBorderRadius::applyValue): Use isNegative and isZero rather
than calling value() unconditionally. Should make calculated values work better.

* html/HTMLPlugInImageElement.cpp:
(WebCore::is100Percent): Use isPercentNotCalculated() before code
that calls percent(), which won't work for a calculated length.

* platform/Length.cpp:
(WebCore::CalculationValueMap::deref): Use adoptRef here instead of calling deref
immediately, so the deref will happen after calling remove. This makes the code
work properly even if it's reentered inside the calculation value's destructor.

* platform/Length.h:
(WebCore::Length::percent): Change assert to isPercentNotCalculated, since the
value function this calls only works for non-calculated values anyway.
(WebCore::Length::isPercentNotCalculated): Added.
(WebCore::Length::isPercent): Changed to call isPercentNotCalculated.
(WebCore::Length::isSpecified): Changed to call isPercent.

* platform/graphics/transforms/TranslateTransformOperation.h:
(WebCore::TranslateTransformOperation::apply): Use isPercentNotCalculated()
instead of type() == Percent; no behavior change.

* rendering/AutoTableLayout.cpp:
(WebCore::AutoTableLayout::recalcColumn): Use isPercentNotCalculated()
before code that calls value() or percent(), which won't work for a calculated length.
(WebCore::AutoTableLayout::computeIntrinsicLogicalWidths): Ditto.
(WebCore::AutoTableLayout::calcEffectiveLogicalWidth): Ditto.
(WebCore::AutoTableLayout::layout): Ditto.
* rendering/FixedTableLayout.cpp:
(WebCore::FixedTableLayout::layout): Ditto.
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::calculateImageIntrinsicDimensions): Ditto.
* rendering/RenderTableSection.cpp:
(WebCore::updateLogicalHeightForCell): Ditto.
(WebCore::RenderTableSection::distributeExtraLogicalHeightToPercentRows): Ditto.
(WebCore::RenderTableSection::distributeExtraLogicalHeightToRows): Ditto.

* rendering/style/RenderStyle.cpp:
(WebCore::requireTransformOrigin): Use modern for loop. Also marked function static,
since it's private to this file.
(WebCore::RenderStyle::applyTransform): Use isPercentNotCalculated() instead of
type() == Percent; no behavior change. Also use a modern for loop and auto& to avoid
a really long type name.

* rendering/svg/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::computeIntrinsicRatioInformation): Use isPercentNotCalculated()
before code that calls percent(), which won't work for a calculated length.

* platform/Length.h:
(WebCore::Length::percent):
(WebCore::Length::isPercentNotCalculated):
(WebCore::Length::isPercent):
(WebCore::Length::isSpecified):
* platform/graphics/transforms/TranslateTransformOperation.h:
(WebCore::TranslateTransformOperation::apply):
* rendering/AutoTableLayout.cpp:
(WebCore::AutoTableLayout::recalcColumn):
(WebCore::AutoTableLayout::computeIntrinsicLogicalWidths):
(WebCore::AutoTableLayout::calcEffectiveLogicalWidth):
(WebCore::AutoTableLayout::layout):
* rendering/FixedTableLayout.cpp:
(WebCore::FixedTableLayout::layout):
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::calculateImageIntrinsicDimensions):
* rendering/RenderTableSection.cpp:
(WebCore::updateLogicalHeightForCell):
(WebCore::RenderTableSection::distributeExtraLogicalHeightToPercentRows):
(WebCore::RenderTableSection::distributeExtraLogicalHeightToRows):
* rendering/style/RenderStyle.cpp:
(WebCore::requireTransformOrigin):
(WebCore::RenderStyle::applyTransform):
* rendering/svg/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::computeIntrinsicRatioInformation):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166920 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/rendering/RenderTableSection.cpp b/Source/WebCore/rendering/RenderTableSection.cpp
index e84691b..1fdeec9 100644
--- a/Source/WebCore/rendering/RenderTableSection.cpp
+++ b/Source/WebCore/rendering/RenderTableSection.cpp
@@ -65,12 +65,11 @@
         Length cRowLogicalHeight = row.logicalHeight;
         switch (logicalHeight.type()) {
         case Percent:
-            if (!(cRowLogicalHeight.isPercent())
-                || (cRowLogicalHeight.isPercent() && cRowLogicalHeight.percent() < logicalHeight.percent()))
+            if (!cRowLogicalHeight.isPercentNotCalculated() || cRowLogicalHeight.percent() < logicalHeight.percent())
                 row.logicalHeight = logicalHeight;
             break;
         case Fixed:
-            if (cRowLogicalHeight.type() < Percent
+            if (cRowLogicalHeight.isAuto() || cRowLogicalHeight.isRelative()
                 || (cRowLogicalHeight.isFixed() && cRowLogicalHeight.value() < logicalHeight.value()))
                 row.logicalHeight = logicalHeight;
             break;
@@ -435,7 +434,7 @@
     totalPercent = std::min(totalPercent, 100);
     int rowHeight = m_rowPos[1] - m_rowPos[0];
     for (unsigned r = 0; r < totalRows; ++r) {
-        if (totalPercent > 0 && m_grid[r].logicalHeight.isPercent()) {
+        if (totalPercent > 0 && m_grid[r].logicalHeight.isPercentNotCalculated()) {
             int toAdd = std::min<int>(extraLogicalHeight, (totalHeight * m_grid[r].logicalHeight.percent() / 100) - rowHeight);
             // If toAdd is negative, then we don't want to shrink the row (this bug
             // affected Outlook Web Access).
@@ -507,7 +506,7 @@
     for (unsigned r = 0; r < totalRows; r++) {
         if (m_grid[r].logicalHeight.isAuto())
             ++autoRowsCount;
-        else if (m_grid[r].logicalHeight.isPercent())
+        else if (m_grid[r].logicalHeight.isPercentNotCalculated())
             totalPercent += m_grid[r].logicalHeight.percent();
     }