8000 Disable DOMParser's includeShadowRoots option by default · WebKit/WebKit@fefa4f6 · GitHub
[go: up one dir, main page]

Skip to content

Commit fefa4f6

Browse files
committed
Disable DOMParser's includeShadowRoots option by default
https://bugs.webkit.org/show_bug.cgi?id=250421 Reviewed by Chris Dumez. Add a new runtime flag to enable includeShadowRoots option in DOMParser and turn this feature off by default. Also deleted a runtime flag for streaming declarative shadow DOM as we're only supporting streaming going forward. * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::insertHTMLTemplateElement): (WebCore::HTMLConstructionSite::attachDeclarativeShadowRootIfNeeded): Deleted. * Source/WebCore/html/parser/HTMLConstructionSite.h: * Source/WebCore/html/parser/HTMLTreeBuilder.cpp: (WebCore::HTMLTreeBuilder::processTemplateEndTag): * Source/WebCore/xml/DOMParser.cpp: (WebCore::DOMParser::parseFromString): Canonical link: https://commits.webkit.org/258768@main
1 parent 03224cf commit fefa4f6

File tree

5 files changed

+15
-26
lines changed

5 files changed

+15
-26
lines changed

Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,6 +1654,19 @@ DeclarativeShadowDOMEnabled:
16541654
WebCore:
16551655
default: true
16561656

1657+
DeclarativeShadowDOMInDOMParserEnabled:
1658+
type: bool
1659+
status: testable
1660+
humanReadableName: "DOMParser support for Declarative Shadow DOM"
1661+
humanReadableDescription: "Enable Declarative Shadow DOM in DOMParser"
1662+
defaultValue:
1663+
WebKitLegacy:
1664+
default: false
1665+
WebKit:
1666+
default: false
1667+
WebCore:
1668+
default: false
1669+
16571670
DefaultARIAForCustomElementsEnabled:
16581671
type: bool
16591672
status: stable
@@ -5595,19 +5608,6 @@ StorageBlockingPolicy:
55955608
WebCore:
55965609
default: StorageBlockingPolicy::AllowAll
55975610

5598-
StreamingDeclarativeShadowDOMEnabled:
5599-
type: bool
5600-
status: stable
5601-
humanReadableName: "Streaming for Declarative Shadow DOM"
5602-
humanReadableDescription: "Enable Streaming for Declarative Shadow DOM"
5603-
defaultValue:
5604-
WebKitLegacy:
5605-
default: true
5606-
WebKit:
5607-
default: true
5608-
WebCore:
5609-
default: true
5610-
56115611
SubgridEnabled:
56125612
type: bool
56135613
status: stable

Source/WebCore/html/parser/HTMLConstructionSite.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,7 @@ void HTMLConstructionSite::insertHTMLElement(AtomHTMLToken&& token)
536536

537537
void HTMLConstructionSite::insertHTMLTemplateElement(AtomHTMLToken&& token)
538538
{
539-
if (m_document.settings().declarativeShadowDOMEnabled() && m_document.settings().streamingDeclarativeShadowDOMEnabled()
540-
&& m_parserContentPolicy.contains(ParserContentPolicy::AllowDeclarativeShadowDOM)) {
539+
if (m_document.settings().declarativeShadowDOMEnabled() && m_parserContentPolicy.contains(ParserContentPolicy::AllowDeclarativeShadowDOM)) {
541540
std::optional<ShadowRootMode> mode;
542541
bool delegatesFocus = false;
543542
for (auto& attribute : token.attributes()) {
@@ -764,12 +763,6 @@ inline Document& HTMLConstructionSite::ownerDocumentForCurrentNode()
764763
return currentNode().document();
765764
}
766765

767-
void HTMLConstructionSite::attachDeclarativeShadowRootIfNeeded(Element& shadowHost, HTMLTemplateElement& templateElement)
768-
{
769-
if (m_parserContentPolicy.contains(ParserContentPolicy::AllowDeclarativeShadowDOM) && m_document.settings().declarativeShadowDOMEnabled() && !shadowHost.document().templateDocumentHost())
770-
templateElement.attachAsDeclarativeShadowRootIfNeeded(shadowHost);
771-
}
772-
773766
static inline JSCustomElementInterface* findCustomElementInterface(Document& ownerDocument, const AtomString& localName)
774767
{
775768
auto* window = ownerDocument.domWindow();

Source/WebCore/html/parser/HTMLConstructionSite.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,6 @@ class HTMLConstructionSite {
177177

178178
OptionSet<ParserContentPolicy> parserContentPolicy() { return m_parserContentPolicy; }
179179

180-
void attachDeclarativeShadowRootIfNeeded(Element& host, HTMLTemplateElement&);
181-
182180
#if ENABLE(TELEPHONE_NUMBER_DETECTION)
183181
bool isTelephoneNumberParsingEnabled() { return m_document.isTelephoneNumberParsingEnabled(); }
184182
#endif

Source/WebCore/html/parser/HTMLTreeBuilder.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -914,8 +914,6 @@ bool HTMLTreeBuilder::processTemplateEndTag(AtomHTMLToken&& token)
914914
m_templateInsertionModes.removeLast();
915915
resetInsertionModeAppropriately();
916916

917-
m_tree.attachDeclarativeShadowRootIfNeeded(shadowHost.get(), templateElement);
918-
919917
return true;
920918
}
921919

Source/WebCore/xml/DOMParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ ExceptionOr<Ref<Document>> DOMParser::parseFromString(const String& string, cons
4545
auto document = DOMImplementation::createDocument(contentType, nullptr, m_settings, URL { });
4646
if (m_contextDocument)
4747
document->setContextDocument(*m_contextDocument.get());
48-
if (options.includeShadowRoots)
48+
if (options.includeShadowRoots && document->settings().declarativeShadowDOMInDOMParserEnabled())
4949
document->setParserContentPolicy({ ParserContentPolicy::AllowScriptingContent, ParserContentPolicy::AllowPluginContent, ParserContentPolicy::AllowDeclarativeShadowDOM });
5050
else
5151
document->setParserContentPolicy({ ParserContentPolicy::AllowScriptingContent, ParserContentPolicy::AllowPluginContent });

0 commit comments

Comments
 (0)
0