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

Side by Side Diff: cc/layer_tree_host_impl.cc

Issue 11293194: ui: Prefer +/- operators to apply offsets. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: gfx:: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 6
7 #include "cc/layer_tree_host_impl.h" 7 #include "cc/layer_tree_host_impl.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 m_maxPageScaleFactor = maxPageScaleFactor; 95 m_maxPageScaleFactor = maxPageScaleFactor;
96 96
97 m_pageScaleFactor = pageScaleFactor; 97 m_pageScaleFactor = pageScaleFactor;
98 return true; 98 return true;
99 } 99 }
100 100
101 gfx::RectF PinchZoomViewport::bounds() const 101 gfx::RectF PinchZoomViewport::bounds() const
102 { 102 {
103 gfx::RectF bounds(gfx::PointF(), m_layoutViewportSize); 103 gfx::RectF bounds(gfx::PointF(), m_layoutViewportSize);
104 bounds.Scale(1 / totalPageScaleFactor()); 104 bounds.Scale(1 / totalPageScaleFactor());
105 bounds.Offset(m_pinchViewportScrollDelta); 105 bounds += m_pinchViewportScrollDelta;
106 return bounds; 106 return bounds;
107 } 107 }
108 108
109 gfx::Vector2dF PinchZoomViewport::applyScroll(const gfx::Vector2dF& delta) 109 gfx::Vector2dF PinchZoomViewport::applyScroll(const gfx::Vector2dF& delta)
110 { 110 {
111 gfx::Vector2dF overflow; 111 gfx::Vector2dF overflow;
112 gfx::RectF pinchedBounds = bounds(); 112 gfx::RectF pinchedBounds = bounds() + delta;
113 113
114 pinchedBounds.Offset(delta);
115 if (pinchedBounds.x() < 0) { 114 if (pinchedBounds.x() < 0) {
116 overflow.set_x(pinchedBounds.x()); 115 overflow.set_x(pinchedBounds.x());
117 pinchedBounds.set_x(0); 116 pinchedBounds.set_x(0);
118 } 117 }
119 118
120 if (pinchedBounds.y() < 0) { 119 if (pinchedBounds.y() < 0) {
121 overflow.set_y(pinchedBounds.y()); 120 overflow.set_y(pinchedBounds.y());
122 pinchedBounds.set_y(0); 121 pinchedBounds.set_y(0);
123 } 122 }
124 123
125 if (pinchedBounds.right() > m_layoutViewportSize.width()) { 124 if (pinchedBounds.right() > m_layoutViewportSize.width()) {
126 overflow.set_x(pinchedBounds.right() - m_layoutViewportSize.width()); 125 overflow.set_x(pinchedBounds.right() - m_layoutViewportSize.width());
127 pinchedBounds.Offset(m_layoutViewportSize.width() - pinchedBounds.right( ), 0); 126 pinchedBounds += gfx::Vector2d(m_layoutViewportSize.width() - pinchedBou nds.right(), 0);
128 } 127 }
129 128
130 if (pinchedBounds.bottom() > m_layoutViewportSize.height()) { 129 if (pinchedBounds.bottom() > m_layoutViewportSize.height()) {
131 overflow.set_y(pinchedBounds.bottom() - m_layoutViewportSize.height()); 130 overflow.set_y(pinchedBounds.bottom() - m_layoutViewportSize.height());
132 pinchedBounds.Offset(0, m_layoutViewportSize.height() - pinchedBounds.bo ttom()); 131 pinchedBounds += gfx::Vector2d(0, m_layoutViewportSize.height() - pinche dBounds.bottom());
133 } 132 }
134 m_pinchViewportScrollDelta = pinchedBounds.OffsetFromOrigin(); 133 m_pinchViewportScrollDelta = pinchedBounds.OffsetFromOrigin();
135 134
136 return overflow; 135 return overflow;
137 } 136 }
138 137
139 WebTransformationMatrix PinchZoomViewport::implTransform() const 138 WebTransformationMatrix PinchZoomViewport::implTransform() const
140 { 139 {
141 WebTransformationMatrix transform; 140 WebTransformationMatrix transform;
142 transform.scale(m_pageScaleDelta); 141 transform.scale(m_pageScaleDelta);
(...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController(); 1483 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController();
1485 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); 1484 double monotonicTime = (time - base::TimeTicks()).InSecondsF();
1486 if (scrollbarController && scrollbarController->animate(monotonicTime)) 1485 if (scrollbarController && scrollbarController->animate(monotonicTime))
1487 m_client->setNeedsRedrawOnImplThread(); 1486 m_client->setNeedsRedrawOnImplThread();
1488 1487
1489 for (size_t i = 0; i < layer->children().size(); ++i) 1488 for (size_t i = 0; i < layer->children().size(); ++i)
1490 animateScrollbarsRecursive(layer->children()[i], time); 1489 animateScrollbarsRecursive(layer->children()[i], time);
1491 } 1490 }
1492 1491
1493 } // namespace cc 1492 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tree_host_common_unittest.cc ('k') | cc/math_util.cc » ('j') | ui/gfx/point_base.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698