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

Unified Diff: cc/layers/scrollbar_layer_impl_base.cc

Issue 409193002: Avoid div-by-zero in thumb quad computation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 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 | cc/layers/scrollbar_layer_unittest.cc » ('j') | cc/layers/scrollbar_layer_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/scrollbar_layer_impl_base.cc
diff --git a/cc/layers/scrollbar_layer_impl_base.cc b/cc/layers/scrollbar_layer_impl_base.cc
index 956f6179f26fca1058342b112263f8a39e258cd0..62b7dee0ad9c297f99d22a4826cdaf498ac21d96 100644
--- a/cc/layers/scrollbar_layer_impl_base.cc
+++ b/cc/layers/scrollbar_layer_impl_base.cc
@@ -212,9 +212,13 @@ gfx::Rect ScrollbarLayerImplBase::ComputeThumbQuadRect() const {
// With the length known, we can compute the thumb's position.
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) + TrackStart();
+
+ int thumb_offset = TrackStart();
+ if (maximum_ > 0) {
+ float ratio = clamped_current_pos / maximum_;
+ float max_offset = track_length - thumb_length;
+ thumb_offset += static_cast<int>(ratio * max_offset);
+ }
float thumb_thickness_adjustment =
thumb_thickness * (1.f - thumb_thickness_scale_factor_);
« no previous file with comments | « no previous file | cc/layers/scrollbar_layer_unittest.cc » ('j') | cc/layers/scrollbar_layer_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698