[webkit-changes] [WebKit/WebKit] 9db1de: Save memory when StyleRule doesn't need nesting su...

Matthieu Dubet noreply at github.com
Tue Feb 14 15:21:22 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 9db1de406e2b5f350982be72632decc09b81e33f
      https://github.com/WebKit/WebKit/commit/9db1de406e2b5f350982be72632decc09b81e33f
  Author: Matthieu Dubet <m_dubet at apple.com>
  Date:   2023-02-14 (Tue, 14 Feb 2023)

  Changed paths:
    M Source/WebCore/bindings/js/JSCSSRuleCustom.cpp
    M Source/WebCore/css/CSSSelectorList.cpp
    M Source/WebCore/css/CSSSelectorList.h
    M Source/WebCore/css/CSSStyleRule.cpp
    M Source/WebCore/css/CSSStyleRule.h
    M Source/WebCore/css/StyleRule.cpp
    M Source/WebCore/css/StyleRule.h
    M Source/WebCore/css/StyleRuleType.h
    M Source/WebCore/css/StyleSheetContents.cpp
    M Source/WebCore/css/parser/CSSParserImpl.cpp
    M Source/WebCore/css/parser/CSSParserImpl.h
    M Source/WebCore/inspector/InspectorStyleSheet.cpp
    M Source/WebCore/style/RuleSetBuilder.cpp
    M Source/WebCore/style/RuleSetBuilder.h

  Log Message:
  -----------
  Save memory when StyleRule doesn't need nesting support
https://bugs.webkit.org/show_bug.cgi?id=252176
rdar://105399781

Reviewed by Antti Koivisto.

Support for CSS Nesting has added 2 members to the StyleRule class
(the resolved selector list, and the list of children rules),
which created a memory regression of Membuster.

This patch creates a separate StyleWithNestingRule to be used when we actually
need the CSS Nesting feature (which is determined at parsing time).

When we don't need the CSS Nesting feature, it has exactly zero memory cost.

* Source/WebCore/bindings/js/JSCSSRuleCustom.cpp:
(WebCore::toJSNewlyCreated):
* Source/WebCore/css/CSSSelectorList.cpp:
(WebCore::CSSSelectorList::hasExplicitNestingParent const):
* Source/WebCore/css/CSSSelectorList.h:
* Source/WebCore/css/CSSStyleRule.cpp:
(WebCore::CSSStyleRule::CSSStyleRule):
(WebCore::CSSStyleRule::nestedRules const):
(WebCore::CSSStyleRule::cssText const):
(WebCore::CSSStyleRule::length const):
(WebCore::CSSStyleRule::item const):
* Source/WebCore/css/CSSStyleRule.h:
* Source/WebCore/css/StyleRule.cpp:
(WebCore::StyleRuleBase::visitDerived):
(WebCore::StyleRuleBase::createCSSOMWrapper const):
(WebCore::StyleRule::StyleRule):
(WebCore::StyleRule::create):
(WebCore::StyleRule::createForSplitting):
(WebCore::StyleRule::resolvedSelectorList const):
(WebCore::StyleRuleWithNesting::create):
(WebCore::StyleRuleWithNesting::StyleRuleWithNesting):
(WebCore::StyleRuleWithNesting::setResolvedSelectorList const):
(WebCore::StyleRuleGroup::StyleRuleGroup):
(WebCore::StyleRuleRareData::createIfNeeded): Deleted.
(WebCore::StyleRule::rareData const): Deleted.
(WebCore::StyleRule::setNestedRules): Deleted.
(WebCore::StyleRule::setResolvedSelectorList const): Deleted.
(WebCore::emptyRuleVector): Deleted.
(WebCore::StyleRule::nestedRules const): Deleted.
* Source/WebCore/css/StyleRule.h:
(WebCore::StyleRuleBase::isStyleRule const):
(WebCore::StyleRuleBase::isStyleRuleWithNesting const):
(WebCore::StyleRuleBase::setType):
(isType):
(WebCore::StyleRuleRareData::createIfNeeded): Deleted.
* Source/WebCore/css/StyleRuleType.h:
* Source/WebCore/css/StyleSheetContents.cpp:
(WebCore::StyleSheetContents::traverseSubresources const):
* Source/WebCore/css/parser/CSSParserImpl.cpp:
(WebCore::CSSParserImpl::createNestingParentRule):
(WebCore::CSSParserImpl::consumeStyleRule):
* Source/WebCore/css/parser/CSSParserImpl.h:
* Source/WebCore/inspector/InspectorStyleSheet.cpp:
(WebCore::flatteningStrategyForStyleRuleType):
* Source/WebCore/style/RuleSetBuilder.cpp:
(WebCore::Style::RuleSetBuilder::addChildRule):
(WebCore::Style::RuleSetBuilder::populateStyleRuleResolvedSelectorList):
(WebCore::Style::RuleSetBuilder::addStyleRuleWithSelectorList):
(WebCore::Style::RuleSetBuilder::addStyleRule):
* Source/WebCore/style/RuleSetBuilder.h:

Canonical link: https://commits.webkit.org/260281@main




More information about the webkit-changes mailing list