diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-10 00:03:19 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-10 00:03:19 +0000 |
commit | 2e648601b082774989dec39da9983a5e27e9a797 (patch) | |
tree | fc961f320f1d39cd9a8d0213382b4221ede73c6b /cc/layer_tree_host_impl.cc | |
parent | c36000e00d75b51321a18aff9260ee7f66f2b54e (diff) | |
download | chromium_src-2e648601b082774989dec39da9983a5e27e9a797.zip chromium_src-2e648601b082774989dec39da9983a5e27e9a797.tar.gz chromium_src-2e648601b082774989dec39da9983a5e27e9a797.tar.bz2 |
ui: Prefer +/- operators to apply offsets.
Adds +/- operators to gfx::Rect that are applied to its origin Point.
Removes gfx::Point method a.OffsetFrom(b) in favor of (b - a).
Begin use +/- instead of Offset() in ui/gfx/ and cc/
New tests:
ui_unittests:RectTest.Offset
R=pkasting,enne
BUG=158416
Review URL: https://codereview.chromium.org/11293194
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167012 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/layer_tree_host_impl.cc')
-rw-r--r-- | cc/layer_tree_host_impl.cc | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc index ead24a4..60ae08f 100644 --- a/cc/layer_tree_host_impl.cc +++ b/cc/layer_tree_host_impl.cc @@ -100,21 +100,17 @@ bool PinchZoomViewport::setPageScaleFactorAndLimits(float pageScaleFactor, float gfx::RectF PinchZoomViewport::bounds() const { - gfx::SizeF scaledViewportSize = m_layoutViewportSize; - scaledViewportSize = scaledViewportSize.Scale(1 / totalPageScaleFactor()); - - gfx::RectF bounds(gfx::PointF(), scaledViewportSize); - bounds.Offset(m_pinchViewportScrollDelta); - + gfx::RectF bounds(gfx::PointF(), m_layoutViewportSize); + bounds.Scale(1 / totalPageScaleFactor()); + bounds += m_pinchViewportScrollDelta; return bounds; } gfx::Vector2dF PinchZoomViewport::applyScroll(const gfx::Vector2dF& delta) { gfx::Vector2dF overflow; - gfx::RectF pinchedBounds = bounds(); + gfx::RectF pinchedBounds = bounds() + delta; - pinchedBounds.Offset(delta); if (pinchedBounds.x() < 0) { overflow.set_x(pinchedBounds.x()); pinchedBounds.set_x(0); @@ -127,12 +123,12 @@ gfx::Vector2dF PinchZoomViewport::applyScroll(const gfx::Vector2dF& delta) if (pinchedBounds.right() > m_layoutViewportSize.width()) { overflow.set_x(pinchedBounds.right() - m_layoutViewportSize.width()); - pinchedBounds.Offset(m_layoutViewportSize.width() - pinchedBounds.right(), 0); + pinchedBounds += gfx::Vector2dF(m_layoutViewportSize.width() - pinchedBounds.right(), 0); } if (pinchedBounds.bottom() > m_layoutViewportSize.height()) { overflow.set_y(pinchedBounds.bottom() - m_layoutViewportSize.height()); - pinchedBounds.Offset(0, m_layoutViewportSize.height() - pinchedBounds.bottom()); + pinchedBounds += gfx::Vector2dF(0, m_layoutViewportSize.height() - pinchedBounds.bottom()); } m_pinchViewportScrollDelta = pinchedBounds.OffsetFromOrigin(); |