Backed out 4 changesets (bug 1879154) for causing bustage on nsUserCharacteristics...
[gecko.git] / dom / webidl / TextEncoder.webidl
blob120d4693d1256a7c6abaedbcb36d2f033962db7e
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4  * You can obtain one at http://mozilla.org/MPL/2.0/.
5  *
6  * The origin of this IDL file is
7  * http://encoding.spec.whatwg.org/#interface-textencoder
8  */
10 interface mixin TextEncoderCommon {
11   /*
12    * This is DOMString in the spec, but the value is always ASCII
13    * and short. By declaring this as ByteString, we get the same
14    * end result (storage as inline Latin1 string in SpiderMonkey)
15    * with fewer conversions.
16    */
17   [Constant]
18   readonly attribute ByteString encoding;
21 dictionary TextEncoderEncodeIntoResult {
22   unsigned long long read;
23   unsigned long long written;
26 [Exposed=(Window,Worker)]
27 interface TextEncoder {
28   constructor();
30   /*
31    * This is spec-wise USVString but marking it as UTF8String as an
32    * optimization. (The SpiderMonkey-provided conversion to UTF-8 takes care of
33    * replacing lone surrogates with the REPLACEMENT CHARACTER, so the
34    * observable behavior of USVString is matched.)
35    */
36   [NewObject, Throws]
37   Uint8Array encode(optional UTF8String input = "");
39   /*
40    * The same comment about UTF8String as above applies here with JSString.
41    *
42    * We use JSString because we don't want to encode the full string, just as
43    * much as the capacity of the Uint8Array.
44    */
45   [CanOOM]
46   TextEncoderEncodeIntoResult encodeInto(JSString source, Uint8Array destination);
48 TextEncoder includes TextEncoderCommon;