LibWeb/Encoding: Take non-nullable options in TextDecoder construction
Also change to StringView instead of FlyString as we were not making use of FlyStrings properties here.
This commit is contained in:
parent
b81269e78b
commit
8caee39bac
2 changed files with 4 additions and 4 deletions
|
|
@ -18,7 +18,7 @@ namespace Web::Encoding {
|
|||
GC_DEFINE_ALLOCATOR(TextDecoder);
|
||||
|
||||
// https://encoding.spec.whatwg.org/#dom-textdecoder
|
||||
WebIDL::ExceptionOr<GC::Ref<TextDecoder>> TextDecoder::construct_impl(JS::Realm& realm, FlyString label, Optional<Bindings::TextDecoderOptions> const& options)
|
||||
WebIDL::ExceptionOr<GC::Ref<TextDecoder>> TextDecoder::construct_impl(JS::Realm& realm, StringView label, Bindings::TextDecoderOptions const& options)
|
||||
{
|
||||
auto& vm = realm.vm();
|
||||
|
||||
|
|
@ -35,10 +35,10 @@ WebIDL::ExceptionOr<GC::Ref<TextDecoder>> TextDecoder::construct_impl(JS::Realm&
|
|||
auto lowercase_encoding_name = encoding.value().to_ascii_lowercase_string();
|
||||
|
||||
// 4. If options["fatal"] is true, then set this’s error mode to "fatal".
|
||||
auto error_mode = options.value_or({}).fatal ? ErrorMode::Fatal : ErrorMode::Replacement;
|
||||
auto error_mode = options.fatal ? ErrorMode::Fatal : ErrorMode::Replacement;
|
||||
|
||||
// 5. Set this’s ignore BOM to options["ignoreBOM"].
|
||||
auto ignore_bom = options.value_or({}).ignore_bom;
|
||||
auto ignore_bom = options.ignore_bom;
|
||||
|
||||
// NOTE: This should happen in decode(), but we don't support streaming yet and share decoders across calls.
|
||||
auto decoder = TextCodec::decoder_for_exact_name(encoding.value());
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class TextDecoder
|
|||
GC_DECLARE_ALLOCATOR(TextDecoder);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<GC::Ref<TextDecoder>> construct_impl(JS::Realm&, FlyString encoding, Optional<Bindings::TextDecoderOptions> const& options = {});
|
||||
static WebIDL::ExceptionOr<GC::Ref<TextDecoder>> construct_impl(JS::Realm&, StringView label, Bindings::TextDecoderOptions const&);
|
||||
|
||||
virtual ~TextDecoder() override;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue