@@ -52,6 +52,17 @@ These "global" variables have both benefits and downsides versus cascading varia
52
52
can be retrieved via ''env()'' ,
53
53
whereas the element-specific nature of ''var()'' was not an appropriate place to pipe that information in.
54
54
55
+ Most [=environment variables=] will have a single value at a time.
56
+ Some, however, are "indexed", representing multiple values at once,
57
+ such as the sizes and positions of several distinct panes of content
58
+ in the ''viewport-segment-*'' variables.
59
+ To refer to these indexed variables, one or more integers must be provided
60
+ alongside the variable name,
61
+ like ''viewport-segment-width 1 0'' ,
62
+ to select a single value from the list or grid of possibilities,
63
+ similar to selecting one element from a list in a traditional programming language
64
+ with a syntax like <code> values[0] </code> .
65
+
55
66
Environment Variables {#environment}
56
67
====================================
57
68
@@ -85,18 +96,23 @@ Safe area inset variables {#safe-area-insets}
85
96
<tr>
86
97
<th> Name
87
98
<th> Value
99
+ <th> Number of dimensions
88
100
<tr>
89
101
<td> <dfn>safe-area-inset-top</dfn>
90
102
<td> <<length>>
103
+ <td> 0 (scalar)
91
104
<tr>
92
105
<td> <dfn>safe-area-inset-right</dfn>
93
106
<td> <<length>>
107
+ <td> 0 (scalar)
94
108
<tr>
95
109
<td> <dfn>safe-area-inset-bottom</dfn>
96
110
<td> <<length>>
111
+ <td> 0 (scalar)
97
112
<tr>
98
113
<td> <dfn>safe-area-inset-left</dfn>
99
114
<td> <<length>>
115
+ <td> 0 (scalar)
100
116
</table>
101
117
102
118
The safe area insets are four [=environment variables=] that define a rectangle by
@@ -108,14 +124,81 @@ the rectangle to be invisible due to the nonrectangular nature of the display. T
108
124
allows authors to limit the layout of essential content to the space inside of the
109
125
safe area rectangle.
110
126
127
+ <index type=value for=env()></index>
128
+
129
+ Viewport segment variables {#viewport-segments}
130
+ ------------------------------------------------------------------
131
+
132
+ <table dfn-type=value dfn-for="env()">
133
+ <tr>
134
+ <th> Name
135
+ <th> Value
136
+ <th> Number of dimensions
137
+ <tr>
138
+ <td> <dfn>viewport-segment-width</dfn>
139
+ <td> <<length>>
140
+ <td> 2
141
+ <tr>
142
+ <td> <dfn>viewport-segment-height</dfn>
143
+ <td> <<length>>
144
+ <td> 2
145
+ <tr>
146
+ <td> <dfn>viewport-segment-top</dfn>
147
+ <td> <<length>>
148
+ <td> 2
149
+ <tr>
150
+ <td> <dfn>viewport-segment-left</dfn>
151
+ <td> <<length>>
152
+ <td> 2
153
+ <tr>
154
+ <td> <dfn>viewport-segment-bottom</dfn>
155
+ <td> <<length>>
156
+ <td> 2
157
+ <tr>
158
+ <td> <dfn>viewport-segment-right</dfn>
159
+ <td> <<length>>
160
+ <td> 2
161
+ </table>
162
+
163
+ The viewport segments are [=environment variables=] that define the position and
164
+ dimensions of a logically separate region of the viewport. Viewport
165
+ segments are created when the viewport is split by one or more hardware features
166
+ (such as a fold or a hinge between separate displays) that act as a divider;
167
+ segments are the regions of the viewport that can be treated as logically distinct
168
+ by the author.
169
+
170
+ The viewport segment [=environment variables=] have two dimensions, which represent
171
+ the x and y position, respectively, in the two dimensional grid created by the
172
+ hardware features separating the segments.
173
+ Segments along the left edge have x position ''0'' , those in the next column to the right have x position ''1'' , etc.
174
+ Similarly, segments along the top edge have y position ''0'' , etc.
175
+
176
+ Note: In certain hardware configurations, the separator itself may occupy logical
177
+ space within the viewport. The dimensions of the separator can be computed by
178
+ calculating the area between the position of the viewport segments.
179
+
180
+ <div class="example">
181
+ When the viewport is split into two side-by-side segments, the viewport segment on
182
+ the left would have indices (0, 0). It's width would be represented as
183
+ ''env(viewport-segment-width 0 0, 300px)'' .
184
+ The viewport segment on the right would have indices (1, 0).
185
+ Similarly, for a viewport split into two vertical segments, the viewport segment
186
+ on the top would have indices (0, 0) and the one on the bottom (0, 1).
187
+ </div>
188
+
189
+ These variables are only defined when there are at least two such segments.
190
+ Viewport units should be used instead when there is no hardware feature
191
+ splitting the viewport, otherwise content will not display as intended when
192
+ viewed on a device with multiple segments.
193
+
111
194
Using Environment Variables: the ''env()'' notation {#env-function}
112
195
===================================================================
113
196
114
197
In order to substitute the value of an [=environment variable=] into a CSS context,
115
198
use the ''env()'' function:
116
199
117
200
<pre class=prod>
118
- <dfn function>env()</dfn> = env( <<custom-ident>> , <<declaration-value>> ? )
201
+ <dfn function>env()</dfn> = env( <<custom-ident>> <<integer [0,∞]>> * , <<declaration-value>> ? )
119
202
</pre>
120
203
121
204
The ''env()'' function can be used in place of any part of a value in any property on any element,
@@ -133,7 +216,10 @@ and in several other places where CSS values are allowed.
133
216
</div>
134
217
135
218
The first argument to ''env()'' provides the name of an [=environment variable=] to be substituted.
136
- The second argument, if provided, is a fallback value,
219
+ Following the first argument are integers that represent indices into the
220
+ dimensions of the [=environment variable=] , if the provided name
221
+ represents an array-like [=environment variable=] .
222
+ The argument after the comma, if provided, is a fallback value,
137
223
which is used as the substitution value
138
224
when the referenced [=environment variable=] does not exist.
139
225
@@ -156,7 +242,9 @@ It is only syntax-checked after ''env()'' functions have been [=substituted=].
156
242
To <dfn export local-lt=substitute>substitute an env()</dfn> in a property or descriptor:
157
243
158
244
1. If the name provided by the first argument of the ''env()'' function
159
- is a recognized [=environment variable=] ,
245
+ is a recognized [=environment variable=] name, the number of supplied integers
246
+ matches the number of dimensions of the [=environment variable=] referenced
247
+ by that name, and values of the indices correspond to a known sub-value,
160
248
replace the ''env()'' function by the value of the named [=environment variable=] .
161
249
162
250
2. Otherwise, if the ''env()'' function has a fallback value as its second argument,
0 commit comments