Commit 89c7a21d authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

Use clampTo in DoublePoint::operator FloatPoint()

Remove some unused conversion helpers that would otherwise need similar
treatment. In the case of ToFloatSize(const DoubleSize&) it was used in
one instance but erroneously so, promoting to DoubleSize just so that it
could convert back to FloatSize/ScrollOffset again.

Bug: 983032
Change-Id: I416f24fc125b447c881edbdebf5d1796483bec85
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1698507Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#676583}
parent b4292a40
...@@ -164,8 +164,7 @@ int RootFrameViewport::VerticalScrollbarWidth( ...@@ -164,8 +164,7 @@ int RootFrameViewport::VerticalScrollbarWidth(
} }
void RootFrameViewport::UpdateScrollAnimator() { void RootFrameViewport::UpdateScrollAnimator() {
GetScrollAnimator().SetCurrentOffset( GetScrollAnimator().SetCurrentOffset(ScrollOffsetFromScrollAnimators());
ToFloatSize(ScrollOffsetFromScrollAnimators()));
} }
ScrollOffset RootFrameViewport::ScrollOffsetFromScrollAnimators() const { ScrollOffset RootFrameViewport::ScrollOffsetFromScrollAnimators() const {
......
...@@ -5,12 +5,15 @@ ...@@ -5,12 +5,15 @@
#include "third_party/blink/renderer/platform/geometry/double_point.h" #include "third_party/blink/renderer/platform/geometry/double_point.h"
#include <algorithm> #include <algorithm>
#include "third_party/blink/renderer/platform/geometry/float_size.h" #include "third_party/blink/renderer/platform/wtf/math_extras.h"
#include "third_party/blink/renderer/platform/geometry/layout_point.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink { namespace blink {
DoublePoint::operator FloatPoint() const {
return FloatPoint(clampTo<float>(x_), clampTo<float>(y_));
}
DoublePoint DoublePoint::ExpandedTo(const DoublePoint& other) const { DoublePoint DoublePoint::ExpandedTo(const DoublePoint& other) const {
return DoublePoint(std::max(x_, other.x_), std::max(y_, other.y_)); return DoublePoint(std::max(x_, other.x_), std::max(y_, other.y_));
} }
......
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
namespace blink { namespace blink {
class LayoutPoint;
class PLATFORM_EXPORT DoublePoint { class PLATFORM_EXPORT DoublePoint {
DISALLOW_NEW(); DISALLOW_NEW();
...@@ -33,7 +31,7 @@ class PLATFORM_EXPORT DoublePoint { ...@@ -33,7 +31,7 @@ class PLATFORM_EXPORT DoublePoint {
constexpr explicit DoublePoint(const DoubleSize& size) constexpr explicit DoublePoint(const DoubleSize& size)
: x_(size.Width()), y_(size.Height()) {} : x_(size.Width()), y_(size.Height()) {}
constexpr explicit operator FloatPoint() const { return FloatPoint(x_, y_); } explicit operator FloatPoint() const;
static constexpr DoublePoint Zero() { return DoublePoint(); } static constexpr DoublePoint Zero() { return DoublePoint(); }
...@@ -123,10 +121,6 @@ inline IntPoint FlooredIntPoint(const DoublePoint& p) { ...@@ -123,10 +121,6 @@ inline IntPoint FlooredIntPoint(const DoublePoint& p) {
return IntPoint(clampTo<int>(floor(p.X())), clampTo<int>(floor(p.Y()))); return IntPoint(clampTo<int>(floor(p.X())), clampTo<int>(floor(p.Y())));
} }
constexpr FloatPoint ToFloatPoint(const DoublePoint& a) {
return FloatPoint(a.X(), a.Y());
}
constexpr DoubleSize ToDoubleSize(const DoublePoint& a) { constexpr DoubleSize ToDoubleSize(const DoublePoint& a) {
return DoubleSize(a.X(), a.Y()); return DoubleSize(a.X(), a.Y());
} }
......
...@@ -104,10 +104,6 @@ inline IntSize ExpandedIntSize(const DoubleSize& p) { ...@@ -104,10 +104,6 @@ inline IntSize ExpandedIntSize(const DoubleSize& p) {
return IntSize(clampTo<int>(ceil(p.Width())), clampTo<int>(ceil(p.Height()))); return IntSize(clampTo<int>(ceil(p.Width())), clampTo<int>(ceil(p.Height())));
} }
constexpr FloatSize ToFloatSize(const DoubleSize& p) {
return FloatSize(p.Width(), p.Height());
}
PLATFORM_EXPORT std::ostream& operator<<(std::ostream&, const DoubleSize&); PLATFORM_EXPORT std::ostream& operator<<(std::ostream&, const DoubleSize&);
} // namespace blink } // namespace blink
......
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