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

Side by Side Diff: cc/layers/viewport.cc

Issue 1236643003: [Android] Suppress overscroll for unscrollable axes in the browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "cc/layers/viewport.h" 5 #include "cc/layers/viewport.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "cc/input/top_controls_manager.h" 8 #include "cc/input/top_controls_manager.h"
9 #include "cc/trees/layer_tree_host_impl.h" 9 #include "cc/trees/layer_tree_host_impl.h"
10 #include "cc/trees/layer_tree_impl.h" 10 #include "cc/trees/layer_tree_impl.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 return false; 151 return false;
152 } 152 }
153 153
154 gfx::Vector2dF Viewport::AdjustOverscroll(const gfx::Vector2dF& delta) const { 154 gfx::Vector2dF Viewport::AdjustOverscroll(const gfx::Vector2dF& delta) const {
155 const float kEpsilon = 0.1f; 155 const float kEpsilon = 0.1f;
156 gfx::Vector2dF adjusted = delta; 156 gfx::Vector2dF adjusted = delta;
157 157
158 if (std::abs(adjusted.x()) < kEpsilon) 158 if (std::abs(adjusted.x()) < kEpsilon)
159 adjusted.set_x(0.0f); 159 adjusted.set_x(0.0f);
160 if (std::abs(adjusted.y()) < kEpsilon) 160 if (std::abs(adjusted.y()) < kEpsilon)
161 adjusted.set_y(0.0f); 161 adjusted.set_y(0.0f);
tdresser 2015/07/10 18:41:30 Why can't these be moved?
jdduke (slow) 2015/07/10 19:12:50 So, the problem is that we're often seeing small r
162 162
163 // Disable overscroll on axes which are impossible to scroll.
164 if (host_impl_->settings().report_overscroll_only_for_scrollable_axes) {
165 if (std::abs(MaxTotalScrollOffset().x()) <= kEpsilon ||
166 !InnerScrollLayer()->user_scrollable_horizontal())
167 adjusted.set_x(0.0f);
168 if (std::abs(MaxTotalScrollOffset().y()) <= kEpsilon ||
169 !InnerScrollLayer()->user_scrollable_vertical())
170 adjusted.set_y(0.0f);
171 }
172
173 return adjusted; 163 return adjusted;
174 } 164 }
175 165
176 gfx::ScrollOffset Viewport::MaxTotalScrollOffset() const { 166 gfx::ScrollOffset Viewport::MaxTotalScrollOffset() const {
177 gfx::ScrollOffset offset; 167 gfx::ScrollOffset offset;
178 168
179 offset += InnerScrollLayer()->MaxScrollOffset(); 169 offset += InnerScrollLayer()->MaxScrollOffset();
180 170
181 if (OuterScrollLayer()) 171 if (OuterScrollLayer())
182 offset += OuterScrollLayer()->MaxScrollOffset(); 172 offset += OuterScrollLayer()->MaxScrollOffset();
(...skipping 14 matching lines...) Expand all
197 187
198 LayerImpl* Viewport::InnerScrollLayer() const { 188 LayerImpl* Viewport::InnerScrollLayer() const {
199 return host_impl_->InnerViewportScrollLayer(); 189 return host_impl_->InnerViewportScrollLayer();
200 } 190 }
201 191
202 LayerImpl* Viewport::OuterScrollLayer() const { 192 LayerImpl* Viewport::OuterScrollLayer() const {
203 return host_impl_->OuterViewportScrollLayer(); 193 return host_impl_->OuterViewportScrollLayer();
204 } 194 }
205 195
206 } // namespace cc 196 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | content/browser/android/overscroll_glow.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698