2022-02-15 14:16:21 +03:30
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2022, Ali Mohammad Pur <mpfard@serenityos.org>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <AK/Forward.h>
|
|
|
|
|
#include <AK/NonnullRefPtr.h>
|
|
|
|
|
#include <LibJS/Forward.h>
|
|
|
|
|
#include <LibTextCodec/Decoder.h>
|
2022-09-04 11:03:16 +02:00
|
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
2026-05-01 19:01:23 +02:00
|
|
|
#include <LibWeb/Bindings/TextDecoder.h>
|
2026-04-28 11:32:35 +02:00
|
|
|
#include <LibWeb/Encoding/TextDecoderCommon.h>
|
2022-02-15 14:16:21 +03:30
|
|
|
#include <LibWeb/Forward.h>
|
2026-05-28 23:14:33 +02:00
|
|
|
#include <LibWeb/WebIDL/Buffers.h>
|
2022-09-25 17:03:42 +01:00
|
|
|
#include <LibWeb/WebIDL/ExceptionOr.h>
|
2022-02-15 14:16:21 +03:30
|
|
|
|
|
|
|
|
namespace Web::Encoding {
|
|
|
|
|
|
|
|
|
|
// https://encoding.spec.whatwg.org/#textdecoder
|
2026-04-28 11:32:35 +02:00
|
|
|
class TextDecoder
|
|
|
|
|
: public Bindings::PlatformObject
|
|
|
|
|
, public TextDecoderCommonMixin {
|
2022-09-04 11:03:16 +02:00
|
|
|
WEB_PLATFORM_OBJECT(TextDecoder, Bindings::PlatformObject);
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DECLARE_ALLOCATOR(TextDecoder);
|
2022-02-15 14:16:21 +03:30
|
|
|
|
2022-09-04 11:03:16 +02:00
|
|
|
public:
|
2026-05-01 19:01:23 +02:00
|
|
|
static WebIDL::ExceptionOr<GC::Ref<TextDecoder>> construct_impl(JS::Realm&, FlyString encoding, Optional<Bindings::TextDecoderOptions> const& options = {});
|
2022-02-15 14:16:21 +03:30
|
|
|
|
2022-09-04 11:03:16 +02:00
|
|
|
virtual ~TextDecoder() override;
|
2022-02-15 14:16:21 +03:30
|
|
|
|
2026-05-28 23:14:33 +02:00
|
|
|
WebIDL::ExceptionOr<String> decode(Optional<WebIDL::BufferSourceVariant>, Optional<Bindings::TextDecodeOptions> const& options = {}) const;
|
2022-02-15 14:16:21 +03:30
|
|
|
|
2022-09-04 11:03:16 +02:00
|
|
|
private:
|
2026-04-28 11:32:35 +02:00
|
|
|
TextDecoder(JS::Realm&, TextCodec::Decoder&, FlyString encoding, ErrorMode error_mode, bool ignore_bom);
|
2022-02-15 14:16:21 +03:30
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2022-02-15 14:16:21 +03:30
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|