| 
									
										
										
										
											2021-12-12 18:03:22 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2021, Linus Groh <linusg@serenityos.org> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <AK/Forward.h>
 | 
					
						
							|  |  |  | #include <AK/NonnullRefPtr.h>
 | 
					
						
							|  |  |  | #include <AK/RefCounted.h>
 | 
					
						
							|  |  |  | #include <LibJS/Forward.h>
 | 
					
						
							| 
									
										
										
										
											2022-09-04 17:09:45 +02:00
										 |  |  | #include <LibWeb/Bindings/PlatformObject.h>
 | 
					
						
							| 
									
										
										
										
											2021-12-12 18:03:22 +00:00
										 |  |  | #include <LibWeb/Forward.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace Web::Encoding { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // https://encoding.spec.whatwg.org/#textencoder
 | 
					
						
							| 
									
										
										
										
											2022-09-04 10:56:37 +02:00
										 |  |  | class TextEncoder final : public Bindings::PlatformObject { | 
					
						
							|  |  |  |     WEB_PLATFORM_OBJECT(TextEncoder, Bindings::PlatformObject); | 
					
						
							| 
									
										
										
										
											2021-12-12 18:03:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-04 10:56:37 +02:00
										 |  |  | public: | 
					
						
							| 
									
										
										
											
												LibWeb: Remove unecessary dependence on Window from assorted classes
These classes only needed Window to get at its realm. Pass a realm
directly to construct Crypto, Encoding, HRT, IntersectionObserver,
NavigationTiming, Page, RequestIdleCallback, Selection, Streams, URL,
and XML classes.
											
										 
											2022-09-25 18:11:21 -06:00
										 |  |  |     static JS::NonnullGCPtr<TextEncoder> construct_impl(JS::Realm&); | 
					
						
							| 
									
										
										
										
											2021-12-12 18:03:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-04 10:56:37 +02:00
										 |  |  |     virtual ~TextEncoder() override; | 
					
						
							| 
									
										
										
										
											2021-12-12 18:03:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-12 18:05:11 +00:00
										 |  |  |     JS::Uint8Array* encode(String const& input) const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-12 18:06:07 +00:00
										 |  |  |     static FlyString const& encoding(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-12 18:03:22 +00:00
										 |  |  | protected: | 
					
						
							|  |  |  |     // https://encoding.spec.whatwg.org/#dom-textencoder
 | 
					
						
							| 
									
										
										
											
												LibWeb: Remove unecessary dependence on Window from assorted classes
These classes only needed Window to get at its realm. Pass a realm
directly to construct Crypto, Encoding, HRT, IntersectionObserver,
NavigationTiming, Page, RequestIdleCallback, Selection, Streams, URL,
and XML classes.
											
										 
											2022-09-25 18:11:21 -06:00
										 |  |  |     explicit TextEncoder(JS::Realm&); | 
					
						
							| 
									
										
										
										
											2021-12-12 18:03:22 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |