Index: Overview-FA.xml =================================================================== RCS file: /sources/public/2006/webapi/FileAPI/Overview-FA.xml,v retrieving revision 1.125 diff -p -U 8 -r1.125 Overview-FA.xml --- Overview-FA.xml 26 Jun 2012 20:25:03 -0000 1.125 +++ Overview-FA.xml 29 Jun 2012 16:56:57 -0000 @@ -394,40 +394,44 @@ If there are no such

Constructors

The Blob() constructor can be invoked with zero, one, or two parameters. When the Blob() constructor is invoked, user agents must run the following steps:

  1. If invoked with zero parameters, return a new Blob object consisting of 0 bytes, with size set to 0, and with type set to the empty string.

  2. -
  3. If invoked with a blobParts array, user agents must run the following substeps:

    +
  4. Otherwise, the constructor if invoked with a blobParts array. Let a be that array.

  5. +
  6. Let bytes be an empty sequence of bytes.

  7. +
  8. Let length be a's length. For 0 ≤ i < length, repeat the following steps:

      -
    1. Let a be the blobParts array. If a consists of DOMString array elements, each such array element must be converted to a sequence of Unicode characters [Unicode] using the algorithm for doing so in WebIDL [WebIDL], and be encoded as UTF-8.

      -
      -

      The algorithm from WebIDL [WebIDL] replaces unmatched surrogates in an invalid UTF-16 string with U+FFFD replacement characters when encoded as UTF-8. Scenarios exist when the Blob constructor may result in some data loss due to lost or scrambled character sequences.

      -
    2. -
    3. If the optional BlobPropertyBag dictionary is not used to invoke the constructor, each DOMString must have transparent line endings. If the optional BlobPropertyBag dictionary is used, and the endings dictionary member is set to "native" each DOMString must have native line endings.

      -
    4. -
    5. If a consists of ArrayBufferView [TypedArray] array elements, each such array element must be converted to a sequence of byteLength bytes from the underlying ArrayBuffer, starting at the byteOffset of the ArrayBufferView [TypedArrays].

    6. -
    7. If a consists of Blob array elements, each such array element must be converted to a sequence of n bytes, where n is the size of the Blob object. The type of the Blob array element is ignored.

    8. -
    9. For 0 < i < a.length, append every array element a[i] to the next array element as a sequence of bytes. The result is a sequence of bytes consisting of all the bytes of the array elements of a in a byte order corresponding to the array element order of a.

    10. -
    11. If the optional BlobPropertyBag dictionary is used to invoke the constructor and has a type member, then user agents must run the following substeps:

      +
    12. Let element be the ith element of a.

    13. +
    14. If element is a DOMString, run the following substeps:

        -
      1. Let s be the type dictionary member. If s consists of any non-ASCII characters, throw a SyntaxError (per [RFC2616]) and return from this algorithm.

      2. -
      3. Convert every character in s to lower case.

      4. -
      5. Parse s as an RFC2616 media-type, tokenizing it according to the ABNF for media-type [RFC2616] with the ASCII "/" character separating tokens representing the type and subtype productions. If s cannot be tokenized according to the ABNF for media-type [RFC2616], throw a SyntaxError and return from this algorithm.

      6. -
      7. If the type and subtype tokens consist of any CTLs or separators, throw a SyntaxError and return from this algorithm (per [RFC2616]).

      8. - +
      9. Let s be the result of converting element to a sequence of Unicode characters [Unicode] using the algorithm for doing so in WebIDL [WebIDL].

      10. +
      11. If the endings dictionary member of the options argument is set to "native", transform all newlines in s to the default line-ending representation of the underlying host operating system.

      12. +
      13. Encode s as UTF-8 and append the resulting bytes to bytes.

      +
      +

      The algorithm from WebIDL [WebIDL] replaces unmatched surrogates in an invalid UTF-16 string with U+FFFD replacement characters. Scenarios exist when the Blob constructor may result in some data loss due to lost or scrambled character sequences.

      +
    15. -
    16. Return a Blob object consisting of all the appended bytes of a, and with this Blob object's size attribute representing the total number of bytes. If the constructor has been invoked without the optional BlobPropertyBag dictionary or if the type member BlobPropertyBag dictionary has not been set then let this Blob object's type attribute be set to the empty string; otherwise, set this Blob object's type to s.

    17. +
    18. If element is an ArrayBufferView [TypedArrays], convert it to a sequence of byteLength bytes from the underlying ArrayBuffer, starting at the byteOffset of the ArrayBufferView [TypedArrays], and append those bytes to bytes.

    19. +
    20. If element is a Blob, append the bytes it represents to bytes. The type of the Blob array element is ignored.

    - -
  9. + +
  10. If the type member of the options argument is not the empty string, run the following substeps:

    +
      +
    1. Let s be the type dictionary member. If s contains any non-ASCII characters, throw a SyntaxError (per [RFC2616]) and return from this algorithm.

    2. +
    3. Convert every character in s to lower case.

    4. +
    5. Parse s as an RFC2616 media-type, tokenizing it according to the ABNF for media-type [RFC2616] with the ASCII "/" character separating tokens representing the type and subtype productions. If s cannot be tokenized according to the ABNF for media-type [RFC2616], throw a SyntaxError and return from this algorithm.

    6. +
    7. If the type and subtype tokens consist of any CTLs or separators, throw a SyntaxError and return from this algorithm (per [RFC2616]).

    8. +
    +
  11. +
  12. Return a Blob object consisting of bytes, with its size set to the length of bytes, and its type set to the type member of the options argument.

Constructor Parameters

The Blob() constructor can be invoked with the parameters below:

A blobParts Array
@@ -442,25 +446,25 @@ If there are no such which takes two members:

6.1. Constructors

The Blob() constructor can be invoked with zero, one, or two parameters. When the Blob() constructor is invoked, user agents must run the following steps:

  1. If invoked with zero parameters, return a new Blob object consisting of 0 bytes, with size set to 0, and with type set to the empty string.

  2. -
  3. If invoked with a blobParts array, user agents must run the following substeps:

    +
  4. Otherwise, the constructor if invoked with a blobParts array. Let a be that array.

  5. +
  6. Let bytes be an empty sequence of bytes.

  7. +
  8. Let length be a's length. For 0 ≤ i < length, repeat the following steps:

      -
    1. Let a be the blobParts array. If a consists of DOMString array elements, each such array element must be converted to a sequence of Unicode characters [Unicode] using the algorithm for doing so in WebIDL [WebIDL], and be encoded as UTF-8.

      -
      Note
      -

      The algorithm from WebIDL [WebIDL] replaces unmatched surrogates in an invalid UTF-16 string with U+FFFD replacement characters when encoded as UTF-8. Scenarios exist when the Blob constructor may result in some data loss due to lost or scrambled character sequences.

      -
    2. -
    3. If the optional BlobPropertyBag dictionary is not used to invoke the constructor, each DOMString must have transparent line endings. If the optional BlobPropertyBag dictionary is used, and the endings dictionary member is set to "native" each DOMString must have native line endings.

      -
    4. -
    5. If a consists of ArrayBufferView [TypedArray] array elements, each such array element must be converted to a sequence of byteLength bytes from the underlying ArrayBuffer, starting at the byteOffset of the ArrayBufferView [TypedArrays].

    6. -
    7. If a consists of Blob array elements, each such array element must be converted to a sequence of n bytes, where n is the size of the Blob object. The type of the Blob array element is ignored.

    8. -
    9. For 0 < i < a.length, append every array element a[i] to the next array element as a sequence of bytes. The result is a sequence of bytes consisting of all the bytes of the array elements of a in a byte order corresponding to the array element order of a.

    10. -
    11. If the optional BlobPropertyBag dictionary is used to invoke the constructor and has a type member, then user agents must run the following substeps:

      +
    12. Let element be the ith element of a.

    13. +
    14. If element is a DOMString, run the following substeps:

        -
      1. Let s be the type dictionary member. If s consists of any non-ASCII characters, throw a SyntaxError (per [RFC2616]) and return from this algorithm.

      2. -
      3. Convert every character in s to lower case.

      4. -
      5. Parse s as an RFC2616 media-type, tokenizing it according to the ABNF for media-type [RFC2616] with the ASCII "/" character separating tokens representing the type and subtype productions. If s cannot be tokenized according to the ABNF for media-type [RFC2616], throw a SyntaxError and return from this algorithm.

      6. -
      7. If the type and subtype tokens consist of any CTLs or separators, throw a SyntaxError and return from this algorithm (per [RFC2616]).

      8. - +
      9. Let s be the result of converting element to a sequence of Unicode characters [Unicode] using the algorithm for doing so in WebIDL [WebIDL].

      10. +
      11. If the endings dictionary member of the options argument is set to "native", transform all newlines in s to the default line-ending representation of the underlying host operating system.

      12. +
      13. Encode s as UTF-8 and append the resulting bytes to bytes.

      +
      Note
      +

      The algorithm from WebIDL [WebIDL] replaces unmatched surrogates in an invalid UTF-16 string with U+FFFD replacement characters. Scenarios exist when the Blob constructor may result in some data loss due to lost or scrambled character sequences.

      +
    15. -
    16. Return a Blob object consisting of all the appended bytes of a, and with this Blob object's size attribute representing the total number of bytes. If the constructor has been invoked without the optional BlobPropertyBag dictionary or if the type member BlobPropertyBag dictionary has not been set then let this Blob object's type attribute be set to the empty string; otherwise, set this Blob object's type to s.

    17. +
    18. If element is an ArrayBufferView [TypedArrays], convert it to a sequence of byteLength bytes from the underlying ArrayBuffer, starting at the byteOffset of the ArrayBufferView [TypedArrays], and append those bytes to bytes.

    19. +
    20. If element is a Blob, append the bytes it represents to bytes. The type of the Blob array element is ignored.

    - -
  9. + +
  10. If the type member of the options argument is not the empty string, run the following substeps:

    +
      +
    1. Let s be the type dictionary member. If s contains any non-ASCII characters, throw a SyntaxError (per [RFC2616]) and return from this algorithm.

    2. +
    3. Convert every character in s to lower case.

    4. +
    5. Parse s as an RFC2616 media-type, tokenizing it according to the ABNF for media-type [RFC2616] with the ASCII "/" character separating tokens representing the type and subtype productions. If s cannot be tokenized according to the ABNF for media-type [RFC2616], throw a SyntaxError and return from this algorithm.

    6. +
    7. If the type and subtype tokens consist of any CTLs or separators, throw a SyntaxError and return from this algorithm (per [RFC2616]).

    8. +
    +
  11. +
  12. Return a Blob object consisting of bytes, with its size set to the length of bytes, and its type set to the type member of the options argument.

6.1.1. Constructor Parameters

The Blob() constructor can be invoked with the parameters below:

A blobParts Array
@@ -451,25 +455,25 @@ If there are no such which takes two members: