Chromium Code Reviews| Index: Source/core/css/MediaValues.h |
| diff --git a/Source/core/css/MediaValues.h b/Source/core/css/MediaValues.h |
| index d306ac43029692f7d6a8f4cab5a4abb09f1f26d8..0ab4a9a97c3a75d09950f3cf06f9f1ccf8d8a9fd 100644 |
| --- a/Source/core/css/MediaValues.h |
| +++ b/Source/core/css/MediaValues.h |
| @@ -37,7 +37,14 @@ public: |
| double tempResult; |
| if (!computeLengthImpl(value, type, defaultFontSize, viewportWidth, viewportHeight, tempResult)) |
| return false; |
| - result = roundForImpreciseConversion<T>(tempResult); |
| + |
| + if (tempResult > std::numeric_limits<T>::max()) |
| + result = std::numeric_limits<T>::max(); |
| + else if (tempResult < std::numeric_limits<T>::min()) |
| + result = std::numeric_limits<T>::min(); |
| + else |
| + result = static_cast<T>(tempResult); |
|
rune
2014/10/08 12:26:39
There is a clampTo templated method you could use.
|
| + |
| return true; |
| } |
| virtual bool computeLength(double value, CSSPrimitiveValue::UnitType, int& result) const = 0; |