| 
									
										
										
										
											2020-11-21 18:32:39 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2020, the SerenityOS developers. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-04-22 01:24:48 -07:00
										 |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							| 
									
										
										
										
											2020-11-21 18:32:39 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <LibWeb/DOM/Event.h>
 | 
					
						
							|  |  |  | #include <LibWeb/DOM/ShadowRoot.h>
 | 
					
						
							| 
									
										
										
										
											2021-02-10 18:23:52 +01:00
										 |  |  | #include <LibWeb/Layout/BlockBox.h>
 | 
					
						
							| 
									
										
										
										
											2020-11-21 18:32:39 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 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(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-10 18:23:52 +01:00
										 |  |  | RefPtr<Layout::Node> ShadowRoot::create_layout_node() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2021-04-23 16:46:57 +02:00
										 |  |  |     return adopt_ref(*new Layout::BlockBox(document(), this, CSS::ComputedValues {})); | 
					
						
							| 
									
										
										
										
											2021-02-10 18:23:52 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-21 18:32:39 +00:00
										 |  |  | } |