From 76e9602edde672dded09e26e8cc7d8141af68de3 Mon Sep 17 00:00:00 2001 From: Simon Pieters Date: Thu, 3 Dec 2015 15:39:27 +0100 Subject: [PATCH 1/2] =?UTF-8?q?[cssom-view]=C2=A0Add=20more=20positioning?= =?UTF-8?q?=20control=20to=20scrollIntoView?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add "center" to ScrollLogicalPosition. * Add inline dictionary member to ScrollIntoViewOptions. Ref. https://www.w3.org/Bugs/Public/show_bug.cgi?id=17152 Ref. https://lists.w3.org/Archives/Public/www-style/2015Dec/0050.html --- cssom-view/Overview.bs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/cssom-view/Overview.bs b/cssom-view/Overview.bs index 0020244a7f5..93e48c74308 100644 --- a/cssom-view/Overview.bs +++ b/cssom-view/Overview.bs @@ -84,6 +84,7 @@ url: http://www.w3.org/TR/DOM-Level-3-Events/#interface-MouseEvent; type: interf spec:dom-ls; type:method; text:addEventListener() spec:css-display-3; type:value; for:display; text:table spec:css-position-3; type:property; text:position +spec:dom-ls; type:interface; text:Document @@ -990,9 +991,10 @@ Extensions to the {{Element}} Interface {#extension-to-the-element-interface} =============================================================================
-enum ScrollLogicalPosition { "start", "end" };
+enum ScrollLogicalPosition { "start", "center", "end" };
 dictionary ScrollIntoViewOptions : ScrollOptions {
   ScrollLogicalPosition block = "start";
+  ScrollLogicalPosition inline;
 };
 
 partial interface Element {
@@ -1049,7 +1051,7 @@ algorithm:
 
 The scrollIntoView(arg) method must run these steps:
 
-
+
 
 1. Let options be null.
 1. If arg is an object, let options be arg.
@@ -1057,8 +1059,7 @@ The scrollIntoView(arg) method must run
 1. If arg is false, let the {{ScrollIntoViewOptions/block}} dictionary member of options have the value "end".
 1. If the element does not have any associated layout box terminate these steps.
 1. Scroll the element into view
-    with the align to top flag set if options {{ScrollIntoViewOptions/block}} dictionary member has the value "start",
-    and the scroll behavior being the value of the {{ScrollOptions/behavior}} dictionary member of options.
+    with the options options.
 1. Optionally perform some other action that brings the element to the user's attention.
 
 The scroll() method must run these steps:
@@ -1218,8 +1219,9 @@ document are not reflected in the objects.
 {{Element}} Scrolling Members {#element-scrolling-members}
 ----------------------------------------------------------
 
-To scroll an element into view element, optionally with an align to top flag set, and optionally with a scroll behavior
-behavior (which is "auto" if omitted), means to run these steps for each ancestor element or viewport that establishes
+To scroll an element into view element,
+with a {{ScrollIntoViewOptions}} dictionary options,
+means to run these steps for each ancestor element or viewport that establishes
 a scrolling box scrolling box, in order of innermost to outermost scrolling box:
 
 1. If the {{Document}} associated with element is not same origin with the {{Document}} associated with the element or viewport associated with box, terminate these steps.
@@ -1227,14 +1229,19 @@ a scrolling box scrolling box, in order of innermost to outerm
 1. Let scrolling box edge A be the beginning edge in the block flow direction of scrolling box, and let element edge A be element bounding border box's edge on the same physical side as that of scrolling box edge A.
 1. Let scrolling box edge B be the ending edge in the block flow direction of scrolling box, and let element edge B be element bounding border box's edge on the same physical side as that of scrolling box edge B.
 1. Let scrolling box edge C be the beginning edge in the inline base direction of scrolling box, and let element edge C be element bounding border box's edge on the same physical side as that of scrolling box edge C.
-1. Let scrolling box edge D be the ending edge in the inline base direction of scrolling box, and let element edge D be element bounding border box's edge on the same physical side as that of box edge D.
+1. Let scrolling box edge D be the ending edge in the inline base direction of scrolling box, and let element edge D be element bounding border box's edge on the same physical side as that of scrolling box edge D.
 1. Let element width be the distance between element edge C and element edge D.
 1. Let scrolling box width be the distance between scrolling box edge C and scrolling box edge D.
 1. Let position be the scroll position scrolling box would have by following these steps:
 
-    1. If the align to top flag is set align element edge A with scrolling box edge A.
-    1. Otherwise, the align to top flag is not set; align element edge B with scrolling box edge B.
-    1. 
+ 1. If the {{ScrollIntoViewOptions/block}} dictionary member of options is "start", align element edge A with scrolling box edge A. + 1. Otherwise, if the {{ScrollIntoViewOptions/block}} dictionary member of options is "end"; align element edge B with scrolling box edge B. + 1. Otherwise, it is "center"; align the center of element bounding border box with the center of scrolling box in scrolling box's block flow direction. + 1. If the {{ScrollIntoViewOptions/inline}} dictionary member of options is "start", align element edge C with scrolling box edge C. + 1. Otherwise, if the {{ScrollIntoViewOptions/inline}} dictionary member of options is "end"; align element edge D with scrolling box edge D. + 1. Otherwise, if the {{ScrollIntoViewOptions/inline}} dictionary member of options is "center", align the center of element bounding border box with the center of scrolling box in scrolling box's inline base direction. + 1. Otherwise, it is not set; follow these steps: +
If element edge C and element edge D are both outside scrolling box edge C and scrolling box edge D
Do nothing. @@ -1258,6 +1265,7 @@ a scrolling box scrolling box, in order of innermost to outerm Let document be the viewport’s associated {{Document}}. Let associated element be document's root element, if there is one, or null otherwise.
+1. Let behavior be the {{ScrollOptions/behavior}} dictionary member of options. 1. Perform a scroll of scrolling box to position, associated element as the associated element and behavior as the scroll behavior. From 4dd6811a29ed5bf4ce0075975ae13cfd946daeb7 Mon Sep 17 00:00:00 2001 From: Simon Pieters Date: Thu, 3 Dec 2015 16:09:47 +0100 Subject: [PATCH 2/2] [cssom-view] Change scrollIntoView({}) to center, and add "nearest" * Change default value of ScrollIntoViewOptions to center/center. * Add a "nearest" value to ScrollLogicalPosition. * scrollIntoView() and scrollIntoView(true|false) use start/end for block flow direction and nearest for inline base direction. --- cssom-view/Overview.bs | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/cssom-view/Overview.bs b/cssom-view/Overview.bs index 93e48c74308..c3e4397a108 100644 --- a/cssom-view/Overview.bs +++ b/cssom-view/Overview.bs @@ -991,10 +991,10 @@ Extensions to the {{Element}} Interface {#extension-to-the-element-interface} =============================================================================
-enum ScrollLogicalPosition { "start", "center", "end" };
+enum ScrollLogicalPosition { "start", "center", "end", "nearest" };
 dictionary ScrollIntoViewOptions : ScrollOptions {
-  ScrollLogicalPosition block = "start";
-  ScrollLogicalPosition inline;
+  ScrollLogicalPosition block = "center";
+  ScrollLogicalPosition inline = "center";
 };
 
 partial interface Element {
@@ -1056,7 +1056,8 @@ The scrollIntoView(arg) method must run
 1. Let options be null.
 1. If arg is an object, let options be arg.
 1. Convert options to a {{ScrollIntoViewOptions}} dictionary. [[!WEBIDL]]
-1. If arg is false, let the {{ScrollIntoViewOptions/block}} dictionary member of options have the value "end".
+1. If arg is not specified or is true, let the {{ScrollIntoViewOptions/block}} dictionary member of options have the value "start", and let the {{ScrollIntoViewOptions/inline}} dictionary member of options have the value "nearest".
+1. If arg is false, let the {{ScrollIntoViewOptions/block}} dictionary member of options have the value "end", and let the {{ScrollIntoViewOptions/inline}} dictionary member of options have the value "nearest".
 1. If the element does not have any associated layout box terminate these steps.
 1. Scroll the element into view
     with the options options.
@@ -1236,11 +1237,24 @@ a scrolling box scrolling box, in order of innermost to outerm
 
     1. If the {{ScrollIntoViewOptions/block}} dictionary member of options is "start", align element edge A with scrolling box edge A.
     1. Otherwise, if the {{ScrollIntoViewOptions/block}} dictionary member of options is "end"; align element edge B with scrolling box edge B.
-    1. Otherwise, it is "center"; align the center of element bounding border box with the center of scrolling box in scrolling box's block flow direction.
+    1. Otherwise, if the {{ScrollIntoViewOptions/block}} dictionary member of options is "center"; align the center of element bounding border box with the center of scrolling box in scrolling box's block flow direction.
+    1. Otherwise, it is "nearest"; follow these steps:
+        
+
If element edge A and element edge B are both outside scrolling box edge A and scrolling box edge B +
Do nothing. + +
If element edge A is outside scrolling box edge A and element width is less than scrolling box width +
If element edge B is outside scrolling box edge B and element width is greater than scrolling box width +
Align element edge A with scrolling box edge A. + +
If element edge A is outside scrolling box edge A and element width is greater than scrolling box width +
If element edge B is outside scrolling box edge B and element width is less than scrolling box width +
Align element edge B with scrolling box edge B. +
1. If the {{ScrollIntoViewOptions/inline}} dictionary member of options is "start", align element edge C with scrolling box edge C. 1. Otherwise, if the {{ScrollIntoViewOptions/inline}} dictionary member of options is "end"; align element edge D with scrolling box edge D. 1. Otherwise, if the {{ScrollIntoViewOptions/inline}} dictionary member of options is "center", align the center of element bounding border box with the center of scrolling box in scrolling box's inline base direction. - 1. Otherwise, it is not set; follow these steps: + 1. Otherwise, it is "nearest"; follow these steps:
If element edge C and element edge D are both outside scrolling box edge C and scrolling box edge D
Do nothing.