LibWeb: Implement FileReaderSync interface

This interface allows the user to read File or Blob objects
synchronously from inside workers.
This commit is contained in:
Tim Ledbetter 2025-02-22 07:15:40 +00:00 committed by Tim Ledbetter
commit bbcd8bd97c
Notes: github-actions[bot] 2025-02-28 04:50:48 +00:00
6 changed files with 170 additions and 9 deletions

View file

@ -81,6 +81,14 @@ public:
void set_onloadend(WebIDL::CallbackType*);
WebIDL::CallbackType* onloadend();
enum class Type {
ArrayBuffer,
BinaryString,
Text,
DataURL,
};
static WebIDL::ExceptionOr<Result> blob_package_data(JS::Realm& realm, ByteBuffer, FileReader::Type type, Optional<String> const&, Optional<String> const& encoding_name = {});
protected:
FileReader(JS::Realm&, ByteBuffer);
@ -91,17 +99,8 @@ protected:
private:
explicit FileReader(JS::Realm&);
enum class Type {
ArrayBuffer,
BinaryString,
Text,
DataURL,
};
WebIDL::ExceptionOr<void> read_operation(Blob&, Type, Optional<String> const& encoding_name = {});
static WebIDL::ExceptionOr<Result> blob_package_data(JS::Realm& realm, ByteBuffer, FileReader::Type type, Optional<String> const&, Optional<String> const& encoding_name);
void queue_a_task(GC::Ref<GC::Function<void()>>);
// Internal state to handle aborting the FileReader.