Skip to content

Commit 67f362e

Browse files
author
Jihye Hong
committed
[css-round-display] Replace device-radius MQ with shape MQ
1 parent c52bc38 commit 67f362e

2 files changed

Lines changed: 119 additions & 144 deletions

File tree

css-round-display/Overview.bs

100644100755
Lines changed: 72 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -59,109 +59,96 @@ The detailed description of Positioned Layout is defined in [[CSS3-POSITIONING]]
5959

6060
<h2 id="extending-media-queries">Extending Media Queries for a round display</h2>
6161
<p>
62-
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 'device-radius' media feature to support a round display. This will allow web authors to apply different styles to a web page on the rounded display.
62+
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.
6363
</p>
6464
<section>
65-
<h3 id="device-radius-media-feature">The 'device-radius' media feature</h3>
66-
To use different style sheets for a rectangle display and for a round display, media queries should support some properties to identify the display shape. The 'device-radius' media feature describes the property of rounded borders of a display.
67-
<div class='example'>
68-
This media query indicates that different style sheets will be applied depending on the display shape.
69-
<pre>
70-
&lt;link media="screen and (device-radius: 0%)" rel="stylesheet" href="rectangle.css" />
71-
&lt;link media="screen and (device-radius: 50%)" rel="stylesheet" href="round.css" />
72-
</pre>
73-
<p>
74-
By the mechanism of media queries, if the value of the 'device-radius' media feature is less than 50%, '<code>rectangle.css</code>' is applied. If it is 50%, '<code>round.css</code>' is applied.
75-
</p>
76-
</div>
77-
<p>As in the '<code>border-radius</code>' property, the 'device-radius' media feature can describe various round shapes of displays, such as rectangle, regular circle, ellipse, and rectangle with round corners.
78-
</p>
65+
<h3 id="device-radius-media-feature">The 'shape' media feature</h3>
66+
To use different style sheets for a rectangle display and for a round display, media queries should support some properties to identify the display shape.
67+
7968
<pre class='descdef mq'>
80-
Name: device-radius
81-
Type: range
69+
Name: shape
70+
Type: discrete
8271
For: @media
83-
Value: [ <<length>> | <<percentage>> ]
84-
Percentage: Refer to corresponding dimension of the display
72+
Value: rect | round
8573
</pre>
8674
<p class="note">
87-
Note: To define a '<code>range</code>' type media feature, the feature may be written as a normal media feature, but with a '<code>min-</code>' or '<code>max-</code>' prefix on the feature name. '<code>min-</code>' or '<code>max-</code>' prefixes express 'greater or equal to' or 'smaller or equal to' constraints respectively.
88-
</p>
89-
<p>
90-
The length or percentage value of the '<code>device-radius</code>' property defines a radius of a quarter ellipse in terms of the shape of the corner of the outer screen edge (This is similar to the '<code>border-radius</code>' property. See the 'border-radius' description). If the length is zero, the shape of screen is a rectangle, otherwise it is a rectangle with rounded corners or a circle or an ellipse. A percentage value of the '<code>device-radius</code>' is proportional to a width and a height of the screen, which have relevance to a horizontal radius and a vertical radius of the screen according to the length of width and height of the screen each. If the screen shape is the regular circle, '<code>device-radius</code>': 50% has a true value since a half of the width(=height) of the regular circle is the radius of the screen shape. In case of an ellipse with 200x100, '<code>device-radius</code>': 50% means that horizontal-radius of the screen is 100px and vertical-radius of the screen is 50px. It can't be described in length, not percentage. A negative value is not allowed.
75+
Note: To define a 'discrete' type media feature, the feature is evaluated in a boolean context.
9176
</p>
9277

93-
<div class='example'>
94-
The example below shows how a web page looks in the different shapes of displays. This is a simple clock written in HTML. (without 'device-radius')
95-
<pre>&lt;!DOCTYPE html>
78+
The ‘shape’ media feature describes the general shape of the targeted display area of the output device. It accepts the following values:
9679

97-
&lt;html>
98-
&lt;head>
99-
&lt;link rel="stylesheet" href="rectangle.css" />
100-
&lt;/head>
101-
&lt;body>
102-
&lt;div id="clockLayer">
80+
<dl dfn-type=value dfn-for="@media/shape">
81+
<dt><dfn>rect</dfn>
82+
<dd>
83+
The shape is an axis aligned rectangle or square, or a similar shape for which the traditional designs are appropriate.
84+
85+
<dt><dfn>round</dfn>
86+
<dd>
87+
The shape is rounded or a similar shape to the circle such as an oval, an ellipse for which distinctively rounded designs are appropriate.
88+
</dl>
89+
90+
<div class='example'>
91+
The example below shows how a web page looks in the different shapes of displays.
92+
This is a simple clock written in HTML without 'shape'.
93+
<pre>&lt;!DOCTYPE html>
94+
95+
&lt;html>
96+
&lt;head>
97+
&lt;link rel="stylesheet" href="rectangle.css" />
98+
&lt;/head>
99+
&lt;body>
103100
&lt;div id="clockLayer">
104-
&lt;div id="date">2015/02/28 (SAT)&lt;/div>
105-
&lt;div id="time">10:11&lt;/div>
106-
&lt;div id="weather">&lt;img src="cloudy.png" />&lt;/div>
101+
&lt;div id="clockLayer">
102+
&lt;div id="date">2015/02/28 (SAT)&lt;/div>
103+
&lt;div id="time">10:11&lt;/div>
104+
&lt;div id="weather">&lt;img src="cloudy.png" />&lt;/div>
105+
&lt;/div>
107106
&lt;/div>
108-
&lt;/div>
109-
&lt;/body>
110-
&lt;/html>
111-
</pre>
112-
113-
<div style="width: 700px; height: 380px; text-align:center">
114-
<div style="float: left; width: 350px;">
115-
<img alt="An image of a rectangle clock within a rectangle display" src="images/device_radius_clock_a.png">
116-
<p>(A) Rectangle Display</p>
107+
&lt;/body>
108+
&lt;/html>
109+
</pre>
110+
111+
<div style="width: 700px; height: 380px; text-align:center">
112+
<div style="float: left; width: 350px;">
113+
<img alt="An image of a rectangle clock within a rectangle display" src="images/device_radius_clock_a.png">
114+
<p>(A) Rectangle Display</p>
115+
</div>
116+
<div style="float: left; ">
117+
<img alt="An image of a round clock within a rectangle display" src="images/device_radius_clock_b.png">
118+
<p>(B) Round Display</p>
119+
</div>
117120
</div>
118-
<div style="float: left; ">
119-
<img alt="An image of a round clock within a rectangle display" src="images/device_radius_clock_b.png">
120-
<p>(B) Round Display</p>
121+
<div style="width: 700px">
122+
<p class="caption">Devices where the 'shape' media feature is not applicable</p>
121123
</div>
122-
</div>
123-
<div style="width: 700px">
124-
<p class="caption">Devices where the 'device-radius' media feature is not applicable</p>
125-
</div>
126-
On the other hand, the example below shows how the 'device-radius' media feature works in the different shapes of displays. This is the same as the code above except for media queries usage. The 'device-radius' media feature can be used as follows:
127-
<pre>&lt;!-- index.html -->
128124

129-
&lt;head>
130-
&lt;link media="screen and (device-radius: 0%)" rel="stylesheet" href="rectangle.css" />
131-
&lt;link media="screen and (device-radius: 50%)" rel="stylesheet" href="round.css" />
132-
&lt;/head>
133-
</pre>
134-
If this example code is loaded in a regular round display, '<code>round.css</code>' will be applied by the media queries mechanism. To render the clock properly, '<code>round.css</code>' could be written as follows.
135-
<pre>
136-
#clockLayer {
137-
border-radius: 50%;
138-
}
139-
#clockInset {
140-
border-radius: 50%;
141-
}
142-
#date {
143-
text-align: center;
144-
}
145-
...
146-
</pre>
147-
<div style="width: 700px; height: 380px; text-align:center">
148-
<div style="float: left; width: 350px;">
149-
<img alt="An image of a rectangle clock within a rectangle display" src="images/device_radius_clock_a.png">
150-
<p>(A) Rectangle Display<br>(w/ <code>device-radius: 0%</code>)</p>
125+
On the other hand, the example below shows how the ‘shape’ media feature works in the different shapes of displays. This is the same as the code above except for media queries usage. The shape media feature can be used as follows:
126+
<pre>&lt;!-- index.html -->
127+
128+
&lt;head>
129+
&lt;link media="screen and (shape: rect)" rel="stylesheet" href="rectangle.css" />
130+
&lt;link media="screen and (shape: round)" rel="stylesheet" href="round.css" />
131+
&lt;/head>
132+
</pre>
133+
If this example code is loaded in a round display, 'round.css' will be applied by the media queries mechanism.
134+
<div style="width: 700px; height: 380px; text-align:center">
135+
<div style="float: left; width: 350px;">
136+
<img alt="An image of a rectangle clock within a rectangle display" src="images/device_radius_clock_a.png">
137+
<p>(A) Rectangle Display<br>(w/ <code>shape: rect</code>)</p>
138+
</div>
139+
<div style="float: left; ">
140+
<img alt="An image of a round clock within a round display" src="images/device_radius_clock_c.png">
141+
<p>(B) Round Display<br>(w/ <code>shape: round</code>)</p>
142+
</div>
151143
</div>
152-
<div style="float: left; ">
153-
<img alt="An image of a round clock within a round display" src="images/device_radius_clock_c.png">
154-
<p>(B) Round Display<br>(w/ <code>device-radius: 50%</code>)</p>
144+
<div style="width: 700px">
145+
<p class="caption">Devices where the 'shape' media feature is applicable</p>
155146
</div>
156147
</div>
157-
<div style="width: 700px">
158-
<p class="caption">Devices where the 'device-radius' media feature is applicable</p>
159-
</div>
160-
</div>
161-
<p class="note">Note: For other shapes, such as polygons, we need to extend the media features with additional parameters. The current features have limitations to support the diversity beyond round shapes. How can we express star-shaped polygons? (e.g. SVG syntax, etc.) Of course, there is a trade-off between simplicity and expressiveness.
148+
149+
<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''
162150
</p>
163-
<p class="issue">
164-
The current 'device-radius' media feature was derived from the syntax of 'border-radius' to specify various shapes, but its usage is a little complicated with several issues. For simplicity and obviousness, 'device-radius' would be changed with the revised syntax. (e.g. Am I round or rounded corners?)
151+
<p class="note">Note: For other shapes, such as polygons, we need to extend the media features with additional parameters. The current features have limitations to support the diversity beyond round shapes. How can we express star-shaped polygons? (e.g. SVG syntax, etc.) Of course, there is a trade-off between simplicity and expressiveness.
165152
</p>
166153

167154
<h2 id="extending-viewport-rule">Extending the @viewport rule</h2>

0 commit comments

Comments
 (0)