summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2023-05-30 09:48:23 +0330
committerAndreas Kling <kling@serenityos.org>2023-05-30 12:50:13 +0200
commit0e3fb39a0ab9a54d708e18bfc638fe3ec182e6d0 (patch)
tree4426b29172d9c707ee7fe4c8b1cfce8177555cf0 /Userland/Libraries
parent540ea9f1c40c5044a4c4f1a13e153393345ee5cf (diff)
downloadserenity-0e3fb39a0ab9a54d708e18bfc638fe3ec182e6d0.zip
LibWeb: Make 'optional BufferSource' IDL arguments actually optional
Previously this was compiled to require an object despite the IDL file specifying 'optional'. This commit makes IDLGenerator respect this modifier, and fixes the only affected instance.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp7
-rw-r--r--Userland/Libraries/LibWeb/Encoding/TextDecoder.h2
2 files changed, 6 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp b/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp
index d975b7f8b5..eb02aa7822 100644
--- a/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp
+++ b/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp
@@ -44,11 +44,14 @@ JS::ThrowCompletionOr<void> TextDecoder::initialize(JS::Realm& realm)
}
// https://encoding.spec.whatwg.org/#dom-textdecoder-decode
-WebIDL::ExceptionOr<DeprecatedString> TextDecoder::decode(JS::Handle<JS::Object> const& input) const
+WebIDL::ExceptionOr<DeprecatedString> TextDecoder::decode(Optional<JS::Handle<JS::Object>> const& input) const
{
+ if (!input.has_value())
+ return TRY_OR_THROW_OOM(vm(), m_decoder.to_utf8({}));
+
// FIXME: Implement the streaming stuff.
- auto data_buffer_or_error = WebIDL::get_buffer_source_copy(*input.cell());
+ auto data_buffer_or_error = WebIDL::get_buffer_source_copy(*input->cell());
if (data_buffer_or_error.is_error())
return WebIDL::OperationError::create(realm(), "Failed to copy bytes from ArrayBuffer");
auto& data_buffer = data_buffer_or_error.value();
diff --git a/Userland/Libraries/LibWeb/Encoding/TextDecoder.h b/Userland/Libraries/LibWeb/Encoding/TextDecoder.h
index 02210830ae..e5e7c72f9b 100644
--- a/Userland/Libraries/LibWeb/Encoding/TextDecoder.h
+++ b/Userland/Libraries/LibWeb/Encoding/TextDecoder.h
@@ -25,7 +25,7 @@ public:
virtual ~TextDecoder() override;
- WebIDL::ExceptionOr<DeprecatedString> decode(JS::Handle<JS::Object> const&) const;
+ WebIDL::ExceptionOr<DeprecatedString> decode(Optional<JS::Handle<JS::Object>> const&) const;
DeprecatedFlyString const& encoding() const { return m_encoding; }
bool fatal() const { return m_fatal; }