Skip to content

Commit c705130

Browse files
authored
[scroll-animations] let source be explicitly nullable (w3c#5202, w3c#5211) (w3c#5263)
Fixing w3c#5202 and w3c#5211 Changes: - Fix IDL to make source nullable. - In CSS source will accept 'auto' and 'none' with none mapping to null. - In JS, we now map missing 'source' to document scrolling element (i.e., auto behavior) and explicitly null 'source' to null. - Correctly check null source when calculating offsets. Other minor cleanups.
1 parent 36627b9 commit c705130

1 file changed

Lines changed: 74 additions & 43 deletions

File tree

scroll-animations-1/Overview.bs

Lines changed: 74 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ dictionary ScrollTimelineOptions {
359359
[Exposed=Window]
360360
interface ScrollTimeline : AnimationTimeline {
361361
constructor(optional ScrollTimelineOptions options = {});
362-
readonly attribute Element source;
362+
readonly attribute Element? source;
363363
readonly attribute ScrollDirection orientation;
364364
readonly attribute (DOMString or ElementBasedOffset) start;
365365
readonly attribute (DOMString or ElementBasedOffset) end;
@@ -378,24 +378,28 @@ determined not by wall-clock time, but by the progress of scrolling in a
378378
: <dfn constructor for=ScrollTimeline lt="ScrollTimeline(options)">ScrollTimeline(options)</dfn>
379379
:: Creates a new {{ScrollTimeline}} object using the following procedure:
380380

381-
1. Let |timeline| be a new {{ScrollTimeline}} object.
381+
1. Let |timeline| be a new {{ScrollTimeline}} object.
382382

383-
1. Let |source| be the result corresponding to the first matching condition from below.
383+
1. Let |source| be the result corresponding to the first matching condition
384+
from the following:
384385

385-
: If the |source| value of |options| is non-null,
386-
:: Let |source| be |source|
386+
<div class="switch">
387387

388-
: Otherwise (|source| is null),
389-
:: Let |source| be the {{scrollingElement}} of the {{Document}} <a lt="document associated with a window">associated</a> with the {{Window}} that is the <a>current global object</a>.
388+
: If the <code>source</code> member of |options| is missing,
389+
:: The {{scrollingElement}} of the {{Document}} <a lt="document
390+
associated with a window">associated</a> with the {{Window}} that is
391+
the <a>current global object</a>.
390392

391-
Note: |source| may still be null after this step, e.g. if the {{Document}} has no {{scrollingElement}}.
393+
: Otherwise,
394+
:: The <code>source</code> member of |options|.
392395

393-
1. Set the {{ScrollTimeline/source}} of |timeline| to |source|.
396+
</div>
394397

395-
1. Assign the {{ScrollTimeline/orientation}}, {{ScrollTimeline/start}}, {{ScrollTimeline/end}}, and {{ScrollTimeline/timeRange}} properties of |timeline| to the corresponding value from |options|.
398+
1. Set the {{ScrollTimeline/source}} of |timeline| to |source|.
396399

397-
Issue(5202): The above steps need clarification, particularly with regards to
398-
handling of null values for |source|.
400+
1. Assign the {{ScrollTimeline/orientation}}, {{ScrollTimeline/start}},
401+
{{ScrollTimeline/end}}, and {{ScrollTimeline/timeRange}} properties of
402+
|timeline| to the corresponding value from |options|.
399403

400404
</div>
401405

@@ -433,7 +437,7 @@ handling of null values for |source|.
433437
{{start}} to {{end}}, to the [=effective time range=].
434438

435439
Issue(4862): We are working to remove the need for {{timeRange}} to be declared.
436-
The most recent work on this involved introduction of the concept of
440+
The most recent work on this involved introduction of the concept of
437441
"progress-based animations" to web animations.
438442

439443
</div>
@@ -471,18 +475,26 @@ one the following values:
471475
The procedure to <dfn>resolve a container-based offset</dfn> given
472476
<var>offset</var> is as follows:
473477

474-
1. [=effective scroll offset=] is the scroll offset corresponding to the first
475-
matching condition from the following:
478+
1. If <em>any</em> of the following are true:
479+
480+
* {{source}} is null, or
481+
* {{source}} does not currently have a [=CSS layout box=], or
482+
* {{source}}'s layout box is not a [=scroll container=].
483+
484+
The [=effective scroll offset=] is null and abort remaining steps.
485+
486+
1. The [=effective scroll offset=] is the scroll offset corresponding to the
487+
first matching condition from the following:
476488
<div class="switch">
477489

478-
: <var>offset</var> is <code>auto</code>
479-
:: Either the beginning or the ending of {{source}}'s scroll range
480-
in {{orientation}} depending on whether the offset is {{start}} or {{end}}.
490+
: <var>offset</var> is <code>auto</code>
491+
:: Either the beginning or the ending of {{source}}'s scroll range in
492+
{{orientation}} depending on whether the offset is {{start}} or {{end}}.
481493

482494
: <var>offset</var> is a <<length-percentage>>
483-
:: The distance indicated by the value along {{source}}'s scroll range in {{orientation}} as
484-
expressed by absolute length, a percentage, or a ''calc()'' expression that resolves to a
485-
<<length>>.
495+
:: The distance indicated by the value along {{source}}'s scroll range in
496+
{{orientation}} as expressed by absolute length, a percentage, or a
497+
''calc()'' expression that resolves to a <<length>>.
486498

487499
</div>
488500

@@ -536,22 +548,27 @@ checked anywhere.
536548
The procedure to <dfn>resolve an element-based offset</dfn> given
537549
<var>offset</var> is as follows:
538550

539-
1. If {{source}} is null,
540-
does not currently have a [=CSS layout box=],
541-
or if its layout box is not a [=scroll container=],
542-
abort the following steps
543-
since then the [=effective scroll offset=] is null.
551+
1. If <em>any</em> of the following are true:
552+
553+
* {{source}} is null, or
554+
* {{source}} does not currently have a [=CSS layout box=], or
555+
* {{source}}'s layout box is not a [=scroll container=].
556+
557+
The [=effective scroll offset=] is null and abort remaining steps.
544558

545559
1. Let <var>target</var> be <var>offset</var>'s {{target}}.
546560

547-
1. If <var>target</var> is null or
548-
does not currently have a [=CSS layout box=],
549-
abort the following steps
550-
since then the [=effective scroll offset=] is null.
561+
1. If <em>any</em> of the following are true:
562+
563+
* <var>target</var> is null, or
564+
* <var>target</var> does not currently have a [=CSS layout box=].
565+
566+
The [=effective scroll offset=] is null and abort remaining steps.
567+
551568

552569
1. If <var>target</var> 's nearest [=scroll container=] ancestor
553570
is not {{source}}
554-
abort the following steps
571+
abort remaining steps
555572
since the [=effective scroll offset=] is null.
556573

557574
1. Let <var>container box</var> be the {{source}}'s [=scrollport=].
@@ -809,7 +826,7 @@ the names are fully case-sensitive; two names are equal only if they are
809826
codepoint-by-codepoint equal. The <<custom-ident>> additionally excludes the
810827
none keyword.
811828

812-
Once specified, a scroll timeline may be associated with a CSS Animation
829+
Once specified, a scroll timeline may be associated with a CSS Animation
813830
[[CSS3-ANIMATIONS]] by using the 'animation-timeline' property.
814831

815832
The <<declaration-list>> inside of ''@scroll-timeline'' rule can only contain the
@@ -826,19 +843,32 @@ Issue(5167): This will likely change in the future.
826843
<pre class='descdef'>
827844
Name: source
828845
For: @scroll-timeline
829-
Value: selector(<<id-selector>>) | none
830-
Initial: none
846+
Value: selector(<<id-selector>>) | auto | none
847+
Initial: auto
831848
</pre>
832849

833-
'source' descriptor determines the scroll timeline's {{source}}. If specified as
834-
a 'selector()' the scroll timeline's {{source}} is the [=scroll container=]
835-
identified by the <<id-selector>>, otherwise if not specified or none then it is
836-
the the {{scrollingElement}} of the {{Document}} <a lt="document associated with
837-
a window">associated</a> with the {{Window}} that is the <a>current global
838-
object</a>.
850+
'source' descriptor determines the scroll timeline's {{source}}.
851+
852+
The value of {{source}} is the result corresponding to the first matching
853+
condition from the following:
854+
855+
<div class="switch">
856+
857+
: If 'source' is a 'selector()'
858+
:: The [=scroll container=] identified by the <<id-selector>>.
859+
860+
: If 'source' is <code>auto</code>
861+
:: The {{scrollingElement}} of the {{Document}} <a lt="document associated with
862+
a window">associated</a> with the {{Window}} that is the
863+
<a>current global object</a>.
864+
865+
: Otherwise ('source' is <code>none</code>)
866+
:: null.
867+
868+
</div>
839869

840-
Issue(4338): consider choosing animation target's nearest scrollable ancestor
841-
instead of document's scrolling Element
870+
Issue(4338): Consider choosing animation target's nearest scrollable ancestor
871+
instead of document's scrolling Element for <code>auto</code>.
842872

843873
<pre class='descdef'>
844874
Name: orientation
@@ -903,7 +933,8 @@ interface CSSScrollTimelineRule : CSSRule {
903933

904934
<dt><dfn>source</dfn></dt>
905935
<dd>
906-
The 'source' descriptor associated with the ''@scroll-timeline'', or "none" if not specified.
936+
The 'source' descriptor associated with the ''@scroll-timeline'', or "auto"
937+
if not specified.
907938
</dd>
908939

909940
<dt><dfn>orientation</dfn></dt>

0 commit comments

Comments
 (0)