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

Unified Diff: cc/layers/scrollbar_layer_impl.cc

Issue 20157002: Don't let scrollbar thumbs run off their tracks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/scrollbar_layer_impl.cc
diff --git a/cc/layers/scrollbar_layer_impl.cc b/cc/layers/scrollbar_layer_impl.cc
index e346ee0650c2d731eaa210ce8cb1fef68a65c557..0dcfcdec74114860caf02f5064b3cc972d118ba5 100644
--- a/cc/layers/scrollbar_layer_impl.cc
+++ b/cc/layers/scrollbar_layer_impl.cc
@@ -4,6 +4,8 @@
#include "cc/layers/scrollbar_layer_impl.h"
+#include <algorithm>
+
#include "cc/animation/scrollbar_animation_controller.h"
#include "cc/layers/layer.h"
#include "cc/layers/quad_sink.h"
@@ -241,7 +243,9 @@ gfx::Rect ScrollbarLayerImpl::ComputeThumbQuadRect() const {
}
// With the length known, we can compute the thumb's position.
- float ratio = current_pos_ / maximum_;
+ float clamped_current_pos =
+ std::min(std::max(current_pos_, 0.f), static_cast<float>(maximum_));
+ float ratio = clamped_current_pos / maximum_;
float max_offset = track_length - thumb_length;
int thumb_offset = static_cast<int>(ratio * max_offset) + track_start_;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698