Skip to content

Commit fb7bdab

Browse files
authored
[cssom-view-1] Extend scroll into view to ranges (w3c#8254)
Generalizes The scroll an element into view algorithm to work also work for a Range as well as an Element. This is trivial as the only use of Element is to call getBoundingClientRect which Range also defines. Additionally exports this algorithm for use in whatwg/html#8282. Nit: also fixes erroneous reference to a non-existent box variable where scrolling box was intended.
1 parent 2fd0ea2 commit fb7bdab

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

cssom-view-1/Overview.bs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ The <dfn method for=Element caniuse=scrollintoview>scrollIntoView(<var>arg</var>
11611161
1. If the element does not have any associated [=CSS/box=],
11621162
or is not available to user-agent features,
11631163
then return.
1164-
1. <a lt='scroll an element into view'>Scroll the element into view</a>
1164+
1. <a lt='scroll a target into view'>Scroll the element into view</a>
11651165
with <var>behavior</var>, <var>block</var>, and <var>inline</var>.
11661166
1. Optionally perform some other action that brings the element to the user's attention.
11671167

@@ -1313,19 +1313,19 @@ The <dfn attribute for=Element>clientHeight</dfn> attribute must run these steps
13131313

13141314
<h3 id=element-scrolling-members>{{Element}} Scrolling Members</h3>
13151315

1316-
To <dfn>scroll an element into view</dfn> <var>element</var>,
1316+
To <dfn export>scroll a target into view</dfn> <var>target</var>, which is an <a for="/">Element</a> or <a>Range</a>,
13171317
with a scroll behavior <var>behavior</var>,
13181318
a block flow direction position <var>block</var>,
13191319
and an inline base direction position <var>inline</var>,
13201320
means to run these steps for each ancestor element or <a>viewport</a> that establishes
13211321
a <a>scrolling box</a> <var>scrolling box</var>, in order of innermost to outermost <a>scrolling box</a>:
13221322

1323-
1. If the {{Document}} associated with <var>element</var> is not <a>same origin</a> with the {{Document}} associated with the element or <a>viewport</a> associated with <var>box</var>, terminate these steps.
1324-
1. Let <var>element bounding border box</var> be the box that the return value of invoking {{Element/getBoundingClientRect()}} on <var>element</var> represents.
1325-
1. Let <var>scrolling box edge A</var> be the <a>beginning edge</a> in the <a>block flow direction</a> of <var>scrolling box</var>, and let <var>element edge A</var> be <var>element bounding border box</var>'s edge on the same physical side as that of <var>scrolling box edge A</var>.
1326-
1. Let <var>scrolling box edge B</var> be the <a>ending edge</a> in the <a>block flow direction</a> of <var>scrolling box</var>, and let <var>element edge B</var> be <var>element bounding border box</var>'s edge on the same physical side as that of <var>scrolling box edge B</var>.
1327-
1. Let <var>scrolling box edge C</var> be the <a>beginning edge</a> in the <a>inline base direction</a> of <var>scrolling box</var>, and let <var>element edge C</var> be <var>element bounding border box</var>'s edge on the same physical side as that of <var>scrolling box edge C</var>.
1328-
1. Let <var>scrolling box edge D</var> be the <a>ending edge</a> in the <a>inline base direction</a> of <var>scrolling box</var>, and let <var>element edge D</var> be <var>element bounding border box</var>'s edge on the same physical side as that of <var>scrolling box edge D</var>.
1323+
1. If the {{Document}} associated with <var>target</var> is not <a>same origin</a> with the {{Document}} associated with the element or <a>viewport</a> associated with <var>scrolling box</var>, terminate these steps.
1324+
1. Let <var>target bounding border box</var> be the box represented by the return value of invoking Element's {{Element/getBoundingClientRect()}}, if <var>target</var> is an <a for="/">Element</a>, or Range's {{Range/getBoundingClientRect()}}, if <var>target</var> is a <a>Range</a>.
1325+
1. Let <var>scrolling box edge A</var> be the <a>beginning edge</a> in the <a>block flow direction</a> of <var>scrolling box</var>, and let <var>element edge A</var> be <var>target bounding border box</var>'s edge on the same physical side as that of <var>scrolling box edge A</var>.
1326+
1. Let <var>scrolling box edge B</var> be the <a>ending edge</a> in the <a>block flow direction</a> of <var>scrolling box</var>, and let <var>element edge B</var> be <var>target bounding border box</var>'s edge on the same physical side as that of <var>scrolling box edge B</var>.
1327+
1. Let <var>scrolling box edge C</var> be the <a>beginning edge</a> in the <a>inline base direction</a> of <var>scrolling box</var>, and let <var>element edge C</var> be <var>target bounding border box</var>'s edge on the same physical side as that of <var>scrolling box edge C</var>.
1328+
1. Let <var>scrolling box edge D</var> be the <a>ending edge</a> in the <a>inline base direction</a> of <var>scrolling box</var>, and let <var>element edge D</var> be <var>target bounding border box</var>'s edge on the same physical side as that of <var>scrolling box edge D</var>.
13291329
1. Let <var>element height</var> be the distance between <var>element edge A</var> and <var>element edge B</var>.
13301330
1. Let <var>scrolling box height</var> be the distance between <var>scrolling box edge A</var> and <var>scrolling box edge B</var>.
13311331
1. Let <var>element width</var> be the distance between <var>element edge C</var> and <var>element edge D</var>.
@@ -1334,7 +1334,7 @@ a <a>scrolling box</a> <var>scrolling box</var>, in order of innermost to outerm
13341334

13351335
1. If <var>block</var> is "<code>start</code>", then align <var>element edge A</var> with <var>scrolling box edge A</var>.
13361336
1. Otherwise, if <var>block</var> is "<code>end</code>", then align <var>element edge B</var> with <var>scrolling box edge B</var>.
1337-
1. Otherwise, if <var>block</var> is "<code>center</code>", then align the center of <var>element bounding border box</var> with the center of <var>scrolling box</var> in <var>scrolling box</var>'s <a>block flow direction</a>.
1337+
1. Otherwise, if <var>block</var> is "<code>center</code>", then align the center of <var>target bounding border box</var> with the center of <var>scrolling box</var> in <var>scrolling box</var>'s <a>block flow direction</a>.
13381338
1. Otherwise, <var>block</var> is "<code>nearest</code>":
13391339
<dl class=switch>
13401340
<dt>If <var>element edge A</var> and <var>element edge B</var> are both outside <var>scrolling box edge A</var> and <var>scrolling box edge B</var>
@@ -1350,7 +1350,7 @@ a <a>scrolling box</a> <var>scrolling box</var>, in order of innermost to outerm
13501350
</dl>
13511351
1. If <var>inline</var> is "<code>start</code>", then align <var>element edge C</var> with <var>scrolling box edge C</var>.
13521352
1. Otherwise, if <var>inline</var> is "<code>end</code>", then align <var>element edge D</var> with <var>scrolling box edge D</var>.
1353-
1. Otherwise, if <var>inline</var> is "<code>center</code>", then align the center of <var>element bounding border box</var> with the center of <var>scrolling box</var> in <var>scrolling box</var>'s <a>inline base direction</a>.
1353+
1. Otherwise, if <var>inline</var> is "<code>center</code>", then align the center of <var>target bounding border box</var> with the center of <var>scrolling box</var> in <var>scrolling box</var>'s <a>inline base direction</a>.
13541354
1. Otherwise, <var>inline</var> is "<code>nearest</code>":
13551355
<dl class=switch>
13561356
<dt>If <var>element edge C</var> and <var>element edge D</var> are both outside <var>scrolling box edge C</var> and <var>scrolling box edge D</var>

0 commit comments

Comments
 (0)