-
Notifications
You must be signed in to change notification settings - Fork 707
/
Copy pathOverview.bs
executable file
·498 lines (422 loc) · 21.2 KB
/
Overview.bs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
<pre class='metadata'>
Title: CSS Round Display Level 1
Level: 1
Status: ED
Work Status: Exploring
ED: https://drafts.csswg.org/css-round-display/
Shortname: css-round-display
TR: https://www.w3.org/TR/css-round-display-1/
Group: csswg
Previous Version: https://www.w3.org/TR/2016/WD-css-round-display-1-20161222/
Previous Version: https://www.w3.org/TR/2016/WD-css-round-display-1-20160301/
Previous Version: https://www.w3.org/TR/2015/WD-css-round-display-1-20150922/
Editor: Hyojin Song, LG Electronics, hyojin22.song@lge.com, w3cid 54503
Editor: Jihye Hong, LG Electronics, jh.hong@lge.com, w3cid 79168
Editor: Soonbo Han (until June 2015), LG Electronics, soonbo.han@lge.com, w3cid 45470
Link Defaults: css-shapes-1 (type) <basic-shape>
Link Defaults: css-transforms-1 (property) transform
Link Defaults: css-transforms-1 (property) transform-origin
Abstract: This document describes CSS extensions to support a round display. The extensions help web authors to build a web page suitable for a round display.
</pre>
<pre class="anchors">
url: https://svgwg.org/svg2-draft/shapes.html#TermShapeElement; type: dfn; spec: SVG2; text: shape element
url: https://www.w3.org/TR/SVG11/struct.html#DefsElement; spec: SVG11; type: element; text: defs
</pre>
<style>
/* example in table layout*/
.example-table {
display:table;
margin: 0 auto 1em;
border-spacing: 2em 0;
min-width: 672px;
}
.example-table > .desc {
display: table-cell;
vertical-align: top;
width: 250px;
text-align: center;
}
</style>
Introduction {#introduction}
==================================================
Conventionally, web pages have been shown through a rectangular screen such as PC, tablet, and smart phone. The window content area in a web browser is a rectangle. Each HTML element follows the W3C box model and thus is also a rectangle.
<br>
Nowadays, devices come in varied shapes of the displays.
It needs to consider the shape of the display when implementing web pages on devices.
However, current web standards lack some features to support the devices as follows:
<ol>
<li>Lack of the capability to detect the shape of a display</li>
<li>Lack of layout mechanisms suitable for the shape of a display</li>
</ol>
In order to facilitate the use of the web especially on a round display, there could be some features to support it.
</p>
<p>
The 'shape' media feature is added to Media Queries.
Current user agents are not capable of detecting the shape of a display so that authors cannot apply various layouts for a round display. To resolve the issue, 'shape' informs the web page of the property regarding the shape of the display.
<br><br>
To apply the shape of a display to content area, we extend the 'shape-inside' property of CSS Shapes. The position of the element which is overflowed from the display is adjusted inside the display when using this property even if the authors don’t know the exact shape of the display.
<br><br>
We also add the 'border-boundary' property to CSS Backgrounds and Borders. The borders of the element can be drawn along the edge of the display even if the element is overflowed.
<br><br>
This module provides features such as:
* Detecting the rounded display
* Aligning contents in the display’s shape
* Drawing borders along the display’s edge
Terminology {#terminology}
==================================================
This specification follows the CSS property definition conventions from [[!CSS21]]. <br/>
The detailed description of Media Queries is defined in [[MEDIAQUERIES-4]]<br/>
The detailed description of CSS Shapes is defined in [[CSS-SHAPES-1]]<br/>
The detailed description of Backgrounds and Borders is defined in [[CSS3BG]]<br/>
The detailed description of Positioned Layout is defined in [[CSS3-POSITIONING]]<br/>
Detecting the shape of the display {#extending-media-queries}
==================================================
Media Queries [[MEDIAQUERIES-4]] define mechanisms to support media-dependent style sheets,
tailored for different environments. We propose to extend Media Queries
by adding the 'shape' media feature to support various types of displays.
This will allow web authors to apply different styles to a web page on the rounded display.
<h3 id="shape-media-feature">The 'shape' media feature</h3>
<pre class='descdef mq'>
Name: shape
Type: discrete
For: @media
Value: rect | round
</pre>
Describes the general shape of the targeted display area of the output device.
It accepts the following values:
<dl dfn-type=value dfn-for="@media/shape">
<dt><dfn>rect</dfn>
<dd>
The shape is an axis aligned rectangle or square, or a similar shape
such as rounded rectangle for which the traditional designs are appropriate.
<dt><dfn>round</dfn>
<dd>
The shape is rounded or a similar shape to the circle such as an oval, an ellipse for which distinctively rounded designs are appropriate.
</dl>
<div class='example'>
The following examples show what 'shape' media feature can do when the web page
is on the various shapes of displays.
The sample web page is a simple clock application written in HTML and seen through
the rectangular display and the rounded display.
In the first example, the clock application doesn't implemented with 'shape' media feature,
so it can't deal with different types of displays.
It only uses 'rectangle.css' which is designed for the rectangular display
no matter what the type of the display is.
On the round display, some parts of the clock application would be clipped.
<pre class="lang-html">
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="rectangle.css" />
</head>
<body>
<div id="clockLayer">
<div id="clockLayer">
<div id="date">2015/02/28 (SAT)</div>
<div id="time">10:11</div>
<div id="weather"><img src="cloudy.png" /></div>
</div>
</div>
</body>
</html>
</pre>
<figure>
<div class="example-table">
<div class="desc">
<img alt="An image of a clock within a rectangle display" src="images/device_radius_clock_a.png">
<p>(A) Rectangle Display</p>
</div>
<div class="desc">
<img alt="An image of a clock within a round display" src="images/device_radius_clock_b.png">
<p>(B) Round Display</p>
</div>
</div>
<figcaption>
Clock Application without the 'shape' media feature
</figcaption>
</figure>
On the other hand, in the second example, the clock application uses 'shape' media feature.
The following media queries are added to the code of the clock application from
the first example.
<pre class="lang-html">
<!-- index.html -->
<head>
<link media="screen and (shape: rect)" rel="stylesheet" href="rectangle.css" />
<link media="screen and (shape: round)" rel="stylesheet" href="round.css" />
</head>
</pre>
If the clock application is loaded in a round display, 'round.css' which is the design for
the round display will be applied by the Media Queries mechanism.
<figure>
<div class="example-table">
<div class="desc">
<img alt="An image of a clock within a rectangle display" src="images/device_radius_clock_a.png">
<p>(A) Rectangle Display<br>(when 'shape: rect' returns ''true'')</p>
</div>
<div class="desc">
<img alt="An image of a clock within a round display" src="images/device_radius_clock_c.png">
<p>(B) Round Display<br>(when 'shape: round' returns ''true'')</p>
</div>
</div>
<figcaption>
Clock Application with the 'shape' media feature
</figcaption>
</figure>
</div>
<p class="note">
Note: So far, the only standard APIs of Operating System which exposes
information about the display's shape is
<a href="https://developer.android.com/reference/android/content/res/Configuration.html?hl=es#isScreenRound%28%29">''isScreenRound()'' API</a>
in Android.
<a href="https://developer.android.com/reference/android/content/res/Configuration.html?hl=es#isScreenRound%28%29">''isScreenRound()'' API</a>
returns a boolean that says round or not.<br>
Refered the semantics of this API, when isScreenRound() returns ''true'', ''shape: round'' should evaluate
to ''true''
and ''shape: rect'' should evaluate to ''false'' when isScreenRound() returns ''false''.<br>
'shape' is dealing with 2 shapes, but it can be extended if there are the needs about
configuring other shapes from the developers.
</p>
<p class="note">Note: There are cases when the UA may know the shape even in the absence of OS APIs.
For example, when rendering to PDF, the shape is known to be a rectangle, so 'shape: rect' evaluates to
''true'' while ''shape: round'' to ''false''
</p>
Extending the @viewport rule {#extending-viewport-rule}
==================================================
<h3 id="viewport-fit-descriptor">The 'viewport-fit' descriptor</h3>
'viewport-fit' can set the size of the visual viewport.
<pre class=descdef>
Name: viewport-fit
For: @viewport
Value: auto | contain | cover
Initial: auto
Percentages: N/A
Computed value: as specified
</pre>
The initial layout viewport seen through the physical screen of the device.
On rounded screen, the part of the page that’s currently shown on-screen is round but
the viewport is rectangular.
Because of this, depending on the size of the viewport, some part of the page may be clipped.
<figure>
<img alt="An image of the clipped area between the viewport bounding box and the device's border" style="width: 250px" src="images/viewport_clipped_area.png">
<figcaption>
Clipped area
</figcaption>
</figure>
'viewport-fit' can control the clipped area by setting the size of the visual viewport.
Values have the following meanings:
<dl dfn-type=value dfn-for=viewport-fit>
<dt><dfn>auto</dfn></dt>
<dd>
This value doesn’t affect the initial layout viewport,
and the whole web page is viewable.
What the UA paints outside of the viewport is undefined.
It may be the background color of the canvas, or anything else
that the UA deems appropriate.
</dd>
<dt><dfn>contain</dfn></dt>
<dd>
The initial layout viewport and the visual viewport are set to the largest rectangle
which is inscribed in the display of th
e device.
What the UA paints outside of the viewport is undefined.
It may be the background color of the canvas, or anything else that
the UA deems appropriate.
</dd>
<p class="note">Note: With this value, 'border-boundary: display' and
'shape-inside: display' have no effect.</p>
<dt><dfn>cover</dfn></dt>
<dd>
The initial layout viewport and the visual viewport are set to the circumscribed
rectangle of the physical screen of the device.
</dd>
</dl>
When setting the size of the bounding box for the viewport on the non-rectangular display, we have to consider the factors like below:
<ul>
<li>Clipped area which is caused because the area of the viewport bounding box is larger than the area of the display</li>
<li>Gap between the bounding box for the viewport and the area of the display</li>
</ul>
The author can decide which factor is more critical than another.
If it have to be guaranteed that any part of the web page isn’t hidden, avoiding clipping is more important than having a gap between the bounding box of the viewport and the border of the screen. If the author doesn’t want web pages to be small for the readability, then it would be better to set 'viewport-fit' as <a href="#valdef-viewport-fit-cover">cover</a> and to implement pages with considering the clipped parts.
<div class='example'>
This example shows the size of the bounding box for the viewport specified with 'viewport-fit' on the rounded display.
When the 'viewport-fit' is specified with <a href="#valdef-viewport-fit-contain">contain</a>, the initial viewport is applied to the largest inscribed rectangle of the display.
<pre class="lang-css">
@viewport (viewport-fit: contain) {
/* CSS for the rectangular design */
}
</pre>
<figure>
<img src="images/viewport_fit_contain.png" alt="An image about the viewport applied to the bounding box specified with 'viewport-fit: contain'" style="width: 300px; text-align: center"/>
<figcaption>
With '<code>viewport-fit: contain</code>'
</figcaption>
</figure>
When <a href="#valdef-viewport-fit-cover">cover</a> is given to the 'viewport-fit', the initial viewport is applied to the circumscribed rectangle of the display.
<pre class="lang-css">
@viewport {
viewport-fit: cover;
}
@media (shape: round){
/* styles for the round design */
}
@media (shape: rect){
/* styles for the rectangular design */
}
</pre>
<figure>
<img src="images/viewport_fit_cover.png" alt="An image about the viewport applied to the bounding box specified with 'viewport-fit: cover'" style="width: 300px; text-align: center"/>
<figcaption>
With '<code>viewport-fit: cover</code>'
</figcaption>
</figure>
</div>
Aligning content along the display border {#aligning-content}
==================================================
<h3 id="shape-inside-property">The 'shape-inside' property</h3>
CSS Shapes [[CSS-SHAPES-1]] define the 'shape-inside' property that aligns contents along the edge of a possibly non-rectangular wrapping area. Web authors may use this feature to fit contents inside a round display. However, it can be challenging to specify the wrapping area to be identical to the shape of a display. To address such cases, 'shape-inside' is extended with a new value named '<code>display</code>', such an element having this value will have its content (or contained elements) aligned along the display border automatically.
<pre class='link-defaults'>
spec:css2; type:type; text:<uri>
</pre>
<pre class='propdef'>
Name: shape-inside
Applies to: block-level elements
Value: auto | outside-shape | [ <<basic-shape>> || shape-box ] | <<image>> | <code>display</code>
Initial: auto
Inherited: no
Computed value: computed lengths for <<basic-shape>>, the absolute URI for <<uri>>, otherwise as specified
Animatable: as specified for <<basic-shape>>, otherwise no
</pre>
The example below shows how the 'shape-inside' property works when it is set to '<code>display</code>'.
Without using Media Queries, contents can be aligned within the display edge automatically.
<div class='example'>
<pre class="lang-html">
<style>
#container {
shape-inside: display;
// the same as circle(50% at 50%, 50%) in a regular round display
}
#green-box { float: left; }
#blue-box { float: right; }
</style>
<div id="container">
<p>
Some inline content
<img id="green-box" src="green-box.jpg" />
with a float left and float right, in a
<img id="blue-box" src="blue-box.jpg" />
simple box with a circle shape-inside.
</p>
</div>
</pre>
<br />
<figure>
<div class="example-table">
<div class="desc">
<img alt="A layout of web contents without shape-inside:display" style="width: 230px" src="images/shape_inside_watch_a.png">
<p>(A) Without '<code>shape-inside</code>'</p>
</div>
<div class="desc">
<img alt="A layout of web contents with shape-inside: display" style="width: 230px" src="images/shape_inside_watch_b.png">
<p>(B) With '<code>shape-inside: display</code>'</p>
</div>
</div>
<figcaption>
Align the content along the display border
</figcaption>
</figure>
</div>
This property is specially useful for complex shapes (e.g. curved, stelliform, polygonal), that wouldn't be covered by <<basic-shape>> (i.e. circle() or ellipse()), allowing web authors to conveniently align contents with the display edge.
When a containing block is placed on one end of the display and the containing block has 'shape-inside: display', the descendant blocks of the containing block are basically put on the overlapping region between the containing block and the display area. The overlapping region's shape is mostly complicated shape, so it's difficult to define the shape using previous method like basic-shape. The figure 4 describes these circumstances as follows.
<figure>
<img alt="An image of two examples to show the principle of shape-inside: display" style="width: 500px" src="images/shape_inside_a.png">
<figcaption>
Align the content along the display border
</figcaption>
</figure>
<p class="issue">
What if content overflows? Clipping or scrolling?
</p>
Drawing borders around the display border {#drawing-borders}
==================================================
<h3 id="border-boundary-property">The 'border-boundary' property</h3>
We add the 'border-boundary' property to set a boundary constraint that affects the borders of an element.
<pre class='propdef'>
Name: border-boundary
Applies to: all elements
Value: none | parent | display
Initial: none
Inherited: yes
</pre>
When the 'border-boundary' property on an element is set to '<code>parent</code>', additional borders of the element could be drawn where the element's area and the borders of its parent are met. When it is set to '<code>display</code>', additional borders could be drawn where the element's area and the borders of screen are met. The default value is '<code>none</code>', imposing no boundary constraint on the borders.
<div class='example'>
The example below shows how the 'border-boundary' property works on drawing borders. The result is shown in Figure 5B.
<pre class="lang-html">
<style>
#container {
border-boundary: display;
}
#redBox {
border: 5px red solid;
}
#greenBox {
border: 5px green solid;
}
#blueBox {
border: 5px blue solid;
}
</style>
<div id="container">
<div id="redBox"></div>
<div id="greenBox"></div>
<div id="blueBox"></div>
</div>
</pre>
<br />
<figure>
<div class="example-table">
<div class="desc">
<img alt="An image of circle drawing border lines without border-boundary: display" style="width: 200px" src="images/border_boundary_a.png">
<p>(A) Without '<code>border-boundary</code>'</p>
</div>
<div class="desc">
<img alt="An image of circle drawing border lines with border-boundary: display" style="width: 200px" src="images/border_boundary_b.png">
<p>(B) With '<code>border-boundary: display</code>'</p>
</div>
</div>
<figcaption>
Align the content along the display border
</figcaption>
</figure>
</div>
<p class="note">Note: If the value of 'border-boundary' is parent or display, border lines of the element are actually just a visual effect. It triggers a layout for rendering in a general way, but in the above cases (border-boundary: parent|display), the layout doesn't occur and it only draws the border lines inward from the containing block's borders. With this situation, the borders might hide contents around the display edge.
</p>
Use Cases {#usecases}
==================================================
Use cases are described on
<a href="https://wiki.csswg.org/ideas/round-display">these</a>.
Changes {#changes}
==================================================
<h3 id="changes_from_March_01_2016">
Changes from <a href="http://www.w3.org/TR/2016/WD-css-round-display-1-20160301/">March 1<sup>th</sup> 2016</a> version</h3>
<ul>
<li>Changed naming of the media query feature for detecting the shape of a display from
<a href="https://www.w3.org/TR/css-round-display-1/#device-radius-media-feature">''device-radius''</a> to 'shape'.</li>
<li>Defined the value type of 'shape' as ''round'' and ''rect''.</li>
<li>Added 'viewport-fit' descriptor for ''@viewport'' rule.</li>
<li>Removed polar positioning and Merged it into Motion Path [[motion-1]].<br>
The element gets positioned in polar coordinate system using 'offset-path' with the ray function, 'offset-distance', and 'offset-position'.<br>
(see <a href="https://github.com/w3c/csswg-drafts/issues/214">issue #214</a>)<br>
</li>
</ul>
See also <a href="https://www.w3.org/TR/css-round-display-1/#changes_from_Sep_22_2015">previous changes</a>.
Security Considerations {#security-considerations}
==================================================
There are no known security issues introduced by these features.
Privacy Considerations {#privacy-considerations}
==================================================
There are no known privacy issues introduced by these features.
Acknowledgements {#acks}
==================================================
This specification is made possible by input from Dong-Young Lee, Soonbo Han, Florian Rivoal, Joone Hur,
Kang-Soo Seo, Sangjo Park, Woojun Jung, Chisoon Jeong, Yunbum Sung, Alan Stearns, Brad Kemper, and the CSS Working Group members.
Thanks also to Adenilson Cavalcanti for editorial input.