haikuwebkit/LayoutTests/fast/shadow-dom/style-resolver-sharing-expe...

29 lines
1.7 KiB
Plaintext
Raw Permalink Normal View History

Share style resolvers between author shadow trees without style sheets https://bugs.webkit.org/show_bug.cgi?id=225102 Reviewed by Sam Weinig. Source/WebCore: Prepare for sharing style resolvers (and all the related data) between shadow trees beyond the currently supported user agent shadow trees. This patch refactors the sharing code and adds support for sharing resolvers for author shadow trees without style sheets. Test: fast/shadow-dom/style-resolver-sharing.html * dom/Document.cpp: (WebCore::Document::userAgentShadowTreeStyleResolver): Deleted. (WebCore::Document::didClearStyleResolver): Deleted. Move the shared UA resolver to Style::Scope. * dom/Document.h: * style/StyleResolver.h: (WebCore::Style::Resolver::wasShared const): (WebCore::Style::Resolver::setWasShared): Add a bit indicating if a resolver has been shared between shadow trees. * style/StyleScope.cpp: (WebCore::Style::Scope::resolver): (WebCore::Style::Scope::createDocumentResolver): (WebCore::Style::Scope::createOrFindSharedShadowTreeResolver): Factor into a function. Share user agent shadow tree resolver (as before) and also resolver for empty author shadow trees. (WebCore::Style::Scope::unshareShadowTreeResolverBeforeMutation): If we mutate an existing resolver we need to make it unavailable for sharing. (WebCore::Style::Scope::clearResolver): (WebCore::Style::Scope::releaseMemory): (WebCore::Style::Scope::analyzeStyleSheetChange): If we are about to mutate already shared resolver we need to create a new one. (WebCore::Style::Scope::updateActiveStyleSheets): If style sheets change and the resolver is shared always look it up again (since it can't be mutated). (WebCore::Style::Scope::updateResolver): (WebCore::Style::Scope::scheduleUpdate): (WebCore::Style::Scope::insertedInDocument): (WebCore::Style::Scope::didChangeStyleSheetEnvironment): (WebCore::Style::Scope::documentScope): (WebCore::Style::Scope::isForUserAgentShadowTree const): (WebCore::Style::Scope::shouldUseSharedUserAgentShadowTreeStyleResolver const): Deleted. (WebCore::Style::Scope::resolverIfExists): Deleted. * style/StyleScope.h: (WebCore::Style::Scope::resolverIfExists): * style/StyleScopeRuleSets.h: (WebCore::Style::ScopeRuleSets::setIsForShadowScope): Deleted. (WebCore::Internals::dumpStyleResolvers): * testing/Internals.h: * testing/Internals.idl: Testing support. LayoutTests: * fast/shadow-dom/style-resolver-sharing-expected.txt: Added. * fast/shadow-dom/style-resolver-sharing.html: Added. Canonical link: https://commits.webkit.org/237187@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276836 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-30 12:19:26 +00:00
Verify that shadow roots with identical styles share style resolvers (have equal identifier below).
(document resolver (identifier=0) (author rule count=0))
(shadow root resolver (user agent) (identifier=1) (author rule count=0))
(shadow root resolver (user agent) (identifier=1) (author rule count=0))
(shadow root resolver (author) (identifier=2) (author rule count=0))
(shadow root resolver (author) (identifier=2) (author rule count=0))
(shadow root resolver (author) (identifier=2) (author rule count=0))
(shadow root resolver (author) (identifier=2) (author rule count=0))
(shadow root resolver (author) (identifier=3) (author rule count=1))
Share style resolvers between author shadow trees with identical style https://bugs.webkit.org/show_bug.cgi?id=225187 <rdar://problem/77317178> Reviewed by Sam Weinig. Source/WebCore: Style resolvers own style resolution and invalidation rule sets, matched declarations cache, and other things. With complex stylesheets that can be lot of data. We currently create a style resolver for each author shadow tree. With web components it is common for a page to have large number of instances of the same component, and so shadow trees with identical style. We already deduplicate shadow tree stylesheets (including inline stylesheets based on string equality). With this patch we'll use these stylesheets as keys for sharing the full style resolvers as well. * style/StyleScope.cpp: (WebCore::Style::Scope::createOrFindSharedShadowTreeResolver): Expand the existing support for sharing between user agent shadow trees and author shadow trees with empty style. Look up shareable resolvers from a map. (WebCore::Style::Scope::unshareShadowTreeResolverBeforeMutation): (WebCore::Style::Scope::makeResolverSharingKey): Make a key from the active stylesheets and a bit indicating the shadow tree type. (WebCore::Style::Scope::releaseMemory): (WebCore::Style::Scope::didChangeStyleSheetEnvironment): * style/StyleScope.h: LayoutTests: * fast/shadow-dom/style-resolver-sharing-expected.txt: * fast/shadow-dom/style-resolver-sharing.html: Canonical link: https://commits.webkit.org/237228@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276882 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-02 05:22:49 +00:00
(shadow root resolver (author) (identifier=3) (author rule count=1))
(shadow root resolver (author) (identifier=3) (author rule count=1))
(shadow root resolver (author) (identifier=3) (author rule count=1))
(shadow root resolver (author) (identifier=3) (author rule count=1))
Share style resolvers between author shadow trees without style sheets https://bugs.webkit.org/show_bug.cgi?id=225102 Reviewed by Sam Weinig. Source/WebCore: Prepare for sharing style resolvers (and all the related data) between shadow trees beyond the currently supported user agent shadow trees. This patch refactors the sharing code and adds support for sharing resolvers for author shadow trees without style sheets. Test: fast/shadow-dom/style-resolver-sharing.html * dom/Document.cpp: (WebCore::Document::userAgentShadowTreeStyleResolver): Deleted. (WebCore::Document::didClearStyleResolver): Deleted. Move the shared UA resolver to Style::Scope. * dom/Document.h: * style/StyleResolver.h: (WebCore::Style::Resolver::wasShared const): (WebCore::Style::Resolver::setWasShared): Add a bit indicating if a resolver has been shared between shadow trees. * style/StyleScope.cpp: (WebCore::Style::Scope::resolver): (WebCore::Style::Scope::createDocumentResolver): (WebCore::Style::Scope::createOrFindSharedShadowTreeResolver): Factor into a function. Share user agent shadow tree resolver (as before) and also resolver for empty author shadow trees. (WebCore::Style::Scope::unshareShadowTreeResolverBeforeMutation): If we mutate an existing resolver we need to make it unavailable for sharing. (WebCore::Style::Scope::clearResolver): (WebCore::Style::Scope::releaseMemory): (WebCore::Style::Scope::analyzeStyleSheetChange): If we are about to mutate already shared resolver we need to create a new one. (WebCore::Style::Scope::updateActiveStyleSheets): If style sheets change and the resolver is shared always look it up again (since it can't be mutated). (WebCore::Style::Scope::updateResolver): (WebCore::Style::Scope::scheduleUpdate): (WebCore::Style::Scope::insertedInDocument): (WebCore::Style::Scope::didChangeStyleSheetEnvironment): (WebCore::Style::Scope::documentScope): (WebCore::Style::Scope::isForUserAgentShadowTree const): (WebCore::Style::Scope::shouldUseSharedUserAgentShadowTreeStyleResolver const): Deleted. (WebCore::Style::Scope::resolverIfExists): Deleted. * style/StyleScope.h: (WebCore::Style::Scope::resolverIfExists): * style/StyleScopeRuleSets.h: (WebCore::Style::ScopeRuleSets::setIsForShadowScope): Deleted. (WebCore::Internals::dumpStyleResolvers): * testing/Internals.h: * testing/Internals.idl: Testing support. LayoutTests: * fast/shadow-dom/style-resolver-sharing-expected.txt: Added. * fast/shadow-dom/style-resolver-sharing.html: Added. Canonical link: https://commits.webkit.org/237187@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276836 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-30 12:19:26 +00:00
After style mutation
(document resolver (identifier=0) (author rule count=0))
(shadow root resolver (user agent) (identifier=1) (author rule count=0))
(shadow root resolver (user agent) (identifier=1) (author rule count=0))
(shadow root resolver (author) (identifier=2) (author rule count=0))
(shadow root resolver (author) (identifier=2) (author rule count=0))
(shadow root resolver (author) (identifier=3) (author rule count=1))
Share style resolvers between author shadow trees with identical style https://bugs.webkit.org/show_bug.cgi?id=225187 <rdar://problem/77317178> Reviewed by Sam Weinig. Source/WebCore: Style resolvers own style resolution and invalidation rule sets, matched declarations cache, and other things. With complex stylesheets that can be lot of data. We currently create a style resolver for each author shadow tree. With web components it is common for a page to have large number of instances of the same component, and so shadow trees with identical style. We already deduplicate shadow tree stylesheets (including inline stylesheets based on string equality). With this patch we'll use these stylesheets as keys for sharing the full style resolvers as well. * style/StyleScope.cpp: (WebCore::Style::Scope::createOrFindSharedShadowTreeResolver): Expand the existing support for sharing between user agent shadow trees and author shadow trees with empty style. Look up shareable resolvers from a map. (WebCore::Style::Scope::unshareShadowTreeResolverBeforeMutation): (WebCore::Style::Scope::makeResolverSharingKey): Make a key from the active stylesheets and a bit indicating the shadow tree type. (WebCore::Style::Scope::releaseMemory): (WebCore::Style::Scope::didChangeStyleSheetEnvironment): * style/StyleScope.h: LayoutTests: * fast/shadow-dom/style-resolver-sharing-expected.txt: * fast/shadow-dom/style-resolver-sharing.html: Canonical link: https://commits.webkit.org/237228@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276882 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-02 05:22:49 +00:00
(shadow root resolver (author) (identifier=3) (author rule count=1))
(shadow root resolver (author) (identifier=4) (author rule count=2))
Share style resolvers between author shadow trees without style sheets https://bugs.webkit.org/show_bug.cgi?id=225102 Reviewed by Sam Weinig. Source/WebCore: Prepare for sharing style resolvers (and all the related data) between shadow trees beyond the currently supported user agent shadow trees. This patch refactors the sharing code and adds support for sharing resolvers for author shadow trees without style sheets. Test: fast/shadow-dom/style-resolver-sharing.html * dom/Document.cpp: (WebCore::Document::userAgentShadowTreeStyleResolver): Deleted. (WebCore::Document::didClearStyleResolver): Deleted. Move the shared UA resolver to Style::Scope. * dom/Document.h: * style/StyleResolver.h: (WebCore::Style::Resolver::wasShared const): (WebCore::Style::Resolver::setWasShared): Add a bit indicating if a resolver has been shared between shadow trees. * style/StyleScope.cpp: (WebCore::Style::Scope::resolver): (WebCore::Style::Scope::createDocumentResolver): (WebCore::Style::Scope::createOrFindSharedShadowTreeResolver): Factor into a function. Share user agent shadow tree resolver (as before) and also resolver for empty author shadow trees. (WebCore::Style::Scope::unshareShadowTreeResolverBeforeMutation): If we mutate an existing resolver we need to make it unavailable for sharing. (WebCore::Style::Scope::clearResolver): (WebCore::Style::Scope::releaseMemory): (WebCore::Style::Scope::analyzeStyleSheetChange): If we are about to mutate already shared resolver we need to create a new one. (WebCore::Style::Scope::updateActiveStyleSheets): If style sheets change and the resolver is shared always look it up again (since it can't be mutated). (WebCore::Style::Scope::updateResolver): (WebCore::Style::Scope::scheduleUpdate): (WebCore::Style::Scope::insertedInDocument): (WebCore::Style::Scope::didChangeStyleSheetEnvironment): (WebCore::Style::Scope::documentScope): (WebCore::Style::Scope::isForUserAgentShadowTree const): (WebCore::Style::Scope::shouldUseSharedUserAgentShadowTreeStyleResolver const): Deleted. (WebCore::Style::Scope::resolverIfExists): Deleted. * style/StyleScope.h: (WebCore::Style::Scope::resolverIfExists): * style/StyleScopeRuleSets.h: (WebCore::Style::ScopeRuleSets::setIsForShadowScope): Deleted. (WebCore::Internals::dumpStyleResolvers): * testing/Internals.h: * testing/Internals.idl: Testing support. LayoutTests: * fast/shadow-dom/style-resolver-sharing-expected.txt: Added. * fast/shadow-dom/style-resolver-sharing.html: Added. Canonical link: https://commits.webkit.org/237187@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276836 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-30 12:19:26 +00:00
(shadow root resolver (author) (identifier=5) (author rule count=2))
(shadow root resolver (author) (identifier=2) (author rule count=0))
(shadow root resolver (author) (identifier=2) (author rule count=0))
Share style resolvers between author shadow trees with identical style https://bugs.webkit.org/show_bug.cgi?id=225187 <rdar://problem/77317178> Reviewed by Sam Weinig. Source/WebCore: Style resolvers own style resolution and invalidation rule sets, matched declarations cache, and other things. With complex stylesheets that can be lot of data. We currently create a style resolver for each author shadow tree. With web components it is common for a page to have large number of instances of the same component, and so shadow trees with identical style. We already deduplicate shadow tree stylesheets (including inline stylesheets based on string equality). With this patch we'll use these stylesheets as keys for sharing the full style resolvers as well. * style/StyleScope.cpp: (WebCore::Style::Scope::createOrFindSharedShadowTreeResolver): Expand the existing support for sharing between user agent shadow trees and author shadow trees with empty style. Look up shareable resolvers from a map. (WebCore::Style::Scope::unshareShadowTreeResolverBeforeMutation): (WebCore::Style::Scope::makeResolverSharingKey): Make a key from the active stylesheets and a bit indicating the shadow tree type. (WebCore::Style::Scope::releaseMemory): (WebCore::Style::Scope::didChangeStyleSheetEnvironment): * style/StyleScope.h: LayoutTests: * fast/shadow-dom/style-resolver-sharing-expected.txt: * fast/shadow-dom/style-resolver-sharing.html: Canonical link: https://commits.webkit.org/237228@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276882 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-02 05:22:49 +00:00
(shadow root resolver (author) (identifier=3) (author rule count=1))
Share style resolvers between author shadow trees without style sheets https://bugs.webkit.org/show_bug.cgi?id=225102 Reviewed by Sam Weinig. Source/WebCore: Prepare for sharing style resolvers (and all the related data) between shadow trees beyond the currently supported user agent shadow trees. This patch refactors the sharing code and adds support for sharing resolvers for author shadow trees without style sheets. Test: fast/shadow-dom/style-resolver-sharing.html * dom/Document.cpp: (WebCore::Document::userAgentShadowTreeStyleResolver): Deleted. (WebCore::Document::didClearStyleResolver): Deleted. Move the shared UA resolver to Style::Scope. * dom/Document.h: * style/StyleResolver.h: (WebCore::Style::Resolver::wasShared const): (WebCore::Style::Resolver::setWasShared): Add a bit indicating if a resolver has been shared between shadow trees. * style/StyleScope.cpp: (WebCore::Style::Scope::resolver): (WebCore::Style::Scope::createDocumentResolver): (WebCore::Style::Scope::createOrFindSharedShadowTreeResolver): Factor into a function. Share user agent shadow tree resolver (as before) and also resolver for empty author shadow trees. (WebCore::Style::Scope::unshareShadowTreeResolverBeforeMutation): If we mutate an existing resolver we need to make it unavailable for sharing. (WebCore::Style::Scope::clearResolver): (WebCore::Style::Scope::releaseMemory): (WebCore::Style::Scope::analyzeStyleSheetChange): If we are about to mutate already shared resolver we need to create a new one. (WebCore::Style::Scope::updateActiveStyleSheets): If style sheets change and the resolver is shared always look it up again (since it can't be mutated). (WebCore::Style::Scope::updateResolver): (WebCore::Style::Scope::scheduleUpdate): (WebCore::Style::Scope::insertedInDocument): (WebCore::Style::Scope::didChangeStyleSheetEnvironment): (WebCore::Style::Scope::documentScope): (WebCore::Style::Scope::isForUserAgentShadowTree const): (WebCore::Style::Scope::shouldUseSharedUserAgentShadowTreeStyleResolver const): Deleted. (WebCore::Style::Scope::resolverIfExists): Deleted. * style/StyleScope.h: (WebCore::Style::Scope::resolverIfExists): * style/StyleScopeRuleSets.h: (WebCore::Style::ScopeRuleSets::setIsForShadowScope): Deleted. (WebCore::Internals::dumpStyleResolvers): * testing/Internals.h: * testing/Internals.idl: Testing support. LayoutTests: * fast/shadow-dom/style-resolver-sharing-expected.txt: Added. * fast/shadow-dom/style-resolver-sharing.html: Added. Canonical link: https://commits.webkit.org/237187@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276836 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-30 12:19:26 +00:00