Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.
Fullscreen defines the fullscreen API for the web platform.
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 http://www.w3.org/TR/.
This is the 03 July 2012 W3C First Public Working Draft of Fullscreen.
This document was jointly produced by the Web Applications Working Group and the CSS Working Group. The Web Applications Working Group is part of the Rich Web Clients Activity and the CSS Working Group is part of the Style Activity. Both of these Working Groups are part of the the W3C Interaction Domain.
Comments related to the API part of this document should be sent to the public-webapps mail list (archived) with a subject header of [fullscreen] and comments related to the rendering part of this document should be sent to the www-style mail list (archived) with a subject header of [fullscreen]. Alternatively, file a bug.
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.
This specification was produced by the WebApps Working Group (part of the Graphics Activity) and the CSS Working Group (part of the Style Activity).
This document was produced by groups operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures (WebApps) and a public list of any patent disclosures (CSS) made in connection with the deliverables of each group; these pages also include 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.
All diagrams, examples, and notes in this specification are non-normative, as are all sections explicitly marked non-normative. Everything else in this specification is normative.
The key words "MUST", "MUST NOT", "REQUIRED", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this specification are to be interpreted as described in RFC2119. For readability, these words do not appear in all uppercase letters in this specification. [RFC2119]
Most terminology used in this specification is from CSS, DOM, and HTML. [CSS] [DOM] [HTML5]
The term context object means the object on which the method or attribute being discussed was called. When the context object is unambiguous, the term can be omitted.
A browsing context A is called a descendant browsing context of a browsing context B if and only if B is an ancestor browsing context of A.
The task source used by this specification is the user interaction task source.
All documents have an associated fullscreen enabled flag and fullscreen element stack. Unless otherwise stated the fullscreen enabled flag is unset and the fullscreen element stack is empty.
HTML defines under what conditions the fullscreen enabled flag is set. [HTML]
To add an element on a document's fullscreen element stack, add it on top of document's browsing context's top layer, and then add it on top of document's fullscreen element stack.
To remove an element from a document's fullscreen element stack, remove it from document's browsing context's top layer, and then remove it from document's fullscreen element stack.
To empty a document's fullscreen element stack, remove all the elements in it from document's browsing context's top layer, and then empty document's fullscreen element stack.
To fully exit fullscreen act as if the
exitFullscreen()
method
was invoked on the
top-level browsing context's
document and
subsequently empty that
document's
fullscreen element stack.
Since a fullscreenchange
event will be
dispatched regardless, emptying the fullscreen element stack
per above is fine.
If an element at the top of a fullscreen element stack is removed from a document, fully exit fullscreen.
partial interface Element { void requestFullscreen(); }; partial interface Document { readonly attribute boolean fullscreenEnabled; readonly attribute Element? fullscreenElement; void exitFullscreen(); };
element . requestFullscreen()
document . fullscreenEnabled
document . fullscreenElement
document . exitFullscreen()
The
requestFullscreen()
method must run these steps:
If any of the following conditions are true,
queue a task to
fire an event
named fullscreenerror
with its
bubbles
attribute set to true on the
context object's
node document, and then terminate these steps:
The context object is not in a document.
The context object's node document, or an ancestor browsing context's document does not have the fullscreen enabled flag set.
The context object's node document fullscreen element stack is not empty and its top element is not an ancestor of the context object.
A descendant browsing context's document has a non-empty fullscreen element stack.
This algorithm is not allowed to show a pop-up.
There is a previously-established user preference, security risk, or platform limitation.
Return, and run the remaining steps asynchronously.
Optionally, perform some animation.
Let doc be element's node document.
Let docs be all doc's ancestor browsing context's documents (if any) and doc, in order of furthest away from doc to doc.
For each document in docs, run these substeps:
Let following document be the document after document in docs, or null if there is no such document.
If following document is null,
queue a task to
add
context object on
document's fullscreen element stack and
fire an event
named fullscreenchange
with its
bubbles
attribute set to true on the
document.
Otherwise, if document's
fullscreen element stack is either empty or its top
element is not
following document's
browsing context container,
queue a task to
add
following document's
browsing context container on
document's fullscreen element stack and
fire an event
named fullscreenchange
with its
bubbles
attribute set to true on
document.
Otherwise, do nothing for this document. It stays the same.
Optionally, display a message indicating how the user can exit displaying the context object fullscreen.
The
fullscreenEnabled
attribute must return true if the context object and all
ancestor browsing context's
documents have
their fullscreen enabled flag set, or false otherwise.
The fullscreenElement
attribute must return the top
element of the
context object's
fullscreen element stack, or null otherwise.
The
exitFullscreen()
method must run these steps:
Let doc be the context object.
If doc's fullscreen element stack is empty, terminate these steps.
Return, and run the remaining steps asynchronously.
Optionally, perform some animation.
Let descendants be all the doc's descendant browsing context's documents with a non-empty fullscreen element stack (if any), ordered so that the child of the doc is last and the document furthest away from the doc is first.
For each descendant in
descendants,
queue a task to
empty
descendant's fullscreen element stack and
fire an event
named fullscreenchange
with its
bubbles
attribute set to true on
descendant.
While doc is not null, run these substeps:
Remove the top element of doc's fullscreen element stack.
If doc's fullscreen element stack is non-empty and the element now at the top is either not in a document or its node document is not doc, run these substeps again.
This is needed because a non-top element in the fullscreen element stack could have been removed from doc.
Queue a task to
fire an event
named fullscreenchange
with its
bubbles
attribute set to true on
doc.
If doc's fullscreen element stack is empty and doc's browsing context has a browsing context container, set doc to that browsing context container's node document.
Otherwise, set doc to null.
User agents are encouraged to implement native media fullscreen controls
in terms of
requestFullscreen()
and
exitFullscreen()
.
If the end user instructs the user agent to end a fullscreen session
initiated via
requestFullscreen()
,
fully exit fullscreen.
This section is to be interpreted equivalently to the Rendering section of HTML. [HTML]
This specification introduces a new stacking layer to the Elaborate description of Stacking Contexts of CSS 2.1. It is called the top layer, comes after step 10 in the painting order, and is therefore rendered closest to the user within a viewport. Each browsing context has one associated viewport and therefore also one top layer. [CSS]
The terminology used in this and following subsection attempts to match CSS 2.1 Appendix E.
The top layer consists of a stack of elements, rendered in the order they have been added to the stack. The last element added to the stack is rendered closest to the user.
The z-index
property has no effect in the
top layer.
An element in this stack has the following attributes:
It generates a new stacking context.
Its parent stacking context is the root stacking context.
Its containing block is the initial containing block.
It is rendered as an atomic unit as if it were a sibling of the root element.
Ancestor elements with overflow, opacity, masks, etc. cannot affect it.
It is not rendered if it, or an ancestor, has the
display
property set to none
.
If its specified position
property is
static
, it computes to absolute
.
Its outline, if any, is to be rendered before step 10 in the painting order.
Unless overridden by another specification, its static position for
left
, right
, and
top
is zero.
::backdrop
pseudo-elementEach element in the top layer's stack has a
::backdrop
pseudo-element.
This pseudo-element is a box rendered immediately below the element (and
above the element below the element in the stack, if any), within the same
top layer.
The ::backdrop
pseudo-element can be used to
create a backdrop that hides the underlying document for an element in the
top layer's stack. E.g. for the element that is displayed
fullscreen as described by this specification.
It does not inherit from any element and is not inherited from. No restrictions are made on what properties apply to this pseudo-element either.
:fullscreen
pseudo-classThe :fullscreen
pseudo-class must match the top
element of the
document's
fullscreen element stack (if any).
@namespace "http://www.w3.org/1999/xhtml"; *|*:fullscreen { position:fixed; top:0; right:0; bottom:0; left:0; margin:0; box-sizing:border-box; width:100%; height:100%; object-fit:contain; } iframe:fullscreen { border:none; } *|*:fullscreen::backdrop { position:fixed; top:0; right:0; bottom:0; left:0; background:black; }
User agents should ensure, e.g. by means of an overlay, that the end user
is aware something is displayed fullscreen. User agents should provide a
means of exiting fullscreen that always works and advertise this to the
user. This is to prevent a site from spoofing the end user by recreating the
user agent or even operating system environment when fullscreen. See also
the definition of
requestFullscreen()
.
To prevent embedded content from going fullscreen only embedded content
specifically allowed via the allowfullscreen
attribute of the
HTML iframe
element will be able to go fullscreen. This
prevents untrusted content from going fullscreen.
Many thanks to Robert O'Callahan for designing the initial model and being awesome.
Thanks to Chris Pearce, Darin Fisher, Edward O'Connor, fantasai, Glenn Maynard, Ian Hickson, João Eiras, Josh Soref, Øyvind Stenhaug, Rafał Chłodnicki, Rune Lillesveen, Sigbjørn Vik, Simon Pieters, and Tab Atkins for also being awesome.