A command is the abstraction behind menu items, buttons, and links.
Commands are defined to have the following facets:
These facets are exposed on elements using the command API:
commandType
Exposes the Type facet of the command.
id
Exposes the ID facet of the command.
label
Exposes the Label facet of the command.
title
Exposes the Hint facet of the command.
icon
Exposes the Icon facet of the command.
accessKeyLabel
Exposes the Access Key facet of the command.
hidden
Exposes the state of the element's hidden
attribute, which is generally
equivalent to the Hidden
State facet of the command. For label
and
legend
elements (used in conjunction with the accesskey
attribute), the Hidden State facet is
derived from another element (the one that the assigned
access key will trigger), and cannot be directly accessed
from the element.
disabled
Exposes the Disabled State facet of the command.
checked
Exposes the Checked State facet of the command.
click
()Triggers the Action of the command.
The commandType
attribute must return a string whose value is either "command
", "radio
", or "checkbox
", depending on whether the Type of the command defined by the
element is "command", "radio", or "checkbox" respectively. If the
element does not define a command, it must return null.
The label
attribute must return the command's Label, or null if the element
does not define a command or does not specify a Label. This attribute will be
shadowed by the label
IDL attribute on
various elements.
The icon
attribute must return the absolute URL of the command's
Icon. If the element does
not specify an icon, or if the element does not define a command,
then the attribute must return null. This attribute will be shadowed
by the icon
IDL attribute on
command
elements.
The disabled
attribute must return true if the command's Disabled State is that
the command is disabled, and false if the command is not
disabled. This attribute is not affected by the command's Hidden State. If the
element does not define a command, the attribute must return
false. This attribute will be shadowed by the disabled
IDL attribute on various elements.
The checked
attribute
must return true if the command's Checked State is that the
command is checked, and false if it is that the command is not
checked. If the element does not define a command, the attribute
must return false. This attribute will be shadowed by the checked
IDL attribute on input
and
command
elements.
The ID facet
is exposed by the id
IDL attribute,
the Hint facet is exposed by
the title
IDL attribute, the AccessKey facet is exposed by
the accessKeyLabel
IDL
attribute, and the Hidden
State facet is exposed by the hidden
IDL attribute.
commands
Returns an HTMLCollection
of the elements in the
Document
that define commands and have IDs.
The commands
attribute
of the document's HTMLDocument
interface must return an
HTMLCollection
rooted at the Document
node, whose filter matches only elements that define commands and have IDs.
User agents may expose the commands whose Hidden State facet is false (visible), e.g. in the user agent's menu bar. User agents are encouraged to do this especially for commands that have Access Keys, as a way to advertise those keys to the user.
a
element to define a commandAn a
element with an href
attribute defines a command.
The Type of the command is "command".
The ID of the command is
the value of the id
attribute of the
element, if the attribute is present and not empty. Otherwise the
command is an anonymous command.
The Label of the command
is the string given by the element's textContent
IDL
attribute.
The Hint of the command
is the value of the title
attribute
of the element. If the attribute is not present, the Hint is the empty string.
The Icon of the command
is the absolute URL obtained from resolving the value of the src
attribute of the first
img
element descendant of the element, relative to that
element, if there is such an element and resolving its attribute is
successful. Otherwise, there is no Icon for the command.
The AccessKey of the command is the element's assigned access key, if any.
The Hidden State
of the command is true (hidden) if the element has a hidden
attribute, and false
otherwise.
The Disabled State facet of the command is always false. (The command is always enabled.)
The Checked State of the command is always false. (The command is never checked.)
The Action of the
command is to fire a click
event at the element.
button
element to define a commandA button
element always defines a command.
The Type, ID, Label, Hint, Icon, Access Key, Hidden State, Checked State, and Action facets of the command are
determined as for a
elements (see the previous section).
The Disabled State of the command mirrors the disabled state of the button.
input
element to define a commandAn input
element whose type
attribute is in one of the Submit Button, Reset Button, Image Button, Button, Radio Button, or Checkbox states defines a command.
The Type of the command
is "radio" if the type
attribute is in the Radio
Button
state, "checkbox" if the type
attribute is in the Checkbox
state, and
"command" otherwise.
The ID of the command is
the value of the id
attribute of the
element, if the attribute is present and not empty. Otherwise the
command is an anonymous command.
The Label of the command depends on the Type of the command:
If the Type is "command",
then it is the string given by the value
attribute, if any, and a
UA-dependent, locale-dependent value that the UA uses to label the
button itself if the attribute is absent.
Otherwise, the Type is
"radio" or "checkbox". If the element is a labeled
control, the textContent
of the first
label
element in tree order whose
labeled control is the element in question is the Label (in DOM terms, this is the
string given by element.labels[0].textContent
). Otherwise,
the value of the value
attribute, if present, is the Label. Otherwise, the Label is the empty string.
The Hint of the command
is the value of the title
attribute
of the input
element. If the attribute is not present, the
Hint is the empty
string.
If the element's type
attribute is in the Image
Button state, and the element has a src
attribute, and that attribute's
value can be successfully resolved relative to the element, then the Icon of the command is the
absolute URL obtained from resolving that attribute
that way. Otherwise, there is no Icon for the command.
The AccessKey of the command is the element's assigned access key, if any.
The Hidden State
of the command is true (hidden) if the element has a hidden
attribute, and false
otherwise.
The Disabled State of the command mirrors the disabled state of the control.
The Checked State of the command is true if the command is of Type "radio" or "checkbox" and the element is checked attribute, and false otherwise.
The Action of the
command, if the element has a defined activation
behavior, is to run synthetic click activation
steps on the element. Otherwise, it is just to fire a
click
event at the
element.
option
element to define a commandAn option
element with an ancestor
select
element and either no value
attribute or a value
attribute that is not the
empty string defines a
command.
The Type of the command
is "radio" if the option
's nearest ancestor
select
element has no multiple
attribute, and
"checkbox" if it does.
The ID of the command is
the value of the id
attribute of the
element, if the attribute is present and not empty. Otherwise the
command is an anonymous command.
The Label of the command
is the value of the option
element's label
attribute, if there is one,
or the value of the option
element's
textContent
IDL attribute if there isn't.
The Hint of the command
is the string given by the element's title
attribute, if any, and the empty
string if the attribute is absent.
There is no Icon for the command.
The AccessKey of the command is the element's assigned access key, if any.
The Hidden State
of the command is true (hidden) if the element has a hidden
attribute, and false
otherwise.
The Disabled
State of the command is true (disabled) if the element is
disabled or if its
nearest ancestor select
element is disabled, and false
otherwise.
The Checked State of the command is true (checked) if the element's selectedness is true, and false otherwise.
The Action of the
command depends on its Type. If the command is of Type "radio" then it must pick the option
element. Otherwise, it must toggle the option
element.
command
element to define
a commandA command
element defines a command.
The Type of the command
is "radio" if the command
's type
attribute is
"radio
", "checkbox" if the attribute's value is
"checkbox
", and "command" otherwise.
The ID of the command is
the value of the id
attribute of the
element, if the attribute is present and not empty. Otherwise the
command is an anonymous command.
The Label of the command
is the value of the element's label
attribute, if there is one,
or the empty string if it doesn't.
The Hint of the command
is the string given by the element's title
attribute, if any, and the
empty string if the attribute is absent.
The Icon for the command
is the absolute URL obtained from resolving the value of the element's icon
attribute, relative to the
element, if it has such an attribute and resolving it is
successful. Otherwise, there is no Icon for the command.
The AccessKey of the command is the element's assigned access key, if any.
The Hidden State
of the command is true (hidden) if the element has a hidden
attribute, and false
otherwise.
The Disabled
State of the command is true (disabled) if the element has a
disabled
attribute, and
false otherwise.
The Checked State
of the command is true (checked) if the element has a checked
attribute, and false
otherwise.
The Action of the
command, if the element has a defined activation
behavior, is to run synthetic click activation
steps on the element. Otherwise, it is just to fire a
click
event at the
element.
accesskey
attribute on a label
element to define a commandA label
element that has an assigned access
key and a labeled control and whose
labeled control defines a
command, itself defines a
command.
The Type of the command is "command".
The ID of the command is
the value of the id
attribute of the
element, if the attribute is present and not empty. Otherwise the
command is an anonymous command.
The Label of the command
is the string given by the element's textContent
IDL
attribute.
The Hint of the command
is the value of the title
attribute
of the element.
There is no Icon for the command.
The AccessKey of the command is the element's assigned access key.
The Hidden State, Disabled State, and Action facets of the command are the same as the respective facets of the element's labeled control.
The Checked State of the command is always false. (The command is never checked.)
accesskey
attribute on a legend
element to define a commandA legend
element that has an assigned access
key and is a child of a fieldset
element that
has a descendant that is not a descendant of the legend
element and is neither a label
element nor a
legend
element but that defines a command, itself defines a command.
The Type of the command is "command".
The ID of the command is
the value of the id
attribute of the
element, if the attribute is present and not empty. Otherwise the
command is an anonymous command.
The Label of the command
is the string given by the element's textContent
IDL
attribute.
The Hint of the command
is the value of the title
attribute
of the element.
There is no Icon for the command.
The AccessKey of the command is the element's assigned access key.
The Hidden State,
Disabled State, and
Action facets of the
command are the same as the respective facets of the first element
in tree order that is a descendant of the parent of the
legend
element that defines a command but is not a
descendant of the legend
element and is neither a
label
nor a legend
element.
The Checked State of the command is always false. (The command is never checked.)
accesskey
attribute to define a command on other elementsAn element that has an assigned access key defines a command.
If one of the other sections that define elements that define commands define that this element defines a command, then that section applies to this element, and this section does not. Otherwise, this section applies to that element.
The Type of the command is "command".
The ID of the command is
the value of the id
attribute of the
element, if the attribute is present and not empty. Otherwise the
command is an anonymous command.
The Label of the command
depends on the element. If the element is a labeled
control, the textContent
of the first
label
element in tree order whose
labeled control is the element in question is the Label (in DOM terms, this is the
string given by element.labels[0].textContent
). Otherwise, the
Label is the
textContent
of the element itself.
The Hint of the command
is the value of the title
attribute
of the element. If the attribute is not present, the Hint is the empty string.
There is no Icon for the command.
The AccessKey of the command is the element's assigned access key.
The Hidden State
of the command is true (hidden) if the element has a hidden
attribute, and false
otherwise.
The Disabled State facet of the command is always false. (The command is always enabled.)
The Checked State of the command is always false. (The command is never checked.)
The Action of the command is to run the following steps:
click
event at the element.device
elementtype
interface HTMLDeviceElement : HTMLElement { attribute DOMString type; readonly attribute any data; };
The device
element represents a device selector, to
allow the user to give the page access to a device, for example a
video camera.
The type
attribute allows the author to specify which kind of device the page
would like access to. The attribute is an enumerated
attribute with the keywords given in the first column of the
following table, and their corresponding states given in the cell in
second column of the same row.
RS232 and USB are only included below to give an idea of where we could go with this. Should we instead just make this only useful for audiovisual streams? Unless there are compelling reasons, we probably should not be this generic. So far, the reasons for RS232 aren't that compelling. For USB, slightly more so.
Keyword | State | Device description | Examples |
---|---|---|---|
media
| Media | Stream of audio and/or video data. | A webcam. |
fs
| File system | File system. | A USB-connected media player. |
rs232
| RS232 | RS232 device. | A serial port. |
usb
| USB | USB device. | A scanner, a music player, a disk jockey, a fish tank. |
processing model: 'change' event fires once user selects a new device; .data is set to new Stream, LocalFS, USB, or RS232 object as appropriate.
<p>To start chatting, select a video camera: <device type=media onchange="update(this.data)"></p> <video autoplay></video> <script> function update(stream) { document.getElementsByTagName('video')[0].src = stream.url; } </script>
The Stream
interface is used to represent
streams.
interface Stream { readonly attribute DOMString url; StreamRecorder record(); };
The url
attribute
must return a File URN representing the
stream. [FILEAPI]
For audio and video streams, the stream must be in a format
supported by the user agent for use in audio
and
video
elements.
This will be pinned down to a specific codec.
When the record()
method is
invoked, the user agent must return a new
StreamRecorder
object associated with the stream.
interface StreamRecorder { File stop(); };
The stop()
method
must return a new File
object representing the data
that was streamed between the creation of the
StreamRecorder
object and the invocation of the stop()
method. [FILEAPI]
For audio and video streams, the file must be in a format
supported by the user agent for use in audio
and
video
elements.
This again will be pinned down to a specific codec.
This section will be moved to a more appropriate
location in due course; it is here currently to keep it near the
device
element to allow reviewers to look at it.
[Constructor(in DOMString serverConfiguration)] interface ConnectionPeer { void sendText(in DOMString text, in optional boolean unimportant); // if second arg is true, then use unreliable low-latency transport (UDP-like), otherwise guarantee delivery (TCP-like) attribute Function ontext; // receiving void sendBitmap(in HTMLImageElement image); attribute Function onbitmap; // receiving void sendFile(in File file); attribute Function onfile; // receiving void addStream(in Stream stream); void removeStream(in Stream stream); readonly attribute Stream[] localStreams; readonly attribute Stream[] remoteStreams; attribute Function onstream; // receiving void getLocalConfiguration(in ConnectionPeerConfigurationCallback callback); // maybe this should be in the constructor, or be an event void addRemoteConfiguration(in DOMString configuration, in optional DOMString remoteOrigin); // remote origin is assumed to be same-origin if not specified. If specified, has to match remote origin (checked in handshake). Should support leading "*." to mean "any subdomain of". void close(); // disconnects and stops listening attribute Function onconnect; attribute Function onerror; attribute Function ondisconnect; }; [Callback=FunctionOnly, NoInterfaceObject] interface ConnectionPeerConfigurationCallback { void handleEvent(in ConnectionPeer server, in DOMString configuration); };
...
This relies on some currently hypothetical other standard to define:
When two peers decide they are going to set up a connection to each other, they both go through these steps. The serverConfig comes from a third-party server they can use to get things like their public IP address or to set up NAT traversal. They also have to send their respective configuration to each other using the same out-of-band mechanism they used to establish that they were going to communicate in the first place.
var serverConfig = ...; // configuration string obtained from server // contains details such as the IP address of a server that can speak some // protocol to help the client determine its public IP address, route packets // if necessary, etc. var local = new ConnectionPeer(serverConfig); local.getLocalConfiguration(function (configuration) { if (configuration != '') { ...; // send configuration to other peer using out-of-band mechanism } else { // we've exhausted our options; wait for connection } }); function ... (configuration) { // called whenever we get configuration information out-of-band local.addRemoteConfiguration(configuration); } local.onconnect = function (event) { // we are connected! local.sendText('Hello'); local.addStream(...); // send video local.onstream = function (event) { // receive video // (videoElement is some <video> element) if (local.remoteStreams.length > 0) videoElement.src = local.remoteStreams[0].url; }; };
To prevent network sniffing from allowing a fourth party to establish a connection to a peer using the information sent out-of-band to the other peer and thus spoofing the client, the configuration information should always be transmitted using an encrypted connection.