mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-19 09:17:38 +03:00
LibWeb: Port TextDecoder interface from DeprecatedString to String
This commit is contained in:
parent
41928c2902
commit
278061e8b9
Notes:
sideshowbarker
2024-07-17 04:01:41 +09:00
Author: https://github.com/shannonbooth Commit: https://github.com/SerenityOS/serenity/commit/278061e8b9 Pull-request: https://github.com/SerenityOS/serenity/pull/20968
@ -4,7 +4,7 @@
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/DeprecatedFlyString.h>
|
||||
#include <AK/FlyString.h>
|
||||
#include <LibJS/Runtime/TypedArray.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Encoding/TextDecoder.h>
|
||||
@ -12,7 +12,7 @@
|
||||
|
||||
namespace Web::Encoding {
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<TextDecoder>> TextDecoder::construct_impl(JS::Realm& realm, DeprecatedFlyString encoding)
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<TextDecoder>> TextDecoder::construct_impl(JS::Realm& realm, FlyString encoding)
|
||||
{
|
||||
auto& vm = realm.vm();
|
||||
|
||||
@ -24,7 +24,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<TextDecoder>> TextDecoder::construct_impl(J
|
||||
}
|
||||
|
||||
// https://encoding.spec.whatwg.org/#dom-textdecoder
|
||||
TextDecoder::TextDecoder(JS::Realm& realm, TextCodec::Decoder& decoder, DeprecatedFlyString encoding, bool fatal, bool ignore_bom)
|
||||
TextDecoder::TextDecoder(JS::Realm& realm, TextCodec::Decoder& decoder, FlyString encoding, bool fatal, bool ignore_bom)
|
||||
: PlatformObject(realm)
|
||||
, m_decoder(decoder)
|
||||
, m_encoding(move(encoding))
|
||||
@ -42,7 +42,7 @@ void TextDecoder::initialize(JS::Realm& realm)
|
||||
}
|
||||
|
||||
// https://encoding.spec.whatwg.org/#dom-textdecoder-decode
|
||||
WebIDL::ExceptionOr<DeprecatedString> TextDecoder::decode(Optional<JS::Handle<JS::Object>> const& input) const
|
||||
WebIDL::ExceptionOr<String> TextDecoder::decode(Optional<JS::Handle<JS::Object>> const& input) const
|
||||
{
|
||||
if (!input.has_value())
|
||||
return TRY_OR_THROW_OOM(vm(), m_decoder.to_utf8({}));
|
||||
|
@ -21,24 +21,24 @@ class TextDecoder : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(TextDecoder, Bindings::PlatformObject);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<TextDecoder>> construct_impl(JS::Realm&, DeprecatedFlyString encoding);
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<TextDecoder>> construct_impl(JS::Realm&, FlyString encoding);
|
||||
|
||||
virtual ~TextDecoder() override;
|
||||
|
||||
WebIDL::ExceptionOr<DeprecatedString> decode(Optional<JS::Handle<JS::Object>> const&) const;
|
||||
WebIDL::ExceptionOr<String> decode(Optional<JS::Handle<JS::Object>> const&) const;
|
||||
|
||||
DeprecatedFlyString const& encoding() const { return m_encoding; }
|
||||
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&, DeprecatedFlyString encoding, bool fatal, bool ignore_bom);
|
||||
TextDecoder(JS::Realm&, TextCodec::Decoder&, FlyString encoding, bool fatal, bool ignore_bom);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
TextCodec::Decoder& m_decoder;
|
||||
DeprecatedFlyString m_encoding;
|
||||
FlyString m_encoding;
|
||||
bool m_fatal { false };
|
||||
bool m_ignore_bom { false };
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
[Exposed=(Window,Worker), UseDeprecatedAKString]
|
||||
[Exposed=(Window,Worker)]
|
||||
interface TextDecoder {
|
||||
// FIXME: 'optional TextDecoderOptions options = {}'
|
||||
constructor(optional DOMString label = "utf-8");
|
||||
|
Loading…
Reference in New Issue
Block a user