mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-11-03 23:00:58 +00:00 
			
		
		
		
	This interface allows the user to read File or Blob objects synchronously from inside workers.
		
			
				
	
	
		
			41 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
/*
 | 
						|
 * Copyright (c) 2025, Tim Ledbetter <tim.ledbetter@ladybird.org>
 | 
						|
 *
 | 
						|
 * SPDX-License-Identifier: BSD-2-Clause
 | 
						|
 */
 | 
						|
 | 
						|
#pragma once
 | 
						|
 | 
						|
#include <LibJS/Forward.h>
 | 
						|
#include <LibWeb/Bindings/PlatformObject.h>
 | 
						|
#include <LibWeb/FileAPI/FileReader.h>
 | 
						|
#include <LibWeb/Forward.h>
 | 
						|
 | 
						|
namespace Web::FileAPI {
 | 
						|
 | 
						|
// https://w3c.github.io/FileAPI/#FileReaderSync
 | 
						|
class FileReaderSync : public Bindings::PlatformObject {
 | 
						|
    WEB_PLATFORM_OBJECT(FileReaderSync, Bindings::PlatformObject);
 | 
						|
    GC_DECLARE_ALLOCATOR(FileReaderSync);
 | 
						|
 | 
						|
public:
 | 
						|
    virtual ~FileReaderSync() override;
 | 
						|
 | 
						|
    [[nodiscard]] static GC::Ref<FileReaderSync> create(JS::Realm&);
 | 
						|
    static GC::Ref<FileReaderSync> construct_impl(JS::Realm&);
 | 
						|
 | 
						|
    WebIDL::ExceptionOr<GC::Root<JS::ArrayBuffer>> read_as_array_buffer(Blob&);
 | 
						|
    WebIDL::ExceptionOr<String> read_as_binary_string(Blob&);
 | 
						|
    WebIDL::ExceptionOr<String> read_as_text(Blob&, Optional<String> const& encoding = {});
 | 
						|
    WebIDL::ExceptionOr<String> read_as_data_url(Blob&);
 | 
						|
 | 
						|
private:
 | 
						|
    explicit FileReaderSync(JS::Realm&);
 | 
						|
 | 
						|
    template<typename Result>
 | 
						|
    WebIDL::ExceptionOr<Result> read_as(Blob&, FileReader::Type, Optional<String> const& encoding = {});
 | 
						|
 | 
						|
    virtual void initialize(JS::Realm&) override;
 | 
						|
};
 | 
						|
 | 
						|
}
 |