Converting time, angle and frequency units in CSS calc() function
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 17 Jan 2015 17:18:23 +0000 (17:18 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 17 Jan 2015 17:18:23 +0000 (17:18 +0000)
commit03828233668efef86de193f4fdd942fc9a758ddc
tree8c975586b416924b8278621d49af6ccae44889fe
parent604c8ce96a5ba6104aa7aacd12cabdd03b01fe0e
Converting time, angle and frequency units in CSS calc() function
https://bugs.webkit.org/show_bug.cgi?id=138356

Reviewed by Darin Adler.

Source/WebCore:

Update CSSPrimitiveValue::primitiveType() to actually query the
primitiveType of the CSSCalcValue instead of assuming a given
type based on its category (e.g. If category is CalcTime, then
assume type is CSS_MS, even though it would be CSS_S as well).

This would like to calculation errors such as:
calc(4s + 1s) -> 5ms

Because we would assume the unit is CSS_MS without actually
checking.

This patch is inspired by the following Blink revision
by <rhodovan.u-szeged@partner.samsung.com> and initial WebKit
patch from <tmeszaros.u-szeged@partner.samsung.com>:
https://src.chromium.org/viewvc/blink?view=rev&revision=179101

Test: fast/css/calc-with-angle-time-frequency.html

* css/CSSCalculationValue.h:
(WebCore::CSSCalcValue::primitiveType):
* css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::primitiveType):

LayoutTests:

Update fast/css/calc-with-angle-time-frequency.html to include more
test cases and actually validate the result of the calculation,
instead of merely setting the CSS property and being happy if we don't
crash.

* fast/css/calc-with-angle-time-frequency-expected.txt:
* fast/css/calc-with-angle-time-frequency.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178627 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/css/calc-with-angle-time-frequency-expected.txt
LayoutTests/fast/css/calc-with-angle-time-frequency.html
Source/WebCore/ChangeLog
Source/WebCore/css/CSSCalculationValue.h
Source/WebCore/css/CSSPrimitiveValue.cpp