Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support AnimationTimeline::getCurrentTime(String range)
Bug: 1385482 Change-Id: I0e8c526187f2cc34edc497bffee5d5e298e52f50 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4035412 Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org> Commit-Queue: Kevin Ellis <kevers@chromium.org> Cr-Commit-Position: refs/heads/main@{#1075167}
- Loading branch information
1 parent
6a20f2a
commit 74a29f2
Showing
9 changed files
with
214 additions
and
49 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
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
43 changes: 0 additions & 43 deletions
43
.../web_tests/external/wpt/scroll-animations/scroll-timelines/idlharness.window-expected.txt
This file was deleted.
Oops, something went wrong.
145 changes: 145 additions & 0 deletions
145
...ernal/wpt/scroll-animations/view-timelines/view-timeline-get-current-time-range-name.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,145 @@ | ||
<!DOCTYPE html> | ||
<html id="top"> | ||
<meta charset="utf-8"> | ||
<title>View timeline delay</title> | ||
<link rel="help" href="https://drafts.csswg.org/scroll-animations-1/#viewtimeline-interface"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/web-animations/testcommon.js"></script> | ||
<script src="/scroll-animations/scroll-timelines/testcommon.js"></script> | ||
<script src="/scroll-animations/view-timelines/testcommon.js"></script> | ||
<style> | ||
#container { | ||
border: 10px solid lightgray; | ||
overflow-x: scroll; | ||
height: 200px; | ||
width: 200px; | ||
} | ||
#content { | ||
display: flex; | ||
flex-flow: row nowrap; | ||
justify-content: flex-start; | ||
width: 1800px; | ||
margin: 0; | ||
} | ||
.spacer { | ||
width: 800px; | ||
display: inline-block; | ||
} | ||
#target { | ||
background-color: green; | ||
height: 100px; | ||
width: 100px; | ||
display: inline-block; | ||
} | ||
</style> | ||
<body> | ||
<div id="container"> | ||
<div id="content"> | ||
<div class="spacer"></div> | ||
<div id="target"></div> | ||
<div class="spacer"></div> | ||
</div> | ||
</div> | ||
</body> | ||
<script type="text/javascript"> | ||
const MAX_SCROLL = 1600; | ||
|
||
promise_test(async t => { | ||
// Points of interest along view timeline: | ||
// 600 px cover start, enter start | ||
// 700 px contain start, enter end | ||
// 800 px contain end, exit start | ||
// 900 px cover end, exit end | ||
const anim = | ||
CreateViewTimelineOpacityAnimation(t, target, | ||
{ axis: 'inline', fill: 'both' }); | ||
let timeline = anim.timeline; | ||
|
||
container.scrollLeft = 600; | ||
await waitForNextFrame(); | ||
|
||
assert_percents_approx_equal(timeline.getCurrentTime('cover'), 0, | ||
MAX_SCROLL, 'Scroll aligned with cover start'); | ||
assert_percents_approx_equal(timeline.getCurrentTime('enter'), 0, | ||
MAX_SCROLL, 'Scroll aligned with enter start'); | ||
assert_percents_approx_equal(timeline.getCurrentTime(), 0, | ||
MAX_SCROLL, | ||
'Scroll aligned with timeline start offset'); | ||
|
||
container.scrollLeft = 650; | ||
await waitForNextFrame(); | ||
|
||
assert_percents_approx_equal(timeline.getCurrentTime('enter'), 50, | ||
MAX_SCROLL, 'Scroll at enter midpoint'); | ||
|
||
container.scrollLeft = 700; | ||
await waitForNextFrame(); | ||
|
||
assert_percents_approx_equal(timeline.getCurrentTime('enter'), 100, | ||
MAX_SCROLL, 'Scroll at enter end'); | ||
assert_percents_approx_equal(timeline.getCurrentTime('contain'), 0, | ||
MAX_SCROLL, 'Scroll at contain start'); | ||
|
||
container.scrollLeft = 750; | ||
await waitForNextFrame(); | ||
|
||
assert_percents_approx_equal(timeline.getCurrentTime('contain'), 50, | ||
MAX_SCROLL, 'Scroll at contain midpoint'); | ||
assert_percents_approx_equal(timeline.getCurrentTime(), 50, | ||
MAX_SCROLL, 'Scroll at timeline midpoint'); | ||
|
||
container.scrollLeft = 800; | ||
await waitForNextFrame(); | ||
|
||
assert_percents_approx_equal(timeline.getCurrentTime('exit'), 0, | ||
MAX_SCROLL, 'Scroll at exit start'); | ||
assert_percents_approx_equal(timeline.getCurrentTime('contain'), 100, | ||
MAX_SCROLL, 'Scroll at contain end'); | ||
|
||
container.scrollLeft = 850; | ||
await waitForNextFrame(); | ||
|
||
assert_percents_approx_equal(timeline.getCurrentTime('exit'), 50, | ||
MAX_SCROLL, 'Scroll at exit midpoint'); | ||
|
||
container.scrollLeft = 900; | ||
await waitForNextFrame(); | ||
|
||
assert_percents_approx_equal(timeline.getCurrentTime('exit'), 100, | ||
MAX_SCROLL, 'Scroll at exit end'); | ||
assert_percents_approx_equal(timeline.getCurrentTime('cover'), 100, | ||
MAX_SCROLL, 'Scroll at cover end'); | ||
assert_percents_approx_equal(timeline.getCurrentTime(), 100, | ||
MAX_SCROLL, 'Scroll at end of timeline'); | ||
|
||
assert_equals(timeline.getCurrentTime('gibberish'), null, | ||
'No current time for unknown named range'); | ||
|
||
// Add insets to force the start and end offsets to align. This forces | ||
// the timeline to become inactive. | ||
// start_offset = target_offset - viewport_size + end_side_inset | ||
// = 600 + end_side_inset | ||
// end_offset = target_offset + target_size - start_side_inset | ||
// = 900 - start_side_inset | ||
// Equating start_offset and end_offset: | ||
// end_side_inset = 300 - start_side_inset; | ||
timeline = | ||
new ViewTimeline ({ | ||
subject: target, | ||
axis: 'inline', | ||
inset: [ CSS.px(150), CSS.px(150) ] | ||
}); | ||
anim.timeline = timeline; | ||
await waitForNextFrame(); | ||
|
||
assert_equals(timeline.currentTime, null, | ||
'Current time is null when scroll-range is zero'); | ||
assert_equals(timeline.getCurrentTime(), null, | ||
'getCurrentTime with an inactive timeline.'); | ||
assert_equals(timeline.getCurrentTime('contain'), null, | ||
'getCurrentTime on a ranged name with an inactive timeline.'); | ||
|
||
}, 'View timeline current time for named range'); | ||
|
||
</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