Chromium Code Reviews| Index: ui/gfx/range/range_f.cc |
| diff --git a/ui/gfx/range/range_f.cc b/ui/gfx/range/range_f.cc |
| index 665dc8b6f29aa1332415e5b1b6c2803691e2313e..9be09b2be8b9d50c9020f92b13ddb67c97740c66 100644 |
| --- a/ui/gfx/range/range_f.cc |
| +++ b/ui/gfx/range/range_f.cc |
| @@ -8,67 +8,12 @@ |
| #include <algorithm> |
| #include <cmath> |
| -#include <limits> |
| #include "base/format_macros.h" |
| #include "base/strings/stringprintf.h" |
| namespace gfx { |
| -RangeF::RangeF() |
| - : start_(0.0f), |
| - end_(0.0f) { |
| -} |
| - |
| -RangeF::RangeF(float start, float end) |
| - : start_(start), |
| - end_(end) { |
| -} |
| - |
| -RangeF::RangeF(float position) |
| - : start_(position), |
| - end_(position) { |
| -} |
| - |
| -// static |
| -const RangeF RangeF::InvalidRange() { |
| - return RangeF(std::numeric_limits<float>::max()); |
| -} |
| - |
| -bool RangeF::IsValid() const { |
| - return *this != InvalidRange(); |
| -} |
| - |
| -float RangeF::GetMin() const { |
| - return std::min(start(), end()); |
| -} |
| - |
| -float RangeF::GetMax() const { |
| - return std::max(start(), end()); |
| -} |
| - |
| -bool RangeF::operator==(const RangeF& other) const { |
| - return start() == other.start() && end() == other.end(); |
| -} |
| - |
| -bool RangeF::operator!=(const RangeF& other) const { |
| - return !(*this == other); |
| -} |
| - |
| -bool RangeF::EqualsIgnoringDirection(const RangeF& other) const { |
| - return GetMin() == other.GetMin() && GetMax() == other.GetMax(); |
| -} |
| - |
| -bool RangeF::Intersects(const RangeF& range) const { |
| - return IsValid() && range.IsValid() && |
| - !(range.GetMax() < GetMin() || range.GetMin() >= GetMax()); |
| -} |
| - |
| -bool RangeF::Contains(const RangeF& range) const { |
| - return IsValid() && range.IsValid() && |
| - GetMin() <= range.GetMin() && range.GetMax() <= GetMax(); |
| -} |
| - |
| RangeF RangeF::Intersect(const RangeF& range) const { |
| float min = std::max(GetMin(), range.GetMin()); |
| float max = std::min(GetMax(), range.GetMax()); |
| @@ -85,21 +30,20 @@ RangeF RangeF::Intersect(const Range& range) const { |
| } |
| Range RangeF::Floor() const { |
| - size_t start = start_ > 0.0f ? static_cast<size_t>(std::floor(start_)) : 0; |
| - size_t end = end_ > 0.0f ? static_cast<size_t>(std::floor(end_)) : 0; |
| + size_t start = start_ > 0.0f ? static_cast<uint32_t>(std::floor(start_)) : 0; |
|
Robert Sesek
2017/03/06 21:27:58
Should the size_t's here move to uint32_t?
Peter Kasting
2017/03/07 00:08:01
Yes. Missed those. Thanks.
|
| + size_t end = end_ > 0.0f ? static_cast<uint32_t>(std::floor(end_)) : 0; |
| return Range(start, end); |
| } |
| Range RangeF::Ceil() const { |
| - size_t start = start_ > 0.0f ? static_cast<size_t>(std::ceil(start_)) : 0; |
| - size_t end = end_ > 0.0f ? static_cast<size_t>(std::ceil(end_)) : 0; |
| + size_t start = start_ > 0.0f ? static_cast<uint32_t>(std::ceil(start_)) : 0; |
| + size_t end = end_ > 0.0f ? static_cast<uint32_t>(std::ceil(end_)) : 0; |
| return Range(start, end); |
| } |
| Range RangeF::Round() const { |
| - size_t start = |
| - start_ > 0.0f ? static_cast<size_t>(std::floor(start_ + 0.5f)) : 0; |
| - size_t end = end_ > 0.0f ? static_cast<size_t>(std::floor(end_ + 0.5f)) : 0; |
| + size_t start = start_ > 0.0f ? static_cast<uint32_t>(std::round(start_)) : 0; |
| + size_t end = end_ > 0.0f ? static_cast<uint32_t>(std::round(end_)) : 0; |
| return Range(start, end); |
| } |