Skip to content

[cssom-view-1] Scroll methods in Element and Window return Promises #12355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 31 additions & 25 deletions cssom-view-1/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -551,12 +551,12 @@ partial interface Window {
[Replaceable] readonly attribute double pageXOffset;
[Replaceable] readonly attribute double scrollY;
[Replaceable] readonly attribute double pageYOffset;
undefined scroll(optional ScrollToOptions options = {});
undefined scroll(unrestricted double x, unrestricted double y);
undefined scrollTo(optional ScrollToOptions options = {});
undefined scrollTo(unrestricted double x, unrestricted double y);
undefined scrollBy(optional ScrollToOptions options = {});
undefined scrollBy(unrestricted double x, unrestricted double y);
Promise<undefined> scroll(optional ScrollToOptions options = {});
Promise<undefined> scroll(unrestricted double x, unrestricted double y);
Promise<undefined> scrollTo(optional ScrollToOptions options = {});
Promise<undefined> scrollTo(unrestricted double x, unrestricted double y);
Promise<undefined> scrollBy(optional ScrollToOptions options = {});
Promise<undefined> scrollBy(unrestricted double x, unrestricted double y);

// client
[Replaceable] readonly attribute long screenX;
Expand Down Expand Up @@ -669,7 +669,7 @@ steps must be run:
1. Let <var>options</var> be null <a lt="converted to an IDL value">converted</a> to a {{ScrollToOptions}} dictionary. [[!WEBIDL]]
1. Let <var>x</var> and <var>y</var> be the arguments, respectively.
1. <a>Normalize non-finite values</a> for <var>x</var> and <var>y</var>.
1. If there is no <a>viewport</a>, abort these steps.
1. If there is no <a>viewport</a>, return a resolved promise and abort the remaining steps.
1. Let <var>viewport width</var> be the width of the <a>viewport</a> excluding the width of the scroll bar, if any.
1. Let <var>viewport height</var> be the height of the <a>viewport</a> excluding the height of the scroll bar, if any.
1.
Expand All @@ -694,11 +694,14 @@ steps must be run:
and aligning the y-coordinate <var>y</var> of the <a>viewport</a> <a>scrolling area</a>
with the top of the <a>viewport</a>.
1. If <var>position</var> is the same as the <a>viewport’s</a> current scroll position,
and the <a>viewport</a> does not have an ongoing <a>smooth scroll</a>, abort these steps.
and the <a>viewport</a> does not have an ongoing <a>smooth scroll</a>, return a resolved promise and abort the remaining steps.
1. Let <var>scrollPromise</var> be a new promise.
1. Return <var>scrollPromise</var>, and run the remaining steps <a>in parallel</a>.
1. Let <var>document</var> be the <a>viewport’s</a> associated {{Document}}.
1. <a for="viewport">Perform a scroll</a> of the <a>viewport</a> to <var>position</var>,
<var>document</var>'s [=root element=] as the associated element, if there is one, or null otherwise,
and the scroll behavior being the value of the {{ScrollOptions/behavior}} dictionary member of <var>options</var>.
1. Resolve <var>scrollPromise</var>.

Issue: User agents do not agree whether this uses the (coordinated) <a>viewport</a> <a for="viewport">perform a scroll</a> or the
<a>scrolling box</a> <a for="/">perform a scroll</a> on the layout viewport's scrolling box.
Expand All @@ -717,7 +720,7 @@ user agent must run these steps:
1. <a>Normalize non-finite values</a> for the {{ScrollToOptions/left}} and {{ScrollToOptions/top}} dictionary members of <var>options</var>.
1. Add the value of {{scrollX}} to the {{ScrollToOptions/left}} dictionary member.
1. Add the value of {{scrollY}} to the {{ScrollToOptions/top}} dictionary member.
1. Act as if the {{Window/scroll()}} method was invoked with <var>options</var> as the only argument.
1. Return the promise returned from {{Window/scroll()}} after the method is invoked with <var>options</var> as the only argument.

The <dfn attribute for=Window>screenX</dfn> and <dfn attribute for=Window>screenLeft</dfn> attributes must return the x-coordinate,
relative to the origin of the <a>Web-exposed screen area</a>, of the left of
Expand Down Expand Up @@ -1185,13 +1188,13 @@ partial interface Element {

boolean checkVisibility(optional CheckVisibilityOptions options = {});

undefined scrollIntoView(optional (boolean or ScrollIntoViewOptions) arg = {});
undefined scroll(optional ScrollToOptions options = {});
undefined scroll(unrestricted double x, unrestricted double y);
undefined scrollTo(optional ScrollToOptions options = {});
undefined scrollTo(unrestricted double x, unrestricted double y);
undefined scrollBy(optional ScrollToOptions options = {});
undefined scrollBy(unrestricted double x, unrestricted double y);
Promise<undefined> scrollIntoView(optional (boolean or ScrollIntoViewOptions) arg = {});
Promise<undefined> scroll(optional ScrollToOptions options = {});
Promise<undefined> scroll(unrestricted double x, unrestricted double y);
Promise<undefined> scrollTo(optional ScrollToOptions options = {});
Promise<undefined> scrollTo(unrestricted double x, unrestricted double y);
Promise<undefined> scrollBy(optional ScrollToOptions options = {});
Promise<undefined> scrollBy(unrestricted double x, unrestricted double y);
attribute unrestricted double scrollTop;
attribute unrestricted double scrollLeft;
readonly attribute long scrollWidth;
Expand Down Expand Up @@ -1323,23 +1326,26 @@ The <dfn method for=Element lt="scroll(options)|scroll(x, y)">scroll()</dfn> met
1. Let the {{ScrollToOptions/left}} dictionary member of <var>options</var> have the value <var>x</var>.
1. Let the {{ScrollToOptions/top}} dictionary member of <var>options</var> have the value <var>y</var>.
1. Let <var>document</var> be the element's <a>node document</a>.
1. If <var>document</var> is not the <a>active document</a>, terminate these steps.
1. If <var>document</var> is not the <a>active document</a>, return a resolved promise and abort the remaining steps.
1. Let <var>window</var> be the value of <var>document</var>'s {{Document/defaultView}} attribute.
1. If <var>window</var> is null, terminate these steps.
1. If the element is the [=root element=] and <var>document</var> is in <a>quirks mode</a>, terminate these steps.
1. If the element is the [=root element=] invoke {{Window/scroll()}} on <var>window</var> with {{Window/scrollX}} on <var>window</var> as first argument and <var>y</var> as second argument,
and terminate these steps.
1. If <var>window</var> is null, return a resolved promise and abort the remaining steps.
1. If the element is the [=root element=] and <var>document</var> is in <a>quirks mode</a>, return a resolved promise and abort the remaining steps.
1. If the element is the [=root element=], return the promise returned by {{Window/scroll()}} on <var>window</var> after the method is invoked with
{{Window/scrollX}} on <var>window</var> as first argument and <var>y</var> as second argument, and abort the remaining steps.
1. If the element is <a>the <code>body</code> element</a>,
<var>document</var> is in <a>quirks mode</a>,
and the element is not <a>potentially scrollable</a>,
invoke {{Window/scroll()}} on <var>window</var> with <var>options</var> as the only argument,
and terminate these steps.
return the promise returned by {{Window/scroll()}} on <var>window</var> after the method is invoked with
<var>options</var> as the only argument, and abort the remaining steps.
1. If the element does not have any associated [=CSS/box=],
the element has no associated <a>scrolling box</a>,
or the element has no overflow,
terminate these steps.
return a resolved promise and abort the remaining steps.
1. Let <var>scrollPromise</var> be a new promise.
1. Return <var>scrollPromise</var>, and run the remaining steps <a>in parallel</a>.
1. <a lt='scroll an element'>Scroll the element</a> to <var>x</var>,<var>y</var>,
with the scroll behavior being the value of the {{ScrollOptions/behavior}} dictionary member of <var>options</var>.
1. Resolve <var>scrollPromise</var>.

When the <dfn method for=Element lt="scrollTo(options)|scrollTo(x, y)">scrollTo()</dfn> method is invoked, the
user agent must act as if the {{Element/scroll()}} method was invoked with the same arguments.
Expand All @@ -1358,7 +1364,7 @@ user agent must run these steps:
1. Let the {{ScrollToOptions/top}} dictionary member of <var>options</var> have the value <var>y</var>.
1. Add the value of {{Element/scrollLeft}} to the {{ScrollToOptions/left}} dictionary member.
1. Add the value of {{Element/scrollTop}} to the {{ScrollToOptions/top}} dictionary member.
1. Act as if the {{Element/scroll()}} method was invoked with <var>options</var> as the only argument.
1. Return the promise returned by {{Element/scroll()}} after the method is invoked with <var>options</var> as the only argument.

The <dfn attribute for=Element>scrollTop</dfn> attribute, on getting, must return the result of running these steps:

Expand Down