[go: up one dir, main page]

W3C

CSS Round Display Level 1

W3C Working Draft,

This version:
https://www.w3.org/TR/2016/WD-css-round-display-1-20161222/
Latest published version:
https://www.w3.org/TR/css-round-display-1/
Editor's Draft:
https://drafts.csswg.org/css-round-display/
Previous Versions:
https://www.w3.org/TR/2016/WD-css-round-display-1-20160301/
https://www.w3.org/TR/2015/WD-css-round-display-1-20150922/
Test Suite:
http://test.csswg.org/suites/css-round-display-1_dev/nightly-unstable/
Issue Tracking:
Inline In Spec
GitHub Issues
Editors:
(LG Electronics)
(LG Electronics)
(LG Electronics)

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.

CSS is a language for describing the rendering of structured documents (such as HTML and XML) on screen, on paper, in speech, etc.

Status of this document

This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at https://www.w3.org/TR/.

Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.

GitHub Issues are preferred for discussion of this specification. When filing an issue, please put the text “css-round-display” in the title, preferably like this: “[css-round-display] …summary of comment…”. All issues and comments are archived, and there is also a historical archive.

This document was produced by the CSS Working Group (part of the Style Activity).

This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.

This document is governed by the 1 September 2015 W3C Process Document.

1. 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.
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:

  1. Lack of the capability to detect the shape of a display
  2. Lack of layout mechanisms suitable for the shape of a display
In order to facilitate the use of the web especially on a round display, there could be some features to support it.

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.

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.

We also add the border-boundary property to CSS Borders. The borders of the element can be drawn along the edge of the display even if the element is overflowed.

For the better web design suitable for a round display, we introduce polar positioning. In conventional positioning method, the Cartesian coordinates, elements are positioned by offsets in x-axis and y-axis. But, we suggest a method to position elements with specifying the distance and angle from the origin point of coordinates.

This module provides features such as:

2. Terminology

This specification follows the CSS property definition conventions from [CSS21].
The detailed description of Media Queries is defined in [MEDIAQUERIES-4]
The detailed description of CSS Shapes is defined in [CSS-SHAPES-1]
The detailed description of Borders is defined in [CSS3-BORDER]
The detailed description of Positioned Layout is defined in [CSS3-POSITIONING]

3. Detecting the shape of the display

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.

3.1. The shape media feature

Name: shape
For: @media
Value: rect | round
Type: discrete

Describes the general shape of the targeted display area of the output device. It accepts the following values:

rect
The shape is an axis aligned rectangle or square, or a similar shape such as rounded rectangle for which the traditional designs are appropriate.
round
The shape is rounded or a similar shape to the circle such as an oval, an ellipse for which distinctively rounded designs are appropriate.
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.

<!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>
An image of a clock within a rectangle display

(A) Rectangle Display

An image of a clock within a round display

(B) Round Display

Clock Application without the shape media feature

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.

<!-- 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>

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.

An image of a clock within a rectangle display

(A) Rectangle Display
(when 'shape: rect' returns true)

An image of a clock within a round display

(B) Round Display
(when 'shape: round' returns true)

Clock Application with the shape media feature

Note: So far, the only standard APIs of Operating System which exposes information about the display’s shape is isScreenRound() API in Android. isScreenRound() API returns a boolean that says round or not.
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.
shape is dealing with 2 shapes, but it can be extended if there are the needs about configuring other shapes from the developers.

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

4. Extending the @viewport rule

4.1. The viewport-fit descriptor

viewport-fit can set the size of the visual viewport.

Name: viewport-fit
For: @viewport
Value: auto | contain | cover
Initial: auto
Percentages: N/A
Media: visual, continuous
Computed value: as specified

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.

An image of the clipped area between the viewport bounding box and the device’s border
Clipped area

viewport-fit can control the clipped area by setting the size of the visual viewport.

Values have the following meanings:

auto
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.
contain
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.

Note: With this value, 'border-boundary: display' and 'shape-inside: display' have no effect.

cover
The initial layout viewport and the visual viewport are set to the circumscribed rectangle of the physical screen of the device.

When setting the size of the bounding box for the viewport on the non-rectangular display, we have to consider the factors like below:

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 cover and to implement pages with considering the clipped parts.

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 contain, the initial viewport is applied to the largest inscribed rectangle of the display.

@viewport (viewport-fit: contain) {
    /* CSS for the rectangular design */
}      
An image about the viewport applied to the bounding box specified with 'viewport-fit: contain'
With 'viewport-fit: contain'

When cover is given to the viewport-fit, the initial viewport is applied to the circumscribed rectangle of the display.

@viewport {
    viewport-fit: cover;
}
@media (shape: round){
    /* styles for the round design */
}
@media (shape: rect){
    /* styles for the rectangular design */
}
An image about the viewport applied to the bounding box specified with 'viewport-fit: cover'
With 'viewport-fit: cover'

5. Aligning content along the display border

5.1. The shape-inside property

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 'display', such an element having this value will have its content (or contained elements) aligned along the display border automatically.

Name: shape-inside
Value: auto | outside-shape | [ <basic-shape> || shape-box ] | <image> | display
Initial: auto
Applies to: block-level elements
Inherited: no
Percentages: n/a
Media: visual
Computed value: computed lengths for <basic-shape>, the absolute URI for <uri>, otherwise as specified
Canonical order: per grammar
Animatable: as specified for <basic-shape>, otherwise no

The example below shows how the shape-inside property works when it is set to 'display'. Without using Media Queries, contents can be aligned within the display edge automatically.

<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>


A layout of web contents without shape-inside:display

(A) Without 'shape-inside'

A layout of web contents with shape-inside: display

(B) With 'shape-inside: display'

Align the content along the display border

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.

An image of two examples to show the principle of shape-inside: display
Align the content along the display border

What if content overflows? Clipping or scrolling?

6. Drawing borders around the display border

6.1. The border-boundary property

We add the border-boundary property to set a boundary constraint that affects the borders of an element.

Name: border-boundary
Value: none | parent | display
Initial: none
Applies to: all elements
Inherited: yes
Percentages: n/a
Media: visual
Computed value: as specified
Canonical order: per grammar
Animation type: discrete

When the border-boundary property on an element is set to 'parent', 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 'display', additional borders could be drawn where the element’s area and the borders of screen are met. The default value is 'none', imposing no boundary constraint on the borders.

The example below shows how the border-boundary property works on drawing borders. The result is shown in Figure 5B.
<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>


An image of circle drawing border lines without border-boundary: display

(A) Without 'border-boundary'

An image of circle drawing border lines with border-boundary: display

(B) With 'border-boundary: display'

Align the content along the display border

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.

7. Use Cases

Use cases are described on these.

8. Changes

8.1. Changes from March 1th 2016 version

See also previous changes.

9. Security Considerations

There are no known security issues introduced by these features.

10. Privacy Considerations

There are no known privacy issues introduced by these features.

11. Acknowledgements

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.

Conformance

Document conventions

Conformance requirements are expressed with a combination of descriptive assertions and RFC 2119 terminology. The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this document are to be interpreted as described in RFC 2119. However, for readability, these words do not appear in all uppercase letters in this specification.

All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes. [RFC2119]

Examples in this specification are introduced with the words “for example” or are set apart from the normative text with class="example", like this:

This is an example of an informative example.

Informative notes begin with the word “Note” and are set apart from the normative text with class="note", like this:

Note, this is an informative note.

Advisements are normative sections styled to evoke special attention and are set apart from other normative text with <strong class="advisement">, like this: UAs MUST provide an accessible alternative.

Conformance classes

Conformance to this specification is defined for three conformance classes:

style sheet
A CSS style sheet.
renderer
A UA that interprets the semantics of a style sheet and renders documents that use them.
authoring tool
A UA that writes a style sheet.

A style sheet is conformant to this specification if all of its statements that use syntax defined in this module are valid according to the generic CSS grammar and the individual grammars of each feature defined in this module.

A renderer is conformant to this specification if, in addition to interpreting the style sheet as defined by the appropriate specifications, it supports all the features defined by this specification by parsing them correctly and rendering the document accordingly. However, the inability of a UA to correctly render a document due to limitations of the device does not make the UA non-conformant. (For example, a UA is not required to render color on a monochrome monitor.)

An authoring tool is conformant to this specification if it writes style sheets that are syntactically correct according to the generic CSS grammar and the individual grammars of each feature in this module, and meet all other conformance requirements of style sheets as described in this module.

Requirements for Responsible Implementation of CSS

The following sections define several conformance requirements for implementing CSS responsibly, in a way that promotes interoperability in the present and future.

Partial Implementations

So that authors can exploit the forward-compatible parsing rules to assign fallback values, CSS renderers must treat as invalid (and ignore as appropriate) any at-rules, properties, property values, keywords, and other syntactic constructs for which they have no usable level of support. In particular, user agents must not selectively ignore unsupported property values and honor supported values in a single multi-value property declaration: if any value is considered invalid (as unsupported values must be), CSS requires that the entire declaration be ignored.

Implementations of Unstable and Proprietary Features

To avoid clashes with future stable CSS features, the CSSWG recommends following best practices for the implementation of unstable features and proprietary extensions to CSS.

Implementations of CR-level Features

Once a specification reaches the Candidate Recommendation stage, implementers should release an unprefixed implementation of any CR-level feature they can demonstrate to be correctly implemented according to spec, and should avoid exposing a prefixed variant of that feature.

To establish and maintain the interoperability of CSS across implementations, the CSS Working Group requests that non-experimental CSS renderers submit an implementation report (and, if necessary, the testcases used for that implementation report) to the W3C before releasing an unprefixed implementation of any CSS features. Testcases submitted to W3C are subject to review and correction by the CSS Working Group.

Further information on submitting testcases and implementation reports can be found from on the CSS Working Group’s website at http://www.w3.org/Style/CSS/Test/. Questions should be directed to the public-css-testsuite@w3.org mailing list.

Index

Terms defined by this specification

Terms defined by reference

References

Normative References

[CSS-CONDITIONAL-3]
CSS Conditional Rules Module Level 3 URL: https://www.w3.org/TR/css3-conditional/
[CSS-DEVICE-ADAPT-1]
Rune Lillesveen; Florian Rivoal; Matt Rakow. CSS Device Adaptation Module Level 1. 29 March 2016. WD. URL: https://www.w3.org/TR/css-device-adapt-1/
[CSS-IMAGES-3]
CSS Image Values and Replaced Content Module Level 3 URL: https://www.w3.org/TR/css3-images/
[CSS-SHAPES-1]
Vincent Hardy; Rossen Atanassov; Alan Stearns. CSS Shapes Module Level 1. 20 March 2014. CR. URL: https://www.w3.org/TR/css-shapes-1/
[CSS-VALUES-3]
Tab Atkins Jr.; Elika Etemad. CSS Values and Units Module Level 3. 29 September 2016. CR. URL: https://www.w3.org/TR/css-values-3/
[CSS21]
Bert Bos; et al. Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification. 7 June 2011. REC. URL: https://www.w3.org/TR/CSS2
[MOTION-1]
Dirk Schulze; Shane Stephens. Motion Path Module Level 1. 9 April 2015. WD. URL: https://www.w3.org/TR/motion-1/
[RFC2119]
S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Best Current Practice. URL: https://tools.ietf.org/html/rfc2119

Informative References

[CSS3-BORDER]
Tapas Roy. CSS3 module: Border. 7 November 2002. WD. URL: https://www.w3.org/TR/css3-border
[CSS3-POSITIONING]
Rossen Atanassov; Arron Eicholz. CSS Positioned Layout Module Level 3. 17 May 2016. WD. URL: https://www.w3.org/TR/css-position-3/
[MEDIAQUERIES-4]
Florian Rivoal; Tab Atkins Jr.. Media Queries Level 4. 6 July 2016. WD. URL: https://www.w3.org/TR/mediaqueries-4/

Property Index

Name Value Initial Applies to Inh. %ages Media Ani­mat­able Anim­ation type Canonical order Com­puted value
shape-inside auto | outside-shape | [ <basic-shape> || shape-box ] | <image> | display auto block-level elements no n/a visual as specified for <basic-shape>, otherwise no per grammar computed lengths for <basic-shape>, the absolute URI for <uri>, otherwise as specified
border-boundary none | parent | display none all elements yes n/a visual discrete per grammar as specified

@media Descriptors

Name Value Initial Type
shape rect | round discrete

@viewport Descriptors

Name Value Initial Computed value Media Percentages
viewport-fit auto | contain | cover auto as specified visual, continuous N/A

Issues Index

What if content overflows? Clipping or scrolling?