Assert should never be reached hit in WebCore::CSSCalcPrimitiveValue::doubleValue
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Jan 2015 05:56:27 +0000 (05:56 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Jan 2015 05:56:27 +0000 (05:56 +0000)
commitd50f7a46dcd21d325447fa1b846186ed38855aee
treeb71dcc845164dfacf8bf38e5ab373ce0ed181cac
parentdc4abb8bd64780d07c6fa7133cfc4e80f40b264a
Assert should never be reached hit in WebCore::CSSCalcPrimitiveValue::doubleValue
https://bugs.webkit.org/show_bug.cgi?id=140180

Reviewed by Darin Adler.

Source/WebCore:

Add support for using floating-point angles with 'turn' unit, as per the
specification:
http://dev.w3.org/csswg/css-values-3/#angles

Previously, we only supported integer values for the 'turn' unit even
though other angle units (e.g. 'deg') handle floating-point values just
fine. Trying to use a floating-point value with 'turn' unit would cause
us to hit an assertion in CSSCalcPrimitiveValue::doubleValue().

Also fix the support for angles in calc().
CSSPrimitiveValue::computeDegrees() was accessing m_primitiveUnitType
member directly, which would be incorrect in the case of calculated
values. This patch switches to calling CSSPrimitiveValue::primitiveType()
which handles calculated values.

Test: fast/css/turn-angle-double.html

* css/CSSCalculationValue.cpp:
(WebCore::hasDoubleValue):
* css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::computeDegrees):

LayoutTests:

Add a layout test to make sure that using float-point angles with 'turn' unit
does not crash and behaves as intended. Also cover the case where calc() is
used.

* fast/css/turn-angle-double-expected.txt: Added.
* fast/css/turn-angle-double.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178102 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/css/turn-angle-double-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/turn-angle-double.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSCalculationValue.cpp
Source/WebCore/css/CSSPrimitiveValue.cpp