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

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: floats 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 m_minPageScaleFactor = minPageScaleFactor; 94 m_minPageScaleFactor = minPageScaleFactor;
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::SizeF scaledViewportSize = m_layoutViewportSize; 103 gfx::RectF bounds(gfx::PointF(), m_layoutViewportSize);
104 scaledViewportSize = scaledViewportSize.Scale(1 / totalPageScaleFactor()); 104 bounds.Scale(1 / totalPageScaleFactor());
105 105 bounds += m_pinchViewportScrollDelta;
106 gfx::RectF bounds(gfx::PointF(), scaledViewportSize);
107 bounds.Offset(m_pinchViewportScrollDelta);
108
109 return bounds; 106 return bounds;
110 } 107 }
111 108
112 gfx::Vector2dF PinchZoomViewport::applyScroll(const gfx::Vector2dF& delta) 109 gfx::Vector2dF PinchZoomViewport::applyScroll(const gfx::Vector2dF& delta)
113 { 110 {
114 gfx::Vector2dF overflow; 111 gfx::Vector2dF overflow;
115 gfx::RectF pinchedBounds = bounds(); 112 gfx::RectF pinchedBounds = bounds() + delta;
116 113
117 pinchedBounds.Offset(delta);
118 if (pinchedBounds.x() < 0) { 114 if (pinchedBounds.x() < 0) {
119 overflow.set_x(pinchedBounds.x()); 115 overflow.set_x(pinchedBounds.x());
120 pinchedBounds.set_x(0); 116 pinchedBounds.set_x(0);
121 } 117 }
122 118
123 if (pinchedBounds.y() < 0) { 119 if (pinchedBounds.y() < 0) {
124 overflow.set_y(pinchedBounds.y()); 120 overflow.set_y(pinchedBounds.y());
125 pinchedBounds.set_y(0); 121 pinchedBounds.set_y(0);
126 } 122 }
127 123
128 if (pinchedBounds.right() > m_layoutViewportSize.width()) { 124 if (pinchedBounds.right() > m_layoutViewportSize.width()) {
129 overflow.set_x(pinchedBounds.right() - m_layoutViewportSize.width()); 125 overflow.set_x(pinchedBounds.right() - m_layoutViewportSize.width());
130 pinchedBounds.Offset(m_layoutViewportSize.width() - pinchedBounds.right( ), 0); 126 pinchedBounds += gfx::Vector2dF(m_layoutViewportSize.width() - pinchedBo unds.right(), 0);
131 } 127 }
132 128
133 if (pinchedBounds.bottom() > m_layoutViewportSize.height()) { 129 if (pinchedBounds.bottom() > m_layoutViewportSize.height()) {
134 overflow.set_y(pinchedBounds.bottom() - m_layoutViewportSize.height()); 130 overflow.set_y(pinchedBounds.bottom() - m_layoutViewportSize.height());
135 pinchedBounds.Offset(0, m_layoutViewportSize.height() - pinchedBounds.bo ttom()); 131 pinchedBounds += gfx::Vector2dF(0, m_layoutViewportSize.height() - pinch edBounds.bottom());
136 } 132 }
137 m_pinchViewportScrollDelta = pinchedBounds.OffsetFromOrigin(); 133 m_pinchViewportScrollDelta = pinchedBounds.OffsetFromOrigin();
138 134
139 return overflow; 135 return overflow;
140 } 136 }
141 137
142 WebTransformationMatrix PinchZoomViewport::implTransform() const 138 WebTransformationMatrix PinchZoomViewport::implTransform() const
143 { 139 {
144 WebTransformationMatrix transform; 140 WebTransformationMatrix transform;
145 transform.scale(m_pageScaleDelta); 141 transform.scale(m_pageScaleDelta);
(...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController(); 1493 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController();
1498 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); 1494 double monotonicTime = (time - base::TimeTicks()).InSecondsF();
1499 if (scrollbarController && scrollbarController->animate(monotonicTime)) 1495 if (scrollbarController && scrollbarController->animate(monotonicTime))
1500 m_client->setNeedsRedrawOnImplThread(); 1496 m_client->setNeedsRedrawOnImplThread();
1501 1497
1502 for (size_t i = 0; i < layer->children().size(); ++i) 1498 for (size_t i = 0; i < layer->children().size(); ++i)
1503 animateScrollbarsRecursive(layer->children()[i], time); 1499 animateScrollbarsRecursive(layer->children()[i], time);
1504 } 1500 }
1505 1501
1506 } // namespace cc 1502 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698