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

Side by Side Diff: third_party/WebKit/Source/platform/scroll/ScrollbarTheme.cpp

Issue 1601303003: Fix smooth scroll overshooting when mouse held down in scrollbar track. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 /* 1 /*
2 * Copyright (C) 2011 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2011 Apple Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 return Platform::current()->scrollbarBehavior()->shouldCenterOnThumb(static_ cast<WebScrollbarBehavior::Button>(evt.button()), evt.shiftKey(), evt.altKey()); 200 return Platform::current()->scrollbarBehavior()->shouldCenterOnThumb(static_ cast<WebScrollbarBehavior::Button>(evt.button()), evt.shiftKey(), evt.altKey());
201 } 201 }
202 202
203 bool ScrollbarTheme::shouldSnapBackToDragOrigin(const ScrollbarThemeClient& scro llbar, const PlatformMouseEvent& evt) 203 bool ScrollbarTheme::shouldSnapBackToDragOrigin(const ScrollbarThemeClient& scro llbar, const PlatformMouseEvent& evt)
204 { 204 {
205 IntPoint mousePosition = scrollbar.convertFromRootFrame(evt.position()); 205 IntPoint mousePosition = scrollbar.convertFromRootFrame(evt.position());
206 mousePosition.move(scrollbar.x(), scrollbar.y()); 206 mousePosition.move(scrollbar.x(), scrollbar.y());
207 return Platform::current()->scrollbarBehavior()->shouldSnapBackToDragOrigin( mousePosition, trackRect(scrollbar), scrollbar.orientation() == HorizontalScroll bar); 207 return Platform::current()->scrollbarBehavior()->shouldSnapBackToDragOrigin( mousePosition, trackRect(scrollbar), scrollbar.orientation() == HorizontalScroll bar);
208 } 208 }
209 209
210 int ScrollbarTheme::thumbPosition(const ScrollbarThemeClient& scrollbar) 210 int ScrollbarTheme::thumbPosition(const ScrollbarThemeClient& scrollbar, float s crollPosition)
211 { 211 {
212 if (scrollbar.enabled()) { 212 if (scrollbar.enabled()) {
213 float size = scrollbar.totalSize() - scrollbar.visibleSize(); 213 float size = scrollbar.totalSize() - scrollbar.visibleSize();
214 // Avoid doing a floating point divide by zero and return 1 when usedTot alSize == visibleSize. 214 // Avoid doing a floating point divide by zero and return 1 when usedTot alSize == visibleSize.
215 if (!size) 215 if (!size)
216 return 0; 216 return 0;
217 float pos = std::max(0.0f, scrollbar.currentPos()) * (trackLength(scroll bar) - thumbLength(scrollbar)) / size; 217 float pos = std::max(0.0f, scrollPosition) * (trackLength(scrollbar) - t humbLength(scrollbar)) / size;
218 return (pos < 1 && pos > 0) ? 1 : pos; 218 return (pos < 1 && pos > 0) ? 1 : pos;
219 } 219 }
220 return 0; 220 return 0;
221 } 221 }
222 222
223 int ScrollbarTheme::thumbLength(const ScrollbarThemeClient& scrollbar) 223 int ScrollbarTheme::thumbLength(const ScrollbarThemeClient& scrollbar)
224 { 224 {
225 if (!scrollbar.enabled()) 225 if (!scrollbar.enabled())
226 return 0; 226 return 0;
227 227
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 return DisplayItem::ScrollbarBackTrack; 341 return DisplayItem::ScrollbarBackTrack;
342 case ForwardTrackPart: 342 case ForwardTrackPart:
343 return DisplayItem::ScrollbarForwardTrack; 343 return DisplayItem::ScrollbarForwardTrack;
344 default: 344 default:
345 ASSERT_NOT_REACHED(); 345 ASSERT_NOT_REACHED();
346 return DisplayItem::ScrollbarBackTrack; 346 return DisplayItem::ScrollbarBackTrack;
347 } 347 }
348 } 348 }
349 349
350 } // namespace blink 350 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698