mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:32:45 +00:00 
			
		
		
		
	 b91c49364d
			
		
	
	
		b91c49364d
		
	
	
	
	
		
			
			This makes it more symmetrical with adopt_own() (which is used to create a NonnullOwnPtr from the result of a naked new.)
		
			
				
	
	
		
			35 lines
		
	
	
	
		
			797 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
	
		
			797 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2020, the SerenityOS developers.
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include <LibWeb/DOM/Event.h>
 | |
| #include <LibWeb/DOM/ShadowRoot.h>
 | |
| #include <LibWeb/Layout/BlockBox.h>
 | |
| 
 | |
| namespace Web::DOM {
 | |
| 
 | |
| ShadowRoot::ShadowRoot(Document& document, Element& host)
 | |
|     : DocumentFragment(document)
 | |
| {
 | |
|     set_host(host);
 | |
| }
 | |
| 
 | |
| EventTarget* ShadowRoot::get_parent(const Event& event)
 | |
| {
 | |
|     if (!event.composed()) {
 | |
|         auto& events_first_invocation_target = downcast<Node>(*event.path().first().invocation_target);
 | |
|         if (events_first_invocation_target.root() == this)
 | |
|             return nullptr;
 | |
|     }
 | |
| 
 | |
|     return host();
 | |
| }
 | |
| 
 | |
| RefPtr<Layout::Node> ShadowRoot::create_layout_node()
 | |
| {
 | |
|     return adopt_ref(*new Layout::BlockBox(document(), this, CSS::ComputedValues {}));
 | |
| }
 | |
| 
 | |
| }
 |