[webkit-changes] [WebKit/WebKit] 147e3e: Reduce custom property storage for sites with larg...

Cameron McCormack noreply at github.com
Wed Feb 15 10:43:07 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 147e3eca970c1bf4808e592c92d1a94ef2723b2f
      https://github.com/WebKit/WebKit/commit/147e3eca970c1bf4808e592c92d1a94ef2723b2f
  Author: Cameron McCormack <heycam at apple.com>
  Date:   2023-02-15 (Wed, 15 Feb 2023)

  Changed paths:
    M Source/WebCore/Sources.txt
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/css/CSSComputedStyleDeclaration.cpp
    M Source/WebCore/css/typedom/ComputedStylePropertyMapReadOnly.cpp
    M Source/WebCore/rendering/style/RenderStyle.cpp
    M Source/WebCore/rendering/style/RenderStyle.h
    A Source/WebCore/rendering/style/StyleCustomPropertyData.cpp
    M Source/WebCore/rendering/style/StyleCustomPropertyData.h
    M Source/WebCore/rendering/style/StyleMiscNonInheritedData.cpp
    M Source/WebCore/rendering/style/StyleMiscNonInheritedData.h

  Log Message:
  -----------
  Reduce custom property storage for sites with large numbers of custom properties on the root
https://bugs.webkit.org/show_bug.cgi?id=252142
<rdar://problem/105372920>

Reviewed by Antti Koivisto and Darin Adler.

Some sites have a large number of custom properties set on the root element,
inheriting into the entire document. When different custom properties or values
are set on descendant elements, we clone all of the inherited properties.

This patch changes the storage in StyleCustomPropertyData so that the
first time we copy() one that has some custom properties in it, we point
the cloned object to the original StyleCustomPropertyData as the source
of inherited custom properties, and leave m_values (now renamed to
m_ownValues) empty. Any subsequent copy() of a StyleCustomPropertyData that
already has a pointer to the inherited custom properties will copy that
pointer, and clone m_ownValues like before.

We don't generate an unlimited linked list of inherited custom
properties to look up, to avoid custom property lookup time having
worst case linear time in the depth of the tree.

This saves around 800 KB on the youtube.com in Membuster.

* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::item const):
* Source/WebCore/css/typedom/ComputedStylePropertyMapReadOnly.cpp:
(WebCore::ComputedStylePropertyMapReadOnly::entries const):
* Source/WebCore/rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::setCustomPropertyValue):
* Source/WebCore/rendering/style/RenderStyle.h:
(WebCore::RenderStyle::inheritedCustomProperties const):
(WebCore::RenderStyle::nonInheritedCustomProperties const):
* Source/WebCore/rendering/style/StyleCustomPropertyData.cpp: Added.
(WebCore::StyleCustomPropertyData::StyleCustomPropertyData):
(WebCore::StyleCustomPropertyData::get const):
(WebCore::StyleCustomPropertyData::set):
(WebCore::StyleCustomPropertyData::operator== const):
(WebCore::StyleCustomPropertyData::forEach const):
(WebCore::StyleCustomPropertyData::findKeyAtIndex const):
(WebCore::StyleCustomPropertyData::size const):
* Source/WebCore/rendering/style/StyleCustomPropertyData.h:
(WebCore::StyleCustomPropertyData::copy const):
(WebCore::StyleCustomPropertyData::operator!= const):
(WebCore::StyleCustomPropertyData::operator== const): Deleted.
(WebCore::StyleCustomPropertyData::setCustomPropertyValue): Deleted.
(WebCore::StyleCustomPropertyData::StyleCustomPropertyData): Deleted.

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




More information about the webkit-changes mailing list