mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-10-31 05:10:57 +00:00 
			
		
		
		
	 6f433c8656
			
		
	
	
		6f433c8656
		
	
	
	
	
		
			
			This is a monster patch that turns all EventTargets into GC-allocated PlatformObjects. Their C++ wrapper classes are removed, and the LibJS garbage collector is now responsible for their lifetimes. There's a fair amount of hacks and band-aids in this patch, and we'll have a lot of cleanup to do after this.
		
			
				
	
	
		
			41 lines
		
	
	
	
		
			1,008 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
	
		
			1,008 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/RefCounted.h>
 | |
| #include <AK/Weakable.h>
 | |
| #include <LibWeb/Bindings/Wrappable.h>
 | |
| #include <LibWeb/DOM/Document.h>
 | |
| #include <LibWeb/DOM/ExceptionOr.h>
 | |
| #include <LibWeb/Forward.h>
 | |
| 
 | |
| namespace Web::HTML {
 | |
| 
 | |
| // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparser
 | |
| class DOMParser final
 | |
|     : public RefCounted<DOMParser>
 | |
|     , public Weakable<DOMParser>
 | |
|     , public Bindings::Wrappable {
 | |
| public:
 | |
|     using WrapperType = Bindings::DOMParserWrapper;
 | |
| 
 | |
|     static DOM::ExceptionOr<NonnullRefPtr<DOMParser>> create_with_global_object(HTML::Window& window)
 | |
|     {
 | |
|         return adopt_ref(*new DOMParser(window));
 | |
|     }
 | |
| 
 | |
|     virtual ~DOMParser() override;
 | |
| 
 | |
|     JS::NonnullGCPtr<DOM::Document> parse_from_string(String const&, Bindings::DOMParserSupportedType type);
 | |
| 
 | |
| private:
 | |
|     explicit DOMParser(HTML::Window&);
 | |
| 
 | |
|     JS::Handle<HTML::Window> m_window;
 | |
| };
 | |
| 
 | |
| }
 |