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

Unified Diff: cc/layers/scrollbar_layer_impl_base.cc

Issue 2841943002: Overlay scrollbars expand only when mouse is near thumb (Closed)
Patch Set: Created 3 years, 8 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: 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 839c0b7f927d488f9ce76813ebd40b7abf66569f..06a91c88e793fa1d4db3529e6c002fa752282a0a 100644
--- a/cc/layers/scrollbar_layer_impl_base.cc
+++ b/cc/layers/scrollbar_layer_impl_base.cc
@@ -107,6 +107,37 @@ bool ScrollbarLayerImplBase::SetThumbThicknessScaleFactor(float factor) {
return true;
}
+gfx::Rect ScrollbarLayerImplBase::ComputeExpandedThumbQuadRect() const {
+ DCHECK(is_overlay_scrollbar());
+ float track_length = TrackLength();
+ int thumb_length = ThumbLength();
+ int thumb_thickness = ThumbThickness();
+ float maximum = scroll_layer_length_ - clip_layer_length_;
+
+ // With the length known, we can compute the thumb's position.
+ float clamped_current_pos = std::min(std::max(current_pos_, 0.f), maximum);
+
+ 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);
+ }
+
+ gfx::RectF thumb_rect;
+ if (orientation_ == HORIZONTAL) {
+ thumb_rect = gfx::RectF(thumb_offset, vertical_adjust_, thumb_length,
+ thumb_thickness);
+ } else {
+ thumb_rect = gfx::RectF(is_left_side_vertical_scrollbar_
+ ? bounds().width() - thumb_thickness
+ : 0,
+ thumb_offset, thumb_thickness, thumb_length);
+ }
+
+ return gfx::ToEnclosingRect(thumb_rect);
+}
+
gfx::Rect ScrollbarLayerImplBase::ComputeThumbQuadRect() const {
// Thumb extent is the length of the thumb in the scrolling direction, thumb
// thickness is in the perpendicular direction. Here's an example of a

Powered by Google App Engine
This is Rietveld 408576698