Document style resolvers should share user rulesets
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 May 2017 14:30:30 +0000 (14:30 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 May 2017 14:30:30 +0000 (14:30 +0000)
commit99c59a95ff4664b10abfaa8fd710bea74b1f5179
treed2ecaf7ec09fe9c0e9b48fcd8e53103493f0c008
parentaa4f4d31dd2e57a7c27153678cc8d59b111cd02f
Document style resolvers should share user rulesets
https://bugs.webkit.org/show_bug.cgi?id=171549

Reviewed by Andreas Kling.

Large user stylesheets (like those used by ad blockers) can end up using lots of memory if
a document uses large number of shadow trees. User style is inherently per-document and
the resulting rulesets can be shared between the document and the shadow trees.

* css/DocumentRuleSets.cpp:
(WebCore::DocumentRuleSets::DocumentRuleSets):
(WebCore::DocumentRuleSets::userStyle):

    Return per-document user style for shadow trees.

(WebCore::DocumentRuleSets::collectFeatures):
* css/DocumentRuleSets.h:
(WebCore::DocumentRuleSets::setUsesSharedUserStyle):
(WebCore::DocumentRuleSets::userStyle): Deleted.
* css/StyleResolver.cpp:
(WebCore::StyleResolver::StyleResolver):
(WebCore::StyleResolver::initializeUserStyle):

    Separate user style initialization from construction.

* css/StyleResolver.h:
* style/StyleScope.cpp:
(WebCore::Style::Scope::resolver):

    Don't initialize user style for user agents shadow trees.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216069 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/css/DocumentRuleSets.cpp
Source/WebCore/css/DocumentRuleSets.h
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/css/StyleResolver.h
Source/WebCore/style/StyleScope.cpp