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

Unified Diff: content/browser/android/overscroll_glow.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 side-by-side diff with in-line comments
Download patch
Index: content/browser/android/overscroll_glow.cc
diff --git a/content/browser/android/overscroll_glow.cc b/content/browser/android/overscroll_glow.cc
index 0aa00e04ac6ad8d8addf8875fa1952befd04963a..c20787164316ccf05be7b4a3f1a75d4e5bcf0096 100644
--- a/content/browser/android/overscroll_glow.cc
+++ b/content/browser/android/overscroll_glow.cc
@@ -77,7 +77,11 @@ gfx::SizeF ComputeSize(OverscrollGlow::Edge edge,
} // namespace
OverscrollGlow::OverscrollGlow(OverscrollGlowClient* client)
- : client_(client), edge_offsets_(), initialized_(false) {
+ : client_(client),
+ edge_offsets_(),
+ initialized_(false),
+ allow_horizontal_overscroll_(true),
+ allow_vertical_overscroll_(true) {
DCHECK(client);
}
@@ -116,12 +120,21 @@ bool OverscrollGlow::OnOverscrolled(base::TimeTicks current_time,
const gfx::Vector2dF& accumulated_overscroll,
gfx::Vector2dF overscroll_delta,
gfx::Vector2dF velocity,
- const gfx::Vector2dF& displacement) {
+ const gfx::Vector2dF& overscroll_location) {
// The size of the glow determines the relative effect of the inputs; an
// empty-sized effect is effectively disabled.
if (viewport_size_.IsEmpty())
return false;
+ if (!allow_horizontal_overscroll_) {
+ overscroll_delta.set_x(0);
+ velocity.set_x(0);
+ }
+ if (!allow_vertical_overscroll_) {
+ overscroll_delta.set_y(0);
+ velocity.set_y(0);
+ }
+
// Ignore sufficiently small values that won't meaningfuly affect animation.
overscroll_delta = ZeroSmallComponents(overscroll_delta);
if (overscroll_delta.IsZero()) {
@@ -143,7 +156,7 @@ bool OverscrollGlow::OnOverscrolled(base::TimeTicks current_time,
if (!velocity.IsZero())
Absorb(current_time, velocity, x_overscroll_started, y_overscroll_started);
else
- Pull(current_time, overscroll_delta, displacement);
+ Pull(current_time, overscroll_delta, overscroll_location);
return CheckNeedsAnimate();
}
@@ -180,6 +193,12 @@ void OverscrollGlow::OnFrameUpdated(
viewport_size.height();
edge_offsets_[OverscrollGlow::EDGE_RIGHT] =
content_size.width() - content_scroll_offset.x() - viewport_size.width();
+
+ // Disallow overscroll on unscrollable axes, matching platform behavior.
+ allow_horizontal_overscroll_ =
+ std::ceil(viewport_size_.width()) < content_size.width();
+ allow_vertical_overscroll_ =
+ std::ceil(viewport_size_.height()) < content_size.height();
tdresser 2015/07/10 18:41:30 We don't need an epsilon check here?
jdduke (slow) 2015/07/10 19:12:50 This is the logic we had before the check got move
}
bool OverscrollGlow::CheckNeedsAnimate() {
@@ -246,8 +265,8 @@ void OverscrollGlow::Pull(base::TimeTicks current_time,
min(overscroll_pull.x(), 0.f), // Left
max(overscroll_pull.y(), 0.f), // Bottom
max(overscroll_pull.x(), 0.f) // Right
- };
-
+ }
tdresser 2015/07/10 18:41:30 Fix ;
jdduke (slow) 2015/07/10 19:12:50 Whoops, done.
+;
gfx::Vector2dF displacement =
gfx::ScaleVector2d(overscroll_location, inv_width, inv_height);
displacement.set_x(max(0.f, min(1.f, displacement.x())));

Powered by Google App Engine
This is Rietveld 408576698