Document style resolvers should share user rulesets
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 May 2017 19:02:43 +0000 (19:02 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 May 2017 19:02:43 +0000 (19:02 +0000)
commitc883fa07ee1be30921453f96a43dab761668aeeb
tree99911e630a26bb684ada8dd0c666bda646cadd1f
parent5e1738f8373ca0a28f6a7fabb4d5617b52e6cee0
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@216083 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/style/StyleScope.cpp