| 
									
										
										
										
											2022-02-15 14:16:21 +03:30
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2022, Ali Mohammad Pur <mpfard@serenityos.org> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <AK/Forward.h>
 | 
					
						
							|  |  |  | #include <AK/NonnullRefPtr.h>
 | 
					
						
							|  |  |  | #include <LibJS/Forward.h>
 | 
					
						
							|  |  |  | #include <LibTextCodec/Decoder.h>
 | 
					
						
							| 
									
										
										
										
											2022-09-04 11:03:16 +02:00
										 |  |  | #include <LibWeb/Bindings/PlatformObject.h>
 | 
					
						
							| 
									
										
										
										
											2022-02-15 14:16:21 +03:30
										 |  |  | #include <LibWeb/Forward.h>
 | 
					
						
							| 
									
										
										
										
											2022-09-25 17:03:42 +01:00
										 |  |  | #include <LibWeb/WebIDL/ExceptionOr.h>
 | 
					
						
							| 
									
										
										
										
											2022-02-15 14:16:21 +03:30
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Web::Encoding { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // https://encoding.spec.whatwg.org/#textdecoder
 | 
					
						
							| 
									
										
										
										
											2022-09-04 11:03:16 +02:00
										 |  |  | class TextDecoder : public Bindings::PlatformObject { | 
					
						
							|  |  |  |     WEB_PLATFORM_OBJECT(TextDecoder, Bindings::PlatformObject); | 
					
						
							| 
									
										
										
										
											2022-02-15 14:16:21 +03:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-04 11:03:16 +02:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2023-01-08 19:23:00 -05:00
										 |  |  |     static WebIDL::ExceptionOr<JS::NonnullGCPtr<TextDecoder>> construct_impl(JS::Realm&, DeprecatedFlyString encoding); | 
					
						
							| 
									
										
										
										
											2022-02-15 14:16:21 +03:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-04 11:03:16 +02:00
										 |  |  |     virtual ~TextDecoder() override; | 
					
						
							| 
									
										
										
										
											2022-02-15 14:16:21 +03:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-30 09:48:23 +03:30
										 |  |  |     WebIDL::ExceptionOr<DeprecatedString> decode(Optional<JS::Handle<JS::Object>> const&) const; | 
					
						
							| 
									
										
										
										
											2022-02-15 14:16:21 +03:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-08 19:23:00 -05:00
										 |  |  |     DeprecatedFlyString const& encoding() const { return m_encoding; } | 
					
						
							| 
									
										
										
										
											2022-02-15 14:16:21 +03:30
										 |  |  |     bool fatal() const { return m_fatal; } | 
					
						
							| 
									
										
										
										
											2023-07-07 22:48:11 -04:00
										 |  |  |     bool ignore_bom() const { return m_ignore_bom; } | 
					
						
							| 
									
										
										
										
											2022-02-15 14:16:21 +03:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-04 11:03:16 +02:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2022-02-15 14:16:21 +03:30
										 |  |  |     // https://encoding.spec.whatwg.org/#dom-textdecoder
 | 
					
						
							| 
									
										
										
										
											2023-01-08 19:23:00 -05:00
										 |  |  |     TextDecoder(JS::Realm&, TextCodec::Decoder&, DeprecatedFlyString encoding, bool fatal, bool ignore_bom); | 
					
						
							| 
									
										
										
										
											2022-02-15 14:16:21 +03:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-28 12:33:35 -05:00
										 |  |  |     virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; | 
					
						
							| 
									
										
										
										
											2023-01-10 06:28:20 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-15 14:16:21 +03:30
										 |  |  |     TextCodec::Decoder& m_decoder; | 
					
						
							| 
									
										
										
										
											2023-01-08 19:23:00 -05:00
										 |  |  |     DeprecatedFlyString m_encoding; | 
					
						
							| 
									
										
										
										
											2022-02-15 14:16:21 +03:30
										 |  |  |     bool m_fatal { false }; | 
					
						
							|  |  |  |     bool m_ignore_bom { false }; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |