Skip to content

Commit 54a1943

Browse files
author
Simon Pieters
committed
[cssom-view] Make scrollIntoView use the element's bounding border box so that elements with several boxes work. Also make scrollIntoView work for SVG elements. https://www.w3.org/Bugs/Public/show_bug.cgi?id=22060
1 parent 02b1b4f commit 54a1943

1 file changed

Lines changed: 32 additions & 26 deletions

File tree

cssom-view/Overview.src.html

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ <h2>Terminology</h2>
214214
<p>A scrolling box of a <span>viewport</span> or element has two <dfn>overflow directions</dfn>, depending on the <span>viewport</span>'s or element's
215215
<span>block flow direction</span> and <span>inline base direction</span>, as follows:
216216

217-
<dl>
217+
<dl class=switch>
218218
<dt>If the <span>block flow direction</span> is top-to-bottom and the <span>inline base direction</span> is left-to-right
219219
<dt>If the <span>block flow direction</span> is left-to-right and the <span>inline base direction</span> is left-to-right
220220
<dd><p>Rightward and downward.
@@ -844,7 +844,7 @@ <h2>Extensions to the <code title>Element</code> Interface</h2>
844844

845845
<p>The <dfn title=dom-Element-scrollIntoView><code>scrollIntoView(<var>top</var>, <var>options</var>)</code></dfn> method must run these steps:</p>
846846
<ol>
847-
<li><p>If the element does not have any associated <span>CSS layout box</span> terminate these steps.</p></li>
847+
<li><p>If the element does not have any associated <span>layout box</span> terminate these steps.</p></li>
848848
<li><p><span title='scroll an element into view'>Scroll the element into view</span> with the
849849
<i>align to top flag</i> set if <var>top</var> is true, and the scroll behavior being the value of the <code title>behavior</code>
850850
dictionary member of <var>options</var>.</p></li>
@@ -1009,7 +1009,7 @@ <h3><code title>Element</code> Scrolling Members</h3>
10091009

10101010
<p>To <dfn>scroll an element into view</dfn> <var>element</var>, optionally with an <i>align to top flag</i> set, and optionally with a scroll behavior
10111011
<var>behavior</var> (which is <code title>auto</code> if omitted), means to run these steps for each ancestor element or <span>viewport</span> that establishes
1012-
a scrolling box <var>box</var>, in order of innermost to outermost scrolling box:</p>
1012+
a scrolling box <var>scrolling box</var>, in order of innermost to outermost scrolling box:</p>
10131013

10141014
<ol>
10151015
<li><p>If the <code data-anolis-spec=dom>Document</code> associated
@@ -1018,50 +1018,56 @@ <h3><code title>Element</code> Scrolling Members</h3>
10181018
<span>viewport</span> associated with <var>box</var>, terminate these
10191019
steps.</p></li>
10201020

1021-
<li><p>Let <var>box edge A</var> be the <span title="beginning edges">beginning edge</span> in the <span>block flow direction</span> of <var>box</var>, and let
1022-
<var>element edge A</var> be <var>element</var>'s border box edge on the same physical side as that of <var>box edge A</var>.
1021+
<li><p>Let <var>element bounding border box</var> be the box that the return value of invoking
1022+
<code title=dom-Element-getBoundingClientRect>getBoundingClientRect()</code> on <var>element</var> represents.
1023+
1024+
<li><p>Let <var>scrolling box edge A</var> be the <span title="beginning edges">beginning edge</span> in the <span>block flow direction</span> of
1025+
<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
1026+
<var>scrolling box edge A</var>.
10231027

1024-
<li><p>Let <var>box edge B</var> be the <span title="ending edges">ending edge</span> in the <span>block flow direction</span> of <var>box</var>, and let
1025-
<var>element edge B</var> be <var>element</var>'s border box edge on the same physical side as that of <var>box edge B</var>.
1028+
<li><p>Let <var>scrolling box edge B</var> be the <span title="ending edges">ending edge</span> in the <span>block flow direction</span> of <var>scrolling
1029+
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
1030+
B</var>.
10261031

1027-
<li><p>Let <var>box edge C</var> be the <span title="beginning edges">beginning edge</span> in the <span>inline base direction</span> of <var>box</var>, and
1028-
let <var>element edge C</var> be <var>element</var>'s border box edge on the same physical side as that of <var>box edge C</var>.
1032+
<li><p>Let <var>scrolling box edge C</var> be the <span title="beginning edges">beginning edge</span> in the <span>inline base direction</span> of
1033+
<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
1034+
<var>scrolling box edge C</var>.
10291035

1030-
<li><p>Let <var>box edge D</var> be the <span title="ending edges">ending edge</span> in the <span>inline base direction</span> of <var>box</var>, and let
1031-
<var>element edge D</var> be <var>element</var>'s border box edge on the same physical side as that of <var>box edge D</var>.
1036+
<li><p>Let <var>scrolling box edge D</var> be the <span title="ending edges">ending edge</span> in the <span>inline base direction</span> of <var>scrolling
1037+
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>box edge D</var>.
10321038

10331039
<li><p>Let <var>element width</var> be the distance between <var>element edge C</var> and <var>element edge D</var>.
10341040

1035-
<li><p>Let <var>box width</var> be the distance between <var>box edge C</var> and <var>box edge D</var>.
1041+
<li><p>Let <var>scrolling box width</var> be the distance between <var>scrolling box edge C</var> and <var>scrolling box edge D</var>.
10361042

1037-
<li><p>Let <var>position</var> be the scroll position <var>box</var> would have by following these steps:
1043+
<li><p>Let <var>position</var> be the scroll position <var>scrolling box</var> would have by following these steps:
10381044

10391045
<ol>
1040-
<li><p>If the <i>align to top flag</i> is set align <var>element edge A</var> with <var>box edge A</var>.</p></li>
1046+
<li><p>If the <i>align to top flag</i> is set align <var>element edge A</var> with <var>scrolling box edge A</var>.</p></li>
10411047

1042-
<li><p>Otherwise, the <i>align to top flag</i> is not set; align <var>element edge B</var> with <var>box edge B</var>.</p></li>
1048+
<li><p>Otherwise, the <i>align to top flag</i> is not set; align <var>element edge B</var> with <var>scrolling box edge B</var>.</p></li>
10431049

10441050
<li>
10451051
<dl class=switch>
1046-
<dt>If <var>element edge C</var> and <var>element edge D</var> are both outside <var>box edge C</var> and <var>box edge D</var>
1052+
<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>
10471053
<dd><p>Do nothing.
10481054

1049-
<dt>If <var>element edge C</var> is outside <var>box edge C</var> and <var>element width</var> is less than <var>box width</var>
1050-
<dt>If <var>element edge D</var> is outside <var>box edge D</var> and <var>element width</var> is greater than <var>box width</var>
1051-
<dd><p>Align <var>element edge C</var> with <var>box edge C</var>.
1055+
<dt>If <var>element edge C</var> is outside <var>scrolling box edge C</var> and <var>element width</var> is less than <var>scrolling box width</var>
1056+
<dt>If <var>element edge D</var> is outside <var>scrolling box edge D</var> and <var>element width</var> is greater than <var>scrolling box width</var>
1057+
<dd><p>Align <var>element edge C</var> with <var>scrolling box edge C</var>.
10521058

1053-
<dt>If <var>element edge C</var> is outside <var>box edge C</var> and <var>element width</var> is greater than <var>box width</var>
1054-
<dt>If <var>element edge D</var> is outside <var>box edge D</var> and <var>element width</var> is less than <var>box width</var>
1055-
<dd><p>Align <var>element edge D</var> with <var>box edge D</var>.
1059+
<dt>If <var>element edge C</var> is outside <var>scrolling box edge C</var> and <var>element width</var> is greater than <var>scrolling box width</var>
1060+
<dt>If <var>element edge D</var> is outside <var>scrolling box edge D</var> and <var>element width</var> is less than <var>scrolling box width</var>
1061+
<dd><p>Align <var>element edge D</var> with <var>scrolling box edge D</var>.
10561062
</dl>
10571063
</ol>
10581064

1059-
<li><p>If <var>position</var> is the same as <var>box</var>'s current scroll position, and <var>box</var> does not have an ongoing
1065+
<li><p>If <var>position</var> is the same as <var>scrolling box</var>'s current scroll position, and <var>scrolling box</var> does not have an ongoing
10601066
<span title=concept-smooth-scroll>smooth scroll</span>, abort these steps.
10611067

10621068
<li>
10631069
<dl class=switch>
1064-
<dt>If <var>box</var> is associated with an element</dt>
1070+
<dt>If <var>scrolling box</var> is associated with an element</dt>
10651071
<dd>
10661072
<p>Let <var>associated element</var> be the element.
10671073
<p>Let <var>task</var> be these steps:
@@ -1071,7 +1077,7 @@ <h3><code title>Element</code> Scrolling Members</h3>
10711077
</ol>
10721078
</dd>
10731079

1074-
<dt>If <var>box</var> is associated with a <span>viewport</span></dt>
1080+
<dt>If <var>scrolling box</var> is associated with a <span>viewport</span></dt>
10751081
<dd>
10761082
<p>Let <var>associated element</var> be the <code data-anolis-spec=dom>Document</code>'s root element, if there is one, or null otherwise.
10771083
<p>Let <var>task</var> be these steps:
@@ -1083,7 +1089,7 @@ <h3><code title>Element</code> Scrolling Members</h3>
10831089
</dd>
10841090
</dl>
10851091
</li>
1086-
<li><p><span>Perform a scroll</span> of <var>box</var> to <var>position</var>, with the set of steps <var>task</var>,
1092+
<li><p><span>Perform a scroll</span> of <var>scrolling box</var> to <var>position</var>, with the set of steps <var>task</var>,
10871093
<var>associated element</var> as the associated element and <var>behavior</var> as the scroll behavior.
10881094

10891095
</ol>

0 commit comments

Comments
 (0)