mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Script: Implement TextDecoderStream
(#38112)
This PR implements the `TextDecoderStream`. Other than introducing the necessary mod and webidl files corresponding to `TextDecoderStream`, this PR also involves some changes in `TextDecoder` and `TrasnformStream`: - The common part that can be shared between `TextDecoder` and `TextDecoderStream` are extracted into a separate type `script::dom::textdecodercommon::TextDecoderCommon`. This type could probably use a different name because there is an interface called `TextDecoderCommon` in the spec (https://encoding.spec.whatwg.org/#textdecodercommon) which just gets included in `TextDecoder` and `TextDecoderStream`. - The three algorithms in `TransformStream` (`cancel`, `flush`, and `transform`) all have become `enum` that has a `Js` variant for a JS function object and a `Native` variant for a rust trait object. Whether the cancel algorithm needs this enum type is debatable as I did not find any interface in the spec that explicitly sets the cancel algorithm. Testing: Existing WPT tests `tests/wpt/tests/encoding/stream` should be sufficient Fixes: #37723 --------- Signed-off-by: minghuaw <michael.wu1107@gmail.com> Signed-off-by: minghuaw <wuminghua7@huawei.com> Signed-off-by: Minghua Wu <michael.wu1107@gmail.com>
This commit is contained in:
parent
25822920cf
commit
554b2da1ad
25 changed files with 797 additions and 752 deletions
|
@ -0,0 +1,9 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://streams.spec.whatwg.org/#generictransformstream
|
||||
interface mixin GenericTransformStream {
|
||||
readonly attribute ReadableStream readable;
|
||||
readonly attribute WritableStream writable;
|
||||
};
|
|
@ -12,7 +12,7 @@ dictionary TextDecodeOptions {
|
|||
boolean stream = false;
|
||||
};
|
||||
|
||||
[Exposed=*]
|
||||
[Exposed=(Window,Worker)]
|
||||
interface TextDecoder {
|
||||
[Throws] constructor(optional DOMString label = "utf-8", optional TextDecoderOptions options = {});
|
||||
|
||||
|
|
15
components/script_bindings/webidls/TextDecoderStream.webidl
Normal file
15
components/script_bindings/webidls/TextDecoderStream.webidl
Normal file
|
@ -0,0 +1,15 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/*
|
||||
* For more information on this interface please see
|
||||
* https://encoding.spec.whatwg.org/#textdecoderstream
|
||||
*/
|
||||
|
||||
[Exposed=*]
|
||||
interface TextDecoderStream {
|
||||
[Throws] constructor(optional DOMString label = "utf-8", optional TextDecoderOptions options = {});
|
||||
};
|
||||
TextDecoderStream includes TextDecoderCommon;
|
||||
TextDecoderStream includes GenericTransformStream;
|
Loading…
Add table
Add a link
Reference in a new issue