Skip to content

Commit f60ebed

Browse files
committed
[cssom-view] Add notIfViewed to ScrollIntoViewOptions; add FocusScrollOptions
notIfViewed was originally suggested in http://www.w3.org/mid/CAE3TfZPmNWvz1z7XPqFjtg5S+m_9BOmNNHsOZuSrR2z2AgyNHA@mail.gmail.com Now it is needed for HTMLElement focus(options) to match the behavior of focus() in browsers. Since the defaults for focus() is different from the defaults for scrollIntoView(), a new dictionary FocusScrollOptions is introduced. For now the defaults for block and inline are UA-defined. whatwg/html#2787 (comment)
1 parent d9690b5 commit f60ebed

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

cssom-view-1/Overview.bs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,9 +1065,15 @@ Note: This {{DOMRect}} object is not <a spec=html>live</a>.
10651065
<pre class=idl>
10661066
enum ScrollLogicalPosition { "start", "center", "end", "nearest" };
10671067
dictionary ScrollIntoViewOptions : ScrollOptions {
1068+
boolean notIfViewed = false;
10681069
ScrollLogicalPosition block = "start";
10691070
ScrollLogicalPosition inline = "nearest";
10701071
};
1072+
dictionary FocusScrollOptions : ScrollOptions {
1073+
boolean notIfViewed = true;
1074+
ScrollLogicalPosition block;
1075+
ScrollLogicalPosition inline;
1076+
};
10711077

10721078
partial interface Element {
10731079
DOMRectList getClientRects();
@@ -1090,6 +1096,13 @@ partial interface Element {
10901096
};
10911097
</pre>
10921098

1099+
The {{ScrollIntoViewOptions}} dictionary is used by {{Element/scrollIntoView()}} and similar APIs
1100+
that primarily scroll something into view.
1101+
1102+
The {{FocusScrollOptions}} dictionary is similar to {{ScrollIntoViewOptions}}, but has different
1103+
defaults, and is used by {{HTMLElement}}'s {{HTMLElement/focus()}} and similar APIs that primarily
1104+
move focus to something, or equivalent, and secondarily scroll it into view.
1105+
10931106
The <dfn method for=Element>getClientRects()</dfn> method, when invoked, must return the result of the following algorithm:
10941107

10951108
1. If the element on which it was invoked does not have an associated <a>layout box</a> return an empty {{DOMRectList}} object and stop this algorithm.
@@ -1130,14 +1143,16 @@ The <dfn method for=Element caniuse=scrollintoview>scrollIntoView(<var>arg</var>
11301143
1. Let <var>behavior</var> be "<code>auto</code>".
11311144
1. Let <var>block</var> be "<code>start</code>".
11321145
1. Let <var>inline</var> be "<code>nearest</code>".
1146+
1. Let <var>notIfViewed</var> be false.
11331147
1. If <var>arg</var> is a {{ScrollIntoViewOptions}} dictionary, then:
11341148
1. Set <var>behavior</var> to the {{ScrollOptions/behavior}} dictionary member of <var>options</var>.
11351149
1. Set <var>block</var> to the {{ScrollIntoViewOptions/block}} dictionary member of <var>options</var>.
11361150
1. Set <var>inline</var> to the {{ScrollIntoViewOptions/inline}} dictionary member of <var>options</var>.
1151+
1. Set <var>notIfViewed</var> to the {{ScrollIntoViewOptions/notIfViewed}} dictionary member of <var>options</var>.
11371152
1. Otherwise, if <var>arg</var> is false, then set <var>block</var> to "<code>end</code>".
11381153
1. If the element does not have any associated <a>layout box</a>, then return.
11391154
1. <a lt='scroll an element into view'>Scroll the element into view</a>
1140-
with <var>behavior</var>, <var>block</var>, and <var>inline</var>.
1155+
with <var>behavior</var>, <var>block</var>, <var>inline</var>, and <var>notIfViewed</var>.
11411156
1. Optionally perform some other action that brings the element to the user's attention.
11421157

11431158
The <dfn method for=Element lt="scroll(options)|scroll(x, y)">scroll()</dfn> method must run these steps:
@@ -1290,8 +1305,9 @@ The <dfn attribute for=Element>clientHeight</dfn> attribute must run these steps
12901305

12911306
To <dfn>scroll an element into view</dfn> <var>element</var>,
12921307
with a scroll behavior <var>behavior</var>,
1293-
a block flow direction position <var>block</var>,
1294-
and an inline base direction position <var>inline</var>,
1308+
a boolean indicating to not scroll if the element is already in view <var>notIfViewed</var>,
1309+
optionally a block flow direction position <var>block</var> (undefined if not given),
1310+
and optionally an inline base direction position <var>inline</var> (undefined if not given),
12951311
means to run these steps for each ancestor element or <a>viewport</a> that establishes
12961312
a <a>scrolling box</a> <var>scrolling box</var>, in order of innermost to outermost <a>scrolling box</a>:
12971313

@@ -1305,6 +1321,15 @@ a <a>scrolling box</a> <var>scrolling box</var>, in order of innermost to outerm
13051321
1. Let <var>scrolling box height</var> be the distance between <var>scrolling box edge A</var> and <var>scrolling box edge B</var>.
13061322
1. Let <var>element width</var> be the distance between <var>element edge C</var> and <var>element edge D</var>.
13071323
1. Let <var>scrolling box width</var> be the distance between <var>scrolling box edge C</var> and <var>scrolling box edge D</var>.
1324+
1. If <var>notIfViewed</var> is true, and <var>element</var> is entirely in view already, then return.
1325+
1326+
ISSUE: Define "entirely in view".
1327+
1328+
1. If <var>block</var> is undefined, set <var>block</var> to a UA-defined value.
1329+
1. If <var>inline</var> is undefined, set <var>inline</var> to a UA-defined value.
1330+
1331+
ISSUE: Define defaults for <var>block</var> and <var>inline</var> for {{FocusScrollOptions}}.
1332+
13081333
1. Let <var>position</var> be the scroll position <var>scrolling box</var> would have by following these steps:
13091334

13101335
1. If <var>block</var> is "<code>start</code>", then align <var>element edge A</var> with <var>scrolling box edge A</var>.

0 commit comments

Comments
 (0)