| Index: third_party/WebKit/Source/platform/LayoutUnit.h
|
| diff --git a/third_party/WebKit/Source/platform/LayoutUnit.h b/third_party/WebKit/Source/platform/LayoutUnit.h
|
| index 552ec0495cd4a9749a89f3bd050ba7c4a390996b..6dc55022c396d84018b473653d709d7886c6ea4c 100644
|
| --- a/third_party/WebKit/Source/platform/LayoutUnit.h
|
| +++ b/third_party/WebKit/Source/platform/LayoutUnit.h
|
| @@ -35,6 +35,7 @@
|
| #include "wtf/Assertions.h"
|
| #include "wtf/MathExtras.h"
|
| #include "wtf/SaturatedArithmetic.h"
|
| +#include <algorithm>
|
| #include <limits.h>
|
| #include <limits>
|
| #include <stdlib.h>
|
| @@ -65,6 +66,7 @@ class LayoutUnit {
|
| DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
|
| public:
|
| LayoutUnit() : m_value(0) { }
|
| + // TODO(leviw): All of the below constructors should be explicit. crbug.com/581254
|
| LayoutUnit(int value) { setValue(value); }
|
| LayoutUnit(unsigned short value) { setValue(value); }
|
| LayoutUnit(unsigned value) { setValue(value); }
|
| @@ -156,6 +158,11 @@ public:
|
| return m_value >> kLayoutUnitFractionalBits;
|
| }
|
|
|
| + LayoutUnit clampToZero() const
|
| + {
|
| + return std::max(*this, LayoutUnit());
|
| + }
|
| +
|
| LayoutUnit fraction() const
|
| {
|
| // Add the fraction to the size (as opposed to the full location) to avoid overflows.
|
| @@ -678,13 +685,13 @@ inline LayoutUnit& operator+=(LayoutUnit& a, const LayoutUnit& b)
|
|
|
| inline LayoutUnit& operator+=(LayoutUnit& a, int b)
|
| {
|
| - a = a + b;
|
| + a = a + LayoutUnit(b);
|
| return a;
|
| }
|
|
|
| inline LayoutUnit& operator+=(LayoutUnit& a, float b)
|
| {
|
| - a = a + b;
|
| + a = LayoutUnit(a + b);
|
| return a;
|
| }
|
|
|
| @@ -696,7 +703,7 @@ inline float& operator+=(float& a, const LayoutUnit& b)
|
|
|
| inline LayoutUnit& operator-=(LayoutUnit& a, int b)
|
| {
|
| - a = a - b;
|
| + a = a - LayoutUnit(b);
|
| return a;
|
| }
|
|
|
| @@ -708,7 +715,7 @@ inline LayoutUnit& operator-=(LayoutUnit& a, const LayoutUnit& b)
|
|
|
| inline LayoutUnit& operator-=(LayoutUnit& a, float b)
|
| {
|
| - a = a - b;
|
| + a = LayoutUnit(a - b);
|
| return a;
|
| }
|
|
|
| @@ -723,11 +730,10 @@ inline LayoutUnit& operator*=(LayoutUnit& a, const LayoutUnit& b)
|
| a = a * b;
|
| return a;
|
| }
|
| -// operator*=(LayoutUnit& a, int b) is supported by the operator above plus LayoutUnit(int).
|
|
|
| inline LayoutUnit& operator*=(LayoutUnit& a, float b)
|
| {
|
| - a = a * b;
|
| + a = LayoutUnit(a * b);
|
| return a;
|
| }
|
|
|
| @@ -742,11 +748,10 @@ inline LayoutUnit& operator/=(LayoutUnit& a, const LayoutUnit& b)
|
| a = a / b;
|
| return a;
|
| }
|
| -// operator/=(LayoutUnit& a, int b) is supported by the operator above plus LayoutUnit(int).
|
|
|
| inline LayoutUnit& operator/=(LayoutUnit& a, float b)
|
| {
|
| - a = a / b;
|
| + a = LayoutUnit(a / b);
|
| return a;
|
| }
|
|
|
|
|