Commit ff69f347 authored by Joshua Bell's avatar Joshua Bell Committed by Commit Bot

WebIDL: Allow [Serializable]/[Transferable]

Document and allow the [Serializable] and [Transferable] IDL extended
attributes. They don't influence code generation (custom code is
required), but should be allowed if the spec has them so that
spec/tests/code can match.

Add those attributes to .idl files that need them, and also clean up a
few other IDL extended attribute documentation nits.

Change-Id: I241d257c2d8cd4eacfb32354772daa54002cf878
Reviewed-on: https://chromium-review.googlesource.com/c/1255595
Commit-Queue: Joshua Bell <jsbell@chromium.org>
Reviewed-by: default avatarMarijn Kruisselbrink <mek@chromium.org>
Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595985}
parent d2a8bb41
......@@ -135,7 +135,9 @@ Extended attributes are generally not inherited: only extended attributes on the
These are defined in the [ECMAScript-specific extended attributes](http://heycam.github.io/webidl/#es-extended-attributes) section of the [Web IDL spec](http://heycam.github.io/webidl/), and alter the binding behavior.
*** note
Unsupported: `[ImplicitThis]`, `[LenientThis]`, `[NamedPropertiesObject]`, `[TreatNonCallableAsNull]`
Unsupported: `[LenientThis]`
Undocumented: `[TreatNonObjectAsNull]`
***
### [CEReactions] _(m, a)_
......@@ -485,6 +487,34 @@ interface Window {
}
```
### [Serializable] _(i)_
Standard: [Serializable](https://html.spec.whatwg.org/multipage/structured-data.html#serializable)
Summary: Serializable objects support being serialized, and later deserialized, for persistence in storage APIs or for passing with `postMessage()`.
```webidl
[Serializable] interface Blob {
...
};
```
This attribute has no effect on code generation and should simply be used in Blink IDL files if the specification uses it. Code to perform the serialization/deserialization must be added to `V8ScriptValueSerializer` for types in `core/` or `V8ScriptValueDeserializerForModules` for types in `modules/`.
### [Transferable] _(i)_
Standard: [Transferable](https://html.spec.whatwg.org/multipage/structured-data.html#transferable)
Summary: Transferable objects support being transferred across Realms with `postMessage()`.
```webidl
[Transferable] interface MessagePort {
...
};
```
This attribute has no effect on code generation and should simply be used in Blink IDL files if the specification uses it. Code to perform the transfer steps must be added to `V8ScriptValueSerializer` for types in `core/` or `V8ScriptValueDeserializerForModules` for types in `modules/`.
### [TreatNullAs] _(a,p)_
Standard: [TreatNullAs](https://heycam.github.io/webidl/#TreatNullAs)
......@@ -1633,8 +1663,12 @@ Added to members of a partial interface definition (and implemented interfaces w
**FIXME:** The following need documentation:
***
* `[PerWorldBindings]` :: interacts with `[LogActivity]`
* `[ImmutablePrototype]`
* `[LegacyInterfaceTypeChecking]`
* `[LogAllWorlds]`
* `[OverrideBuiltins]` :: used on named accessors
* `[PerWorldBindings]` :: interacts with `[LogActivity]`
* `[WebAgentAPI]`
-------------
......
......@@ -97,7 +97,9 @@ RuntimeCallStatsCounter=*
SameObject
SaveSameObject
SecureContext=|*
Serializable
SetterCallWith=ExecutionContext|ScriptState|ScriptArguments|CurrentWindow|EnteredWindow
Transferable
TreatNonObjectAsNull
TreatNullAs=NullString|EmptyString
URL
......
......@@ -28,14 +28,15 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// https://w3c.github.io/FileAPI/#blob
// https://w3c.github.io/FileAPI/#blob-section
typedef (ArrayBuffer or ArrayBufferView or Blob or USVString) BlobPart;
[
Constructor(optional sequence<BlobPart> blobParts, optional BlobPropertyBag options),
ConstructorCallWith=ExecutionContext,
RaisesException=Constructor,
Exposed=(Window,Worker)
Exposed=(Window,Worker),
Serializable
] interface Blob {
readonly attribute unsigned long long size;
readonly attribute DOMString type;
......
......@@ -23,13 +23,14 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// https://w3c.github.io/FileAPI/#file
// https://w3c.github.io/FileAPI/#file-section
[
Constructor(sequence<BlobPart> fileBits, USVString fileName, optional FilePropertyBag options),
ConstructorCallWith=ExecutionContext,
RaisesException=Constructor,
Exposed=(Window,Worker)
Exposed=(Window,Worker),
Serializable
] interface File : Blob {
readonly attribute DOMString name;
readonly attribute long long lastModified;
......
......@@ -26,7 +26,8 @@
// https://w3c.github.io/FileAPI/#filelist-section
[
Exposed=(Window,Worker)
Exposed=(Window,Worker),
Serializable
] interface FileList {
getter File? item(unsigned long index);
readonly attribute unsigned long length;
......
......@@ -8,7 +8,8 @@
Constructor(optional (DOMString or sequence<unrestricted double>) init),
RaisesException=Constructor,
ConstructorCallWith=ExecutionContext,
Exposed=(Window,Worker)
Exposed=(Window,Worker),
Serializable
] interface DOMMatrix : DOMMatrixReadOnly {
[RaisesException, NewObject] static DOMMatrix fromMatrix(optional DOMMatrixInit other);
[RaisesException, NewObject] static DOMMatrix fromFloat32Array(Float32Array array32);
......
......@@ -8,7 +8,8 @@
Constructor(optional (DOMString or sequence<unrestricted double>) init),
RaisesException=Constructor,
ConstructorCallWith=ExecutionContext,
Exposed=(Window,Worker)
Exposed=(Window,Worker),
Serializable
] interface DOMMatrixReadOnly {
[RaisesException, NewObject] static DOMMatrixReadOnly fromMatrix(optional DOMMatrixInit other);
[RaisesException, NewObject] static DOMMatrixReadOnly fromFloat32Array(Float32Array array32);
......
......@@ -7,7 +7,8 @@
[
Constructor(optional unrestricted double x = 0, optional unrestricted double y = 0,
optional unrestricted double z = 0, optional unrestricted double w = 1),
Exposed=(Window,Worker)
Exposed=(Window,Worker),
Serializable
] interface DOMPoint : DOMPointReadOnly {
[NewObject] static DOMPoint fromPoint(optional DOMPointInit other);
inherit attribute unrestricted double x;
......
......@@ -7,7 +7,8 @@
[
Constructor(optional unrestricted double x = 0, optional unrestricted double y = 0,
optional unrestricted double z = 0, optional unrestricted double w = 1),
Exposed=(Window,Worker)
Exposed=(Window,Worker),
Serializable
] interface DOMPointReadOnly {
[NewObject] static DOMPointReadOnly fromPoint(optional DOMPointInit other);
......
......@@ -7,7 +7,8 @@
[
Constructor(optional DOMPointInit p1, optional DOMPointInit p2,
optional DOMPointInit p3, optional DOMPointInit p4),
Exposed=(Window,Worker)
Exposed=(Window,Worker),
Serializable
]
interface DOMQuad {
[NewObject] static DOMQuad fromRect(optional DOMRectInit other);
......
......@@ -9,7 +9,8 @@
optional unrestricted double y = 0,
optional unrestricted double width = 0,
optional unrestricted double height = 0),
Exposed=(Window,Worker)
Exposed=(Window,Worker),
Serializable
] interface DOMRect : DOMRectReadOnly {
[NewObject] static DOMRect fromRect(optional DOMRectInit other);
......
......@@ -7,7 +7,8 @@
[
Constructor(optional unrestricted double x = 0, optional unrestricted double y = 0,
optional unrestricted double width = 0, optional unrestricted double height = 0),
Exposed=(Window,Worker)
Exposed=(Window,Worker),
Serializable
] interface DOMRectReadOnly {
[NewObject] static DOMRectReadOnly fromRect(optional DOMRectInit other);
......
......@@ -27,7 +27,7 @@
*/
// https://html.spec.whatwg.org/#dom-imagedata
// https://github.com/junov/CanvasColorSpace/blob/master/CanvasColorSpaceProposal.md#imagedata
// https://github.com/WICG/canvas-color-space/blob/master/CanvasColorSpaceProposal.md#imagedata
typedef (Uint8ClampedArray or Uint16Array or Float32Array) ImageDataArray;
......@@ -35,7 +35,8 @@ typedef (Uint8ClampedArray or Uint16Array or Float32Array) ImageDataArray;
Constructor(unsigned long sw, unsigned long sh),
Constructor(Uint8ClampedArray data, unsigned long sw, optional unsigned long sh),
Exposed=(Window,Worker),
RaisesException=Constructor
RaisesException=Constructor,
Serializable
] interface ImageData {
[RuntimeEnabled=CanvasColorManagement] ImageDataColorSettings getColorSettings();
......
......@@ -2,10 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://html.spec.whatwg.org/#images
// https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#images-2
[
Exposed=(Window,Worker)
Exposed=(Window,Worker),
Serializable,
Transferable
] interface ImageBitmap {
readonly attribute unsigned long width;
readonly attribute unsigned long height;
......
......@@ -25,11 +25,12 @@
*
*/
// https://html.spec.whatwg.org/#message-ports
// https://html.spec.whatwg.org/multipage/web-messaging.html#message-ports
[
ActiveScriptWrappable,
Exposed=(Window,Worker,AudioWorklet)
Exposed=(Window,Worker,AudioWorklet),
Transferable
] interface MessagePort : EventTarget {
[CallWith=ScriptState, RaisesException, Measure] void postMessage(any message, optional sequence<object> transfer = []);
[RuntimeEnabled=PostMessageOptions, CallWith=ScriptState, RaisesException, Measure] void postMessage(any message, PostMessageOptions options);
......
......@@ -7,6 +7,7 @@
[
Constructor([EnforceRange] unsigned long width, [EnforceRange] unsigned long height),
Exposed=(Window,Worker),
Transferable,
RuntimeEnabled=OffscreenCanvas,
MeasureAs=OffscreenCanvas
] interface OffscreenCanvas : EventTarget {
......
......@@ -29,7 +29,7 @@
*/
// https://w3c.github.io/webrtc-pc/#rtccertificate-interface
[Exposed=Window]
[Exposed=Window, Serializable]
interface RTCCertificate {
// The expiration time in ms relative to epoch, 1970-01-01T00:00:00Z.
readonly attribute DOMTimeStamp expires;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment