mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-10-31 21:30:58 +00:00 
			
		
		
		
	 c4826eae4f
			
		
	
	
		c4826eae4f
		
	
	
	
	
		
			
			There's a subtle difference here. A "block box" in the spec is a block-level box, while a "block container" is a box whose children are either all inline-level boxes in an IFC, or all block-level boxes participating in a BFC. Notably, an "inline-block" box is a "block container" but not a "block box" since it is itself inline-level.
		
			
				
	
	
		
			55 lines
		
	
	
	
		
			1.5 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			55 lines
		
	
	
	
		
			1.5 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2020, the SerenityOS developers.
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include <LibWeb/DOM/Document.h>
 | |
| #include <LibWeb/DOM/Event.h>
 | |
| #include <LibWeb/DOM/ShadowRoot.h>
 | |
| #include <LibWeb/DOMParsing/InnerHTML.h>
 | |
| #include <LibWeb/Layout/BlockContainer.h>
 | |
| 
 | |
| namespace Web::DOM {
 | |
| 
 | |
| ShadowRoot::ShadowRoot(Document& document, Element& host)
 | |
|     : DocumentFragment(document)
 | |
| {
 | |
|     set_host(host);
 | |
| }
 | |
| 
 | |
| // https://dom.spec.whatwg.org/#ref-for-get-the-parent%E2%91%A6
 | |
| EventTarget* ShadowRoot::get_parent(const Event& event)
 | |
| {
 | |
|     if (!event.composed()) {
 | |
|         auto& events_first_invocation_target = verify_cast<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::BlockContainer(document(), this, CSS::ComputedValues {}));
 | |
| }
 | |
| 
 | |
| // https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml
 | |
| String ShadowRoot::inner_html() const
 | |
| {
 | |
|     return serialize_fragment(/* FIXME: Providing true for the require well-formed flag (which may throw) */);
 | |
| }
 | |
| 
 | |
| // https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml
 | |
| ExceptionOr<void> ShadowRoot::set_inner_html(String const& markup)
 | |
| {
 | |
|     auto result = DOMParsing::InnerHTML::inner_html_setter(*this, markup);
 | |
|     if (result.is_exception())
 | |
|         return result.exception();
 | |
| 
 | |
|     set_needs_style_update(true);
 | |
|     return {};
 | |
| }
 | |
| 
 | |
| }
 |