Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4589)

Unified Diff: cc/page_scale_animation.cc

Issue 11361186: ui: Add methods to clamp Sizes, Points, and Vectors from above or below. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/layer_tree_host_impl.cc ('k') | cc/tiled_layer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/page_scale_animation.cc
diff --git a/cc/page_scale_animation.cc b/cc/page_scale_animation.cc
index 877cacb96f501f3996ed4409a08a72c9abc522f1..c93ab2b12297cc03f90bd8686f57e72833fa18eb 100644
--- a/cc/page_scale_animation.cc
+++ b/cc/page_scale_animation.cc
@@ -5,10 +5,11 @@
#include "config.h"
#include "cc/page_scale_animation.h"
+
+#include "cc/geometry.h"
#include "ui/gfx/point_f.h"
#include "ui/gfx/rect_f.h"
-#include <algorithm>
#include <math.h>
namespace {
@@ -138,13 +139,9 @@ void PageScaleAnimation::inferTargetAnchorFromScrollOffsets()
void PageScaleAnimation::clampTargetScrollOffset()
{
- gfx::Vector2dF maxScrollPosition;
- maxScrollPosition.set_x(m_rootLayerSize.width() - viewportSizeAtScale(m_targetPageScaleFactor).width());
- maxScrollPosition.set_y(m_rootLayerSize.height() - viewportSizeAtScale(m_targetPageScaleFactor).height());
- m_targetScrollOffset.set_x(std::max<float>(0, m_targetScrollOffset.x()));
- m_targetScrollOffset.set_y(std::max<float>(0, m_targetScrollOffset.y()));
- m_targetScrollOffset.set_x(std::min<float>(maxScrollPosition.x(), m_targetScrollOffset.x()));
- m_targetScrollOffset.set_y(std::min<float>(maxScrollPosition.y(), m_targetScrollOffset.y()));
+ gfx::Vector2dF maxScrollOffset = BottomRight(gfx::RectF(m_rootLayerSize)) - BottomRight(gfx::RectF(viewportSizeAtScale(m_targetPageScaleFactor)));
+ m_targetScrollOffset.ClampToMin(gfx::Vector2dF());
+ m_targetScrollOffset.ClampToMax(maxScrollOffset);
}
gfx::Vector2dF PageScaleAnimation::scrollOffsetAtTime(double time) const
« no previous file with comments | « cc/layer_tree_host_impl.cc ('k') | cc/tiled_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698