diff --git a/css-viewport-1/Overview.bs b/css-viewport-1/Overview.bs index f335a2193f7e..8b43b40a5e79 100644 --- a/css-viewport-1/Overview.bs +++ b/css-viewport-1/Overview.bs @@ -526,6 +526,52 @@ The unscaled value of a CSS length relative to an element is t The {{Window/devicePixelRatio}} of a frame is multiplied by the [=effective zoom=] inherited by its parent frame. +

Extensions to the {{Window}} Interface

+ +
+partial interface Window {
+[SameObject, Replaceable] readonly attribute Viewport viewport;
+};
+
+ +

Viewport

+ +

The {{Viewport}} Interface

+ +
+[Exposed=Window]
+interface Viewport {
+  readonly attribute FrozenArray<DOMRect> segments;
+};
+
+ +

+ The segments property +

+ +The {{segments}} property is an array of {{DOMRect}} that represent the dimensions of each existing viewport segment. +Each {{DOMRect}} contains the geometry of the segment (x, y, width, height) in ''/px''. + +Additonal details about the definition of a viewport segment can be found here: [[css-env-1#viewport-segments]]. + +The {{segments}} attribute must run these steps: +1. If the {{Viewport}}'s associated {{Document}} is not fully active, return 0. +2. Returns null if there is only a single viewport segment and abort these steps. +3. Otherwise, return the {{Viewport}}'s segments array. + +
+This section is not normative. + +The {{segments}} property represents an immutable snapshot of the device {{segments}} when the value was queried. +If the device state changes (rotation, window resize, posture change), the value previously retrieved will be invalid. Developers can listen to {{ScreenOrientation/onchange|Screen Orientation}}, {{Window/resize|Window Resize}}, or {{DevicePosture/onchange|Posture}} changes events to detect device state changes. + +
+If a viewport of 400px by 400px is split horizontally into two side-by-side segments, the {{segments}} array will have the following content: +[DOMRect(0, 0, 400, 200), DOMRect(0, 200, 400, 200)] +
+ +
+

Appendix A. Changes

This appendix is informative.