From c9f1ad5fd2f8b19aca0eef8a229b699afdd80017 Mon Sep 17 00:00:00 2001 From: Adam Vandolder Date: Thu, 7 Dec 2023 21:27:10 +0000 Subject: [PATCH] Bug 1712140 - Part 5: Block Declarative ShadowDOM behind feature pref. r=emilio Differential Revision: https://phabricator.services.mozilla.com/D194846 --- dom/webidl/Document.webidl | 1 + dom/webidl/Element.webidl | 3 +++ dom/webidl/HTMLTemplateElement.webidl | 6 ++++-- dom/webidl/ShadowRoot.webidl | 2 ++ layout/build/nsContentDLF.cpp | 3 ++- modules/libpref/init/StaticPrefList.yaml | 6 ++++++ 6 files changed, 18 insertions(+), 3 deletions(-) diff --git a/dom/webidl/Document.webidl b/dom/webidl/Document.webidl index 5aeea181e085..c82710bf8fa2 100644 --- a/dom/webidl/Document.webidl +++ b/dom/webidl/Document.webidl @@ -151,6 +151,7 @@ interface Document : Node { // https://html.spec.whatwg.org/multipage/dom.html#the-document-object partial interface Document { + [Pref="dom.webcomponents.shadowdom.declarative.enabled"] static Document parseHTMLUnsafe(DOMString html); [PutForwards=href, LegacyUnforgeable] readonly attribute Location? location; diff --git a/dom/webidl/Element.webidl b/dom/webidl/Element.webidl index 1f8d0f379d43..603dfd9bdc3e 100644 --- a/dom/webidl/Element.webidl +++ b/dom/webidl/Element.webidl @@ -276,6 +276,7 @@ dictionary ShadowRootInit { required ShadowRootMode mode; boolean delegatesFocus = false; SlotAssignmentMode slotAssignment = "named"; + [Pref="dom.webcomponents.shadowdom.declarative.enabled"] boolean clonable = false; }; @@ -406,5 +407,7 @@ partial interface Element { }; partial interface Element { + // https://html.spec.whatwg.org/#dom-element-sethtmlunsafe + [Pref="dom.webcomponents.shadowdom.declarative.enabled"] undefined setHTMLUnsafe(DOMString html); }; diff --git a/dom/webidl/HTMLTemplateElement.webidl b/dom/webidl/HTMLTemplateElement.webidl index ff17b16b91a8..ce71a51fe59e 100644 --- a/dom/webidl/HTMLTemplateElement.webidl +++ b/dom/webidl/HTMLTemplateElement.webidl @@ -14,6 +14,8 @@ interface HTMLTemplateElement : HTMLElement { [HTMLConstructor] constructor(); readonly attribute DocumentFragment content; - [CEReactions] attribute DOMString shadowRootMode; - [CEReactions] attribute boolean shadowRootDelegatesFocus; + [CEReactions, Pref="dom.webcomponents.shadowdom.declarative.enabled"] + attribute DOMString shadowRootMode; + [CEReactions, Pref="dom.webcomponents.shadowdom.declarative.enabled"] + attribute boolean shadowRootDelegatesFocus; }; diff --git a/dom/webidl/ShadowRoot.webidl b/dom/webidl/ShadowRoot.webidl index 2c7c8ed2cbb7..3a39894d112a 100644 --- a/dom/webidl/ShadowRoot.webidl +++ b/dom/webidl/ShadowRoot.webidl @@ -57,6 +57,8 @@ interface ShadowRoot : DocumentFragment }; partial interface ShadowRoot { + // https://html.spec.whatwg.org/#dom-shadowroot-sethtmlunsafe + [Pref="dom.webcomponents.shadowdom.declarative.enabled"] undefined setHTMLUnsafe(DOMString html); }; diff --git a/layout/build/nsContentDLF.cpp b/layout/build/nsContentDLF.cpp index 7c4528e49fb7..a9234099b0e0 100644 --- a/layout/build/nsContentDLF.cpp +++ b/layout/build/nsContentDLF.cpp @@ -314,7 +314,8 @@ nsresult nsContentDLF::CreateDocument( nsCOMPtr viewer = NS_NewDocumentViewer(); doc->SetContainer(static_cast(aContainer)); - doc->SetAllowDeclarativeShadowRoots(true); + doc->SetAllowDeclarativeShadowRoots( + mozilla::StaticPrefs::dom_webcomponents_shadowdom_declarative_enabled()); // Initialize the document to begin loading the data. An // nsIStreamListener connected to the parser is returned in diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index 7706151a62c3..aa7a83e4cff5 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -4528,6 +4528,12 @@ value: false mirror: always +# Is support for Declarative ShadowDOM enabled? +- name: dom.webcomponents.shadowdom.declarative.enabled + type: bool + value: @IS_NIGHTLY_BUILD@ + mirror: always + # Is support for the Web GPU API enabled? - name: dom.webgpu.enabled type: RelaxedAtomicBool