LibWeb: Add "allow declarative shadow roots" flag to Document

This commit is contained in:
Andreas Kling 2024-06-25 09:41:35 +02:00 committed by Andreas Kling
parent 637ccbec35
commit f3070118b1
Notes: sideshowbarker 2024-07-16 22:24:48 +09:00
3 changed files with 23 additions and 1 deletions

View File

@ -288,7 +288,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> Document::create_and_initialize(
// URL: creationURL
// current document readiness: "loading"
// about base URL: navigationParams's about base URL
// FIXME: allow declarative shadow roots: true
// allow declarative shadow roots: true
auto document = HTML::HTMLDocument::create(window->realm());
document->m_type = type;
document->m_content_type = move(content_type);
@ -300,6 +300,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> Document::create_and_initialize(
document->set_url(*creation_url);
document->m_readiness = HTML::DocumentReadyState::Loading;
document->m_about_base_url = navigation_params.about_base_url;
document->set_allow_declarative_shadow_roots(true);
document->m_window = window;
@ -5209,4 +5210,16 @@ Vector<JS::Handle<DOM::Range>> Document::find_matching_text(String const& query,
return matches;
}
// https://dom.spec.whatwg.org/#document-allow-declarative-shadow-roots
bool Document::allow_declarative_shadow_roots() const
{
return m_allow_declarative_shadow_roots;
}
// https://dom.spec.whatwg.org/#document-allow-declarative-shadow-roots
void Document::set_allow_declarative_shadow_roots(bool allow)
{
m_allow_declarative_shadow_roots = allow;
}
}

View File

@ -400,6 +400,9 @@ public:
bool is_fully_active() const;
bool is_active() const;
[[nodiscard]] bool allow_declarative_shadow_roots() const;
void set_allow_declarative_shadow_roots(bool);
JS::NonnullGCPtr<HTML::History> history();
JS::NonnullGCPtr<HTML::History> history() const;
@ -929,6 +932,9 @@ private:
// instead they generate boxes as if they were siblings of the root element.
OrderedHashTable<JS::NonnullGCPtr<Element>> m_top_layer_elements;
OrderedHashTable<JS::NonnullGCPtr<Element>> m_top_layer_pending_removals;
// https://dom.spec.whatwg.org/#document-allow-declarative-shadow-roots
bool m_allow_declarative_shadow_roots { false };
};
template<>

View File

@ -246,6 +246,9 @@ WebIDL::ExceptionOr<BrowsingContext::BrowsingContextAndDocument> BrowsingContext
// about base URL: creatorBaseURL
document->set_about_base_url(creator_base_url);
// allow declarative shadow roots: true
document->set_allow_declarative_shadow_roots(true);
// 16. If creator is non-null, then:
if (creator) {
// 1. Set document's referrer to the serialization of creator's URL.