Non classé

Prototype declarative shadow DOM by rniwa · Pull Request #4693 · WebKit/WebKit


46837e5 Prototype declarative shadow DOM https://bugs.webkit.org/show_bug.cgi?id=245556 Reviewed by Chris Dumez. Implement the declarative shadow DOM an experimental feature. See whatwg/html#5465 and whatwg/dom#892 There are a few differences between what’s being proposed and what we implement: 1. getInnerHTML method is not added; we’ve given quite a few feedback on this method, and it’s nowhere near ready for implementation. 2. Declarative shadow DOMs inside another template element doesn’t automatically get converted to a shadow tree, and there is no special treatment of declarative shadow DOM when cloning Nodes. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/popups/popup-light-dismiss.tentative-expected.txt: Rebaselined. * LayoutTests/imported/w3c/web-platform-tests/shadow-dom/declarative/declarative-shadow-dom-attachment.tentative-expected.txt: Rebaselined the test now that we pass more test cases. * LayoutTests/imported/w3c/web-platform-tests/shadow-dom/declarative/declarative-shadow-dom-basic.tentative-expected.txt: Ditto. * LayoutTests/imported/w3c/web-platform-tests/shadow-dom/declarative/declarative-shadow-dom-opt-in.tentative-expected.txt: Ditto. * LayoutTests/imported/w3c/web-platform-tests/shadow-dom/declarative/innerhtml-before-closing-tag.tentative-expected.txt: Ditto. * LayoutTests/imported/w3c/web-platform-tests/shadow-dom/declarative/move-template-before-closing-tag-expected.txt: Removed. * LayoutTests/imported/w3c/web-platform-tests/shadow-dom/declarative/move-template-before-closing-tag.tentative-expected.txt: Ditto. * LayoutTests/imported/w3c/web-platform-tests/shadow-dom/declarative/script-access.tentative-expected.txt: Rebaselined. * Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml: Added a runtime flag. * Source/WebCore/CMakeLists.txt: * Source/WebCore/DerivedSources-input.xcfilelist: * Source/WebCore/DerivedSources-output.xcfilelist: * Source/WebCore/DerivedSources.make: * Source/WebCore/Sources.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/dom/DOMImplementation.cpp: (WebCore::createXMLDocument): Disable declarative shadow DOM in a document created by DOMImplementation.createDocument. (WebCore::DOMImplementation::createDocument): Ditto. (WebCore::DOMImplementation::createHTMLDocument): Ditto. * Source/WebCore/dom/Document.cpp: (WebCore::Document::Document): Initialize newly introduced m_parserContentPolicy with DefaultParserContentPolicy. (WebCore::Document::createParser): Specify m_parserContentPolicy as an argument to XMLDocumentParser::create. * Source/WebCore/dom/Document.h: (WebCore::Document::parserContentPolicy const): Added. (WebCore::Document::setParserContentPolicy): Added. * Source/WebCore/dom/Element.cpp: (WebCore::Element::attachShadow): Returns the shadow root of declarative shadow DOM if one is available. This happens exactly once since this function then clears the flag from ShadowRoot. (WebCore::Element::attachDeclarativeShadow): Added. * Source/WebCore/dom/Element.h: * Source/WebCore/dom/FragmentScriptingPermission.h: (WebCore::ParserContentPolicy): Added AllowDeclarativeShadowDOM. * Source/WebCore/dom/ScriptableDocumentParser.h: (WebCore::ScriptableDocumentParser::parserContentPolicy const): Made this const. (WebCore::ScriptableDocumentParser::setParserContentPolicy): Added. (WebCore::ScriptableDocumentParser::ScriptableDocumentParser): Added * Source/WebCore/dom/ShadowRoot.h: (WebCore::ShadowRoot::isDeclarativeShadowRoot): Added. (WebCore::ShadowRoot::setIsDeclarativeShadowRoot): Added. * Source/WebCore/html/HTMLAttributeNames.in: * Source/WebCore/html/HTMLDocument.cpp: (WebCore::HTMLDocument::createParser): Pass in the parser content policy. * Source/WebCore/html/HTMLTemplateElement.cpp: (WebCore::HTMLTemplateElement::attachAsDeclarativeShadowRootIfNeeded): Added. Implements the main logic of declarative shadow DOM. * Source/WebCore/html/HTMLTemplateElement.h: * Source/WebCore/html/parser/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::attachDeclarativeShadowRootIfNeeded): Added. * Source/WebCore/html/parser/HTMLConstructionSite.h: * Source/WebCore/html/parser/HTMLDocumentParser.cpp: (WebCore::HTMLDocumentParser::HTMLDocumentParser): Takes OptionSet as an argument. (WebCore::HTMLDocumentParser::create): Ditto. * Source/WebCore/html/parser/HTMLDocumentParser.h: * Source/WebCore/html/parser/HTMLTreeBuilder.cpp: (WebCore::HTMLTreeBuilder::processTemplateEndTag): Attach the template content as the declarative shadow DOM if applicable. * Source/WebCore/xml/DOMParser.cpp: (WebCore::DOMParser::parseFromString): Added ParseFromStringOptions as an argument. * Source/WebCore/xml/DOMParser.h: * Source/WebCore/xml/DOMParser.idl: * Source/WebCore/xml/ParseFromStringOptions.h: Added. * Source/WebCore/xml/ParseFromStringOptions.idl: Added. * Source/WebCore/xml/XMLHttpRequest.cpp: (XMLHttpRequest::responseXML): Disable declarative shadow DOM in the response document. * Source/WebCore/xml/parser/XMLDocumentParser.h: (WebCore::XMLDocumentParser::create): Takes OptionSet as an argument. * Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp: (WebCore::XMLDocumentParser::XMLDocumentParser): Ditto. Canonical link: https://commits.webkit.org/254964@main 2561ad4 Misc iOS, tvOS & watchOS macOS Linux Windows ✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe   🛠 🧪 win ✅ 🧪 bindings ✅ 🛠 ios-sim   🛠 mac-debug ✅ 🛠 gtk ✅ 🛠 wincairo ✅ 🧪 webkitperl   🧪 ios-wk2 ✅ 🛠 mac-AS-debug ✅ 🧪 gtk-wk2 ✅ 🧪 api-ios ✅ 🧪 api-mac ❌ 🧪 api-gtk ✅ 🛠 🧪 jsc ✅ 🛠 tv ✅ 🧪 mac-wk1 ✅ 🛠 jsc-armv7 ✅ 🛠 tv-sim ✅ 🧪 mac-wk2 ✅ 🧪 jsc-armv7-tests ✅ 🛠 🧪 merge ✅ 🛠 watch   🧪 mac-AS-debug-wk2 ✅ 🛠 jsc-mips ✅ 🛠 watch-sim ✅ 🧪 mac-wk2-stress ❌ 🧪 jsc-mips-tests Source: SwissUXNews