forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Percent based scrolling: Fix mousewheel for large scrollers
With percent based scrolling turned on, small mousewheel scrolls do not work for scrollers with very large offsets. Small percentage values like 0.1 (10%) could not be resolved against very large scrollers (>4M) with offsets > 0.5x that of the scroller on both the main thread and compositor, as they are clamped to 0 and no scroll delta is computed. This change fixes the issue by converting the percentage to a scroll delta in LayerTreeHostImpl::CanConsumeDelta for the compositor, and ScrollManager::CanScroll in the main thread. In addition, scroll speed is now ignored by gpu benchmarking when a test uses percent based scrolling. Percentage based scrolls do not require a velocity and are delivered as a single event. This prevents DCHECK_GT(total_duration_in_us, 0) from being hit in SyntheticSmoothMoveGesture::ComputeNextMoveSegment. Bug: 1057834 Change-Id: Ifec649729a1bb8ef7a5d09311ba93f90b24873ee Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2145706 Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: David Bokan <bokan@chromium.org> Reviewed-by: Daniel Libby <dlibby@microsoft.com> Reviewed-by: Rahul Arakeri <arakeri@microsoft.com> Commit-Queue: Sahir Vellani <sahir.vellani@microsoft.com> Cr-Commit-Position: refs/heads/master@{#762989}
- Loading branch information
Showing
8 changed files
with
112 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
third_party/blink/web_tests/fast/scrolling/percentage-mousewheel-large-scroll-offset.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<!doctype html> | ||
<script src="../../resources/testharness.js"></script> | ||
<script src="../../resources/testharnessreport.js"></script> | ||
<script src="../../resources/gesture-util.js"></script> | ||
<style> | ||
#scroll-div { | ||
width:400px; height:100px; | ||
overflow: auto; | ||
position:relative; | ||
} | ||
#range-div { | ||
width:4194410px; height: 4194410px; | ||
border:1px solid red; | ||
position:absolute; | ||
top: 10px; | ||
left: 10px; | ||
} | ||
</style> | ||
<div id="scroll-div"> | ||
<div id="range-div"></div> | ||
</div> | ||
<script> | ||
var scroller = document.querySelector("#scroll-div"); | ||
// Scroll div to some large offset that is > 0.5*4194410 | ||
const LARGE_SCROLL_OFFSET = 2097206; | ||
scroller.scrollTop = LARGE_SCROLL_OFFSET; | ||
scroller.scrollLeft = LARGE_SCROLL_OFFSET; | ||
const SCROLL_PERCENTAGE = 0.1; | ||
promise_test(async () => { | ||
// Scroll the inner scroller by the SCROLL_PERCENTAGE. | ||
var originalTopOffset = scroller.scrollTop; | ||
var originalLeftOffset = scroller.scrollLeft; | ||
|
||
// Use negative scroll percentages because we want to scroll up and left | ||
await percentScroll(-SCROLL_PERCENTAGE, | ||
-SCROLL_PERCENTAGE, | ||
50, | ||
50, | ||
GestureSourceType.MOUSE_INPUT); | ||
|
||
function isCorrectOffset() { | ||
return scroller.scrollTop <= | ||
Math.round(originalTopOffset - scroller.clientHeight * SCROLL_PERCENTAGE); | ||
} | ||
await waitFor(isCorrectOffset, | ||
"Scrolling by 10% must scroll the correct amount."); | ||
|
||
assert_less_than(scroller.scrollTop, originalTopOffset, | ||
"Must be able to scroll vertically by percentage even when at large offset"); | ||
assert_less_than(scroller.scrollLeft, originalLeftOffset, | ||
"Must be able to scroll horizontally by percentage even when at large offset"); | ||
|
||
|
||
}, "Can scroll by percentage at large offset"); | ||
|
||
|
||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters