@@ -52,6 +52,9 @@ These "global" variables have both benefits and downsides versus cascading varia
5252 can be retrieved via ''env()'' ,
5353 whereas the element-specific nature of ''var()'' was not an appropriate place to pipe that information in.
5454
55+ [=Environment variables=] can be either be scalar values or array-like values which require the
56+ author to provide 0-based indices into the available dimensions to refer to a specific value.
57+
5558Environment Variables {#environment}
5659====================================
5760
@@ -85,18 +88,23 @@ Safe area inset variables {#safe-area-insets}
8588 <tr>
8689 <th> Name
8790 <th> Value
91+ <th> Number of dimensions
8892 <tr>
8993 <td> <dfn>safe-area-inset-top</dfn>
9094 <td> <<length>>
95+ <td> 0 (scalar)
9196 <tr>
9297 <td> <dfn>safe-area-inset-right</dfn>
9398 <td> <<length>>
99+ <td> 0 (scalar)
94100 <tr>
95101 <td> <dfn>safe-area-inset-bottom</dfn>
96102 <td> <<length>>
103+ <td> 0 (scalar)
97104 <tr>
98105 <td> <dfn>safe-area-inset-left</dfn>
99106 <td> <<length>>
107+ <td> 0 (scalar)
100108</table>
101109
102110The safe area insets are four [=environment variables=] that define a rectangle by
@@ -108,14 +116,79 @@ the rectangle to be invisible due to the nonrectangular nature of the display. T
108116allows authors to limit the layout of essential content to the space inside of the
109117safe area rectangle.
110118
119+ <index type=value for=env()></index>
120+
121+ Viewport segment variables {#viewport-segments}
122+ ------------------------------------------------------------------
123+
124+ <table dfn-type=value dfn-for="env()">
125+ <tr>
126+ <th> Name
127+ <th> Value
128+ <th> Number of dimensions
129+ <tr>
130+ <td> <dfn>viewport-segment-width</dfn>
131+ <td> <<length>>
132+ <td> 2
133+ <tr>
134+ <td> <dfn>viewport-segment-height</dfn>
135+ <td> <<length>>
136+ <td> 2
137+ <tr>
138+ <td> <dfn>viewport-segment-top</dfn>
139+ <td> <<length>>
140+ <td> 2
141+ <tr>
142+ <td> <dfn>viewport-segment-left</dfn>
143+ <td> <<length>>
144+ <td> 2
145+ <tr>
146+ <td> <dfn>viewport-segment-bottom</dfn>
147+ <td> <<length>>
148+ <td> 2
149+ <tr>
150+ <td> <dfn>viewport-segment-right</dfn>
151+ <td> <<length>>
152+ <td> 2
153+ </table>
154+
155+ The viewport segments are [=environment variables=] that define the position and
156+ dimensions of a logically separate region of the viewport. Viewport
157+ segments are created when the viewport is split by one or more hardware features
158+ (such as a fold or a hinge between separate displays) that act as a divider;
159+ segments are the regions of the viewport that can be treated as logically distinct
160+ by the author.
161+
162+ The viewport segment [=environment variables=] have two dimensions, which represent
163+ the x and y position, respectively, in the two dimensional grid created by the
164+ hardware features separating the segments.
165+
166+ Note: In certain hardware configurations, the separator itself may occupy logical
167+ space within the viewport. The dimensions of the separator can be computed by
168+ calculating the area between the position of the viewport segments.
169+
170+ <div class="example">
171+ When the viewport is split into two side-by-side segments, the viewport segment on
172+ the left would have indices (0, 0). It's width would be represented as
173+ ''env(viewport-segment-width 0 0, 300px)'' .
174+ The viewport segment on the right would have indices (1, 0).
175+ Similarly, for a viewport split into two vertical segments, the viewport segment
176+ on the top would have indices (0, 0) and the one on the bottom (0, 1).
177+ </div>
178+
179+ These variables are only defined when there are at least two such segments.
180+ Viewport units should be used instead when there is no hardware feature
181+ splitting the viewport, otherwise content will not display as intended when
182+ viewed on a device with multiple segments.
183+
111184Using Environment Variables: the ''env()'' notation {#env-function}
112185===================================================================
113186
114187In order to substitute the value of an [=environment variable=] into a CSS context,
115188use the ''env()'' function:
116189
117190<pre class=prod>
118- <dfn function>env()</dfn> = env( <<custom-ident>> , <<declaration-value>> ? )
191+ <dfn function>env()</dfn> = env( <<custom-ident>> <<integer>> {0,2} , <<declaration-value>> ? )
119192</pre>
120193
121194The ''env()'' function can be used in place of any part of a value in any property on any element,
@@ -133,7 +206,10 @@ and in several other places where CSS values are allowed.
133206</div>
134207
135208The first argument to ''env()'' provides the name of an [=environment variable=] to be substituted.
136- The second argument, if provided, is a fallback value,
209+ Following the first argument are integers that represent indices into the
210+ dimensions of the [=environment variable=] , if the provided name
211+ represents an array-like [=environment variable=] .
212+ The argument after the comma, if provided, is a fallback value,
137213which is used as the substitution value
138214when the referenced [=environment variable=] does not exist.
139215
@@ -156,7 +232,9 @@ It is only syntax-checked after ''env()'' functions have been [=substituted=].
156232 To <dfn export local-lt=substitute>substitute an env()</dfn> in a property or descriptor:
157233
158234 1. If the name provided by the first argument of the ''env()'' function
159- is a recognized [=environment variable=] ,
235+ is a recognized [=environment variable=] name, the number of supplied integers
236+ matches the number of dimensions of the [=environment variable=] referenced
237+ by that name, and values of the indices result in a valid value,
160238 replace the ''env()'' function by the value of the named [=environment variable=] .
161239
162240 2. Otherwise, if the ''env()'' function has a fallback value as its second argument,
0 commit comments