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

Side by Side Diff: cc/layer_impl.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/geometry.h ('k') | cc/layer_tree_host_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_impl.h" 7 #include "cc/layer_impl.h"
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 NOTREACHED(); 177 NOTREACHED();
178 return 0; 178 return 0;
179 } 179 }
180 180
181 gfx::Vector2dF LayerImpl::scrollBy(const gfx::Vector2dF& scroll) 181 gfx::Vector2dF LayerImpl::scrollBy(const gfx::Vector2dF& scroll)
182 { 182 {
183 gfx::Vector2dF minDelta = -m_scrollOffset; 183 gfx::Vector2dF minDelta = -m_scrollOffset;
184 gfx::Vector2dF maxDelta = m_maxScrollOffset - m_scrollOffset; 184 gfx::Vector2dF maxDelta = m_maxScrollOffset - m_scrollOffset;
185 // Clamp newDelta so that position + delta stays within scroll bounds. 185 // Clamp newDelta so that position + delta stays within scroll bounds.
186 gfx::Vector2dF newDelta = (m_scrollDelta + scroll); 186 gfx::Vector2dF newDelta = (m_scrollDelta + scroll);
187 newDelta = ClampFromBelow(newDelta, minDelta); 187 newDelta.ClampToMin(minDelta);
188 newDelta = ClampFromAbove(newDelta, maxDelta); 188 newDelta.ClampToMax(maxDelta);
189 gfx::Vector2dF unscrolled = m_scrollDelta + scroll - newDelta; 189 gfx::Vector2dF unscrolled = m_scrollDelta + scroll - newDelta;
190 190
191 if (m_scrollDelta == newDelta) 191 if (m_scrollDelta == newDelta)
192 return unscrolled; 192 return unscrolled;
193 193
194 m_scrollDelta = newDelta; 194 m_scrollDelta = newDelta;
195 if (m_scrollbarAnimationController) 195 if (m_scrollbarAnimationController)
196 m_scrollbarAnimationController->updateScrollOffset(this); 196 m_scrollbarAnimationController->updateScrollOffset(this);
197 noteLayerPropertyChangedForSubtree(); 197 noteLayerPropertyChangedForSubtree();
198 198
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 707
708 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) 708 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer)
709 { 709 {
710 if (!m_scrollbarAnimationController) 710 if (!m_scrollbarAnimationController)
711 m_scrollbarAnimationController = ScrollbarAnimationController::create(th is); 711 m_scrollbarAnimationController = ScrollbarAnimationController::create(th is);
712 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); 712 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer);
713 m_scrollbarAnimationController->updateScrollOffset(this); 713 m_scrollbarAnimationController->updateScrollOffset(this);
714 } 714 }
715 715
716 } // namespace cc 716 } // namespace cc
OLDNEW
« no previous file with comments | « cc/geometry.h ('k') | cc/layer_tree_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698