Commit 643f4512 authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

Clamp double to int instead of using static_cast.

Better overflow handling for CSSPrimitiveValue::Create.

Bug: 904872
Change-Id: Ieafc28406497b4a676994efdc6515959549a7ba1
Reviewed-on: https://chromium-review.googlesource.com/c/1335527Reviewed-by: default avatarAnders Ruud <andruud@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607947}
parent 10ca0d32
...@@ -97,7 +97,7 @@ CSSPrimitiveValue* CSSPrimitiveValue::Create(double value, UnitType type) { ...@@ -97,7 +97,7 @@ CSSPrimitiveValue* CSSPrimitiveValue::Create(double value, UnitType type) {
if (value < 0 || value > CSSValuePool::kMaximumCacheableIntegerValue) if (value < 0 || value > CSSValuePool::kMaximumCacheableIntegerValue)
return new CSSPrimitiveValue(value, type); return new CSSPrimitiveValue(value, type);
int int_value = static_cast<int>(value); int int_value = clampTo<int>(value);
if (value != int_value) if (value != int_value)
return new CSSPrimitiveValue(value, type); return new CSSPrimitiveValue(value, type);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment