Commit 0cb58580 authored by Anders Hartvoll Ruud's avatar Anders Hartvoll Ruud Committed by Commit Bot

[scroll-animations] Allow null source in ScrollTimeline constructor

The spec was recently updated to differentiate between the source
being missing and the source being null. The former means that the
source should default to document.scrollingElement, and the latter
means that there is no source.

Note: In the CSS API, this translates to 'auto' and 'none',
respectively. Support for this has already landed in a previous CL.

Bug: 1100907
Change-Id: I1436b16d06b7a7ae0de55e2706a7b5d87c0290b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2367837Reviewed-by: default avatarKevin Ellis <kevers@chromium.org>
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801085}
parent 026e0ec7
......@@ -95,7 +95,7 @@ Node* ResolveScrollSource(Element* scroll_source) {
ScrollTimeline* ScrollTimeline::Create(Document& document,
ScrollTimelineOptions* options,
ExceptionState& exception_state) {
Element* scroll_source = options->scrollSource()
Element* scroll_source = options->hasScrollSource()
? options->scrollSource()
: document.scrollingElement();
......
......@@ -14,7 +14,7 @@ enum ScrollDirection {
enum ScrollTimelineAutoKeyword { "auto" };
dictionary ScrollTimelineOptions {
Element? scrollSource = null;
Element? scrollSource;
ScrollDirection orientation = "block";
(DOMString or ScrollTimelineElementBasedOffset) startScrollOffset = "auto";
(DOMString or ScrollTimelineElementBasedOffset) endScrollOffset = "auto";
......
This is a testharness.js-based test.
Found 60 tests; 58 PASS, 2 FAIL, 0 TIMEOUT, 0 NOTRUN.
Found 61 tests; 59 PASS, 2 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS A ScrollTimeline can be created with a scrollSource
PASS A ScrollTimeline can be created with a non-scrolling scrollSource
PASS A ScrollTimeline created with a null scrollSource should use the document.scrollingElement
PASS A ScrollTimeline created with a null scrollSource should have no scrollSource
PASS A ScrollTimeline created without a scrollSource should use the document.scrollingElement
PASS A ScrollTimeline created with the default orientation should default to 'block'
PASS 'block' is a valid orientation value
PASS 'inline' is a valid orientation value
......
......@@ -49,13 +49,14 @@ test(t => {
test(t => {
assert_equals(
new ScrollTimeline({scrollSource: null, timeRange: 100}).scrollSource,
document.scrollingElement);
// The default value for scrollSource should also map to the
// document.scrollingElement.
null);
}, 'A ScrollTimeline created with a null scrollSource should have no scrollSource');
test(t => {
assert_equals(
new ScrollTimeline({timeRange: 100}).scrollSource,
document.scrollingElement);
}, 'A ScrollTimeline created with a null scrollSource should use the document.scrollingElement');
}, 'A ScrollTimeline created without a scrollSource should use the document.scrollingElement');
// orientation
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment