diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-11-20 10:33:36 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-11-22 11:45:12 +0000 |
commit | be59a35641616a4cf23c4a13fa0632624b021c1b (patch) | |
tree | 9da183258bdf9cc413f7562079d25ace6955467f /chromium/ui/gfx/geometry/rect.cc | |
parent | d702e4b6a64574e97fc7df8fe3238cde70242080 (diff) | |
download | qtwebengine-chromium-be59a35641616a4cf23c4a13fa0632624b021c1b.tar.gz |
BASELINE: Update Chromium to 62.0.3202.101
Change-Id: I2d5eca8117600df6d331f6166ab24d943d9814ac
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/ui/gfx/geometry/rect.cc')
-rw-r--r-- | chromium/ui/gfx/geometry/rect.cc | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/chromium/ui/gfx/geometry/rect.cc b/chromium/ui/gfx/geometry/rect.cc index b5ceda58291..63c0bbf04f0 100644 --- a/chromium/ui/gfx/geometry/rect.cc +++ b/chromium/ui/gfx/geometry/rect.cc @@ -15,7 +15,7 @@ #endif #include "base/logging.h" -#include "base/numerics/saturated_arithmetic.h" +#include "base/numerics/clamped_math.h" #include "base/strings/stringprintf.h" #include "build/build_config.h" #include "ui/gfx/geometry/insets.h" @@ -69,8 +69,8 @@ static void SaturatedClampRange(int min, int max, int* origin, int* span) { return; } - int effective_span = base::SaturatedSubtraction(max, min); - int span_loss = base::SaturatedSubtraction(max, min + effective_span); + int effective_span = base::ClampSub(max, min); + int span_loss = base::ClampSub(max, min + effective_span); // If the desired width is within the limits of ints, we can just // use the simple computations to represent the range precisely. @@ -83,12 +83,12 @@ static void SaturatedClampRange(int min, int max, int* origin, int* span) { // Now we have to approximate. If one of min or max is close enough // to zero we choose to represent that one precisely. The other side is // probably practically "infinite", so we move it. - if (base::SaturatedAbsolute(max) < std::numeric_limits<int>::max() / 2) { + constexpr unsigned kMaxDimension = std::numeric_limits<int>::max() / 2; + if (base::SafeUnsignedAbs(max) < kMaxDimension) { // Maintain origin + span == max. *span = effective_span; *origin = max - effective_span; - } else if (base::SaturatedAbsolute(min) < - std::numeric_limits<int>::max() / 2) { + } else if (base::SafeUnsignedAbs(min) < kMaxDimension) { // Maintain origin == min. *span = effective_span; *origin = min; @@ -116,10 +116,8 @@ void Rect::Inset(int left, int top, int right, int bottom) { origin_ += Vector2d(left, top); // left+right might overflow/underflow, but width() - (left+right) might // overflow as well. - set_width(base::SaturatedSubtraction(width(), - base::SaturatedAddition(left, right))); - set_height(base::SaturatedSubtraction(height(), - base::SaturatedAddition(top, bottom))); + set_width(base::ClampSub(width(), base::ClampAdd(left, right))); + set_height(base::ClampSub(height(), base::ClampAdd(top, bottom))); } void Rect::Offset(int horizontal, int vertical) { |