diff --git a/cssom-view-1/Overview.bs b/cssom-view-1/Overview.bs index 2dee6e91f28..b56a3ddd990 100644 --- a/cssom-view-1/Overview.bs +++ b/cssom-view-1/Overview.bs @@ -420,22 +420,25 @@ an associated element or [=pseudo-element=] element and optionally a (which is "auto" if omitted), the following steps must be run: -
    -
  1. Abort any ongoing smooth scroll for box. -
  2. If the user agent honors the 'scroll-behavior' property and one of the following are true: +1. Abort any ongoing smooth scroll for box. +1. Resolve any pending promise for box with false. +1. Let scrollPromise be a new promise. +1. Return scrollPromise, and run the remaining steps in parallel. +1. If the user agent honors the 'scroll-behavior' property and one of the following is true: - ...then perform a smooth scroll of box to position. Once the position has finished updating, emit the scrollend event. - Otherwise, perform an instant scroll of box to position. After an instant scroll emit the scrollend event. + then perform a smooth scroll of box to position; + otherwise, perform an instant scroll of box to position. +1. Wait until either the position has finished updating, or scrollPromise has been resolved. +1. If the scroll position changed as a result of this call, emit the scrollend event. +1. Resolve scrollPromise with true if it is still in the pending state. Note: behavior: "instant" always performs an instant scroll by this algorithm. Note: If the scroll position did not change as a result of the user interaction or programmatic invocation, where no translations were applied as a result, then no scrollend event fires because no scrolling occurred. -
-
@@ -460,8 +463,17 @@ When a user agent is to perform a scroll of a < 1. Let element be doc's root element if there is one, null otherwise. 1. Perform a scroll of the viewport's scrolling box to its current scroll position + (layout dx, layout dy) with element as the associated element, and behavior as the scroll behavior. + Let scrollPromise1 be the promise returned from this step. 1. Perform a scroll of vv's scrolling box to its current scroll position + (visual dx, visual dy) with element as the associated element, and behavior as the scroll behavior. + Let scrollPromise2 be the promise returned from this step. +1. Let scrollPromise be a new promise. +1. Return scrollPromise, and run the remaining steps in parallel. +1. Wait until either both scrollPromise1 and scrollPromise2 get resolved with true, or any of them settles in any other state (i.e. gets resolved with false or gets rejected). +1. If both scrollPromise1 and scrollPromise2 were resolved with true, + resolve scrollPromise with true. + Otherwise resolve scrollPromise with false, + and also resolve with false any of scrollPromise1 or scrollPromise2 that is still in the pending state. Note: Conceptually, the visual viewport is scrolled until it "bumps up" against the layout viewport edge and then "pushes" the layout viewport by applying the scroll delta to the layout viewport. @@ -551,12 +563,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 scroll(optional ScrollToOptions options = {}); + Promise scroll(unrestricted double x, unrestricted double y); + Promise scrollTo(optional ScrollToOptions options = {}); + Promise scrollTo(unrestricted double x, unrestricted double y); + Promise scrollBy(optional ScrollToOptions options = {}); + Promise scrollBy(unrestricted double x, unrestricted double y); // client [Replaceable] readonly attribute long screenX; @@ -569,6 +581,8 @@ partial interface Window { }; +Issue: Should the scroll methods above return a result object and if so what information should they provide? #12355 + When the matchMedia(query) method is invoked these steps must be run:
  1. Let parsed media query list be the result of @@ -669,7 +683,7 @@ steps must be run: 1. Let options be null converted to a {{ScrollToOptions}} dictionary. [[!WEBIDL]] 1. Let x and y be the arguments, respectively. 1. Normalize non-finite values for x and y. -1. If there is no viewport, abort these steps. +1. If there is no viewport, return a promise resolved with false and abort the remaining steps. 1. Let viewport width be the width of the viewport excluding the width of the scroll bar, if any. 1. Let viewport height be the height of the viewport excluding the height of the scroll bar, if any. 1. @@ -694,11 +708,13 @@ steps must be run: and aligning the y-coordinate y of the viewport scrolling area with the top of the viewport. 1. If position is the same as the viewport’s current scroll position, - and the viewport does not have an ongoing smooth scroll, abort these steps. + and the viewport does not have an ongoing smooth scroll, return a promise resolved with false and abort the remaining steps. 1. Let document be the viewport’s associated {{Document}}. 1. Perform a scroll of the viewport to position, document'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 options. + Let scrollPromise be the promise returned from this step. +1. Return scrollPromise. Issue: User agents do not agree whether this uses the (coordinated) viewport perform a scroll or the scrolling box perform a scroll on the layout viewport's scrolling box. @@ -717,7 +733,7 @@ user agent must run these steps: 1. Normalize non-finite values for the {{ScrollToOptions/left}} and {{ScrollToOptions/top}} dictionary members of options. 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 options as the only argument. +1. Return the promise returned from {{Window/scroll()}} after the method is invoked with options as the only argument. The screenX and screenLeft attributes must return the x-coordinate, relative to the origin of the Web-exposed screen area, of the left of @@ -1185,13 +1201,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 scrollIntoView(optional (boolean or ScrollIntoViewOptions) arg = {}); + Promise scroll(optional ScrollToOptions options = {}); + Promise scroll(unrestricted double x, unrestricted double y); + Promise scrollTo(optional ScrollToOptions options = {}); + Promise scrollTo(unrestricted double x, unrestricted double y); + Promise scrollBy(optional ScrollToOptions options = {}); + Promise scrollBy(unrestricted double x, unrestricted double y); attribute unrestricted double scrollTop; attribute unrestricted double scrollLeft; readonly attribute long scrollWidth; @@ -1204,6 +1220,8 @@ partial interface Element { }; +Issue: Should the scroll methods above return a result object and if so what information should they provide? #12355 + Note: The {{CheckVisibilityOptions/checkOpacity}} and {{CheckVisibilityOptions/checkVisibilityCSS}} properties are historical names. These properties have aliases that match the new naming scheme, namely {{CheckVisibilityOptions/opacityProperty}} and {{CheckVisibilityOptions/visibilityProperty}}. @@ -1304,10 +1322,12 @@ The scrollIntoView(arg 1. Otherwise, if arg is false, then set block to "end". 1. If the element does not have any associated [=CSS/box=], or is not available to user-agent features, - then return. + then return a promise resolved with false and abort the remaining steps. 1. Scroll the element into view with behavior, block, inline, and container. + Let scrollPromise be the promise returned from this step 1. Optionally perform some other action that brings the element to the user's attention. +1. Return scrollPromise. The scroll() method must run these steps: @@ -1323,23 +1343,24 @@ The scroll() met 1. Let the {{ScrollToOptions/left}} dictionary member of options have the value x. 1. Let the {{ScrollToOptions/top}} dictionary member of options have the value y. 1. Let document be the element's node document. -1. If document is not the active document, terminate these steps. +1. If document is not the active document, return a promise resolved with false and abort the remaining steps. 1. Let window be the value of document's {{Document/defaultView}} attribute. -1. If window is null, terminate these steps. -1. If the element is the [=root element=] and document is in quirks mode, terminate these steps. -1. If the element is the [=root element=] invoke {{Window/scroll()}} on window with {{Window/scrollX}} on window as first argument and y as second argument, - and terminate these steps. +1. If window is null, return a promise resolved with false and abort the remaining steps. +1. If the element is the [=root element=] and document is in quirks mode, return a promise resolved with false and abort the remaining steps. +1. If the element is the [=root element=], return the promise returned by {{Window/scroll()}} on window after the method is invoked with + {{Window/scrollX}} on window as first argument and y as second argument, and abort the remaining steps. 1. If the element is the body element, document is in quirks mode, and the element is not potentially scrollable, - invoke {{Window/scroll()}} on window with options as the only argument, - and terminate these steps. + return the promise returned by {{Window/scroll()}} on window after the method is invoked with + options 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 scrolling box, or the element has no overflow, - terminate these steps. + return a promise resolved with false and abort the remaining steps. 1. Scroll the element to x,y, - with the scroll behavior being the value of the {{ScrollOptions/behavior}} dictionary member of options. + with the scroll behavior being the value of the {{ScrollOptions/behavior}} dictionary member of options. Let scrollPromise be the promise returned from this step. +1. Return scrollPromise. When the scrollTo() method is invoked, the user agent must act as if the {{Element/scroll()}} method was invoked with the same arguments. @@ -1358,7 +1379,7 @@ user agent must run these steps: 1. Let the {{ScrollToOptions/top}} dictionary member of options have the value y. 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 options as the only argument. +1. Return the promise returned by {{Element/scroll()}} after the method is invoked with options as the only argument. The scrollTop attribute, on getting, must return the result of running these steps: @@ -1527,9 +1548,11 @@ an inline base direction position inline, and an optional containing Element to stop scrolling after reaching container, means to run these steps: +1. Let ancestorPromises be an empty set of promises. 1. For each ancestor element or viewport that establishes a scrolling box scrolling box, in order of innermost to outermost scrolling box, run these substeps: - 1. If the {{Document}} associated with target is not same origin with the {{Document}} associated with the element or viewport associated with scrolling box, terminate these steps. + 1. If the {{Document}} associated with target is not same origin with the {{Document}} associated with the element or viewport associated with scrolling box, + abort any remaining iteration of this loop. 1. Let position be the scroll position resulting from running the steps to determine the scroll-into-view position of target with behavior as the |scroll behavior|, block as the |block flow position|, inline as the |inline base direction position| and scrolling box as the |scrolling box|. 1. If position is not the same as scrolling box's current scroll position, or scrolling box has an ongoing smooth scroll, @@ -1538,15 +1561,24 @@ means to run these steps:
    Perform a scroll of the element's scrolling box to position, with the element as the associated element and behavior as the scroll behavior. + Add the promise retured from this step to the set ancestorPromises.
    If scrolling box is associated with a viewport
    1. Let document be the viewport’s associated {{Document}}. 1. Let root element be document's [=root element=], if there is one, or null otherwise. 1. Perform a scroll of the viewport to position, with root element as the associated element and behavior as the scroll behavior. + Add the promise retured from this step in the set ancestorPromises. 1. If container is not null and scrolling box is a [=shadow-including inclusive ancestor=] of container, - abort the rest of these steps. + abort any remaining iteration of this loop. +1. Let scrollPromise be a new promise. +1. Return scrollPromise, and run the remaining steps in parallel. +1. Wait until either all promises in ancestorPromises get resolved with true, or any of them settles in any other state (i.e. gets resolved with false or gets rejected). +1. If all promises in ancestorPromises were resolved with true, + resolve scrollPromise with true. + Otherwise resolve scrollPromise with false, + and also resolve with false any promise in ancestorPromises that is still in the pending state.
@@ -1570,8 +1602,10 @@ To scroll an element (or [=pseudo-element=]) element to Let y be min(0, max(y, element padding edge height - element scrolling area height)). 1. Let position be the scroll position box would have by aligning scrolling area x-coordinate x with the left of box and aligning scrolling area y-coordinate y with the top of box. -1. If position is the same as box's current scroll position, and box does not have an ongoing smooth scroll, abort these steps. +1. If position is the same as box's current scroll position, and box does not have an ongoing smooth scroll, return a promise resolved with false and abort the remaining steps. 1. Perform a scroll of box to position, element as the associated element and behavior as the scroll behavior. + Let scrollPromise be the promise returned from this step. +1. Return scrollPromise.