mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:27:35 +00:00
LibWeb: Add constructor options to TextDecoder
This commit is contained in:
parent
9ed8c0b183
commit
f1ead552ce
5 changed files with 47 additions and 15 deletions
|
@ -16,23 +16,33 @@
|
|||
|
||||
namespace Web::Encoding {
|
||||
|
||||
// https://encoding.spec.whatwg.org/#textdecoderoptions
|
||||
struct TextDecoderOptions {
|
||||
bool fatal = false;
|
||||
bool ignore_bom = false;
|
||||
};
|
||||
|
||||
// https://encoding.spec.whatwg.org/#textdecodeoptions
|
||||
struct TextDecodeOptions {
|
||||
bool stream = false;
|
||||
};
|
||||
|
||||
// https://encoding.spec.whatwg.org/#textdecoder
|
||||
class TextDecoder : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(TextDecoder, Bindings::PlatformObject);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<TextDecoder>> construct_impl(JS::Realm&, FlyString encoding);
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<TextDecoder>> construct_impl(JS::Realm&, FlyString encoding, Optional<TextDecoderOptions> const& options = {});
|
||||
|
||||
virtual ~TextDecoder() override;
|
||||
|
||||
WebIDL::ExceptionOr<String> decode(Optional<JS::Handle<JS::Object>> const&) const;
|
||||
WebIDL::ExceptionOr<String> decode(Optional<JS::Handle<JS::Object>> const&, Optional<TextDecodeOptions> const& options = {}) const;
|
||||
|
||||
FlyString const& encoding() const { return m_encoding; }
|
||||
bool fatal() const { return m_fatal; }
|
||||
bool ignore_bom() const { return m_ignore_bom; }
|
||||
|
||||
private:
|
||||
// https://encoding.spec.whatwg.org/#dom-textdecoder
|
||||
TextDecoder(JS::Realm&, TextCodec::Decoder&, FlyString encoding, bool fatal, bool ignore_bom);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue