Activation of [[mediacapture-extensions]]'s [[[mediacapture-extensions#media-capture-html-elements|<usermedia>]]] element should only be allowed by an intentional click (or other gesture) by the user. Programmatic activation or tricking a user in activating the element ("clickjacking") should not activate the element. This note proposes specific mechanisms to accomplish this, based on the original [[pepc]] design. The intent of this note is to provide a basis of discussion for standardization of these measures.
This is a purely informational note.
[[mediacapture-extensions]]' definition of the trusted algorithm contains two notes, reproduced here:
At the top of the trusted algorithm:
In trusted,
step 2, following a recommendation to
run additional, implementation-defined steps
:
This document proposes those guidelines.
User agents should run additional, implementation-defined steps to determine trusted-ness of |event|.Replace this step with the following step:
To guarantee meaningful user intent, we will assume that an activation is — generally — what the user means to do. We also define circumstances that where the user agent assumes non-intentional activation, and call these activation blockers. A usermedia element then maintains a set of current activation blockers, and will disregard an activation if the set of current blockers is non-empty.
Supporting activation blockers requires the following internal slots at the element:
To prevent a page from "spamming" the user with a large number of elements, we'd like to keep track of the number of active elements. To accomplish this, the [=/navigable=] maintains an [=ordered set=] of elements, [[ActivationBlockableElements]]. This [=ordered set=] is used to evaluate the blockers of type [=ActivationBlocker/unsuccessful_registration=].
The key goal of the elements in this specification is to reflect a user's conscious choice, and we need to make sure the user cannot easily be tricked into activating it. To do so, we maintain a list of blocker reasons, which may - permanently or temporarily - prevent the element from being activated.
These blockers come with two lifetimes: temporary, or until revoked.
| Blocker name | Blocker type | Example condition |
|---|---|---|
| unsuccessful_registration | [=revocable blocker|revocable=] | When too many other elements for the same [=powerful feature=] have been inserted into the same document. |
| recently_attached | [=temporary blocker|temporary=] | When the element has just been attached to the DOM. |
| intersection_changed | [=temporary blocker|temporary=] | When the element is being moved. |
| intersection_out_of_viewport_or_clipped | [=revocable blocker|revocable=] | When the element is not or not fully in the viewport. |
| intersection_occluded_or_distorted | [=revocable blocker|revocable=] | When the element is fully in the viewport, but still not fully visible (e.g. because it's partly behind other content). |
| style_invalid | [=revocable blocker|revocable=] |
usermedia elements constrain the styling that can be applied to them. These are expressed as conditions on their styling, and come in two flavours:
If the following conditions aren't met, a [=ActivationBlocker/style_invalid=] [=revocable blocker=] is added:
A usermedia element is expected to render with the following [=user-agent style sheet=]:
@namespace "http://www.w3.org/1999/xhtml";
usermedia {
opacity: 1.0;
line-height: normal !important;
white-space: nowrap !important;
user-select: none !important;
appearance: auto !important;
box-sizing: content-box !important;
vertical-align: middle !important;
text-emphasis: initial !important;
text-shadow: initial !important;
text-decoration: initial !important;
}
In addition to the [=user-agent style sheet=] in subsection [[[#style-stylesheet]]], we would like to express some style bounds based on the computed style of the element. These should be treated as a [=user-agent style sheet=], too.
For notational convenience, we imagine that the [=computed value=] of
an element could be accessed in CSS rules with computed,
just like the inherited value of an element can via the
[=CSS/inherit=] keyword. Then the following sheet expresses
the style bounds:
@namespace "http://www.w3.org/1999/xhtml";
usermedia {
outline-offset: clamp(0, computed, none); /* No negative outline-offsets. */
font-weight: clamp(200, computed, none); /* No font-weights below 200. */
word-spacing: clamp(0, computed, 0.5em); /* Word-spacing between 0..0.5em */
letter-spacing: clamp(-0.05em, computed, 0.2em); /* Letter spacing between -0.05..0.2em */
min-height: clamp(1em, computed, none);
max-height: clamp(none, computed, 3em);
min-width: clamp(none, computed, calc(fit-content));
border-width: clamp(none, computed, 1em);
font-style: if(computed = "normal" or computed = "italic", computed, "normal");
display: if (computed = "inline-block" or computed = "none", computed, "inline-block");
cursor: if (computed = "pointer" or computed = "not-allowed", computed, "pointer");
box-shadow: if (computed = "inset", "none", computed);
}
Additionally, some rules apply based on conditions not easily expressible as CSS.
If height is `auto`, then apply:
@namespace "http://www.w3.org/1999/xhtml";
usermedia {
padding-top: clamp(1em, computed, none);
padding-bottom: calc(padding-top);
}
If width is `auto`, then apply:
@namespace "http://www.w3.org/1999/xhtml";
usermedia {
padding-left: clamp(none, computed, 5em);
padding-right: calc(padding-left);
}
Apply the following sheet, if the element does not have all of the following:
@namespace "http://www.w3.org/1999/xhtml";
usermedia {
max-width: clamp(none, computed, calc(3 * fit-content));
}
The following CSS properties can be used normally:
Properties that are not listed above, or in the rules in this section, and aren't logically equivalent to one of the properties mentioned here, will be ignored.