From cb925ee1fc2325c1cc5f16800fec42f11604b7b0 Mon Sep 17 00:00:00 2001 From: Yoshiki Shibukawa Date: Mon, 9 Sep 2013 01:44:13 -0700 Subject: [PATCH] Add FileSystem, FileWriter API to web.jsx --- idl2jsx/build.pl | 2 + idl2jsx/idl2jsx.pl | 9 + idl2jsx/spec/FileSystemAPI | 1419 ++++++++++++++++++++++++++++++++++++ idl2jsx/spec/FileWriterAPI | 1036 ++++++++++++++++++++++++++ idl2jsx/spec/cssom | 656 +++++++++++------ idl2jsx/spec/cssom-view | 165 +++-- lib/js/js/web.jsx | 313 +++++++- t/lib/010.web.jsx | 272 ++++++- 8 files changed, 3564 insertions(+), 308 deletions(-) create mode 100644 idl2jsx/spec/FileSystemAPI create mode 100644 idl2jsx/spec/FileWriterAPI diff --git a/idl2jsx/build.pl b/idl2jsx/build.pl index 1acee71f..fd79e7e6 100755 --- a/idl2jsx/build.pl +++ b/idl2jsx/build.pl @@ -49,6 +49,8 @@ 'url-whatwg; http://url.spec.whatwg.org/', # e.g. URLUtils 'html5; http://www.w3.org/TR/html5/single-page.html', 'FileAPI; http://www.w3.org/TR/2012/WD-FileAPI-20121025/', + 'FileWriterAPI; http://www.w3.org/TR/2012/WD-file-writer-api-20120417/', + 'FileSystemAPI; http://www.w3.org/TR/2012/WD-file-system-api-20120417/', "webaudio; http://www.w3.org/TR/2012/WD-webaudio-20121213/", "touch-events; http://www.w3.org/TR/touch-events/", diff --git a/idl2jsx/idl2jsx.pl b/idl2jsx/idl2jsx.pl index 0b4b7c68..96fb58f7 100755 --- a/idl2jsx/idl2jsx.pl +++ b/idl2jsx/idl2jsx.pl @@ -128,6 +128,15 @@ # http://www.w3.org/TR/file-system-api/ 'FileCallback' => 'function(:File):void', + # http://www.w3.org/TR/2012/WD-file-system-api-20120417/ + 'FileSystemCallback' => 'function(filesystem:FileSystem):void', + 'EntryCallback' => 'function(entry:Entry):void', + 'EntriesCallback' => 'function(entries:Entry[]):void', + 'MetadataCallback' => 'function(metadata:Metadata):void', + 'FileWriterCallback' => 'function(fileWriter:FileWriter):void', + 'VoidCallback' => 'function():void', + 'ErrorCallback' => 'function(err:DOMError):void', + # http://www.w3.org/TR/2012/WD-mediacapture-streams-20120628/#dictionary-mediatrackconstraints-members # http://datatracker.ietf.org/doc/draft-burnett-rtcweb-constraints-registry/ 'MediaTrackConstraintSet' => 'Map.', diff --git a/idl2jsx/spec/FileSystemAPI b/idl2jsx/spec/FileSystemAPI new file mode 100644 index 00000000..76beb841 --- /dev/null +++ b/idl2jsx/spec/FileSystemAPI @@ -0,0 +1,1419 @@ + + + + File API: Directories and System + + + + + +

W3C

File API: Directories and System

W3C Working Draft 17 April 2012

This version:
http://www.w3.org/TR/2012/WD-file-system-api-20120417/
Latest published version:
http://www.w3.org/TR/file-system-api/
Latest editor's draft:
http://dev.w3.org/2009/dap/file-system/file-dir-sys.html
Previous version:
http://www.w3.org/TR/2011/WD-file-system-api-20110419/
Editor:
Eric Uhrhane, Google
+

+

Abstract

+ This specification defines an API to navigate file system hierarchies, and defines + a means by which a user agent may expose sandboxed sections of a + user's local filesystem to web applications. It builds on + [FILE-WRITER-ED], which in turn built on [FILE-API-ED], each adding a + different kind of functionality. +

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 http://www.w3.org/TR/.

This document was published by the WebApps Working Group as a Working Draft. This document is intended to become a W3C Recommendation. If you wish to make comments regarding this document, please send them to public-webapps@w3.org (subscribe, archives). All feedback is welcome.

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

Table of Contents

+ +

1. Conformance

As well as sections marked as non-normative, all authoring guidelines, diagrams, examples, and notes in this specification are non-normative. Everything else in this specification is normative.

+

The key words must, must not, required, should, should not, recommended, may, and optional in this specification are to be interpreted as described in [RFC2119].

+ +

+ This specification defines conformance criteria that apply to a single + product: a user agent that implements the interfaces that it + contains. +

+
+ +
+

2. Introduction

This section is non-normative.

+

+ This API is intended to satisfy client-side-storage use cases not + well served by databases. These are generally applications that involve + large binary blobs and/or share data with applications outside of the + browser. +

+

+ It is intended to be minimal in extent, but sufficiently powerful that + easy-to-use libraries may be built on top of it. +

+
+

2.1 Use Cases

+
    +
  1. Persistent uploader +
      +
    • When a file or directory is selected for upload, it copies it + into a local sandbox and uploads a chunk at a time.
    • +
    • It can restart uploads after browser crashes, network + interruptions, etc.
    • +
    +
  2. +
  3. Video game or other app with lots of media assets +
      +
    • It downloads one or several large tarballs, and expands them + locally into a directory structure.
    • +
    • The same download should work on any operating system.
    • +
    • It can manage prefetching just the next-to-be-needed assets in + the background, so going to the next game level or activating a new + feature doesn't require waiting for a download.
    • +
    • It uses those assets directly from its local cache, by direct + file reads or by handing local URLs to image or video tags, WebGL + asset loaders, etc.
    • +
    • The files may be of arbitrary binary format.
    • +
    • On the server side, a compressed tarball will often be much + smaller than a collection of separately-compressed files. Also, 1 + tarball instead of 1000 little files will involve fewer seeks, all + else being equal.
    • +
    +
  4. + +
  5. Audio/Photo editor with offline access or local cache for speed +
      +
    • The data blobs are potentially quite large, and are + read-write.
    • +
    • It may want to do partial writes to files (ovewriting just the + ID3/EXIF tags, for example).
    • +
    • The ability to organize project files by creating directories + would be useful.
    • +
    • Edited files should be accessable by client-side applications + [iTunes, Picasa]. +
    +
  6. + +
  7. Offline video viewer +
      +
    • It downloads large files (>1GB) for later viewing.
    • +
    • It needs efficient seek + streaming.
    • +
    • It must be able to hand a URL to the video tag.
    • +
    • It should enable access to partly-downloaded files e.g. to let + you watch the first episode of the DVD even if your download didn't + complete before you got on the plane.
    • +
    • It should be able to pull a single episode out of the middle of + a download and give just that to the video tag.
    • +
    +
  8. + +
  9. Offline Web Mail Client +
      +
    • Downloads attachments and stores them locally.
    • +
    • Caches user-selected attachments for later upload.
    • +
    • Needs to be able to refer to cached attachments and image + thumbnails for display and upload.
    • +
    • Should be able to trigger the UA's download manager just as if + talking to a server.
    • +
    • Should be able to upload an email with attachments as a + multipart post, rather than sending a file at a time in an XHR.
    • +
    +
  10. +
+
+
+

2.2 Examples

+
// In the DOM or worker context:
+
+function useAsyncFS(fs) {
+  // see getAsText example in [FILE-API-ED].
+  fs.root.getFile("already_there.txt", null, function (f) {
+    getAsText(f.file());
+  });
+
+  // But now we can also write to the file; see [FILE-WRITER-ED].
+  fs.root.getFile("logFile", {create: true}, function (f) {
+    f.createWriter(writeDataToLogFile);
+  });
+}
+requestFileSystem(TEMPORARY, 1024 * 1024, function(fs) {
+  useAsyncFS(fs);
+});
+
+// In a worker:
+
+var tempFS = requestFileSystem(TEMPORARY, 1024 * 1024);
+var logFile = tempFS.root.getFile("logFile", {create: true});
+var writer = logFile.createWriter();
+writer.seek(writer.length);
+writeDataToLogFile(writer);
+
+
+
+

3. Terminology

+ +

+ The term throw in this specification, as it pertains to + exceptions, is used as defined in the DOM4 specification [DOM4]. +

+

+ DOMError is defined in the DOM4 specification [DOM4]. +

+

+ File is defined in the File API specification [FILE-API-ED]. +

+

+ FileWriter and FileWriterSync are defined in the + FileWriter specification [FILE-WRITER-ED]. +

+

+
+

4. Data Persistence and accessing the API

+
+

4.1 Temporary vs. Persistent Storage

This section is non-normative.

+

+ An application can request temporary or persistent + storage space. Temporary storage may be easier to get, at the UA's + discretion [looser quota restrictions, available without prompting the + user], but the data stored there may be deleted at the UA's + convenience, e.g. to deal with a shortage of disk space. +

+

+ Conversely, once persistent storage has been granted, data + stored there by the application should not be deleted by the UA + without user intervention. The application may of course delete it at + will. The UA should require permission from the user before granting + persistent storage space to the application. +

+

+ This API specifies the standard origin isolation in a filesystem + context, along with persistence of data across invocations. + Applications will likely use temporary storage for caching, and + if it's still around from a previous session, it is often useful. + Persistent data, on the other hand, is useless if you can't access it + again the next time you're invoked. However, even persistent + data may be deleted manually by the user [either through the UA or via + direct filesystem operations]. +

+
+
+

4.2 Restrictions

+ FileSystem and FileSystemSync objects returned by + requestFileSystem must have the following properties: +
    +
  • The filesystems accessible by any origin must be disjoint from + those accessible by any other origin.
  • +
  • Data stored in a persistent filesystem should not be + deleted by the UA, other than in response to a removal API call, + without explicit authorization from the user.
  • +
  • Data stored in a temporary filesystem may be deleted by + the UA at its discretion, without application or user + intervention.
  • +
  • If +
      +
    1. an application in a given origin requests a persistent + filesystem on multiple occasions;
    2. +
    3. each request is granted;
    4. +
    5. and data from an earlier request still exists in the first + filesystem at the time of a subsequent request.
    6. +
    + then the FileSystem or FileSystemSync returned from + the subsequent request must refer to the same underlying filesystem + and root directory as the previous request.
  • +
  • If +
      +
    1. an application in a given origin requests a temporary + filesystem on multiple occasions;
    2. +
    3. each request is granted;
    4. +
    5. and data from an earlier request still exists in the first + filesystem at the time of a subsequent request.
    6. +
    + then the FileSystem or FileSystemSync returned from + the subsequent request should refer to the same underlying + filesystem and root directory as the previous request.
  • +
+
+
+

4.3 Security Considerations

This section is non-normative.

+

+ Because this API may allow untrusted code to read and write parts of a + user's hard drive, there are a number of security and privacy issues + that must be dealt with. Risks to the user include: +

    +
  • Denial of service by filling a local disk or using up IO + bandwidth. This can be mitigated in part through quota + limitations.
  • +
  • Theft or erasure of private data. This is mitigated by limiting + the scope of access to the local filesystem to a chroot-like, + origin-specific sandbox.
  • +
  • Storing malicious executables or illegal data on a user's + system. This is similar to the risk of any download, and similar + security precautions apply, but is potentially worse in that: +
      +
    • It may involve multiple files.
    • +
    • The files may be in a part of the filesystem that's harder + for the user to find than the standard downloads directory.
    • +
    • The malicious writes may happen long enough after granting + of filesystem access that the user doesn't connect the two + events.
    • +
    + This may be mitigated by restricting file creation/rename to + non-executable extensions, virtualizing paths [leading to + unguessable or non-executable filenames] and by making sure the + execute bit is not set on any file created or modified via the API. +
  • +
+

+

+ As with any other client-side storage, filesystem access allows for + cookie-resurrection attacks. UAs will likely wish to present the + option of clearing it when the user clears any other origin-specific + storage, blocking access to it when cookies are blocked, etc. This is + especially important if temporary storage space is permitted by + default without explicit user permission. +

+
+
+

4.4 Obtaining access to file system entry points

+

+ There are several ways in which a file system entry point can be + obtained. Not all user agents may in fact implement all of + them. However, in order to avoid blocking UI actions while waiting on + filesystem IO, we define only an asynchronous interface for Window, + and restrict the synchronous API to the Worker context defined in + [WEBWORKERS-ED]. +

+
+

4.4.1 Using LocalFileSystem

+
Window implements LocalFileSystem;

All instances of the Window type are defined to also implement the LocalFileSystem interface.

+
WorkerGlobalScope implements LocalFileSystem;

All instances of the WorkerGlobalScope type are defined to also implement the LocalFileSystem interface.

+
[Supplemental, NoInterfaceObject]
+interface LocalFileSystem {
+    const unsigned short TEMPORARY = 0;
+    const unsigned short PERSISTENT = 1;
+    void requestFileSystem (unsigned short type, unsigned long long size, FileSystemCallback successCallback, optional ErrorCallback errorCallback);
+    void resolveLocalFileSystemURL (DOMString url, EntryCallback successCallback, optional ErrorCallback errorCallback);
+};
+
4.4.1.1 Methods
requestFileSystem
+

+ Requests a filesystem in which to store application data. +

+

+ If successful, this function must give access to an + origin-private filesystem, as defined above. +

+ +
ParameterTypeNullableOptionalDescription
typeunsigned short + Whether the filesystem requested should be persistent, + as defined above. Use one of TEMPORARY or + PERSISTENT. +
sizeunsigned long long + This is an indicator of how much storage space, in bytes, the + application expects to need. +
successCallbackFileSystemCallback + The callback that is called when the user agent provides + a filesystem. +
errorCallbackErrorCallback + A callback that is called when errors happen, or when the + request to obtain the filesystem is denied. +
Return type: void
resolveLocalFileSystemURL
+

+ Allows the user to look up the Entry for a file or directory + referred to by a local URL. +

+ +
ParameterTypeNullableOptionalDescription
urlDOMString + A URL referring to a local file in a filesystem accessable via + this API. +
successCallbackEntryCallback + A callback that is called to report the Entry to which the + supplied URL refers. +
errorCallbackErrorCallback + A callback that is called when errors happen, or when the + request to obtain the Entry is denied. +
Return type: void
4.4.1.2 Constants
PERSISTENT of type unsigned short
+ Used for storage that should not be removed by the user + agent without application or user permission. +
TEMPORARY of type unsigned short
+ Used for storage with no guarantee of persistence. +
+
+
+

4.4.2 Using LocalFileSystemSync

+
WorkerGlobalScope implements LocalFileSystemSync;

All instances of the WorkerGlobalScope type are defined to also implement the LocalFileSystemSync interface.

+
[Supplemental, NoInterfaceObject]
+interface LocalFileSystemSync {
+    const unsigned short TEMPORARY = 0;
+    const unsigned short PERSISTENT = 1;
+    FileSystemSync requestFileSystemSync (unsigned short type, unsigned long long size);
+    EntrySync      resolveLocalFileSystemSyncURL (DOMString url);
+};
+
4.4.2.1 Methods
requestFileSystemSync
+

+ Requests a filesystem in which to store application data. +

+

+ If successful, this function must give access to an + origin-private filesystem, as defined above. +

+ +
ParameterTypeNullableOptionalDescription
typeunsigned short + Whether the filesystem requested should be persistent, + as defined above. Use one of TEMPORARY or + PERSISTENT. +
sizeunsigned long long + This is an indicator of how much storage space, in bytes, the + application expects to need. +
Return type: FileSystemSync
resolveLocalFileSystemSyncURL
+

+ Allows the user to look up the Entry for a file or directory + referred to by a local URL. +

+ +
ParameterTypeNullableOptionalDescription
urlDOMString + A URL referring to a local file in a filesystem accessable via + this API. +
Return type: EntrySync
4.4.2.2 Constants
PERSISTENT of type unsigned short
+ Used for storage that should not be removed by the user + agent without application or user permission. +
TEMPORARY of type unsigned short
+ Used for storage with no guarantee of persistence. +
+
+
+
+ +
+

5. Shared data types

+
+

5.1 The Metadata interface

+

+ This interface supplies information about the state of a file or + directory. +

+
interface Metadata {
+    readonly attribute Date               modificationTime;
+    readonly attribute unsigned long long size;
+};
+

5.1.1 Attributes

modificationTime of type Date, readonly
+ This is the time at which the file or directory was last modified. +
size of type unsigned long long, readonly
+ The size of the file, in bytes. This must return 0 for directories. +
+
+
+

5.2 The Flags dictionary

+

+ This dictionary is used to supply arguments to methods that look up or + create files or directories. +

+
dictionary Flags {
+    boolean create;
+    boolean exclusive;
+};
+

5.2.1 Dictionary Flags Members

create of type boolean
+ Used to indicate that the user wants to create a file or directory + if it was not previously there. +
exclusive of type boolean
+ By itself, exclusive must have no effect. Used with + create, it must cause getFile and getDirectory to + fail if the target path already exists. +
+
+

5.2.2 Examples

This section is non-normative.

+
// Get the data directory, creating it if it doesn't exist.
+dataDir = fsSync.root.getDirectory("data", {create: true});
+
+// Create the lock file, if and only if it doesn't exist.
+try {
+  lockFile = dataDir.getFile("lockfile.txt",
+                             {create: true, exclusive: true});
+} catch (ex) {
+  // It already exists, or something else went wrong.
+  ...
+}
+
+
+
+ +
+

6. The asynchronous filesystem interface

+
+

6.1 The FileSystem interface

+

+ This interface represents a file system. +

+
interface FileSystem {
+    readonly attribute DOMString      name;
+    readonly attribute DirectoryEntry root;
+};
+

6.1.1 Attributes

name of type DOMString, readonly
+ This is the name of the file system. The specifics of naming + filesystems is unspecified, but a name must be unique across the + list of exposed file systems. +
root of type DirectoryEntry, readonly
+ The root directory of the file system. +
+
+ +
+

6.2 The Entry interface

+

+ An abstract interface representing entries in a file system, each of + which may be a File or DirectoryEntry. +

+
interface Entry {
+    readonly attribute boolean    isFile;
+    readonly attribute boolean    isDirectory;
+    void      getMetadata (MetadataCallback successCallback, optional ErrorCallback errorCallback);
+    readonly attribute DOMString  name;
+    readonly attribute DOMString  fullPath;
+    readonly attribute FileSystem filesystem;
+    void      moveTo (DirectoryEntry parent, optional DOMString newName, optional EntryCallback successCallback, optional ErrorCallback errorCallback);
+    void      copyTo (DirectoryEntry parent, optional DOMString newName, optional EntryCallback successCallback, optional ErrorCallback errorCallback);
+    DOMString toURL ();
+    void      remove (VoidCallback successCallback, optional ErrorCallback errorCallback);
+    void      getParent (EntryCallback successCallback, optional ErrorCallback errorCallback);
+};
+

6.2.1 Attributes

filesystem of type FileSystem, readonly
+ The file system on which the entry resides. +
fullPath of type DOMString, readonly
+ The full absolute path from the root to the entry. +
isDirectory of type boolean, readonly
+ Entry is a directory. +
isFile of type boolean, readonly
+ Entry is a file. +
name of type DOMString, readonly
+ The name of the entry, excluding the path leading to it. +

6.2.2 Methods

copyTo
+

+ Copy an entry to a different location on the file system. + It is an error to try to: +

    +
  • copy a directory inside itself or to any child at any + depth;
  • +
  • copy an entry into its parent if a name different from its + current one isn't provided;
  • +
  • copy a file to a path occupied by a directory;
  • +
  • copy a directory to a path occupied by a file;
  • +
  • copy any element to a path occupied by a directory which is + not empty.
  • +
+ A copy of a file on top of an existing file must attempt to + delete and replace that file.
+ A copy of a directory on top of an existing empty directory must + attempt to delete and replace that directory.
+ Directory copies are always recursive--that is, they copy all + contents of the directory. +

+ +
ParameterTypeNullableOptionalDescription
parentDirectoryEntry + The directory to which to move the entry. +
newNameDOMString + The new name of the entry. Defaults to the Entry's current name + if unspecified. +
successCallbackEntryCallback + A callback that is called with the Entry for the new object. +
errorCallbackErrorCallback + A callback that is called when errors happen. +
Return type: void
getMetadata
+

+ Look up metadata about this entry. +

+ +
ParameterTypeNullableOptionalDescription
successCallbackMetadataCallback + A callback that is called with the time of the last + modification. +
errorCallbackErrorCallback + A callback that is called when errors happen. +
Return type: void
getParent
+ Look up the parent DirectoryEntry containing this Entry. If this + Entry is the root of its filesystem, its parent is itself. + +
ParameterTypeNullableOptionalDescription
successCallbackEntryCallback + A callback that is called to return the parent Entry. +
errorCallbackErrorCallback + A callback that is called when errors happen. +
Return type: void
moveTo
+

+ Move an entry to a different location on the file system. + It is an error to try to: +

    +
  • move a directory inside itself or to any child at any + depth;
  • +
  • move an entry into its parent if a name different from its + current one isn't provided;
  • +
  • move a file to a path occupied by a directory;
  • +
  • move a directory to a path occupied by a file;
  • +
  • move any element to a path occupied by a directory which is + not empty.
  • +
+ A move of a file on top of an existing file must attempt to + delete and replace that file.
+ A move of a directory on top of an existing empty directory must + attempt to delete and replace that directory. +

+ +
ParameterTypeNullableOptionalDescription
parentDirectoryEntry + The directory to which to move the entry. +
newNameDOMString + The new name of the entry. Defaults to the Entry's current name + if unspecified. +
successCallbackEntryCallback + A callback that is called with the Entry for the new location. +
errorCallbackErrorCallback + A callback that is called when errors happen. +
Return type: void
remove
+

+ Deletes a file or directory. It is an error to attempt to delete + a directory that is not empty. It is an error to attempt to + delete the root directory of a filesystem. +

+ +
ParameterTypeNullableOptionalDescription
successCallbackVoidCallback + A callback that is called on success. +
errorCallbackErrorCallback + A callback that is called when errors happen. +
Return type: void
toURL
+

+ Returns a URL that can be used to identify this entry. + Unlike the URN defined in [FILE-API-ED], it has no specific + expiration; as it describes a location on disk, it should be valid + at least as long as that location exists. +

+
+

+ Do we want to spec out the URL format/scheme? It would be quite + nice if these could be edited and manipulated easily, as with + normal filesystem paths. +

+

+ How and where can these URLs be used? Can they be interchangeable + with online URLs for the same domain? +

+

+ Proposal currently under discussion: +

    +
  • Use a format such as + filesystem:http://example.domain/persistent-or-temporary/path/to/file.html.
  • +
  • URLs should be usable for anything that online URLs can be + used for, whether they appear in online or filesystem-resident + web pages.
  • +
  • However, they can only be used by the origin that owns the + filesystem. No other origin can e.g. reference another origin's + filesystem in an IMG tag.
  • +
+

+
+
No parameters.
Return type: DOMString
+
+ +
+

6.3 The DirectoryEntry interface

+

+ This interface represents a directory on a file system. +

+
interface DirectoryEntry : Entry {
+    DirectoryReader createReader ();
+    void            getFile (DOMString path, optional Flags options, optional EntryCallback successCallback, optional ErrorCallback errorCallback);
+    void            getDirectory (DOMString path, optional Flags options, optional EntryCallback successCallback, optional ErrorCallback errorCallback);
+    void            removeRecursively (VoidCallback successCallback, optional ErrorCallback errorCallback);
+};
+

6.3.1 Methods

createReader
+

+ Creates a new DirectoryReader to read Entries from this Directory. +

+
No parameters.
Return type: DirectoryReader
getDirectory
+

+ Creates or looks up a directory. +

+ +
ParameterTypeNullableOptionalDescription
pathDOMString + Either an absolute path or a relative path from + this DirectoryEntry to the directory to be looked up or created. + It is an error to attempt to create a directory whose immediate + parent does not yet exist. +
optionsFlags +
    +
  • If create and exclusive are both + true and the path already exists, getDirectory must fail.
  • +
  • If create is true, the path doesn't exist, + and no other error occurs, getDirectory must create and return + a corresponding DirectoryEntry.
  • +
  • If create is not true and the path doesn't + exist, getDirectory must fail.
  • +
  • If create is not true and the path exists, + but is a file, getDirectory must fail.
  • +
  • Otherwise, if no other error occurs, getDirectory must + return a DirectoryEntry corresponding to path.
  • +
+
successCallbackEntryCallback + A callback that is called to return the DirectoryEntry selected + or created. +
errorCallbackErrorCallback + A callback that is called when errors happen. +
Return type: void
getFile
+

+ Creates or looks up a file. +

+ +
ParameterTypeNullableOptionalDescription
pathDOMString + Either an absolute path or a relative path from + this DirectoryEntry to the file to be looked up or created. It + is an error to attempt to create a file whose immediate parent + does not yet exist. +
optionsFlags +
    +
  • If create and exclusive are both + true, and the path already exists, getFile must fail.
  • +
  • If create is true, the path doesn't exist, + and no other error occurs, getFile must create it as a + zero-length file and return a corresponding FileEntry.
  • +
  • If create is not true and the path doesn't + exist, getFile must fail.
  • +
  • If create is not true and the path exists, + but is a directory, getFile must fail.
  • +
  • Otherwise, if no other error occurs, getFile must + return a FileEntry corresponding to path.
  • +
+
successCallbackEntryCallback + A callback that is called to return the File selected or + created. +
errorCallbackErrorCallback + A callback that is called when errors happen. +
Return type: void
removeRecursively
+

+ Deletes a directory and all of its contents, if any. In the event + of an error [e.g. trying to delete a directory that contains a + file that cannot be removed], some of the contents of the + directory may be deleted. It is an error to attempt to delete the + root directory of a filesystem. +

+ +
ParameterTypeNullableOptionalDescription
successCallbackVoidCallback + A callback that is called on success. +
errorCallbackErrorCallback + A callback that is called when errors happen. +
Return type: void
+
+ +
+

6.4 The DirectoryReader interface

+

+ This interface lets a user list files and directories in a directory. + If there are no additions to or deletions from a directory between the + first and last call to readEntries, and no errors occur, then: +

    +
  • A series of calls to readEntries must return each entry in the + directory exactly once.
  • +
  • Once all entries have been returned, the next call to + readEntries must produce an empty array.
  • +
  • If not all entries have been returned, the array produced by + readEntries must not be empty.
  • +
  • The entries produced by readEntries must not include the + directory itself ["."] or its parent [".."].
  • +
+

+
interface DirectoryReader {
+    void readEntries (EntriesCallback successCallback, optional ErrorCallback errorCallback);
+};
+

6.4.1 Methods

readEntries
+

+ Read the next block of entries from this directory. +

+ +
ParameterTypeNullableOptionalDescription
successCallbackEntriesCallback + Called once per successful call to readEntries to deliver the + next previously-unreported set of Entries in the associated + Directory. If all Entries have already been returned from + previous invocations of readEntries, successCallback must be + called with a zero-length array as an argument. +
errorCallbackErrorCallback + A callback indicating that there was an error reading from the + Directory. +
Return type: void
+
+ +
+

6.5 The FileEntry interface

+

+ This interface represents a file on a file system. +

+
interface FileEntry : Entry {
+    void createWriter (FileWriterCallback successCallback, optional ErrorCallback errorCallback);
+    void file (FileCallback successCallback, optional ErrorCallback errorCallback);
+};
+

6.5.1 Methods

createWriter
+

+ Creates a new FileWriter associated with the file + that this FileEntry represents. +

+ +
ParameterTypeNullableOptionalDescription
successCallbackFileWriterCallback + A callback that is called with the new FileWriter. +
errorCallbackErrorCallback + A callback that is called when errors happen. +
Return type: void
file
+

+ Returns a File that represents the current state of + the file that this FileEntry represents. +

+ +
ParameterTypeNullableOptionalDescription
successCallbackFileCallback + A callback that is called with the File. +
errorCallbackErrorCallback + A callback that is called when errors happen. +
Return type: void
+
+ +
+

6.6 Callbacks

+

+ Several calls in this API are asynchronous, and use callbacks. +

+ +
+

6.6.1 The FileSystemCallback interface

+

+ When requestFileSystem() succeeds, the following + callback is made: +

+
[Callback=FunctionOnly]
+interface FileSystemCallback {
+    void handleEvent (FileSystem filesystem);
+};
+
6.6.1.1 Methods
handleEvent
+

+ The file system was successfully obtained. +

+ +
ParameterTypeNullableOptionalDescription
filesystemFileSystem + The file systems to which the app is granted access. +
Return type: void
+
+ +
+

6.6.2 The EntryCallback interface

+

+ This interface is the callback used to look up Entry objects. +

+
[Callback=FunctionOnly]
+interface EntryCallback {
+    void handleEvent (Entry entry);
+};
+
6.6.2.1 Methods
handleEvent
+ Used to supply an Entry as a response to a user query. +
ParameterTypeNullableOptionalDescription
entryEntry
Return type: void
+
+ +
+

6.6.3 The EntriesCallback interface

+

+ When readEntries() succeeds, the following callback is + made. +

+
[Callback=FunctionOnly]
+interface EntriesCallback {
+    void handleEvent (Entry[] entries);
+};
+
6.6.3.1 Methods
handleEvent
+ Used to supply an array of Entries as a response to a user query. +
ParameterTypeNullableOptionalDescription
entriesEntry[]
Return type: void
+
+ +
+

6.6.4 The MetadataCallback interface

+

+ This interface is the callback used to look up file and directory + metadata. +

+
[Callback=FunctionOnly]
+interface MetadataCallback {
+    void handleEvent (Metadata metadata);
+};
+
6.6.4.1 Methods
handleEvent
+

+ Used to supply file or directory metadata as a response to a + user query. +

+
ParameterTypeNullableOptionalDescription
metadataMetadata
Return type: void
+
+ +
+

6.6.5 The FileWriterCallback interface

+

+ This interface is the callback used to create a + FileWriter. +

+
[Callback=FunctionOnly]
+interface FileWriterCallback {
+    void handleEvent (FileWriter fileWriter);
+};
+
6.6.5.1 Methods
handleEvent
+

+ Used to supply a FileWriter as a response to a user + query. +

+
ParameterTypeNullableOptionalDescription
fileWriterFileWriter
Return type: void
+
+ +
+

6.6.6 The FileCallback interface

+

+ This interface is the callback used to obtain a File. +

+
[Callback=FunctionOnly]
+interface FileCallback {
+    void handleEvent (File file);
+};
+
6.6.6.1 Methods
handleEvent
+

+ Used to supply a File as a response to a user query. +

+
ParameterTypeNullableOptionalDescription
fileFile
Return type: void
+
+ +
+

6.6.7 The VoidCallback interface

+

+ This interface is the generic callback used to indicate success of + an asynchronous method. +

+
[Callback=FunctionOnly]
+interface VoidCallback {
+    void handleEvent ();
+};
+
6.6.7.1 Methods
handleEvent
+
No parameters.
Return type: void
+
+ +
+

6.6.8 The ErrorCallback interface

+

+ When an error occurs, the following callback is made: +

+
[Callback=FunctionOnly]
+interface ErrorCallback {
+    void handleEvent (DOMError err);
+};
+
6.6.8.1 Methods
handleEvent
+

+ There was an error with the request. Details are provided by the + err parameter. +

+ +
ParameterTypeNullableOptionalDescription
errDOMError + The error that was generated. +
Return type: void
+
+
+
+
+

7. The synchronous filesystem interface

+
+

7.1 The FileSystemSync interface

+

+ This interface represents a file system. +

+
interface FileSystemSync {
+    readonly attribute DOMString          name;
+    readonly attribute DirectoryEntrySync root;
+};
+

7.1.1 Attributes

name of type DOMString, readonly
+ This is the name of the file system. The specifics of naming + filesystems is unspecified, but a name must be unique across the + list of exposed file systems. +
root of type DirectoryEntrySync, readonly
+ The root directory of the file system. +
+
+ +
+

7.2 The EntrySync interface

+

+ An abstract interface representing entries in a file system, each of + which may be a FileEntrySync or DirectoryEntrySync. +

+ Some have requested support for archive files. I've not required + that, but I've left space for it by not ruling out having both + isFile and isDirectory be true. I welcome comments on this + approach. +
+

+
interface EntrySync {
+    readonly attribute boolean        isFile;
+    readonly attribute boolean        isDirectory;
+    Metadata           getMetadata ();
+    readonly attribute DOMString      name;
+    readonly attribute DOMString      fullPath;
+    readonly attribute FileSystemSync filesystem;
+    EntrySync          moveTo (DirectoryEntrySync parent, optional DOMString newName);
+    EntrySync          copyTo (DirectoryEntrySync parent, optional DOMString newName);
+    DOMString          toURL ();
+    void               remove ();
+    DirectoryEntrySync getParent ();
+};
+

7.2.1 Attributes

filesystem of type FileSystemSync, readonly
+ The file system on which the entry resides. +
fullPath of type DOMString, readonly
+ The full absolute path from the root to the entry. +
isDirectory of type boolean, readonly
+ EntrySync is a directory. +
isFile of type boolean, readonly
+ EntrySync is a file. +
name of type DOMString, readonly
+ The name of the entry, excluding the path leading to it. +

7.2.2 Methods

copyTo
+

+ Copy an entry to a different location on the file system. + It is an error to try to: +

    +
  • copy a directory inside itself or to any child at any + depth;
  • +
  • copy an entry into its parent if a name different from its + current one isn't provided;
  • +
  • copy a file to a path occupied by a directory;
  • +
  • copy a directory to a path occupied by a file;
  • +
  • copy any element to a path occupied by a directory which is + not empty.
  • +
+ A copy of a file on top of an existing file must attempt to + delete and replace that file.
+ A copy of a directory on top of an existing empty directory must + attempt to delete and replace that directory.
+ Directory copies are always recursive--that is, they copy all + contents of the directory. +

+ +
ParameterTypeNullableOptionalDescription
parentDirectoryEntrySync + The directory to which to move the entry. +
newNameDOMString + The new name of the entry. Defaults to the EntrySync's current + name if unspecified. +
Return type: EntrySync
getMetadata
+

+ Look up metadata about this entry. +

+
No parameters.
Return type: Metadata
getParent
+ Look up the parent DirectoryEntrySync containing this Entry. If + this EntrySync is the root of its filesystem, its parent is itself. +
No parameters.
Return type: DirectoryEntrySync
moveTo
+

+ Move an entry to a different location on the file system. + It is an error to try to: +

    +
  • move a directory inside itself or to any child at any + depth;
  • +
  • move an entry into its parent if a name different from its + current one isn't provided;
  • +
  • move a file to a path occupied by a directory;
  • +
  • move a directory to a path occupied by a file;
  • +
  • move any element to a path occupied by a directory which is + not empty.
  • +
+ A move of a file on top of an existing file must attempt to + delete and replace that file. + A move of a directory on top of an existing empty directory must + attempt to delete and replace that directory. +

+ +
ParameterTypeNullableOptionalDescription
parentDirectoryEntrySync + The directory to which to move the entry. +
newNameDOMString + The new name of the entry. Defaults to the EntrySync's current + name if unspecified. +
Return type: EntrySync
remove
+

+ Deletes a file or directory. It is an error to attempt to delete + a directory that is not empty. It is an error to attempt to + delete the root directory of a filesystem. +

+
No parameters.
Return type: void
toURL
+

+ Returns a URL that can be used to identify this entry. + Unlike the URN defined in [FILE-API-ED], it has no specific + expiration; as it describes a location on disk, it should be valid + at least as long as that location exists. +

+
No parameters.
Return type: DOMString
+
+ +
+

7.3 The DirectoryEntrySync interface

+

+ This interface represents a directory on a file system. +

+
interface DirectoryEntrySync : EntrySync {
+    DirectoryReaderSync createReader ();
+    FileEntrySync       getFile (DOMString path, optional Flags options);
+    DirectoryEntrySync  getDirectory (DOMString path, optional Flags options);
+    void                removeRecursively ();
+};
+

7.3.1 Methods

createReader
+

+ Creates a new DirectoryReaderSync to read EntrySyncs from this + DirectorySync. +

+
No parameters.
Return type: DirectoryReaderSync
getDirectory
+

+ Creates or looks up a directory. +

+ +
ParameterTypeNullableOptionalDescription
pathDOMString + Either an absolute path or a relative path from + this DirectoryEntrySync to the directory to be looked up or + created. It is an error to attempt to create a directory whose + immediate parent does not yet exist. +
optionsFlags +
    +
  • If create and exclusive are both + true and the path already exists, getDirectory must fail.
  • +
  • If create is true, the path doesn't exist, + and no other error occurs, getDirectory must create and return + a corresponding DirectoryEntry.
  • +
  • If create is not true and the path doesn't + exist, getDirectory must fail.
  • +
  • If create is not true and the path exists, + but is a file, getDirectory must fail.
  • +
  • Otherwise, if no other error occurs, getDirectory must + return a DirectoryEntrySync corresponding to path.
  • +
+
Return type: DirectoryEntrySync
getFile
+

+ Creates or looks up a file. +

+ +
ParameterTypeNullableOptionalDescription
pathDOMString + Either an absolute path or a relative path from + this DirectoryEntrySync to the file to be looked up or created. + It is an error to attempt to create a file whose immediate + parent does not yet exist. +
optionsFlags +
    +
  • If create and exclusive are both + true and the path already exists, getFile must fail.
  • +
  • If create is true, the path doesn't exist, + and no other error occurs, getFile must create it as a + zero-length file and return a corresponding FileEntry.
  • +
  • If create is not true and the path doesn't + exist, getFile must fail.
  • +
  • If create is not true and the path exists, + but is a directory, getFile must fail.
  • +
  • Otherwise, if no other error occurs, getFile must + return a FileEntrySync corresponding to path.
  • +
+
Return type: FileEntrySync
removeRecursively
+

+ Deletes a directory and all of its contents, if any. In the event + of an error [e.g. trying to delete a directory that contains a + file that cannot be removed], some of the contents of the + directory may be deleted. It is an error to attempt to delete the + root directory of a filesystem. +

+
No parameters.
Return type: void
+
+ +
+

7.4 The DirectoryReaderSync interface

+

+ This interface lets a user list files and directories in a directory. + If there are no additions to or deletions from a directory between the + first and last call to readEntries, and no errors occur, then: +

    +
  • A series of calls to readEntries must return each entry in the + directory exactly once.
  • +
  • Once all entries have been returned, the next call to + readEntries must produce an empty array.
  • +
  • If not all entries have been returned, the array produced by + readEntries must not be empty.
  • +
  • The entries produced by readEntries must not include the + directory itself ["."] or its parent [".."].
  • +
+

+
interface DirectoryReaderSync {
+    EntrySync[] readEntries ();
+};
+

7.4.1 Methods

readEntries
+

+ Read the next block of entries from this directory. +

+
No parameters.
Return type: EntrySync[]
+
+ +
+

7.5 The FileEntrySync interface

+

+ This interface represents a file on a file system. +

+
interface FileEntrySync : EntrySync {
+    FileWriterSync createWriter ();
+    File           file ();
+};
+

7.5.1 Methods

createWriter
+

+ Creates a new FileWriterSync associated with the file + that this FileEntrySync represents. +

+
No parameters.
Return type: FileWriterSync
file
+

+ Returns a File that represents the current state of + the file that this FileEntrySync represents. +

+
No parameters.
Return type: File
+
+
+ +
+

8. Errors and Exceptions

+
+

8.1 Occurrence

This section is non-normative.

+

+ Error conditions can occur when attempting to write files. The list + below of potential error conditions is informative, with links to + normative descriptions of errors: +

+

+ An operation on a file may fail due to the file [or a parent directory] + having been removed before the operation is attempted. See + NotFoundError. +

+

+ An operation on a file may not make sense, e.g. moving a directory into + one of its own children. See InvalidModificationError. +

+

+ An operation on a file may not make sense if the underlying filesystem + has had changes made since the reference was obtained. See + TypeMismatchError, InvalidStateError. +

+

+ Users may accidentally attempt to create a file where another already + exists. See PathExistsError. +

+
+
+

8.2 Definitions

+

+ Synchronous methods must throw an exception of the + most appropriate type in the table below if there has been an error with + writing. +

+

+ If an error occurs while processing an asynchronous method, + the err argument to the ErrorCallback must + be a DOMError object [DOM4] of the most appropriate + type from the table below. +

+

Error Descriptions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameDescription
EncodingError + A path or URL supplied to the API was malformed. +
InvalidModificationError + The modification requested was illegal. Examples of invalid + modifications include moving a directory into its own child, + moving a file into its parent directory without changing its + name, or copying a directory to a path occupied by a file. +
InvalidStateError + An operation depended on state cached in an interface object, + but that state that has changed since it was read from disk. +
+ Which values will actually go stale? Modification + time, name, more rarely type. If an atomic save [replacing + a file with a new one of the same name] happens underneath, + should we even be required to notice? +
+
NotFoundError + A required file or directory could not be found at the time an + operation was processed. +
NotReadableErr + A required file or directory could be read. +
NoModificationAllowedError + The user attempted to write to a file or directory + which could not be modified due to the state of the underlying + filesystem. +
PathExistsError + The user agent failed to create a file or directory due + to the existence of a file or directory with the same path. +
QuotaExceededError + The operation failed because it would cause the application to + exceed its storage quota. +
SecurityError +
    +
  • A required file was unsafe for access within a Web + application
  • +
  • Too many calls are being made on filesystem + resources
  • +
+ This is a security error code to be used in situations not + covered by any other error codes. +
TypeMismatchError + The user has attempted to look up a file or directory, but the + Entry found is of the wrong type [e.g. is a DirectoryEntry + when the user requested a FileEntry]. +
+
+
+ +
+

9. Uniformity of interface

+
+

+ In order to make it easy for web app developers to write portable + applications that work on all platforms, we enforce certain restrictions + and make certain guarantees with respect to paths used in this API. +

This section is non-normative.

+
+ The implementation must refuse to create any file or directory whose name + or existence would violate these rules. The implementation must not + accept a noncompliant path where it designates the new name of a file or + directory to be moved, copied, or created. +

+
+

9.1 Case-sensitivity

+

+ Paths in this filesystem must be case sensitive and case-preserving. +

+
+
+

9.2 Encoding

+

+ Implementations must accept any valid UTF-8 sequence + as a path segment, so long as it does not include any characters + or sequences restricted below. When returning paths or path segments, + implementations must return them in the same normalization in which + they were presented. +

+
+
+

9.3 Naming restrictions

+

File and directory names must not contain either of the following + characters: +

    +
  • '/' (U+002F)
  • +
  • NUL (U+0000)
  • +
+
+

+ There's been discussion on whether backslash '\' (U+005c) should be + disallowed or not. In favor of leaving it in is that it's a legal + character on some filesystems, and it seems somewhat arbitrary to + remove it. Opposed is that it may cause confusion, and in at least + some cases complicates implementation. +

+
+

+
+
+

9.4 Directories

+

+ The directory separator is '/' (U+002F). +

+

+ The character '/', when it is the first character in a path, refers to + the root directory. +

+

+ All absolute paths begin with '/'; no relative paths begin with '/'. +

+

+ A relative path describes how to get from a particular + directory to a file or directory. All methods that accept paths are on + DirectoryEntry or DirectoryEntrySync objects; the paths, + if relative, are interpreted as being relative to the directories + represented by these objects. +

+

+ An absolute path is a relative path from the root + directory, prepended with a '/'. +

+

+ '.', when used where it is legal to use a directory name, refers to the + currently-referenced directory. Thus 'foo/./bar' is equivalent to + 'foo/bar', and './foo' is equivalent to 'foo'. +

+

+ '..', when used where it is legal to use a directory name, refers to the + parent of the currently-referenced directory. Thus, 'foo/..' refers to + the directory containing 'foo', and '../foo' refers to an element named + 'foo' in the parent of the directory on whose DirectoryEntry or + DirectoryEntrySync the method receiving the path is being called. +

+
+
+

+ What about path and path segment lengths? Should we limit them at + all? It's hard to control the true length of a path, due to + renames of parent directories, so we really just want to reject the + obviously-too-long; they won't often really come up anyway. + We should at least provide minimum lengths for paths and segments. +

+

+ Should we limit the number of elements in a directory? +

+
+
+
+

A. Acknowledgements

+

+ Thanks to Arun Ranganathan for his File API, Opera for theirs, and Robin + Berjon both for his work on various file APIs and for ReSpec. +

+
+ + +

B. References

B.1 Normative references

[DOM4]
Anne van Kesteren; Aryeh Gregor; Ms2ger. DOM4. 5 January 2012. W3C Working Draft. (Work in progress.) URL: http://www.w3.org/TR/2012/WD-dom-20120105/ +
[FILE-API-ED]
Arun Ranganathan; Jonas Sicking. File API. W3C Editor's Draft. (Work in progress.) URL: http://dev.w3.org/2006/webapi/FileAPI/ +
[FILE-WRITER-ED]
Eric Uhrhane. File Writer API. W3C Editor's Draft. (Work in progress.) URL: http://dev.w3.org/2009/dap/file-system/file-writer.html +
[RFC2119]
S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Internet RFC 2119. URL: http://www.ietf.org/rfc/rfc2119.txt +
[WEBWORKERS-ED]
Ian Hickson. Web Workers. W3C Editor's Draft. (Work in progress.) URL: http://dev.w3.org/html5/workers/ +

B.2 Informative references

No informative references.

diff --git a/idl2jsx/spec/FileWriterAPI b/idl2jsx/spec/FileWriterAPI new file mode 100644 index 00000000..ac98cb21 --- /dev/null +++ b/idl2jsx/spec/FileWriterAPI @@ -0,0 +1,1036 @@ + + + + File API: Writer + + + + + +

W3C

File API: Writer

W3C Working Draft 17 April 2012

This version:
http://www.w3.org/TR/2012/WD-file-writer-api-20120417/
Latest published version:
http://www.w3.org/TR/file-writer-api/
Latest editor's draft:
http://dev.w3.org/2009/dap/file-system/file-writer.html
Previous version:
http://www.w3.org/TR/2011/WD-file-writer-api-20110419/
Editor:
Eric Uhrhane, Google
+

+

Abstract

+

+ This specification defines an API for writing to files from web applications. + This API is designed to be used in conjunction with, and depends on + definitions in, other APIs and elements on the web platform. Most + relevant among these are [FILE-API-ED] and [WEBWORKERS-ED]. +

+

+ This API includes: +

    +
  • A BlobBuilder interface, which enables one to build a + Blob from a String. +
  • A FileSaver interface, which provides methods to write a + Blob to a file, and an event model to monitor the + progress of those writes.
  • +
  • A FileWriter interface, which expands on FileSaver to add + a richer set of output options.
  • +
  • A FileWriterSync interface, which provides methods to + write and modify files synchronously in a Web Worker.
  • +
+

+

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 http://www.w3.org/TR/.

+

This document represents the early consensus of the group on + the scope and features of the proposed File API: Writer. Issues and + editors notes in the document highlight some of + the points on which the group is still working and would + particularly like to get feedback.

+

This document was published by the WebApps Working Group as a Working Draft. This document is intended to become a W3C Recommendation. If you wish to make comments regarding this document, please send them to public-webapps@w3.org (subscribe, archives). All feedback is welcome.

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

+ + + +

1. Conformance

As well as sections marked as non-normative, all authoring guidelines, diagrams, examples, and notes in this specification are non-normative. Everything else in this specification is normative.

+

The key words must, must not, required, should, should not, recommended, may, and optional in this specification are to be interpreted as described in [RFC2119].

+ +

+ This specification defines conformance criteria that apply to a single + product: user agents that implement the interfaces that it + contains. +

+ +

+ Everything in this specification is normative except for examples and + sections marked as being informative. +

+ +

+ The keywords must, must not, required, shall, shall not, should, should + not, recommended, may, and optional in this document are to be + interpreted as described in Key words for use in RFCs to + Indicate Requirement Levels [RFC2119]. +

+ +

+ The following conformance classes are defined by this specification: +

+
conforming implementation
+
+

+ A user agent is considered to be a conforming + implementation if it satisfies all of the must-, required- and + shall-level criteria in this specification that apply to + implementations. +

+
+
+

+
+ +
+

2. Terminology and Algorithms

+

+ The terms and algorithms event handler attributes, event + handler event types, Function, task, + task queue, task source, and queue a + task are defined by the HTML 5 specification [HTML5]. +

+

+ When this specification refers to a write method, it includes + both write and truncate. +

+

+ When this specification refers to a write algorithm, it + includes the algorithm invoked by any write method as well as the + FileSaver write algorithm. +

+

+ When this specification says to terminate an algorithm the + user agent must terminate the algorithm after finishing the step it is + on. Any write algorithm defined in this specification can be + terminated by an abort() call. +

+

+ When this specification says to make progress notifications, + the following are normative: +

    +
  • While the write method is processing, queue a task + to fire a progress event called progress at the + FileSaver object about every 50ms or for every byte written, + whichever is less frequent.
  • +
  • At least one event called progress + must fire before write is fired, and at 100% completion + of the write operation; if 100% of the file can written in less than + 50ms, user agents must fire a progress event called + progress at completion.
  • +
+

+

+ When this specification says to fire a progress event called + e (for some ProgressEvent e), the + following are normative: +

    +
  • The progress event e does not bubble. + e.bubbles must be false [DOM4].
  • +
  • The progress event e is NOT cancelable. + e.cancelable must be false [DOM4].
  • +
  • The term "fire an event" is defined in DOM4 [DOM4]. + Progress events are defined in Progress Events + [PROGRESS-EVENTS-ED].
  • +
+

+ The term throw in this specification, as it pertains to + exceptions, is used as defined in the DOM4 specification [DOM4]. +

+

+

+ The term Blob is defined by the File API specification + [FILE-API-ED]. +

+

+ The term ArrayBuffer is defined by the Typed Arrays + specification [TYPED-ARRAYS]. +

+

+ This specification includes algorithms (steps) as part of the definition + of methods. Conforming implementations (referred to as user + agents from here on) may use other algorithms in the + implementation of these methods, provided the end result is the same. +

+
+ +
+

3. Introduction

This section is non-normative.

+

+ Web applications are currently fairly limited in how they can write to + files. One can present a link for download, but creating and writing + files of arbitrary type, or modifying downloaded files on their way to + the disk, is difficult or impossible. This specification defines an + API through which user agents can permit applications to write + generated or downloaded files. +

+

+ The [FILE-API-ED] defined interfaces for reading files, manipulation + of Blobs of data, and errors raised by file accesses. This + specification extends that work with a way to construct Blobs and + with synchronous and asynchronous file-writing interfaces. As with + reading, writing files on the main thread should happen asynchronously + to avoid blocking UI actions. Long-running writes provide status + information through delivery of progress events. +

+
+

3.1 Examples

+

+ Here is a simple function that writes a text file, given a FileWriter: +

+
function writeFile(writer) {
+  function done(evt) {
+    alert("Write completed.");
+  }
+  function error(evt) {
+    alert("Write failed:" + evt);
+  }
+
+  var bb = new BlobBuilder();
+  bb.append("Lorem ipsum");
+  writer.onwrite = done;
+  writer.onerror = error;
+  writer.write(bb.getBlob());
+}
+

+ Here's an example of obtaining and using a FileSaver: +

+
var bb = new BlobBuilder();
+bb.append("Lorem ipsum");
+var fileSaver = window.saveAs(bb.getBlob(), "test_file");
+fileSaver.onwriteend = myOnWriteEnd;
+

+
+
+ +
+

4. The BlobBuilder interface

+

+ The BlobBuilder is used to construct Blobs. +

+
The BlobBuilder interface is deprecated in favor of the + new constructible Blob. However, at this time implementations + generally support BlobBuilder and not constructible Blob. +
+
[Constructor]
+interface BlobBuilder {
+    Blob getBlob (optional DOMString contentType);
+    void append (DOMString text, optional DOMString endings);
+    void append (Blob data);
+    void append (ArrayBuffer data);
+};
+

4.1 Methods

append
+

+ Appends the supplied text to the current contents of the + BlobBuilder, writing it as UTF-8, converting newlines as + specified in endings. +

+ +
ParameterTypeNullableOptionalDescription
textDOMString + The data to write. +
endingsDOMString +
Can we do without endings? Any choice other + than "native" can be implemented by the app author, and + most file formats don't care about line endings. "Native" + would be handy for sharing certain types of text files with apps + outside the browser [e.g. Makefiles on a system where make is + expecting \n will have issues if they're written with \r\n]. Is + it worth it? Can this be worked around if we don't supply + it?
+

+ This parameter specifies how strings containing \n + are to be written out. If the user does not provide the + endings parameter, user agents must act as + if the user had specified a value of 'transparent'. If the user + provides the endings parameter, user agents + must convert newlines as specified below. The possible values + are: +

+ + + + + + + + + + +
ValueDescription
"transparent" + Code points from the string must remain unchanged. +
"native" + Newlines must be transformed to the default line-ending + representation of the underlying host operating system. For + example, if the underlying OS is Windows, newlines will be + transformed into \r\n pairs as the text is + appended to the state of the BlobBuilder. +
+
Return type: void
append
+

+ Appends the supplied Blob to the current contents of the + BlobBuilder. +

+ +
ParameterTypeNullableOptionalDescription
dataBlob + The data to append. +
Return type: void
append
+

+ Appends the supplied ArrayBuffer to the current contents of the + BlobBuilder. +

+ +
ParameterTypeNullableOptionalDescription
dataArrayBuffer + The data to append. +
Return type: void
getBlob
+

+ Returns the current contents of the BlobBuilder as a + Blob. +

+ +
ParameterTypeNullableOptionalDescription
contentTypeDOMString + Sets the content type of the blob produced. +
Return type: Blob
+
+

4.2 Constructor

+

+ When the BlobBuilder constructor is invoked, user agents + must return a new BlobBuilder object. +

+

+ This constructor must be visible when the script's global object is + either a Window object or an object implementing the WorkerUtils + interface. +

+
+
+
+

5. The FileSaver interface

+

+ This interface provides methods to monitor the asynchronous writing of + blobs to disk using progress events [PROGRESS-EVENTS-ED] and event + handler attributes. +

+

+ This interface is specified to be used within the context of the global + object (Window [HTML5]) and within Web Workers (WorkerUtils + [WEBWORKERS-ED]). +

+
[Constructor(Blob data)]
+interface FileSaver : EventTarget {
+    void abort ();
+    const unsigned short INIT = 0;
+    const unsigned short WRITING = 1;
+    const unsigned short DONE = 2;
+    readonly attribute unsigned short readyState;
+    readonly attribute DOMError       error;
+    [TreatNonCallableAsNull]
+             attribute Function       onwritestart;
+    [TreatNonCallableAsNull]
+             attribute Function       onprogress;
+    [TreatNonCallableAsNull]
+             attribute Function       onwrite;
+    [TreatNonCallableAsNull]
+             attribute Function       onabort;
+    [TreatNonCallableAsNull]
+             attribute Function       onerror;
+    [TreatNonCallableAsNull]
+             attribute Function       onwriteend;
+};
+

5.1 Attributes

error of type DOMError, readonly
+

+ The last error that occurred on the FileSaver. +

+
onabort of type Function
+

+ Handler for abort events. +

+
onerror of type Function
+

+ Handler for error events. +

+
onprogress of type Function
+

+ Handler for progress events. +

+
onwrite of type Function
+

+ Handler for write events. +

+
onwriteend of type Function
+

+ Handler for writeend events. +

+
onwritestart of type Function
+

+ Handler for writestart events. +

+
readyState of type unsigned short, readonly
+

+ The FileSaver object can be in one of 3 states. The + readyState attribute, on getting, must return the + current state, which must be one of the following values: +

+

+

5.2 Methods

abort
+

+ When the abort method is called, user agents + must run the steps below: +

    +
  1. If readyState == DONE or + readyState == INIT, terminate this + overall series of steps without doing anything else.
  2. +
  3. Set readyState to DONE.
  4. +
  5. If there are any tasks from the object's FileSaver + task source in one of the task queues, then remove + those tasks.
  6. +
  7. Terminate the write algorithm being + processed.
  8. +
  9. Set the error attribute to a + DOMError object of type "AbortError".
  10. +
  11. Fire a progress event called abort
  12. +
  13. Fire a progress event called writeend
  14. +
  15. Terminate this algorithm.
  16. +
+

+
No parameters.
Return type: void

5.3 Constants

DONE of type unsigned short
+ The entire Blob has been written to the file, an error occurred + during the write, or the write was aborted using abort(). The + FileSaver is no longer writing the blob. +
INIT of type unsigned short
+ The object has been constructed, but there is no pending write. +
WRITING of type unsigned short
+ The blob is being written. +
+
+

5.4 The FileSaver Constructor

+

+ The FileSaver(data) constructor takes one argument: the + Blob of data to be saved to a file. +

+

+ When the FileSaver constructor is called, the user agent + must return a new FileSaver object with readyState + set to INIT. +

+

+ This constructor must be visible when the script's global object is + either a Window object or an object implementing the WorkerUtils + interface. +

+
+
+

5.5 The FileSaver Task Source

+ +

+ The FileSaver interface enables asynchronous writes on + individual files by dispatching events to event handler methods. Unless + stated otherwise, the task source that is used in this + specification is the FileSaver. This task source is + used for any event task that is asynchronously dispatched, or for + event tasks that are queued for dispatching. +

+

+ After its constructor has returned, a new FileSaver must asynchronously + execute the following steps. They are referred to elsewhere as the + FileSaver write algorithm. +

+
    +
  1. Set readyState to WRITING.
    FileSaver should really set readyState to WRITING before + the user gets a handle to it, so that abort works. But FileWriter + shouldn't, so it can't be an enforced part of the inherited + interface. Also, writestart should be tied to the INIT->WRITING + transition, so how would the holder of a FileSaver that wasn't a + FileWriter ever see that?
  2. +
  3. If an error occurs during file write, proceed to the error steps + below. +
      +
    1. Queue a task that will: +
        +
      1. Set the error attribute; on getting the + error attribute must be a + DOMError object whose type + indicates the kind of error that has occurred.
      2. +
      3. Set readyState to DONE.
      4. +
      5. Fire a progress event called + error.
      6. +
      7. Fire a progress event called + writeend.
      8. +
    2. +
    3. Terminate this overall set of steps.
    4. +
    +
  4. +
  5. Queue a task to fire a progress event called + writestart.
  6. +
  7. Make progress notifications.
  8. +
  9. On completion of the write, queue a task to: +
      +
    1. Set readyState to DONE.
    2. +
    3. Fire a progress event called + write.
    4. +
    5. Fire a progress event called + writeend.
    6. +
    7. Terminate this overall set of steps.
    8. +
    +
  10. +
+
+
+

5.6 Event Handler Attributes

+

+ The following are the event handler attributes (and their + corresponding event handler event types) that user agents must + support on FileSaver as DOM attributes: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
event handler attributeevent handler event type
onwritestartwritestart
onprogressprogress
onwritewrite
onabortabort
onerrorerror
onwriteendwriteend
+
+
+
+

6. The FileSaverSync interface

+
+

+ It seems like this should have a blocking constructor and no methods + or properties, if it's to follow the constructor-based model of the + asynchronous interface. A global method seems like it would be + cleaner, though. Is it important that they match? If so, the asynch + constructor could turn into a method instead. +

+

+ It's been pointed out that a method name like "saveAs" is too short + and generic; any global symbol should be longer and more explicit in + order to avoid confusion and naming conflicts. +

+
+
+
+

7. The FileWriter interface

+

+ This interface expands on the FileSaver interface to allow for + multiple write actions, rather than just saving a single Blob. +

+
+ Since this is intended to be used only with the sandboxed filesystem, + it could potentially move to the filesystem + spec. +
+
interface FileWriter : FileSaver {
+    readonly attribute unsigned long long position;
+    readonly attribute unsigned long long length;
+    void write (Blob data);
+    void seek (long long offset);
+    void truncate (unsigned long long size);
+};
+

7.1 Attributes

length of type unsigned long long, readonly
+

+ The length of the file. If the user does not have read access to the + file, this must be the highest byte offset at which the user has + written. +

+
position of type unsigned long long, readonly
+

+ The byte offset at which the next write to the file will occur. + This must be no greater than length.
+ A newly-created FileWriter must have position set to 0. +

+

7.2 Methods

seek
+

+ Seek sets the file position at which the next write will occur. +

+

+ When the seek method is called, user agents must + run the steps below. +

+
    +
  1. If readyState is WRITING, + throw an InvalidStateError and terminate this series + of steps.
  2. +
  3. Set position to offset.
  4. +
  5. If position > length then set + position to length.
  6. +
  7. If position < 0 then set + position to position + length.
  8. +
  9. If position < 0 then set + position to 0.
  10. +
+

+ +
ParameterTypeNullableOptionalDescription
offsetlong long +

+ If nonnegative, an absolute byte offset into the file.
+ If negative, an offset back from the end of the file. +

+
Return type: void
truncate
+

+ Changes the length of the file to that specified. If shortening the + file, data beyond the new length must be discarded. If extending + the file, the existing data must be zero-padded up to the new + length. +

+

+ When the truncate method is called, user agents + must run the steps below (unless otherwise indicated). +

+
    +
  1. If readyState is WRITING, throw + an InvalidStateError and terminate this series of steps.
  2. +
  3. Set readyState to WRITING.
  4. +
  5. If an error occurs during truncate, proceed to the error steps + below. +
      +
    1. Set the error attribute; on getting the + error attribute must be a + DOMError object whose type + indicates the kind of error that has occurred.
    2. +
    3. Set readyState to DONE.
    4. +
    5. Fire a progress event called + error.
    6. +
    7. Fire a progress event called + writeend
    8. +
    9. On getting, the length and + position attributes should indicate any + modification to the file.
    10. +
    11. Terminate this overall set of steps.
    12. +
    +
  6. +
  7. Fire a progress event called + writestart.
  8. +
  9. Return from the truncate method, but continue processing the + other steps in this algorithm.
  10. +
  11. Upon successful completion: +
      +
    • length must be equal to size.
    • +
    • position must be the lesser of +
        +
      • its pre-truncate value,
      • +
      • size.
      • +
      +
    • +
    • Queue a task to: +
        +
      1. Set readyState to DONE.
      2. +
      3. Fire a progress event called + write
      4. +
      5. Fire a progress event called + writeend
      6. +
      7. Terminate this overall set of steps.
      8. +
      +
    • +
    +
  12. +
+

+ +
ParameterTypeNullableOptionalDescription
sizeunsigned long long + The size to which the length of the file is to be adjusted, + measured in bytes. +
Return type: void
write
+

+ Write the supplied data to the file at position. When + the write method is called, user agents must run + the steps below (unless otherwise indicated). +

    +
  1. If readyState is WRITING, + throw an InvalidStateError and terminate this series + of steps.
  2. +
  3. Set readyState to WRITING.
  4. +
  5. If an error occurs during file write, proceed to the error + steps below. +
      +
    1. Set the error attribute; on getting the + error attribute must be a + DOMError object whose type + indicates the kind of error that has occurred.
    2. +
    3. Set readyState to DONE.
    4. +
    5. Fire a progress event called + error.
    6. +
    7. Fire a progress event called + writeend
    8. +
    9. On getting, the length and + position attributes should indicate any + fractional data successfully written to the file.
    10. +
    11. Terminate this overall set of steps.
    12. +
    +
  6. +
  7. Fire a progress event called + writestart.
  8. +
  9. Return from the write method, but continue processing + the other steps in this algorithm.
  10. +
  11. Make progress notifications. On getting, while + processing the write method, the + length and position attributes must + indicate the progress made in writing the file as of the last + progress notification. +
  12. +
  13. + Upon successful completion of a write: +
      +
    • position must indicate an increase of + data.size over its pre-write state.
    • +
    • length must be the greater of (the pre-write + length) and (the pre-write position + plus data.size).
    • +
    • Queue a task to: +
        +
      1. Set readyState to DONE.
      2. +
      3. Fire a progress event called + write.
      4. +
      5. Fire a progress event called + writeend.
      6. +
      7. Terminate this overall set of steps.
      8. +
      +
    • +
    +
  14. +
+

+ +
ParameterTypeNullableOptionalDescription
dataBlob + The blob to write. +
Return type: void
+
+
+

8. The FileWriterSync interface

+

+ This interface lets users write, truncate, and append to files using + simple synchronous calls. +

+

+ This interface is specified to be used only within Web Workers + (WorkerUtils [WEBWORKERS-ED]). +

+
+ Since this is intended to be used only with the sandboxed filesystem, + it could potentially move to the filesystem + spec. +
+
interface FileWriterSync {
+    readonly attribute unsigned long long position;
+    readonly attribute unsigned long long length;
+    void write (Blob data);
+    void seek (long long offset);
+    void truncate (unsigned long long size);
+};
+

8.1 Attributes

length of type unsigned long long, readonly
+

+ The length of the file. If the user does not have read access to + the file, this must be the highest byte offset at which the user has + written. +

+
position of type unsigned long long, readonly
+

+ The byte offset at which the next write to the file will occur. + This must be no greater than length. +

+

8.2 Methods

seek
+

+ Seek sets the file position at which the next write will occur. +

+ +
ParameterTypeNullableOptionalDescription
offsetlong long + An absolute byte offset into the file. If offset + is greater than length, length is used + instead. If offset is less than zero, + length is added to it, so that it is treated as an + offset back from the end of the file. If it is still less than + zero, zero is used. +
Return type: void
truncate
+

+ Changes the length of the file to that specified. If shortening the + file, data beyond the new length must be discarded. If extending + the file, the existing data must be zero-padded up to the new + length. +

+

+ Upon successful completion: +

    +
  • length must be equal to size.
  • +
  • position must be the lesser of +
      +
    • its pre-truncate value,
    • +
    • size.
    • +
    +
  • +
+

+ +
ParameterTypeNullableOptionalDescription
sizeunsigned long long + The size to which the length of the file is to be adjusted, + measured in bytes. +
Return type: void
write
+

+ Write the supplied data to the file at position. + Upon completion, position will increase by + data.size. +

+ +
ParameterTypeNullableOptionalDescription
dataBlob + The blob to write. +
Return type: void
+
+
+

9. Errors and Exceptions

+
+

9.1 Occurrence

This section is non-normative.

+

+ Error conditions can occur when attempting to write files. The list + below of potential error conditions is informative, with links to + normative descriptions of errors: +

+

+ The directory containing the file being written may not exist at the + time an asynchronous or synchronous write method is called. This + may be due to it having been moved or deleted after a reference to it + was acquired (e.g. concurrent modification with another + application).
+ See NotFoundError. +

+

+ The file being written may have been removed. If the file is not there, + writing to an offset other than zero is not permitted.
+ See NotFoundError. +

+

+ A file may be unwritable. This may be due to permission problems that + occur after a reference to a file has been acquired (e.g. concurrent + lock with another application).
+ See NoModificationAllowedError. +

+

+ User agents may determine that some files are unsafe for use within web + applications. Additionally, some file and directory structures may be + considered restricted by the underlying filesystem; attempts to write to + them may be considered a security violation. See the security + considerations.
+ See SecurityError. +

+

+ A web application may attempt to initiate a write, seek, or truncate via + a FileWriter in the WRITING state.
+ See InvalidStateError. +

+

+ During the writing of a file, the web application may itself wish to + abort the call to an asynchronous write + method.
+ See AbortError. +

+

+ A web application may request unsupported line endings. + See SyntaxError. +

+

+ As documented in [FILE-API-ED], various errors may occur during + reading from the Blob that is the source of the data to be written. + These include NotFoundError, SecurityError, and + NotReadableError. +

+
+

9.2 Definitions

+

+ Synchronous write methods must throw an exception of the + most appropriate type in the table below if there has been an error with + writing. +

+

+ If an error occurs while processing an asynchronous write method, + the error attribute of the FileSaver object must + return a DOMError object [DOM4] of the most appropriate + type from the table below. Otherwise it must return null. +

+

Error Descriptions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameDescription
AbortErrorThe read operation was aborted, typically with a call to + abort(). +
InvalidStateErrorAn application attempted to initiate a write, truncate, or + seek using a FileWriter which is already in the + WRITING state. +
NotFoundErrorOne or more of the following occurred: +
    +
  • the directory containing the file to be written could + not be found at the time the write was processed.
  • +
  • the file to be written does not exist at the time the + write was processed, and an offset other than + zero is specified.
  • +
  • the blob that is the source of data to be written could + not be found at the time the write was processed. +
+
NoModificationAllowedErrorThe application attempted to write to a file which cannot be + modified due to the state of the underlying filesystem. +
NotReadableErrorThe source Blob could not be read, typically due to + permission problems that occur after the Blob reference + was acquired. +
QuotaExceededError + The operation failed because it would have caused the + application to exceed its storage quota. +
SecurityError + One or more of the following occurred: +
    +
  • it was determined that certain files are unsafe for + access within a Web application
  • +
  • it was determined that too many write calls are being + made on file resources
  • +
  • it was determined that the file to be written, or the + source data to be read, has changed on disk since the user + selected it
  • +
+ This is an error to be used in situations not covered by any + other error. +
SyntaxError + The application attempted to supply an invalid line ending + specifier to the API. +
+
+
+
+

10. Security Considerations

This section is non-normative.

+
+

10.1 Basic Security Model

+

+ Most of the security issues pertaining to writing to a file on the + user's drive are the same as those involved in downloading arbitrary + files from the Internet. The primary difference [in the case of + FileWriter] stems from the fact that the file may be continuously + written and re-written, at least until such a time as it is deemed + closed by the user agent. This has an impact on disk quota, IO + bandwidth, and on processes that may require analysing the content of + the file. +

+
+
+

10.2 Write-Only Files

+

+ When a user grants an application write access to a file, it doesn't + necessarily imply that the app should also receive read access to that + file or any of that file's metadata [including length]. This + specification describes a way in which that information can be kept + secret for write-only files. If the application has obtained a + FileWriter through a mechanism that also implies read access, + those restrictions may be relaxed. +

+
+
+

10.3 Quotas

+

+ Where quotas are concerned, user agents may wish to monitor the + size of the file(s) being written and possibly interrupt the script and + warn the user if certain limits of file size, remaining space, or disk + bandwidth are reached. +

+
+
+

10.4 Other Standard Techniques

+

+ Other parts of the download protection tool-chain such as flagging files + as unsafe to open, refusing to create dangerous file names, and making + sure that the mime type of a file matches its extension may naturally + be applied. +

+
+
+
+

A. Acknowledgements

+

+ Thanks to Arun Ranganathan for his File API, Opera for theirs, and Robin + Berjon both for his work on various file APIs and for ReSpec. +

+
+ + +

B. References

B.1 Normative references

[DOM4]
Anne van Kesteren; Aryeh Gregor; Ms2ger. DOM4. 5 January 2012. W3C Working Draft. (Work in progress.) URL: http://www.w3.org/TR/2012/WD-dom-20120105/ +
[FILE-API-ED]
Arun Ranganathan; Jonas Sicking. File API. W3C Editor's Draft. (Work in progress.) URL: http://dev.w3.org/2006/webapi/FileAPI/ +
[HTML5]
Ian Hickson. HTML5. 29 March 2012. W3C Working Draft. (Work in progress.) URL: http://www.w3.org/TR/html5 +
[PROGRESS-EVENTS-ED]
Anne van Kesteren. Progress Events 1.0. W3C Editor's Draft. (Work in progress.) URL: http://dvcs.w3.org/hg/progress/raw-file/tip/Overview.html +
[RFC2119]
S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Internet RFC 2119. URL: http://www.ietf.org/rfc/rfc2119.txt +
[TYPED-ARRAYS]
David Herman, Kenneth Russell. Typed Arrays Khronos Working Draft. (Work in progress.) URL: https://www.khronos.org/registry/typedarray/specs/latest/ +
[WEBWORKERS-ED]
Ian Hickson. Web Workers. W3C Editor's Draft. (Work in progress.) URL: http://dev.w3.org/html5/workers/ +

B.2 Informative references

No informative references.

diff --git a/idl2jsx/spec/cssom b/idl2jsx/spec/cssom index a1ceba05..ac3f3f85 100644 --- a/idl2jsx/spec/cssom +++ b/idl2jsx/spec/cssom @@ -16,7 +16,7 @@

CSS Object Model (CSSOM)

-

Editor's Draft 28 June 2013

+

Editor's Draft 5 September 2013

@@ -90,7 +90,7 @@ 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 28 June 2013 Editor's Draft of CSSOM. Please send comments to +

This is the 5 September 2013 Editor's Draft of CSSOM. Please send comments to www-style@w3.org (archived) with [cssom] at the start of the subject line. @@ -162,16 +162,18 @@ must disclose the information in accordance with

  • 6.4.6 The CSSGroupingRule Interface
  • 6.4.7 The CSSMediaRule Interface
  • 6.4.8 The CSSPageRule Interface
  • -
  • 6.4.9 The CSSNamespaceRule Interface
  • -
  • 6.5 CSS Declaration Blocks +
  • 6.4.9 The CSSMarginRule Interface
  • +
  • 6.4.10 The CSSNamespaceRule Interface
  • +
  • 6.5 CSS Declarations
  • +
  • 6.6 CSS Declaration Blocks
  • -
  • 6.6 CSS Values +
  • 6.6.1 The CSSStyleDeclaration Interface
  • +
  • 6.7 CSS Values
  • +
  • 6.7.2.1 Examples
  • 7 DOM Access to CSS Declaration Blocks
    • 7.1 The ElementCSSInlineStyle Interface
    • @@ -268,8 +270,10 @@ and A where A is actually an interface, it generally means an object implementing interface A.

      -

      The terms whitespace, ignored, specified value, computed value and used value are defined in CSS. -[CSS] +

      The terms whitespace and ignored are defined in CSS. [CSS] + +

      The terms cascaded value, computed value and used value are defined in CSS Cascade and Inheritance. +[CSSCASCADE]

      The terms simple selector, sequence of simple selectors, universal selector and group of selectors are defined in Selectors. [SELECTORS] @@ -279,7 +283,7 @@ Selectors. [SELECTORS]

      The term list of CSS page selectors refers to the comma-separated list of page selectors, as defined in CSS Paged Media Module. [CSSPAGE] -

      The terms set and clear to refer to the true and +

      The terms set and unset to refer to the true and false values of binary flags or variables, respectively. These terms are also used as verbs in which case they refer to mutating some value to make it true or false, respectively.

      @@ -290,8 +294,8 @@ mutating some value to make it true or false, respectively.

      The term supported CSS property refers to a CSS property that the user agent implements, and that is defined to be a case-insensitive property in the CSS specification. A supported CSS property must be in its lowercase form for the purpose of comparisons this specification. -

      CSS properties that are case-sensitive such as CSS Variables are author-defined and are represented with dedicated interfaces, and do not -participate in the base CSSOM API. [CSSVARIABLES] +

      The term author-defined CSS property refers to var-* properties as defined in CSS Custom Properties for Cascading Variables, +and are case-sensitive. [CSSVARIABLES]

      The terms ::before pseudo-element and ::after pseudo-element refer to the :before and :after pseudo-elements in CSS, except in this specification the pseudo-elements are assumed to exist for all elements even if no box is generated for them. [CSS] @@ -867,7 +871,7 @@ represents a style sheet as defined by the CSS specification. In the CSSOM a

      alternate flag
      -

      Specified when created. Either set or clear. Clear by default.

      +

      Specified when created. Either set or unset. Unset by default.

      The following CSS style sheets have @@ -881,9 +885,9 @@ represents a style sheet as defined by the CSS specification. In the CSSOM a

      disabled flag
      -

      Either set or clear. Clear by default.

      +

      Either set or unset. Unset by default.

      -

      Even when clear it does not necessarily mean that the +

      Even when unset it does not necessarily mean that the CSS style sheet is actually used for rendering.

      @@ -893,7 +897,7 @@ represents a style sheet as defined by the CSS specification. In the CSSOM a CSS style sheet.
      origin-clean flag -

      Specified when created. Either set or clear. If it is set, the API allows reading and modifying of the CSS +

      Specified when created. Either set or unset. If it is set, the API allows reading and modifying of the CSS rules.

  • @@ -917,7 +921,8 @@ represents a style sheet as defined by the CSS specification. In the CSSOM a -->ownerNode; readonly attribute StyleSheet? parentStyleSheet; readonly attribute DOMString? title; - [PutForwards=mediaText] readonly attribute MediaList media; + [SameObject, PutForwards=mediaText] readonly attribute MediaList media; attribute boolean disabled; }; @@ -956,7 +961,7 @@ is set, or false otherwise. On setting, the CSSStyleSheet interface represents a CSS style sheet.

    interface CSSStyleSheet : StyleSheet {
       readonly attribute CSSRule? ownerRule;
    -  readonly attribute CSSRuleList cssRules;
    +  [SameObject] readonly attribute CSSRuleList cssRules;
       unsigned long insertRule(DOMString rule, unsigned long index);
       void deleteRule(unsigned long index);
     };
    @@ -967,10 +972,10 @@ CSS rule. If a value other than null is ever returned, then that same value

    The cssRules attribute must follow these steps:

      -
    1. If the origin-clean flag is clear, +

    2. If the origin-clean flag is unset, throw a SecurityError exception.

    3. Return a read-only, live CSSRuleList object representing - the CSS rules. The same object must be returned on each get access.

      + the CSS rules.

      Even though the returned CSSRuleList object is read-only (from the perspective of client-authored script), it can nevertheless change over time due to its liveness status. For example, invoking the insertRule() or deleteRule() methods can result in @@ -980,7 +985,7 @@ CSS rule. If a value other than null is ever returned, then that same value

      The insertRule(rule, index) method must run the following steps:

        -
      1. If the origin-clean flag is clear, +

      2. If the origin-clean flag is unset, throw a SecurityError exception.

      3. Return the result of invoking insert a CSS rule rule in the CSS rules at index. @@ -989,7 +994,7 @@ CSS rule. If a value other than null is ever returned, then that same value

        The deleteRule(index) method must run the following steps:

          -
        1. If the origin-clean flag is clear, +

        2. If the origin-clean flag is unset, throw a SecurityError exception.

        3. Remove a CSS rule in the CSS rules at index.

        @@ -1037,13 +1042,13 @@ steps:

        these steps.
      4. If the title is not the empty string, the - alternate flag is clear, and + alternate flag is unset, and preferred CSS style sheet set name is the empty string change the preferred CSS style sheet set name to the title.

      5. -

        If any of the following is true clear the +

        If any of the following is true unset the disabled flag and terminate these steps:

      +

      A style sheet referenced by an xml-stylesheet processing instruction using the rules in this section, in the context of +the Document of an XML parser is said to be +a style sheet that is blocking scripts if the ProcessingInstruction +node was created by that Document's parser, and the style sheet was +enabled when the node was created by the parser, and the style sheet ready flag is not yet set, and, the last time the +event loop reached step 1, the node was in that Document, and the user agent hasn't given up on that particular style sheet +yet. A user agent may give up on such a style sheet at any time.

      @@ -1684,11 +1696,14 @@ must be run:

      "alternate", or false otherwise.
      origin-clean flag -

      Set if response is CORS-same-origin, or clear otherwise. +

      Set if response is CORS-same-origin, or unset otherwise.

    +

    A style sheet referenced by a HTTP Link header using the rules in this section is said to be a style sheet +that is blocking scripts if the style sheet was enabled when created, and the style sheet ready flag is not yet set, +and the user agent hasn't given up on that particular style sheet yet. A user agent may give up on such a style sheet at any time.

    6.4 CSS Rules

    @@ -1723,8 +1738,15 @@ This item is initialized to reference an associated style sheet when the rule is

    In addition to the above state, each CSS rule may be associated with other state in accordance with its type.

    -

    To parse a CSS rule from a string string, invoke parse a rule with string and return -the value returned.

    +

    To parse a CSS rule from a string string, run the following steps: + +

      +
    1. Let rule be the return value of invoking parse a rule with string. +

    2. If rule is a syntax error, return rule. +

    3. Let parsed rule be the result of parsing rule according to the appropriate CSS specifications, dropping parts that are said to be + ignored. If the whole style rule is dropped, return a syntax error. +

    4. Return parsed rule. +

    To serialize a CSS rule, perform one of the following in accordance with the CSS rule's type:

    @@ -1872,6 +1894,7 @@ inherits from this interface.

    const unsigned short MEDIA_RULE = 4; const unsigned short FONT_FACE_RULE = 5; const unsigned short PAGE_RULE = 6; + const unsigned short MARGIN_RULE = 9; const unsigned short NAMESPACE_RULE = 10; readonly attribute unsigned short type; attribute DOMString cssText; @@ -1895,6 +1918,8 @@ inherits from this interface.

    If the object is a CSSPageRule

    Return PAGE_RULE (numeric value 6).

    If the object is a CSSNamespaceRule +

    Return MARGIN_RULE (numeric value 9). +

    If the object is a CSSMarginRule

    Return NAMESPACE_RULE (numeric value 10).

    Otherwise

    Return a value defined on the CSSOM Constants wiki page. @@ -1945,7 +1970,7 @@ unreachable.

    interface CSSStyleRule : CSSRule {
       attribute DOMString selectorText;
    -  [PutForwards=cssText] readonly attribute CSSStyleDeclaration style;
     };
    @@ -1959,9 +1984,21 @@ unreachable.

    The style attribute must return a CSSStyleDeclaration object for the style rule, with the -declarations being the declared declarations in the rule, in the same order as they were -specified, with shorthand properties expanded into their longhand properties, in canonical order.

    +following properties: +
    +
    readonly flag +

    Unset. +

    declarations +

    The declared declarations in the rule, in specified order.

    +
    parent CSS rule +

    The context object. +

    owner node +

    Null. +

    +

    The specified order for declarations is the same as specified, but with shorthand properties +expanded into their longhand properties, in canonical order. If a property is specified more than once (after shorthand expansion), only the +one with greatest cascading order must be represented, at the same relative position as it was specified. [CSSCASCADE]

    6.4.4 The CSSCharsetRule Interface

    @@ -1981,8 +2018,9 @@ specified, with shorthand properties expanded into their longhand properties, in
    interface CSSImportRule : CSSRule {
       readonly attribute DOMString href;
    -  [PutForwards=mediaText] readonly attribute MediaList media;
    -  readonly attribute CSSStyleSheet styleSheet;
    +  [SameObject, PutForwards=mediaText] readonly attribute MediaList media;
    +  [SameObject] readonly attribute CSSStyleSheet styleSheet;
     };

    The href attribute must return the URL specified by @@ -2003,7 +2041,7 @@ list is simply empty, i.e., an @import at-rule always has

    The CSSGroupingRule interface represents an at-rule that contains other rules nested inside itself.

    interface CSSGroupingRule : CSSRule {
    -  readonly attribute CSSRuleList cssRules;
    +  [SameObject] readonly attribute CSSRuleList cssRules;
       unsigned long insertRule(DOMString rule, unsigned long index);
       void deleteRule(unsigned long index);
     };
    @@ -2024,7 +2062,8 @@ invoking insert a CSS rule rule into

    The CSSMediaRule interface represents an @media at-rule.

    interface CSSMediaRule : CSSGroupingRule {
    -  [PutForwards=mediaText] readonly attribute MediaList media;
    +  [SameObject, PutForwards=mediaText] readonly attribute MediaList media;
     };

    The media attribute must return a MediaList object for the list of media queries specified @@ -2038,9 +2077,9 @@ with the @media at-rule.

    parse a list of CSS page selectors and serialize a list of CSS page selectors.

    -
    interface CSSPageRule : CSSRule {
    -  attribute DOMString selectorText;
    -  [PutForwards=cssText] readonly attribute CSSStyleDeclaration style;
     };
    @@ -2053,11 +2092,49 @@ with the @media at-rule.

  • Otherwise, if the algorithm returns a null value, do nothing.

  • -

    The style attribute must return a CSSStyleDeclaration for the @page -at-rule.

    +

    The style attribute must return a CSSStyleDeclaration object for the +@page at-rule, with the following properties: +

    +
    readonly flag +

    Unset. +

    declarations +

    The declared declarations in the rule, in specified order.

    +
    parent CSS rule +

    The context object. +

    owner node +

    Null. +

    -

    6.4.9 The CSSNamespaceRule Interface

    +

    6.4.9 The CSSMarginRule Interface

    + +

    The CSSMarginRule interface represents a margin at-rule (e.g. @top-left) in an @page at-rule. +[CSSPAGE] + +

    interface CSSMarginRule : CSSRule {
    +  readonly attribute DOMString name;
    +  [SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style;
    +};
    + +

    The name attribute must return the name of the margin at-rule. The @ character is not +included in the name. [CSSSYNTAX] + +

    The style attribute must return a CSSStyleDeclaration object for the +margin at-rule, with the following properties: +

    +
    readonly flag +

    Unset. +

    declarations +

    The declared declarations in the rule, in specified order.

    +
    parent CSS rule +

    The context object. +

    owner node +

    Null. +

    + + +

    6.4.10 The CSSNamespaceRule Interface

    The CSSNamespaceRule interface represents an @namespace at-rule.

    @@ -2097,58 +2174,120 @@ empty string if there is no prefix. -

    6.5 CSS Declaration Blocks

    +

    6.5 CSS Declarations

    + +

    A CSS declaration is an abstract concept that is not exposed as an object in the DOM. A CSS declaration has the following associated +properties: + +

    +
    property name +

    The property name of the declaration. +

    value +

    The value of the declaration represented as a list of component values. +

    important flag +

    Either set or unset. Can be changed. +

    case-sensitive flag +

    Set if the property name is defined to be case-sensitive according to its specification, + otherwise unset. +

    + +

    6.6 CSS Declaration Blocks

    A CSS declaration block is an ordered collection of CSS -properties with their associated values, also named CSS declarations. In +properties with their associated values, also named CSS declarations. In the DOM a CSS declaration block is a CSSStyleDeclaration object. A -CSS declaration block has two associated properties:

    +CSS declaration block has the following associated properties:

    readonly flag
    -

    Clear if the object can be manipulated. Set if it can not be - manipulated. Unless otherwise stated it is clear.

    +

    Unset if the object can be manipulated. Set if it can not be + manipulated. Unless otherwise stated it is unset.

    declarations
    -

    The CSS declarations associated with the object.

    +

    The CSS declarations associated with the object.

    + +
    parent CSS rule +

    The CSS rule that the CSS declaration block is associated with, if any, or null otherwise. + +

    owner node +

    The Element or PseudoElement that the CSS declaration block is associated with, if any, or + null otherwise.

    -

    To parse a CSS declaration block from a string string, invoke parse a list of declarations with -string and return the value returned.

    +

    To parse a CSS declaration block from a string string, follow these steps: + +

      +
    1. Let declarations be the return value of invoking parse a list of declarations with string. +

    2. Let parsed declarations be a new empty list. +

    3. For each item declaration in declarations, follow these substeps: +

        +
      1. Let parsed declaration be the result of parsing declaration according to the appropriate CSS specifications, dropping parts that + are said to be ignored. If the whole declaration is dropped, let parsed declaration be null. +

      2. If parsed declaration is not null, append it to parsed declarations. +

      +
    4. Return parsed declarations. +

    + +

    To serialize a CSS declaration with property name property, value value and optionally an important flag set, follow +these steps: -

    To serialize a CSS declaration block -represented by a CSSStyleDeclaration instance named d, -let s be the empty string, then run the steps below:

    +
      +
    1. Let s be the empty string. +

    2. Append property to s. +

    3. Append ": " (U+003A U+0020) to s. +

    4. Append value to s. +

    5. If the important flag is set, append " !important" (U+0020 U+0021 U+0069 U+006D U+0070 U+006F U+0072 U+0074 U+0061 U+006E + U+0074) to s. +

    6. Append ";" (U+003B) to s. +

    7. Return s. +

    + +

    To serialize a CSS declaration block declaration block means to run the steps below:

      -
    1. If d.length is zero (0), then return s.

    2. -
    3. For each i from zero (0) through d.length - 1 (inclusive), perform the following sub-steps:

      -
        -
      1. Let n be the value returned by d.item(i).

      2. -
      3. Let v be the value returned by d.getPropertyValue(n).

      4. -
      5. If v is the empty string, then continue.

      6. -
      7. -

        Otherwise (v is non-empty), perform the following sub-steps:

        -
          -
        1. If s is not empty, then append a single SPACE (U+0020) to s.

        2. -
        3. Append n to s.

        4. -
        5. Append COLON (U+003A) followed by a single SPACE (U+0020), i.e., ": ", to s.

        6. -
        7. Append v to s.

        8. -
        -
      8. -
      9. Let p be the value returned by d.getPropertyPriority(n).

      10. -
      11. -

        If p is not the empty string, then perform the following sub-steps:

        +
      12. Let list be an empty array. +

      13. Let already serialized be an empty array. +

      14. Declaration loop: For each CSS declaration declaration in declaration block's + declarations, follow these substeps: +

          +
        1. Let property be declaration's property name. +

        2. If property is in already serialized, continue with the steps labeled declaration loop. +

        3. If property maps to one or more shorthand properties, let shorthands be an array of those shorthand properties, in + preferred order, and follow these substeps:

            -
          1. Append a single SPACE (U+0020) followed by EXCLAMATION MARK (U+0021), i.e., " !", to s.

          2. -
          3. Append p to s.

          4. +
          5. Let longhands an array consisting of all CSS declarations in declaration block's + declarations that that are not in already serialized and have a + property name that + maps to one of the shorthand properties in shorthands. +

          6. Shorthand loop: For each shorthand in shorthands, follow these substeps: +

              +
            1. If all properties that map to shorthand are not present in longhands, continue with the steps labeled shorthand loop. +

            2. Let current longhands be an empty array. +

            3. Append all CSS declarations in longhands have a + property name that maps to shorthand to current longhands. +

            4. If there is one or more CSS declarations in current longhands have their + important flag set and one or more with it unset, continue with + the steps labeled shorthand loop. +

            5. Let value be the result of invoking serialize a CSS value of current longhands. +

            6. If value is the empty string, continue with the steps labeled shorthand loop. +

            7. Let serialized declaration be the result of invoking serialize a CSS declaration with property name + shorthand, value value, and the important flag set if the CSS declarations in + current longhands have their important flag set. +

            8. Append serialized declaration to list. +

            9. Append the property names of all items of current longhands to already serialized. +

            10. Remove the items present in current longhands from longhands. +

          -
        4. -
        5. Append SEMICOLON (U+003B), i.e., ";", to s.

        6. -
        -
      15. -
      16. Return s.

      17. +
      18. If property is in already serialized, continue with the steps labeled declaration loop. +

      19. Let value be the result of invoking serialize a CSS value of declaration. +

      20. Let serialized declaration be the result of invoking serialize a CSS declaration with property name property, value + value, and the important flag set if declaration has its important + flag set. +

      21. Append serialized declaration to list. +

      22. Append property to already serialized. +

      +
    4. Return list joined with " " (U+0020).

    The serialization of an empty CSS declaration block is the empty string.

    @@ -2156,8 +2295,20 @@ let s be the empty string, then run the steps below:

    The serialization of a non-empty CSS declaration block does not include any surrounding whitespace, i.e., no whitepsace appears before the first property name and no whitespace appears after the final semicolon delimiter that follows the last property value.

    +

    The preferred order of a list of shorthand properties shorthands is as follows: + +

      +
    1. Order shorthands lexicographically. +

    2. Move all items in shorthands that begin with "-" (U+002D) last in the list, retaining their relative order. +

    3. Move all items in shorthands that begin with "-" (U+002D) but do not begin with "-webkit-" last in the + list, retaining their relative order. +

    4. Order shorthands by the number of longhand properties that map to it, with the greatest number first. +

    + +

    6.6.1 The CSSStyleDeclaration Interface

    -

    6.5.1 The CSSStyleDeclaration Interface

    +

    The CSSStyleDeclaration interface represents a CSS declaration block, including its underlying state, where this +underlying state depends upon the source of the CSSStyleDeclaration instance.

    -

    The CSSStyleDeclaration interface represents a CSS declaration block, including its underlying state, where this -underlying state depends upon the source of the CSSStyleDeclaration instance.

    -
    interface CSSStyleDeclaration {
       attribute DOMString cssText;
       readonly attribute unsigned long length;
    @@ -2179,15 +2327,15 @@ underlying state depends upon the source of the getPropertyValue(DOMString property);
       DOMString getPropertyPriority(DOMString property);
       void setProperty(DOMString property, [TreatNullAs=EmptyString] DOMString value, [TreatNullAs=EmptyString] optional DOMString priority = "");
    +  -->[TreatNullAs=EmptyString] optional DOMString priority);
       DOMString removeProperty(DOMString property);
    -  readonly attribute CSSRule? parentRule;
    +  readonly attribute CSSRule? parentRule;
                attribute DOMString cssFloat;
     };
    -

    The object's supported property indices are the numbers in the range zero to one less than the number of declarations in -the declarations. If there are no such declarations, then there are no -supported property indices. +

    The object's supported property indices are the numbers in the range zero to one less than the number of +CSS declarations in the declarations. If there are no such +CSS declarations, then there are no supported property indices.

    The cssText attribute must return the result of serializing the declarations.

    @@ -2197,15 +2345,15 @@ the NoModificationAllowedError
    exception and terminate these steps.
  • Empty the declarations.

  • Parse the given value and, if the return value is not the empty list, insert the items in the list - into the declarations, in the same order as they were specified, with shorthand properties - expanded into their longhand properties, in canonical order.

  • + into the declarations, in specified + order. -

    The length attribute must return the number of declarations in the -declarations.

    +

    The length attribute must return the number of CSS +declarations in the declarations.

    -

    The item(index) method must return the name of the property at position -index.

    +

    The item(index) method must return the +property name of the CSS declaration at position index.

    The getPropertyValue(property) method must run these steps:

      @@ -2215,15 +2363,16 @@ the case-sensitive match for a property of a declaration in the - declarations, let declaration be that declaration, or null otherwise. +
    1. If longhand is a case-sensitive match for a property + name of a CSS declaration in the declarations, let declaration + be that CSS declaration, or null otherwise.

    2. If declaration is null, return the empty string and terminate these steps.

    3. Append the declaration to list.

  • Return the serialization of list and terminate these steps.

  • If property is a case-sensitive - match for a property of a declaration in the + match for a property name of a CSS declaration in the declarations, return the result of invoking serialize a CSS value of that declaration and terminate these steps.

  • Return the empty string. @@ -2243,10 +2392,9 @@ the case-sensitive match for a property of a - declaration in the declarations that has the - important flag set, return - the string "important".

    + case-sensitive match for a property name of a CSS + declaration in the declarations that has the + important flag set, return the string "important".

  • Return the empty string. @@ -2257,14 +2405,15 @@ value would be "important". priority) method must run these steps:

    1. If the readonly flag is set, throw - an NoModificationAllowedError exception and terminate these steps.

    2. + a NoModificationAllowedError exception and terminate these steps.
    3. Let property be property converted to ASCII lowercase.

    4. If property is not a case-sensitive match for a supported CSS property, terminate this algorithm.

    5. If value is the empty string, invoke removeProperty() with property as argument and terminate this algorithm.

    6. -
    7. If priority is neither an ASCII case-insensitive match for the string "important" - nor the empty string terminate this algorithm.

    8. +
    9. If priority is not specified, let priority action be "leave as is". Otherwise, if priority is the empty string, let + priority action be "unset important". Otherwise, if priority is an ASCII case-insensitive match for the + string "important", set priority action to "set important". Otherwise, terminate this algorithm.

    10. Let component value list be the result of parsing value.

      value can not include "!important".

      @@ -2272,23 +2421,25 @@ value would be "important".
    11. If component value list is null terminate these steps.

    12. If property is a shorthand property, then for each longhand property longhand that property maps to, in canonical order, set the CSS property longhand to the appropriate value(s) from component value list, with - the important flag set if priority is not the empty string, and with the list of declarations being the + priority action being priority action, and with the list of declarations being the declarations.

    13. Otherwise, set the CSS property property to component value list, with - the important flag set if priority is not the empty string, and with the list of declarations being the + priority action being priority action, and with the list of declarations being the declarations.

    -

    To set a CSS property property to a value component value list and optionally with an important flag set, in a -list of declarations declarations, follow these steps: +

    To set a CSS property property to a value component value list and with priority action being either "set +important", "unset important" or "leave as is", in a list of declarations declarations, follow these steps:

      -
    1. If property is a case-sensitive match for a property of a declaration in - declarations, let declaration be that declaration. -

    2. Otherwise, append a new declaration with the property name property to declarations and let declaration be that - declaration. -

    3. Set declaration's value to component value list. -

    4. Set the declaration's important flag if important is set, or unset it otherwise. +

    5. If property is a case-sensitive match for a property + name of a CSS declaration in declarations, let declaration be that CSS declaration. +

    6. Otherwise, append a new CSS declaration with the property name property + to declarations and let declaration be that CSS declaration. +

    7. Set declaration's value to component value list. +

    8. If priority action is "set important", set declaration's important flag. +

    9. Otherwise, if priority action is "unset important", unset declaration's important + flag.

    The removeProperty(property) method must run these steps:

    @@ -2300,13 +2451,14 @@ list of declarations declarations, follow these steps: with property as argument.
  • If property is a shorthand property, for each longhand property longhand that property maps to, invoke removeProperty() with longhand as argument. -

  • Otherwise, if property is a case-sensitive match for a property of a declaration in the - declarations, remove the declaration. +

  • Otherwise, if property is a case-sensitive match for a + property name of a CSS declaration in the + declarations, remove that CSS declaration.

  • Return value. -

    The parentRule attribute must return the CSSrule object the -CSSStyleDeclaration is object is associated with or null if it is not associated with a CSSrule object.

    +

    The parentRule attribute must return the +parent CSS rule.

    The cssFloat attribute, on getting, must return the result of invoking @@ -2408,10 +2560,10 @@ follows:

    -

    6.6 CSS Values

    +

    6.7 CSS Values

    -

    6.6.1 Parsing CSS Values

    +

    6.7.1 Parsing CSS Values

    To parse a CSS value value for a given property means to follow these steps: @@ -2429,33 +2581,36 @@ part of the property value space and will therefore cause -

    6.6.2 Serializing CSS Values

    +

    6.7.2 Serializing CSS Values

    -

    To serialize a CSS value of a declaration declaration or a list of longhand declarations list, follow -these rules:

    +

    To serialize a CSS value of a CSS declaration declaration or a list of longhand CSS +declarations list, follow these rules:

    1. If this algorithm is invoked with a list list, follow these substeps:

        -
      1. Let shorthand be the shorthand property that exactly maps to all the longhand properties in list. +

      2. Let shorthand be the shorthand property that exactly maps to all the longhand properties in list. If there are multiple such + shorthand properties, use the first in preferred order.

      3. If shorthand cannot represent the values of list in its grammar, return the empty string and terminate these steps.

      4. Let trimmed list be a new empty array. -

      5. For each declaration declaration in list, if declaration's value is not the initial value, or if +

      6. For each CSS declaration declaration in list, if declaration's + value is not the initial value, or if declaration is a required component of the shorthand property, append declaration to trimmed list.

      7. If trimmed list is empty, append the value of the first item in list to trimmed list.

      8. Let values be a new empty array. -

      9. For each declaration declaration in trimmed list, invoke serialize a CSS value of declaration, and - append the result to values. +

      10. For each CSS declaration declaration in trimmed list, invoke serialize a CSS value of + declaration, and append the result to values.

      11. Return the result of joining values as appropriate according to the grammar of shorthand and terminate these steps.

    2. Let values be a new empty array. -

    3. Append the result of invoking serialize a CSS component value of declaration's value to values. -

    4. If the grammar of the property of declaration is defined to be whitespace-separated, return the result of invoking serialize a - whitespace-separated list of values and terminate these steps. -

    5. If the grammar of the property of declaration is defined to be comma-separated, return the result of invoking serialize a - comma-separated list of values. +

    6. Append the result of invoking serialize a CSS component value of declaration's + value to values. +

    7. If the grammar of the property name of declaration is defined to be + whitespace-separated, return the result of invoking serialize a whitespace-separated list of values and terminate these steps. +

    8. If the grammar of the property name of declaration is defined to be comma-separated, + return the result of invoking serialize a comma-separated list of values.

    To @@ -2468,8 +2623,7 @@ depends on the component, as follows:

    converted to ASCII lowercase.
  • <angle>
    -

    The number of degrees serialized as per <number> followed by - the literal string "deg".

    +

    The <number> component serialized as per <number> followed by the unit in canonical form as defined in its respective specification.

    <color>
    @@ -2550,18 +2704,18 @@ depends on the component, as follows:

    <counter>
    -

    The concatenation of:

    +

    The return value of the following algorithm:

      -
    1. If <counter> has three CSS component values the string - "counters(".

    2. -
    3. If <counter> has two CSS component values the string - "counter(".

    4. -
    5. The result of - serializing the - serialized - CSS component values belonging to <counter> as list while omitting - the last CSS component value if it is 'decimal'.

    6. -
    7. ")" (U+0029).

    8. +
    9. Let s be the empty string. +

    10. If <counter> has three CSS component values append the string + "counters(" to s.

    11. +
    12. If <counter> has two CSS component values append the string + "counter(" to s.

    13. +
    14. Let list be a list of CSS component values belonging to <counter>, omitting the last CSS component value if it is 'decimal'. +

    15. Let each item in list be the result of invoking serialize a CSS component value on that item. +

    16. Append the result of invoking serialize a comma-separated list on list to s. +

    17. Append ")" (U+0029) to s.

    18. +
    19. Return s.

    @@ -2610,11 +2764,17 @@ depends on the component, as follows:

    <number> followed by the literal string "dpcm".
    <shape>
    -

    The string "rect(", followed by the result - of serializing the - serialized - CSS component values belonging to <shape> as list, followed by - ")" (U+0029).

    +
    +

    The return value of the following algorithm: +

      +
    1. Let s be the string "rect(". +

    2. Let list be a list of the CSS component values belonging to <shape>. +

    3. Let each item in list be the result of invoking serialize a CSS component value of that item. +

    4. Append the result of invoking serialize a comma-separated list on list to s. +

    5. Append ")" (U+0029) to s. +

    6. Return s. +

    +
    <string>
    <family-name>
    @@ -2652,7 +2812,7 @@ the CSS3/CSS4 timeline by moving the above definitions to the drafts that define the CSS components.

    -
    6.6.2.1 Examples
    +
    6.7.2.1 Examples

    Here are some examples of before and after results on specified values. The before column could be what the author wrote in a style sheet, while @@ -2689,22 +2849,28 @@ the after column shows what querying the DOM would return.

    [NoInterfaceObject]
     interface ElementCSSInlineStyle {
    -  [PutForwards=cssText] readonly attribute CSSStyleDeclaration style;
     };
    -

    The style attribute must return a CSS declaration block with the -declarations being set to the result of parsing -the style content attribute, in the same order as specified, with shorthand properties expanded to their longhand properties, in canonical -order. If the -style content attribute is absent, the object represents an empty list of -declarations. Mutating the CSSStyleDeclaration object must set the -style content attribute on the element to the -serialization of the -CSSStyleDeclaration's declarations. -The same object must be returned each time. The object is live; if the -style content attribute is set, changed or removed, the declarations must be -updated as appropriate.

    +

    The style attribute must return a live CSS declaration block with the following +properties: +

    +
    readonly flag +

    Unset. +

    declarations +

    The result of parsing the style content attribute, in + specified order. If the style content attribute is absent, the object represents an + empty list of CSS declarations. Mutating the declarations + must set the style content attribute on the context object to the + serialization of the declarations. If the + style content attribute is set, changed or removed, the declarations must be + updated as appropriate. +

    parent CSS rule +

    Null. +

    owner node +

    The context object. +

    If the user agent supports HTML, the following IDL applies: [HTML] @@ -2718,8 +2884,8 @@ updated as appropriate.

    7.2 Extensions to the Window Interface

    partial interface Window {
    -  CSSStyleDeclaration getComputedStyle(Element elt, optional DOMString pseudoElt);
    +  [NewObject] CSSStyleDeclaration getComputedStyle(Element elt, optional DOMString pseudoElt);
     };

    The getComputedStyle(elt, pseudoElt) method must run these @@ -2741,18 +2907,21 @@ steps:

    obj be the ::after pseudo-element of elt.
  • -

    Return a CSS declaration block with the - readonly flag set and the - declarations set to all longhand properties - that are supported CSS properties with the value being the resolved value - computed for obj using the style rules associated - with doc.

    -

    This means that even if obj is in a - different document (e.g. one fetched via XMLHttpRequest) it - will still use the style rules associated with the document that is - associated with the global object on which - getComputedStyle() was - invoked to compute the CSS declaration block.

    +

    Return a live CSS declaration block with the following properties: +

    +
    readonly flag +

    Set. +

    declarations +

    All longhand properties that are supported CSS properties, in lexicographical order, with the value being + the resolved value computed for obj using the style rules associated with doc.

    +

    This means that even if obj is in a different document (e.g. one fetched via XMLHttpRequest) it will still use + the style rules associated with the document that is associated with the global object on which + getComputedStyle() was invoked to compute the CSS declaration block.

    +
    parent CSS rule +

    Null. +

    owner node +

    obj. +

  • Because of historical IDL limitations the getComputedStyle() method used to be on @@ -2770,43 +2939,78 @@ document if obj is an [NoInterfaceObject] interface GetStyleUtils { - readonly attribute CSSStyleDeclaration specifiedStyle; - readonly attribute CSSStyleDeclaration defaultStyle; - readonly attribute CSSStyleDeclaration computedStyle; - readonly attribute CSSStyleDeclaration usedStyle; + [SameObject] readonly attribute CSSStyleDeclaration cascadedStyle; + [SameObject] readonly attribute CSSStyleDeclaration rawComputedStyle; + [SameObject] readonly attribute CSSStyleDeclaration usedStyle; }; -

    The specifiedStyle attribute must return a CSS declaration block -with the readonly flag set and the -declarations set to all longhand properties -that are supported CSS properties with the value being the specified value -computed for the context object using the style rules associated -with the context object's associated document.

    - -

    The defaultStyle attribute must return a CSS declaration block with -the readonly flag set and the -declarations set to all longhand properties that are -supported CSS properties with the value being the -computed value computed for the context object using the user-agent-level style rules and user-level style rules -associated with the context object's associated document, ignoring transitions, animations, author-level style -rules, author-level presentational hints and override-level style rules.

    - -

    The computedStyle attribute must return a CSS declaration block with -the readonly flag set and the -declarations set to all longhand properties -that are supported CSS properties with the value being the computed value -computed for the context object using the style rules associated -with the context object's associated document.

    - -

    The usedStyle attribute must return a CSS declaration block with the -readonly flag set and the -declarations set to all longhand properties -that are supported CSS properties with the value being the used value -computed for the context object using the style rules associated -with the context object's associated document.

    - -

    The specifiedStyle, computedStyle and -usedStyle methods expose information from CSS style sheets with the +

    The cascadedStyle attribute must return a live CSS declaration block +with the following properties: +

    +
    readonly flag +

    Set. +

    declarations +

    All longhand properties that are supported CSS properties, in lexicographical order, that have a + cascaded value for the context object, with the value being the cascaded value computed for the + context object using the style rules associated with the context object's associated + document.

    +
    parent CSS rule +

    Null. +

    owner node +

    The context object. +

    + + + +

    The rawComputedStyle attribute must return a live CSS declaration +block with the following properties: +

    +
    readonly flag +

    Set. +

    declarations +

    All longhand properties that are supported CSS properties, in lexicographical order, with the value being + the computed value computed for the context object using the style rules associated with the + context object's associated document.

    +
    parent CSS rule +

    Null. +

    owner node +

    The context object. +

    + +

    The usedStyle attribute must return a live CSS declaration block with the +following properties: +

    +
    readonly flag +

    Set. +

    declarations +

    All longhand properties that are supported CSS properties, in lexicographical order, with the value being + the used value computed for the context object using the style rules associated with the + context object's associated document.

    +
    parent CSS rule +

    Null. +

    owner node +

    The context object. +

    + +

    The cascadedStyle, rawComputedStyle +and usedStyle methods expose information from CSS style sheets with the origin-clean flag unset. @@ -2951,6 +3155,9 @@ Message Header Field Registry.

    [CSS]
    CSS, Bert Bos, Tantek Çelik, Ian Hickson et al.. W3C. +
    [CSSCASCADE] +
    CSS Cascading and Inheritance, Håkon Wium Lie, fantasai and Tab Atkins Jr.. +
    [CSSNAMESPACES]
    CSS Namespaces Module, Elika J. Etemad and Anne van Kesteren. W3C. @@ -2961,7 +3168,7 @@ Message Header Field Registry.
    CSS Syntax Module, Tab Atkins Jr.. W3C.
    [CSSVARIABLES] -
    (Non-normative) CSS Custom Properties for Cascading Variables Module, Tab Atkins Jr.. W3C. +
    CSS Custom Properties for Cascading Variables Module, Tab Atkins Jr.. W3C.
    [DOM]
    DOM, Anne van Kesteren, Aryeh Gregor and Ms2ger. WHATWG. @@ -3024,10 +3231,13 @@ Hallvord R. M. Steen, Ian Hickson, John Daggett, Lachlan Hunt, +Mike Sherov, Morten Stenshorne, Øyvind Stenhaug, +Peter Sloetjes, Philip Taylor, Robert O'Callahan, +Simon Sapin, Sjoerd Visscher, Sylvain Galineau, diff --git a/idl2jsx/spec/cssom-view b/idl2jsx/spec/cssom-view index 0b8b4062..52de3920 100644 --- a/idl2jsx/spec/cssom-view +++ b/idl2jsx/spec/cssom-view @@ -16,7 +16,7 @@

    CSSOM View Module

    -

    Editor's Draft 27 June 2013

    +

    Editor's Draft 6 September 2013

    @@ -83,7 +83,7 @@ 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 27 June 2013 Editor's Draft of CSSOM View. Please send +

    This is the 6 September 2013 Editor's Draft of CSSOM View. Please send comments to www-style@w3.org (archived) @@ -289,8 +289,8 @@ case that element acts as viewport and initial containing block.

    The right-most edge of the element's right padding edge and the right margin edge of the element's all descendant boxes, excluding boxes that have an ancestor of the element as their containing block.

    bottom edge -

    The bottom-most edge of the element's bottom padding edge and the bottom margin edge of the element's all descendant boxes, - excluding boxes that have an ancestor of the element as their containing block. +

    The bottom-most edge of the element's bottom padding edge and the bottom margin edge of the element's all descendant + boxes, excluding boxes that have an ancestor of the element as their containing block.

    left edge

    The element's left padding edge.

    @@ -316,8 +316,8 @@ case that element acts as viewport and initial containing block.
    right edge

    The element's right padding edge.

    bottom edge -

    The bottom-most edge of the element's bottom padding edge and the bottom margin edge of the element's all descendant boxes, - excluding boxes that have an ancestor of the element as their containing block. +

    The bottom-most edge of the element's bottom padding edge and the bottom margin edge of the element's all descendant + boxes, excluding boxes that have an ancestor of the element as their containing block.

    left edge

    The left-most edge of the element's left padding edge and the left margin edge of the element's all descendant boxes, excluding boxes that have an ancestor of the element as their containing block. @@ -421,7 +421,7 @@ layout box (the column or column group, respectively).

    3.1 CSS pixels

    All coordinates and dimensions for the APIs defined in this -specification are in CSS pixels. +specification are in CSS pixels, unless otherwise specified.

    This does not apply to e.g. matchMedia() as the units @@ -494,14 +494,18 @@ be enum ScrollBehavior { "auto", "instant", "smooth" }; dictionary ScrollOptions { - double x; - double y; ScrollBehavior behavior = "auto"; }; partial interface Window { MediaQueryList matchMedia(DOMString query); - readonly attribute Screen screen; + [SameObject] readonly attribute Screen screen; + + // browsing context + void moveTo(double x, double y); + void moveBy(double x, double y); + void resizeTo(double x, double y); + void resizeBy(double x, double y); // viewport readonly attribute double innerWidth; @@ -535,11 +539,74 @@ partial interface screen attribute must return the Screen object -associated with the Window object. It always returns the same -object.

    +associated with the Window object.

    Accessing screen through a WindowProxy object might yield different results when the Document is navigated.

    +

    The moveTo method must follow these steps: + +

      +
    1. Optionally, terminate these steps. +

    2. Let target be the browsing context of the context + object. +

    3. Let source be the browsing context of the incumbent script. +

    4. If source is not allowed to resize and move target, terminate these steps. +

    5. Optionally, clamp x and y in a user-agent-defined manner so that the window does not move outside the available space. +

    6. Move target's window such that the window's top left corner is at coordinates (x, y) relative to the top left corner of + the output device, measured in CSS pixels at 100% zoom. The positive axes are rightward and downward. +

    + +

    The moveBy method must follow these steps: + +

      +
    1. Optionally, terminate these steps. +

    2. Let target be the browsing context of the context + object. +

    3. Let source be the browsing context of the incumbent script. +

    4. If source is not allowed to resize and move target, terminate these steps. +

    5. Optionally, clamp x and y in a user-agent-defined manner so that the window does not move outside the available space. +

    6. Move target's window x CSS pixels at 100% zoom righward and y CSS pixels at 100% zoom downward. +

    + + +

    The resizeTo method must follow these steps: + +

      +
    1. Optionally, terminate these steps. +

    2. Let target be the browsing context of the context + object. +

    3. Let source be the browsing context of the incumbent script. +

    4. If source is not allowed to resize and move target, terminate these steps. +

    5. Optionally, clamp x and y in a user-agent-defined manner so that the window does not get too small or bigger than the available + space. +

    6. Resize target's window by moving its right and bottom edges such that the distance between the left and right edges are x CSS + pixels at 100% zoom and the distance between the top and bottom edges are y CSS pixels at 100% zoom. +

    7. Optionally, move target's window in a user-agent-defined manner so that it does not grow outside the available space. +

    + +

    The resizeBy method must follow these steps: + +

      +
    1. Optionally, terminate these steps. +

    2. Let target be the browsing context of the context + object. +

    3. Let source be the browsing context of the incumbent script. +

    4. If source is not allowed to resize and move target, terminate these steps. +

    5. Optionally, clamp x and y in a user-agent-defined manner so that the window does not get too small or bigger than the available + space. +

    6. Resize target's window by moving its right edge x CSS pixels at 100% zoom righward and its bottom edge y CSS pixels at + 100% zoom downward. +

    7. Optionally, move target's window in a user-agent-defined manner so that it does not grow outside the available space. +

    + +

    A browsing context A is allowed to resize and move a browsing +context B if all the following conditions are met: + +

    +

    The innerWidth attribute must return the viewport width including the size of a rendered scroll bar (if any), or zero if there is no viewport.

    @@ -689,14 +756,16 @@ it is already in the list of media };

    The availWidth attribute must return the available width of the rendering surface of the output -device.

    +device, in CSS pixels at 100% zoom.

    The availHeight attribute must return the available height of the rendering surface of the output -device.

    +device, in CSS pixels at 100% zoom.

    -

    The width attribute must return the width of the output device.

    +

    The width attribute must return the width of the output device, in CSS pixels at 100% zoom. +

    -

    The height attribute must return the height of the output device.

    +

    The height attribute must return the height of the output device, in CSS pixels at 100% zoom. +

    The colorDepth attribute must return 24.

    @@ -828,12 +897,19 @@ returns a value:

    7 Extensions to the Element Interface

    -
    partial interface Element {
    +
    dictionary ScrollOptionsHorizontal : ScrollOptions {
    +  double x;
    +};
    +dictionary ScrollOptionsVertical : ScrollOptions  {
    +  double y;
    +};
    +
    +partial interface Element {
       ClientRectList getClientRects();
       ClientRect getBoundingClientRect();
       void scrollIntoView(optional boolean top = true, optional ScrollOptions options);
    -  attribute (double or ScrollOptions) scrollTop;
    -  attribute (double or ScrollOptions) scrollLeft;
    +  attribute (double or ScrollOptionsVertical) scrollTop;
    +  attribute (double or ScrollOptionsHorizontal) scrollLeft;
       readonly attribute double scrollWidth;
       readonly attribute double scrollHeight;
       readonly attribute double clientTop;
    @@ -920,25 +996,25 @@ var exampleHeight = example.height;

    When setting the scrollTop attribute these steps must be run:

      -
    1. If the given value is a ScrollOptions object, and the y dictionary member is not present, abort these steps. -

    2. If the given value is a ScrollOptions object, let y be the value of the y dictionary member. Otherwise, - let y be the given value.

    3. +
    4. If the given value is a ScrollOptionsVertical object, and the y dictionary member is not present, abort these steps. +

    5. If the given value is a ScrollOptionsVertical object, let y be the value of the y dictionary member. + Otherwise, let y be the given value.

    6. If the element does not have any associated CSS layout box, the element is the root element and the Document is in quirks mode, or the element has no associated scrolling box, or the element has no overflow, terminate these steps.

    7. If the element is the root element invoke scroll() with zero as first - argument and y as second, and, if the given value is a ScrollOptions object, the given value as the third argument.

    8. + argument and y as second, and, if the given value is a ScrollOptionsVertical object, the given value as the third argument.
    9. If the element is the HTML body element, the Document is in quirks mode, and the element does not have any vertical overflow, invoke scroll() with scrollX as first - argument and y as second, and, if the given value is a ScrollOptions object, the given value as the third argument.

    10. + argument and y as second, and, if the given value is a ScrollOptionsVertical object, the given value as the third argument.
    11. Scroll the element to scrollLeft,y, with the scroll behavior being the value of the behavior dictionary - member if the given value is a ScrollOptions object, or auto otherwise. + member if the given value is a ScrollOptionsVertical object, or auto otherwise.

    The scrollLeft attribute must return the result of running these steps:

    @@ -958,27 +1034,27 @@ var exampleHeight = example.height;

    When setting the scrollLeft attribute these steps must be run:

      -
    1. If the given value is a ScrollOptions object, and the x dictionary member is not present, abort these steps. -

    2. If the given value is a ScrollOptions object, let x be the value of the x dictionary member. Otherwise, - let x be the given value.

    3. +
    4. If the given value is a ScrollOptionsHorizontal object, and the x dictionary member is not present, abort these steps. +

    5. If the given value is a ScrollOptionsHorizontal object, let x be the value of the x dictionary member. + Otherwise, let x be the given value.

    6. If the element does not have any associated CSS layout box, the element is the root element and the Document is in quirks mode, or the element has no associated scrolling box, or the element has no overflow, terminate these steps.

    7. If the element is the root element invoke scroll() with - x as first argument and zero as second, and, if the given value is a ScrollOptions object, the given value as the third + x as first argument and zero as second, and, if the given value is a ScrollOptionsHorizontal object, the given value as the third argument.

    8. If the element is the HTML body element, the Document is in quirks mode, and the element does not have any vertical overflow, invoke scroll() with x as first argument and - scrollY as second, and, if the given value is a ScrollOptions object, the given value as the third + scrollY as second, and, if the given value is a ScrollOptionsHorizontal object, the given value as the third argument.

    9. Scroll the element to x,scrollTop, with the scroll behavior being the value of the behavior dictionary - member if the given value is a ScrollOptions object, or auto otherwise. + member if the given value is a ScrollOptionsHorizontal object, or auto otherwise.

    The scrollWidth attribute must return the result of running these steps:

    @@ -1032,9 +1108,10 @@ var exampleHeight = example.height;

    The clientWidth attribute must run these steps:

    1. If the element has no associated CSS layout box or if the CSS layout box is inline, return zero. -

    2. If the element is the root element and the element's document's browsing context is a - top-level browsing context, return the viewport width excluding the size of a rendered scroll bar (if - any). +

    3. If the element is the root element and the element's document is not in quirks mode, or + if the element is the HTML body element and the element's document is in + quirks mode, return the viewport width excluding the size of a rendered scroll bar + (if any).

    4. Return the width of the padding edge excluding the width of any rendered scrollbar between the padding edge and the border edge.

    @@ -1042,8 +1119,10 @@ var exampleHeight = example.height;

    The clientHeight attribute must run these steps:

    1. If the element has no associated CSS layout box or if the CSS layout box is inline, return zero. -

    2. If the element is the root element and the element's document's browsing context is a - top-level browsing context, return the viewport height excluding the size of a rendered scroll bar (if any). +

    3. If the element is the root element and the element's document is not in quirks mode, or + if the element is the HTML body element and the element's document is in + quirks mode, return the viewport height excluding the size of a rendered scroll + bar (if any).

    4. Return the height of the padding edge excluding the height of any rendered scrollbar between the padding edge and the border edge.

    @@ -1203,7 +1282,7 @@ a scrolling box scrolling box, in order of innermost to outermost scr

    8 Extensions to the HTMLElement Interface

    partial interface HTMLElement {
    -  readonly attribute Element offsetParent;
    +  readonly attribute Element? offsetParent;
       readonly attribute double offsetTop;
       readonly attribute double offsetLeft;
       readonly attribute double offsetWidth;
    @@ -1361,10 +1440,10 @@ browsers -->
     };
     
     partial dictionary MouseEventInit {
    -  double screenX = 0;
    -  double screenY = 0;
    -  double clientX = 0;
    -  double clientY = 0;
    +  double screenX = 0.0;
    +  double screenY = 0.0;
    +  double clientX = 0.0;
    +  double clientY = 0.0;
     };

    The screenX attribute must return the x-coordinate of @@ -1572,12 +1651,15 @@ David Vest, Elliott Sprehn, Garrett Smith, Hallvord R. M. Steen, +Kang-Hao Lu, Leif Arne Storset, Luiz Agostini, Maciej Stachowiak, Michael Dyck, Mike Wilson, Morten Stenshorne, +Olli Pettay, +Pavel Curtis, Peter-Paul Koch, Rachel Kmetz, Robert O'Callahan, @@ -1585,6 +1667,7 @@ Sam Weinig, Scott Johnson, Sebastian Zartner, Sylvain Galineau, +Tab Atkins, Tarquin Wilton-Jones, Thomas Moore, and Xiaomei Ji diff --git a/lib/js/js/web.jsx b/lib/js/js/web.jsx index 0b0b67c4..4abcc783 100644 --- a/lib/js/js/web.jsx +++ b/lib/js/js/web.jsx @@ -647,11 +647,9 @@ native class Element extends Node { // implements GetStyleUtils /** @see http://dev.w3.org/csswg/cssom/ */ - __readonly__ var specifiedStyle : CSSStyleDeclaration; + __readonly__ var cascadedStyle : CSSStyleDeclaration; /** @see http://dev.w3.org/csswg/cssom/ */ - __readonly__ var defaultStyle : CSSStyleDeclaration; - /** @see http://dev.w3.org/csswg/cssom/ */ - __readonly__ var computedStyle : CSSStyleDeclaration; + __readonly__ var rawComputedStyle : CSSStyleDeclaration; /** @see http://dev.w3.org/csswg/cssom/ */ __readonly__ var usedStyle : CSSStyleDeclaration; @@ -666,9 +664,9 @@ native class Element extends Node { /** @see http://dev.w3.org/csswg/cssom-view/ */ function scrollIntoView(top : boolean, options : ScrollOptions) : void; /** @see http://dev.w3.org/csswg/cssom-view/ */ - var scrollTop : variant/*(double or ScrollOptions)*/; + var scrollTop : variant/*(double or ScrollOptionsVertical)*/; /** @see http://dev.w3.org/csswg/cssom-view/ */ - var scrollLeft : variant/*(double or ScrollOptions)*/; + var scrollLeft : variant/*(double or ScrollOptionsHorizontal)*/; /** @see http://dev.w3.org/csswg/cssom-view/ */ __readonly__ var scrollWidth : number/*double*/; /** @see http://dev.w3.org/csswg/cssom-view/ */ @@ -1523,6 +1521,8 @@ native class CSSRule { __readonly__ var FONT_FACE_RULE : number/*unsigned short*/; static __readonly__ var PAGE_RULE : number/*unsigned short*/; __readonly__ var PAGE_RULE : number/*unsigned short*/; + static __readonly__ var MARGIN_RULE : number/*unsigned short*/; + __readonly__ var MARGIN_RULE : number/*unsigned short*/; static __readonly__ var NAMESPACE_RULE : number/*unsigned short*/; __readonly__ var NAMESPACE_RULE : number/*unsigned short*/; __readonly__ var type : number/*unsigned short*/; @@ -1573,13 +1573,21 @@ native final class CSSMediaRule extends CSSGroupingRule { } // end of CSSMediaRule /** @see http://dev.w3.org/csswg/cssom/ */ -native final class CSSPageRule extends CSSRule { +native final class CSSPageRule extends CSSGroupingRule { var selectorText : string/*DOMString*/; __readonly__ var style : CSSStyleDeclaration; } // end of CSSPageRule +/** @see http://dev.w3.org/csswg/cssom/ */ +native final class CSSMarginRule extends CSSRule { + + __readonly__ var name : string/*DOMString*/; + __readonly__ var style : CSSStyleDeclaration; + +} // end of CSSMarginRule + /** @see http://dev.w3.org/csswg/cssom/ */ native final class CSSNamespaceRule extends CSSRule { @@ -2119,6 +2127,15 @@ native final __fake__ class Window extends EventTarget { function matchMedia(query : string/*DOMString*/) : MediaQueryList; /** @see http://dev.w3.org/csswg/cssom-view/ */ __readonly__ var screen : Screen; + // browsing context + /** @see http://dev.w3.org/csswg/cssom-view/ */ + function moveTo(x : number/*double*/, y : number/*double*/) : void; + /** @see http://dev.w3.org/csswg/cssom-view/ */ + function moveBy(x : number/*double*/, y : number/*double*/) : void; + /** @see http://dev.w3.org/csswg/cssom-view/ */ + function resizeTo(x : number/*double*/, y : number/*double*/) : void; + /** @see http://dev.w3.org/csswg/cssom-view/ */ + function resizeBy(x : number/*double*/, y : number/*double*/) : void; // viewport /** @see http://dev.w3.org/csswg/cssom-view/ */ __readonly__ var innerWidth : number/*double*/; @@ -2287,6 +2304,25 @@ native final __fake__ class Window extends EventTarget { function btoa(btoa : string/*DOMString*/) : string/*DOMString*/; function atob(atob : string/*DOMString*/) : string/*DOMString*/; + // implements LocalFileSystem + + /** @see http://www.w3.org/TR/2012/WD-file-system-api-20120417/ */ + static __readonly__ var TEMPORARY : number/*unsigned short*/; + /** @see http://www.w3.org/TR/2012/WD-file-system-api-20120417/ */ + __readonly__ var TEMPORARY : number/*unsigned short*/; + /** @see http://www.w3.org/TR/2012/WD-file-system-api-20120417/ */ + static __readonly__ var PERSISTENT : number/*unsigned short*/; + /** @see http://www.w3.org/TR/2012/WD-file-system-api-20120417/ */ + __readonly__ var PERSISTENT : number/*unsigned short*/; + /** @see http://www.w3.org/TR/2012/WD-file-system-api-20120417/ */ + function requestFileSystem(type : number/*unsigned short*/, size : number/*unsigned long long*/, successCallback : function(filesystem:FileSystem):void/*FileSystemCallback*/) : void; + /** @see http://www.w3.org/TR/2012/WD-file-system-api-20120417/ */ + function requestFileSystem(type : number/*unsigned short*/, size : number/*unsigned long long*/, successCallback : function(filesystem:FileSystem):void/*FileSystemCallback*/, errorCallback : function(err:DOMError):void/*ErrorCallback*/) : void; + /** @see http://www.w3.org/TR/2012/WD-file-system-api-20120417/ */ + function resolveLocalFileSystemURL(url : string/*DOMString*/, successCallback : function(entry:Entry):void/*EntryCallback*/) : void; + /** @see http://www.w3.org/TR/2012/WD-file-system-api-20120417/ */ + function resolveLocalFileSystemURL(url : string/*DOMString*/, successCallback : function(entry:Entry):void/*EntryCallback*/, errorCallback : function(err:DOMError):void/*ErrorCallback*/) : void; + // implements WindowSessionStorage /** @see http://dev.w3.org/html5/webstorage/ */ @@ -2331,9 +2367,8 @@ native final __fake__ class Window extends EventTarget { /** @see http://dev.w3.org/csswg/cssom/ */ native __fake__ class GetStyleUtils { - __readonly__ var specifiedStyle : CSSStyleDeclaration; - __readonly__ var defaultStyle : CSSStyleDeclaration; - __readonly__ var computedStyle : CSSStyleDeclaration; + __readonly__ var cascadedStyle : CSSStyleDeclaration; + __readonly__ var rawComputedStyle : CSSStyleDeclaration; __readonly__ var usedStyle : CSSStyleDeclaration; } // end of GetStyleUtils @@ -2345,8 +2380,6 @@ native final class PseudoElement extends GetStyleUtils { /** @see http://dev.w3.org/csswg/cssom-view/ */ /* dictionary */ class ScrollOptions { - var x : number/*double*/; - var y : number/*double*/; var behavior : string/*ScrollBehavior*/; } // end of ScrollOptions @@ -2382,11 +2415,25 @@ native final class CaretPosition { } // end of CaretPosition +/** @see http://dev.w3.org/csswg/cssom-view/ */ +/* dictionary */ class ScrollOptionsHorizontal extends ScrollOptions { + + var x : number/*double*/; + +} // end of ScrollOptionsHorizontal + +/** @see http://dev.w3.org/csswg/cssom-view/ */ +/* dictionary */ class ScrollOptionsVertical extends ScrollOptions { + + var y : number/*double*/; + +} // end of ScrollOptionsVertical + /** @see http://www.w3.org/TR/html5/single-page.html */ native class HTMLElement extends Element { /** @see http://dev.w3.org/csswg/cssom-view/ */ - __readonly__ var offsetParent : Element; + __readonly__ var offsetParent : Nullable.; /** @see http://dev.w3.org/csswg/cssom-view/ */ __readonly__ var offsetTop : number/*double*/; /** @see http://dev.w3.org/csswg/cssom-view/ */ @@ -4449,6 +4496,246 @@ native final class FileReaderSync { } // end of FileReaderSync +/** @see http://www.w3.org/TR/2012/WD-file-writer-api-20120417/ */ +native final class BlobBuilder { + + function constructor(); + + function getBlob() : Blob; + function getBlob(contentType : string/*DOMString*/) : Blob; + function append(text : string/*DOMString*/) : void; + function append(text : string/*DOMString*/, endings : string/*DOMString*/) : void; + function append(data : Blob) : void; + function append(data : ArrayBuffer) : void; + +} // end of BlobBuilder + +/** @see http://www.w3.org/TR/2012/WD-file-writer-api-20120417/ */ +native class FileSaver extends EventTarget { + + function constructor(data : Blob); + + function abort() : void; + static __readonly__ var INIT : number/*unsigned short*/; + __readonly__ var INIT : number/*unsigned short*/; + static __readonly__ var WRITING : number/*unsigned short*/; + __readonly__ var WRITING : number/*unsigned short*/; + static __readonly__ var DONE : number/*unsigned short*/; + __readonly__ var DONE : number/*unsigned short*/; + __readonly__ var readyState : number/*unsigned short*/; + __readonly__ var error : DOMError; + var onwritestart : function(:Event):void/*Function*/; + var onprogress : function(:Event):void/*Function*/; + var onwrite : function(:Event):void/*Function*/; + var onabort : function(:Event):void/*Function*/; + var onerror : function(:Event):void/*Function*/; + var onwriteend : function(:Event):void/*Function*/; + +} // end of FileSaver + +/** @see http://www.w3.org/TR/2012/WD-file-writer-api-20120417/ */ +native final class FileWriter extends FileSaver { + + __readonly__ var position : number/*unsigned long long*/; + __readonly__ var length : number/*unsigned long long*/; + function write(data : Blob) : void; + function seek(offset : number/*long long*/) : void; + function truncate(size : number/*unsigned long long*/) : void; + +} // end of FileWriter + +/** @see http://www.w3.org/TR/2012/WD-file-writer-api-20120417/ */ +native final class FileWriterSync { + + __readonly__ var position : number/*unsigned long long*/; + __readonly__ var length : number/*unsigned long long*/; + function write(data : Blob) : void; + function seek(offset : number/*long long*/) : void; + function truncate(size : number/*unsigned long long*/) : void; + +} // end of FileWriterSync + +/** @see http://www.w3.org/TR/2012/WD-file-system-api-20120417/ */ +native __fake__ class LocalFileSystem { + + static __readonly__ var TEMPORARY : number/*unsigned short*/; + __readonly__ var TEMPORARY : number/*unsigned short*/; + static __readonly__ var PERSISTENT : number/*unsigned short*/; + __readonly__ var PERSISTENT : number/*unsigned short*/; + function requestFileSystem(type : number/*unsigned short*/, size : number/*unsigned long long*/, successCallback : function(filesystem:FileSystem):void/*FileSystemCallback*/) : void; + function requestFileSystem(type : number/*unsigned short*/, size : number/*unsigned long long*/, successCallback : function(filesystem:FileSystem):void/*FileSystemCallback*/, errorCallback : function(err:DOMError):void/*ErrorCallback*/) : void; + function resolveLocalFileSystemURL(url : string/*DOMString*/, successCallback : function(entry:Entry):void/*EntryCallback*/) : void; + function resolveLocalFileSystemURL(url : string/*DOMString*/, successCallback : function(entry:Entry):void/*EntryCallback*/, errorCallback : function(err:DOMError):void/*ErrorCallback*/) : void; + +} // end of LocalFileSystem + +/** @see http://www.w3.org/TR/2012/WD-file-system-api-20120417/ */ +native final __fake__ class LocalFileSystemSync { + + static __readonly__ var TEMPORARY : number/*unsigned short*/; + __readonly__ var TEMPORARY : number/*unsigned short*/; + static __readonly__ var PERSISTENT : number/*unsigned short*/; + __readonly__ var PERSISTENT : number/*unsigned short*/; + function requestFileSystemSync(type : number/*unsigned short*/, size : number/*unsigned long long*/) : FileSystemSync; + function resolveLocalFileSystemSyncURL(url : string/*DOMString*/) : EntrySync; + +} // end of LocalFileSystemSync + +/** @see http://www.w3.org/TR/2012/WD-file-system-api-20120417/ */ +native final class Metadata { + + __readonly__ var modificationTime : Date; + __readonly__ var size : number/*unsigned long long*/; + +} // end of Metadata + +/** @see http://www.w3.org/TR/2012/WD-file-system-api-20120417/ */ +/* dictionary */ class Flags { + + var create : boolean; + var exclusive : boolean; + +} // end of Flags + +/** @see http://www.w3.org/TR/2012/WD-file-system-api-20120417/ */ +native final class FileSystem { + + __readonly__ var name : string/*DOMString*/; + __readonly__ var root : DirectoryEntry; + +} // end of FileSystem + +/** @see http://www.w3.org/TR/2012/WD-file-system-api-20120417/ */ +native class Entry { + + __readonly__ var isFile : boolean; + __readonly__ var isDirectory : boolean; + function getMetadata(successCallback : function(metadata:Metadata):void/*MetadataCallback*/) : void; + function getMetadata(successCallback : function(metadata:Metadata):void/*MetadataCallback*/, errorCallback : function(err:DOMError):void/*ErrorCallback*/) : void; + __readonly__ var name : string/*DOMString*/; + __readonly__ var fullPath : string/*DOMString*/; + __readonly__ var filesystem : FileSystem; + function moveTo(parent : DirectoryEntry) : void; + function moveTo(parent : DirectoryEntry, newName : string/*DOMString*/) : void; + function moveTo(parent : DirectoryEntry, newName : string/*DOMString*/, successCallback : function(entry:Entry):void/*EntryCallback*/) : void; + function moveTo(parent : DirectoryEntry, newName : string/*DOMString*/, successCallback : function(entry:Entry):void/*EntryCallback*/, errorCallback : function(err:DOMError):void/*ErrorCallback*/) : void; + function copyTo(parent : DirectoryEntry) : void; + function copyTo(parent : DirectoryEntry, newName : string/*DOMString*/) : void; + function copyTo(parent : DirectoryEntry, newName : string/*DOMString*/, successCallback : function(entry:Entry):void/*EntryCallback*/) : void; + function copyTo(parent : DirectoryEntry, newName : string/*DOMString*/, successCallback : function(entry:Entry):void/*EntryCallback*/, errorCallback : function(err:DOMError):void/*ErrorCallback*/) : void; + function toURL() : string/*DOMString*/; + function remove(successCallback : function():void/*VoidCallback*/) : void; + function remove(successCallback : function():void/*VoidCallback*/, errorCallback : function(err:DOMError):void/*ErrorCallback*/) : void; + function getParent(successCallback : function(entry:Entry):void/*EntryCallback*/) : void; + function getParent(successCallback : function(entry:Entry):void/*EntryCallback*/, errorCallback : function(err:DOMError):void/*ErrorCallback*/) : void; + +} // end of Entry + +/** @see http://www.w3.org/TR/2012/WD-file-system-api-20120417/ */ +native final class DirectoryEntry extends Entry { + + function createReader() : DirectoryReader; + function getFile(path : string/*DOMString*/) : void; + function getFile(path : string/*DOMString*/, options : Flags) : void; + function getFile(path : string/*DOMString*/, options : Flags, successCallback : function(entry:Entry):void/*EntryCallback*/) : void; + function getFile(path : string/*DOMString*/, options : Flags, successCallback : function(entry:Entry):void/*EntryCallback*/, errorCallback : function(err:DOMError):void/*ErrorCallback*/) : void; + function getDirectory(path : string/*DOMString*/) : void; + function getDirectory(path : string/*DOMString*/, options : Flags) : void; + function getDirectory(path : string/*DOMString*/, options : Flags, successCallback : function(entry:Entry):void/*EntryCallback*/) : void; + function getDirectory(path : string/*DOMString*/, options : Flags, successCallback : function(entry:Entry):void/*EntryCallback*/, errorCallback : function(err:DOMError):void/*ErrorCallback*/) : void; + function removeRecursively(successCallback : function():void/*VoidCallback*/) : void; + function removeRecursively(successCallback : function():void/*VoidCallback*/, errorCallback : function(err:DOMError):void/*ErrorCallback*/) : void; + +} // end of DirectoryEntry + +/** @see http://www.w3.org/TR/2012/WD-file-system-api-20120417/ */ +native final class DirectoryReader { + + function readEntries(successCallback : function(entries:Entry[]):void/*EntriesCallback*/) : void; + function readEntries(successCallback : function(entries:Entry[]):void/*EntriesCallback*/, errorCallback : function(err:DOMError):void/*ErrorCallback*/) : void; + +} // end of DirectoryReader + +/** @see http://www.w3.org/TR/2012/WD-file-system-api-20120417/ */ +native final class FileEntry extends Entry { + + function createWriter(successCallback : function(fileWriter:FileWriter):void/*FileWriterCallback*/) : void; + function createWriter(successCallback : function(fileWriter:FileWriter):void/*FileWriterCallback*/, errorCallback : function(err:DOMError):void/*ErrorCallback*/) : void; + function file(successCallback : function(:File):void/*FileCallback*/) : void; + function file(successCallback : function(:File):void/*FileCallback*/, errorCallback : function(err:DOMError):void/*ErrorCallback*/) : void; + +} // end of FileEntry + +// alias FileSystemCallback = function(filesystem:FileSystem):void + +// alias EntryCallback = function(entry:Entry):void + +// alias EntriesCallback = function(entries:Entry[]):void + +// alias MetadataCallback = function(metadata:Metadata):void + +// alias FileWriterCallback = function(fileWriter:FileWriter):void + +// alias FileCallback = function(file:File):void + +// alias VoidCallback = function():void + +// alias ErrorCallback = function(err:DOMError):void + +/** @see http://www.w3.org/TR/2012/WD-file-system-api-20120417/ */ +native final class FileSystemSync { + + __readonly__ var name : string/*DOMString*/; + __readonly__ var root : DirectoryEntrySync; + +} // end of FileSystemSync + +/** @see http://www.w3.org/TR/2012/WD-file-system-api-20120417/ */ +native class EntrySync { + + __readonly__ var isFile : boolean; + __readonly__ var isDirectory : boolean; + function getMetadata() : Metadata; + __readonly__ var name : string/*DOMString*/; + __readonly__ var fullPath : string/*DOMString*/; + __readonly__ var filesystem : FileSystemSync; + function moveTo(parent : DirectoryEntrySync) : EntrySync; + function moveTo(parent : DirectoryEntrySync, newName : string/*DOMString*/) : EntrySync; + function copyTo(parent : DirectoryEntrySync) : EntrySync; + function copyTo(parent : DirectoryEntrySync, newName : string/*DOMString*/) : EntrySync; + function toURL() : string/*DOMString*/; + function remove() : void; + function getParent() : DirectoryEntrySync; + +} // end of EntrySync + +/** @see http://www.w3.org/TR/2012/WD-file-system-api-20120417/ */ +native final class DirectoryEntrySync extends EntrySync { + + function createReader() : DirectoryReaderSync; + function getFile(path : string/*DOMString*/) : FileEntrySync; + function getFile(path : string/*DOMString*/, options : Flags) : FileEntrySync; + function getDirectory(path : string/*DOMString*/) : DirectoryEntrySync; + function getDirectory(path : string/*DOMString*/, options : Flags) : DirectoryEntrySync; + function removeRecursively() : void; + +} // end of DirectoryEntrySync + +/** @see http://www.w3.org/TR/2012/WD-file-system-api-20120417/ */ +native final class DirectoryReaderSync { + + function readEntries() : EntrySync[]; + +} // end of DirectoryReaderSync + +/** @see http://www.w3.org/TR/2012/WD-file-system-api-20120417/ */ +native final class FileEntrySync extends EntrySync { + + function createWriter() : FileWriterSync; + function file() : File; + +} // end of FileEntrySync + /** @see http://www.w3.org/TR/2012/WD-webaudio-20121213/ */ native class AudioContext { diff --git a/t/lib/010.web.jsx b/t/lib/010.web.jsx index aa70cc64..b9d3f934 100644 --- a/t/lib/010.web.jsx +++ b/t/lib/010.web.jsx @@ -405,23 +405,22 @@ class _Test extends TestCase { var v16 : string/*DOMString*/ = o.outerHTML; o.insertAdjacentHTML(X.getstring(), X.getstring()); var f8 : Nullable. = o.pseudo(X.getstring()); - var v17 : CSSStyleDeclaration = o.specifiedStyle; - var v18 : CSSStyleDeclaration = o.defaultStyle; - var v19 : CSSStyleDeclaration = o.computedStyle; - var v20 : CSSStyleDeclaration = o.usedStyle; + var v17 : CSSStyleDeclaration = o.cascadedStyle; + var v18 : CSSStyleDeclaration = o.rawComputedStyle; + var v19 : CSSStyleDeclaration = o.usedStyle; var f9 : ClientRectList = o.getClientRects(); var f10 : ClientRect = o.getBoundingClientRect(); o.scrollIntoView(); o.scrollIntoView(X.getboolean()); o.scrollIntoView(X.getboolean(), X.getScrollOptions()); - var v21 : variant/*(double or ScrollOptions)*/ = o.scrollTop; - var v22 : variant/*(double or ScrollOptions)*/ = o.scrollLeft; - var v23 : number/*double*/ = o.scrollWidth; - var v24 : number/*double*/ = o.scrollHeight; - var v25 : number/*double*/ = o.clientTop; - var v26 : number/*double*/ = o.clientLeft; - var v27 : number/*double*/ = o.clientWidth; - var v28 : number/*double*/ = o.clientHeight; + var v20 : variant/*(double or ScrollOptionsVertical)*/ = o.scrollTop; + var v21 : variant/*(double or ScrollOptionsHorizontal)*/ = o.scrollLeft; + var v22 : number/*double*/ = o.scrollWidth; + var v23 : number/*double*/ = o.scrollHeight; + var v24 : number/*double*/ = o.clientTop; + var v25 : number/*double*/ = o.clientLeft; + var v26 : number/*double*/ = o.clientWidth; + var v27 : number/*double*/ = o.clientHeight; var f11 : Nullable. = o.querySelector(X.getstring()); var f12 : NodeList = o.querySelectorAll(X.getstring()); } // Element @@ -1028,12 +1027,14 @@ class _Test extends TestCase { var v10 : number/*unsigned short*/ = o.FONT_FACE_RULE; var v11 : number/*unsigned short*/ = CSSRule.PAGE_RULE; var v12 : number/*unsigned short*/ = o.PAGE_RULE; - var v13 : number/*unsigned short*/ = CSSRule.NAMESPACE_RULE; - var v14 : number/*unsigned short*/ = o.NAMESPACE_RULE; - var v15 : number/*unsigned short*/ = o.type; - var v16 : string/*DOMString*/ = o.cssText; - var v17 : Nullable. = o.parentRule; - var v18 : Nullable. = o.parentStyleSheet; + var v13 : number/*unsigned short*/ = CSSRule.MARGIN_RULE; + var v14 : number/*unsigned short*/ = o.MARGIN_RULE; + var v15 : number/*unsigned short*/ = CSSRule.NAMESPACE_RULE; + var v16 : number/*unsigned short*/ = o.NAMESPACE_RULE; + var v17 : number/*unsigned short*/ = o.type; + var v18 : string/*DOMString*/ = o.cssText; + var v19 : Nullable. = o.parentRule; + var v20 : Nullable. = o.parentStyleSheet; } // CSSRule function compile_CSSStyleRule(o : CSSStyleRule) : void { @@ -1066,6 +1067,11 @@ class _Test extends TestCase { var v2 : CSSStyleDeclaration = o.style; } // CSSPageRule + function compile_CSSMarginRule(o : CSSMarginRule) : void { + var v1 : string/*DOMString*/ = o.name; + var v2 : CSSStyleDeclaration = o.style; + } // CSSMarginRule + function compile_CSSNamespaceRule(o : CSSNamespaceRule) : void { var v1 : string/*DOMString*/ = o.namespaceURI; var v2 : string/*DOMString*/ = o.prefix; @@ -1588,6 +1594,10 @@ class _Test extends TestCase { var f2 : CSSStyleDeclaration = o.getComputedStyle(X.getElement(), X.getstring()); var f3 : MediaQueryList = o.matchMedia(X.getstring()); var v1 : Screen = o.screen; + o.moveTo(X.getnumber(), X.getnumber()); + o.moveBy(X.getnumber(), X.getnumber()); + o.resizeTo(X.getnumber(), X.getnumber()); + o.resizeBy(X.getnumber(), X.getnumber()); var v2 : number/*double*/ = o.innerWidth; var v3 : number/*double*/ = o.innerHeight; var v4 : number/*double*/ = o.scrollX; @@ -1721,9 +1731,17 @@ class _Test extends TestCase { var v105 : Nullable./*EventHandler*/ = o.onunload; var f18 : string/*DOMString*/ = o.btoa(X.getstring()); var f19 : string/*DOMString*/ = o.atob(X.getstring()); - var v106 : Storage = o.sessionStorage; - var v107 : Storage = o.localStorage; - var v108 : IDBFactory = o.indexedDB; + var v106 : number/*unsigned short*/ = Window.TEMPORARY; + var v107 : number/*unsigned short*/ = o.TEMPORARY; + var v108 : number/*unsigned short*/ = Window.PERSISTENT; + var v109 : number/*unsigned short*/ = o.PERSISTENT; + o.requestFileSystem(X.getnumber(), X.getnumber(), X.getfunction_filesystem_FileSystem__void()); + o.requestFileSystem(X.getnumber(), X.getnumber(), X.getfunction_filesystem_FileSystem__void(), X.getfunction_err_DOMError__void()); + o.resolveLocalFileSystemURL(X.getstring(), X.getfunction_entry_Entry__void()); + o.resolveLocalFileSystemURL(X.getstring(), X.getfunction_entry_Entry__void(), X.getfunction_err_DOMError__void()); + var v110 : Storage = o.sessionStorage; + var v111 : Storage = o.localStorage; + var v112 : IDBFactory = o.indexedDB; var f20 : number/*long*/ = o.setTimeout(X.getfunction___void()); var f21 : number/*long*/ = o.setTimeout(X.getfunction___void(), X.getnumber()); o.clearTimeout(X.getnumber()); @@ -1732,8 +1750,8 @@ class _Test extends TestCase { o.clearInterval(X.getnumber()); o.postMessage(X.getvariant(), X.getstring()); o.postMessage(X.getvariant(), X.getstring(), X.getTransferable__()); - var v109 : Nullable./*int?*/ = o.orientation; - var v110 : Nullable./*EventHandler*/ = o.onorientationchange; + var v113 : Nullable./*int?*/ = o.orientation; + var v114 : Nullable./*EventHandler*/ = o.onorientationchange; var f24 : number/*long*/ = o.requestAnimationFrame(X.getfunction_time_number__void()); o.cancelAnimationFrame(X.getnumber()); var f25 : number/*long*/ = o.webkitRequestAnimationFrame(X.getfunction_time_number__void()); @@ -1743,19 +1761,16 @@ class _Test extends TestCase { } // Window function compile_GetStyleUtils(o : GetStyleUtils) : void { - var v1 : CSSStyleDeclaration = o.specifiedStyle; - var v2 : CSSStyleDeclaration = o.defaultStyle; - var v3 : CSSStyleDeclaration = o.computedStyle; - var v4 : CSSStyleDeclaration = o.usedStyle; + var v1 : CSSStyleDeclaration = o.cascadedStyle; + var v2 : CSSStyleDeclaration = o.rawComputedStyle; + var v3 : CSSStyleDeclaration = o.usedStyle; } // GetStyleUtils function compile_PseudoElement(o : PseudoElement) : void { } // PseudoElement function compile_ScrollOptions(o : ScrollOptions) : void { - var v1 : number/*double*/ = o.x; - var v2 : number/*double*/ = o.y; - var v3 : string/*ScrollBehavior*/ = o.behavior; + var v1 : string/*ScrollBehavior*/ = o.behavior; } // ScrollOptions function compile_MediaQueryList(o : MediaQueryList) : void { @@ -1780,8 +1795,16 @@ class _Test extends TestCase { var f1 : Nullable. = o.getClientRect(); } // CaretPosition + function compile_ScrollOptionsHorizontal(o : ScrollOptionsHorizontal) : void { + var v1 : number/*double*/ = o.x; + } // ScrollOptionsHorizontal + + function compile_ScrollOptionsVertical(o : ScrollOptionsVertical) : void { + var v1 : number/*double*/ = o.y; + } // ScrollOptionsVertical + function compile_HTMLElement(o : HTMLElement) : void { - var v1 : Element = o.offsetParent; + var v1 : Nullable. = o.offsetParent; var v2 : number/*double*/ = o.offsetTop; var v3 : number/*double*/ = o.offsetLeft; var v4 : number/*double*/ = o.offsetWidth; @@ -3284,6 +3307,174 @@ class _Test extends TestCase { var f5 : string/*DOMString*/ = o.readAsDataURL(X.getBlob()); } // FileReaderSync + function compile_BlobBuilder(o : BlobBuilder) : void { + var c1 = new BlobBuilder(); + var f1 : Blob = o.getBlob(); + var f2 : Blob = o.getBlob(X.getstring()); + o.append(X.getstring()); + o.append(X.getstring(), X.getstring()); + o.append(X.getBlob()); + o.append(X.getArrayBuffer()); + } // BlobBuilder + + function compile_FileSaver(o : FileSaver) : void { + var c1 = new FileSaver(X.getBlob()); + o.abort(); + var v1 : number/*unsigned short*/ = FileSaver.INIT; + var v2 : number/*unsigned short*/ = o.INIT; + var v3 : number/*unsigned short*/ = FileSaver.WRITING; + var v4 : number/*unsigned short*/ = o.WRITING; + var v5 : number/*unsigned short*/ = FileSaver.DONE; + var v6 : number/*unsigned short*/ = o.DONE; + var v7 : number/*unsigned short*/ = o.readyState; + var v8 : DOMError = o.error; + var v9 : function(:Event):void/*Function*/ = o.onwritestart; + var v10 : function(:Event):void/*Function*/ = o.onprogress; + var v11 : function(:Event):void/*Function*/ = o.onwrite; + var v12 : function(:Event):void/*Function*/ = o.onabort; + var v13 : function(:Event):void/*Function*/ = o.onerror; + var v14 : function(:Event):void/*Function*/ = o.onwriteend; + } // FileSaver + + function compile_FileWriter(o : FileWriter) : void { + var v1 : number/*unsigned long long*/ = o.position; + var v2 : number/*unsigned long long*/ = o.length; + o.write(X.getBlob()); + o.seek(X.getnumber()); + o.truncate(X.getnumber()); + } // FileWriter + + function compile_FileWriterSync(o : FileWriterSync) : void { + var v1 : number/*unsigned long long*/ = o.position; + var v2 : number/*unsigned long long*/ = o.length; + o.write(X.getBlob()); + o.seek(X.getnumber()); + o.truncate(X.getnumber()); + } // FileWriterSync + + function compile_LocalFileSystem(o : LocalFileSystem) : void { + var v1 : number/*unsigned short*/ = LocalFileSystem.TEMPORARY; + var v2 : number/*unsigned short*/ = o.TEMPORARY; + var v3 : number/*unsigned short*/ = LocalFileSystem.PERSISTENT; + var v4 : number/*unsigned short*/ = o.PERSISTENT; + o.requestFileSystem(X.getnumber(), X.getnumber(), X.getfunction_filesystem_FileSystem__void()); + o.requestFileSystem(X.getnumber(), X.getnumber(), X.getfunction_filesystem_FileSystem__void(), X.getfunction_err_DOMError__void()); + o.resolveLocalFileSystemURL(X.getstring(), X.getfunction_entry_Entry__void()); + o.resolveLocalFileSystemURL(X.getstring(), X.getfunction_entry_Entry__void(), X.getfunction_err_DOMError__void()); + } // LocalFileSystem + + function compile_LocalFileSystemSync(o : LocalFileSystemSync) : void { + var v1 : number/*unsigned short*/ = LocalFileSystemSync.TEMPORARY; + var v2 : number/*unsigned short*/ = o.TEMPORARY; + var v3 : number/*unsigned short*/ = LocalFileSystemSync.PERSISTENT; + var v4 : number/*unsigned short*/ = o.PERSISTENT; + var f1 : FileSystemSync = o.requestFileSystemSync(X.getnumber(), X.getnumber()); + var f2 : EntrySync = o.resolveLocalFileSystemSyncURL(X.getstring()); + } // LocalFileSystemSync + + function compile_Metadata(o : Metadata) : void { + var v1 : Date = o.modificationTime; + var v2 : number/*unsigned long long*/ = o.size; + } // Metadata + + function compile_Flags(o : Flags) : void { + var v1 : boolean = o.create; + var v2 : boolean = o.exclusive; + } // Flags + + function compile_FileSystem(o : FileSystem) : void { + var v1 : string/*DOMString*/ = o.name; + var v2 : DirectoryEntry = o.root; + } // FileSystem + + function compile_Entry(o : Entry) : void { + var v1 : boolean = o.isFile; + var v2 : boolean = o.isDirectory; + o.getMetadata(X.getfunction_metadata_Metadata__void()); + o.getMetadata(X.getfunction_metadata_Metadata__void(), X.getfunction_err_DOMError__void()); + var v3 : string/*DOMString*/ = o.name; + var v4 : string/*DOMString*/ = o.fullPath; + var v5 : FileSystem = o.filesystem; + o.moveTo(X.getDirectoryEntry()); + o.moveTo(X.getDirectoryEntry(), X.getstring()); + o.moveTo(X.getDirectoryEntry(), X.getstring(), X.getfunction_entry_Entry__void()); + o.moveTo(X.getDirectoryEntry(), X.getstring(), X.getfunction_entry_Entry__void(), X.getfunction_err_DOMError__void()); + o.copyTo(X.getDirectoryEntry()); + o.copyTo(X.getDirectoryEntry(), X.getstring()); + o.copyTo(X.getDirectoryEntry(), X.getstring(), X.getfunction_entry_Entry__void()); + o.copyTo(X.getDirectoryEntry(), X.getstring(), X.getfunction_entry_Entry__void(), X.getfunction_err_DOMError__void()); + var f1 : string/*DOMString*/ = o.toURL(); + o.remove(X.getfunction___void()); + o.remove(X.getfunction___void(), X.getfunction_err_DOMError__void()); + o.getParent(X.getfunction_entry_Entry__void()); + o.getParent(X.getfunction_entry_Entry__void(), X.getfunction_err_DOMError__void()); + } // Entry + + function compile_DirectoryEntry(o : DirectoryEntry) : void { + var f1 : DirectoryReader = o.createReader(); + o.getFile(X.getstring()); + o.getFile(X.getstring(), X.getFlags()); + o.getFile(X.getstring(), X.getFlags(), X.getfunction_entry_Entry__void()); + o.getFile(X.getstring(), X.getFlags(), X.getfunction_entry_Entry__void(), X.getfunction_err_DOMError__void()); + o.getDirectory(X.getstring()); + o.getDirectory(X.getstring(), X.getFlags()); + o.getDirectory(X.getstring(), X.getFlags(), X.getfunction_entry_Entry__void()); + o.getDirectory(X.getstring(), X.getFlags(), X.getfunction_entry_Entry__void(), X.getfunction_err_DOMError__void()); + o.removeRecursively(X.getfunction___void()); + o.removeRecursively(X.getfunction___void(), X.getfunction_err_DOMError__void()); + } // DirectoryEntry + + function compile_DirectoryReader(o : DirectoryReader) : void { + o.readEntries(X.getfunction_entries_Entry____void()); + o.readEntries(X.getfunction_entries_Entry____void(), X.getfunction_err_DOMError__void()); + } // DirectoryReader + + function compile_FileEntry(o : FileEntry) : void { + o.createWriter(X.getfunction_fileWriter_FileWriter__void()); + o.createWriter(X.getfunction_fileWriter_FileWriter__void(), X.getfunction_err_DOMError__void()); + o.file(X.getfunction__File__void()); + o.file(X.getfunction__File__void(), X.getfunction_err_DOMError__void()); + } // FileEntry + + function compile_FileSystemSync(o : FileSystemSync) : void { + var v1 : string/*DOMString*/ = o.name; + var v2 : DirectoryEntrySync = o.root; + } // FileSystemSync + + function compile_EntrySync(o : EntrySync) : void { + var v1 : boolean = o.isFile; + var v2 : boolean = o.isDirectory; + var f1 : Metadata = o.getMetadata(); + var v3 : string/*DOMString*/ = o.name; + var v4 : string/*DOMString*/ = o.fullPath; + var v5 : FileSystemSync = o.filesystem; + var f2 : EntrySync = o.moveTo(X.getDirectoryEntrySync()); + var f3 : EntrySync = o.moveTo(X.getDirectoryEntrySync(), X.getstring()); + var f4 : EntrySync = o.copyTo(X.getDirectoryEntrySync()); + var f5 : EntrySync = o.copyTo(X.getDirectoryEntrySync(), X.getstring()); + var f6 : string/*DOMString*/ = o.toURL(); + o.remove(); + var f7 : DirectoryEntrySync = o.getParent(); + } // EntrySync + + function compile_DirectoryEntrySync(o : DirectoryEntrySync) : void { + var f1 : DirectoryReaderSync = o.createReader(); + var f2 : FileEntrySync = o.getFile(X.getstring()); + var f3 : FileEntrySync = o.getFile(X.getstring(), X.getFlags()); + var f4 : DirectoryEntrySync = o.getDirectory(X.getstring()); + var f5 : DirectoryEntrySync = o.getDirectory(X.getstring(), X.getFlags()); + o.removeRecursively(); + } // DirectoryEntrySync + + function compile_DirectoryReaderSync(o : DirectoryReaderSync) : void { + var f1 : EntrySync[] = o.readEntries(); + } // DirectoryReaderSync + + function compile_FileEntrySync(o : FileEntrySync) : void { + var f1 : FileWriterSync = o.createWriter(); + var f2 : File = o.file(); + } // FileEntrySync + function compile_AudioContext(o : AudioContext) : void { var c1 = new AudioContext(); var v1 : AudioDestinationNode = o.destination; @@ -5381,6 +5572,10 @@ native class X { static function getDelayNode() : DelayNode; static function getDeviceMotionEventInit() : DeviceMotionEventInit; static function getDeviceOrientationEventInit() : DeviceOrientationEventInit; + static function getDirectoryEntry() : DirectoryEntry; + static function getDirectoryEntrySync() : DirectoryEntrySync; + static function getDirectoryReader() : DirectoryReader; + static function getDirectoryReaderSync() : DirectoryReaderSync; static function getDocument() : Document; static function getDocumentFragment() : DocumentFragment; static function getDocumentType() : DocumentType; @@ -5389,6 +5584,8 @@ native class X { static function getDynamicsCompressorNode() : DynamicsCompressorNode; static function getElement() : Element; static function getElement__() : Element[]; + static function getEntrySync() : EntrySync; + static function getEntrySync__() : EntrySync[]; static function getErrorEventInit() : ErrorEventInit; static function getEvent() : Event; static function getEventInit() : EventInit; @@ -5396,7 +5593,12 @@ native class X { static function getEventTarget() : EventTarget; static function getExternal() : External; static function getFile() : File; + static function getFileEntrySync() : FileEntrySync; static function getFileList() : FileList; + static function getFileSystem() : FileSystem; + static function getFileSystemSync() : FileSystemSync; + static function getFileWriterSync() : FileWriterSync; + static function getFlags() : Flags; static function getFloat32Array() : Float32Array; static function getFocusEventInit() : FocusEventInit; static function getFormData() : FormData; @@ -5454,6 +5656,7 @@ native class X { static function getMediaStream__() : MediaStream[]; static function getMessageEventInit() : MessageEventInit; static function getMessagePort() : MessagePort; + static function getMetadata() : Metadata; static function getMouseEvent() : MouseEvent; static function getMouseEventInit() : MouseEventInit; static function getMutationObserverInit() : MutationObserverInit; @@ -5587,12 +5790,19 @@ native class X { static function getXMLHttpRequestUpload() : XMLHttpRequestUpload; static function getboolean() : boolean; static function getfunction__Event__void() : function(:Event):void; + static function getfunction__File__void() : function(:File):void; static function getfunction__IDBTransactionSync__number__void() : function(:IDBTransactionSync,:number):void; static function getfunction__IDBTransactionSync__void() : function(:IDBTransactionSync):void; static function getfunction__MediaQueryList__void() : function(:MediaQueryList):void; static function getfunction___void() : function():void; static function getfunction_decodedData_AudioBuffer__void() : function(decodedData:AudioBuffer):void; + static function getfunction_entries_Entry____void() : function(entries:Entry[]):void; + static function getfunction_entry_Entry__void() : function(entry:Entry):void; + static function getfunction_err_DOMError__void() : function(err:DOMError):void; static function getfunction_errorInformation_string__void() : function(errorInformation:string):void; + static function getfunction_fileWriter_FileWriter__void() : function(fileWriter:FileWriter):void; + static function getfunction_filesystem_FileSystem__void() : function(filesystem:FileSystem):void; + static function getfunction_metadata_Metadata__void() : function(metadata:Metadata):void; static function getfunction_mutations_MutationRecord___observer_MutationObserver__void() : function(mutations:MutationRecord[],observer:MutationObserver):void; static function getfunction_permission_string__void() : function(permission:string):void; static function getfunction_positionError_PositionError__void() : function(positionError:PositionError):void;