Skip to content
Permalink
Browse files
Use a HashSet instead of a std::unique_ptr<HashSet> for StyleRareNonI…
…nheritedData.customPaintWatchedProperties

https://bugs.webkit.org/show_bug.cgi?id=239863

Reviewed by Yusuke Suzuki.

Use a HashSet instead of a std::unique_ptr<HashSet> for StyleRareNonInheritedData.customPaintWatchedProperties.
A HashSet is already essentially a pointer, no need for the extra dereferencing.

* Source/WebCore/rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::addCustomPaintWatchProperty):
(WebCore::changedCustomPaintWatchedProperty):
* Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp:
(WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
(WebCore::StyleRareNonInheritedData::operator== const):
* Source/WebCore/rendering/style/StyleRareNonInheritedData.h:

Canonical link: https://commits.webkit.org/250105@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@293596 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
cdumez committed Apr 28, 2022
1 parent 6451b4e commit 599eabc911786809de247f487c1454de7ebb6517
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
@@ -1112,25 +1112,20 @@ static bool rareInheritedDataChangeRequiresRepaint(const StyleRareInheritedData&
void RenderStyle::addCustomPaintWatchProperty(const AtomString& name)
{
auto& data = m_rareNonInheritedData.access();
if (!data.customPaintWatchedProperties)
data.customPaintWatchedProperties = makeUnique<HashSet<AtomString>>();
data.customPaintWatchedProperties->add(name);
data.customPaintWatchedProperties.add(name);
}

inline static bool changedCustomPaintWatchedProperty(const RenderStyle& a, const StyleRareNonInheritedData& aData, const RenderStyle& b, const StyleRareNonInheritedData& bData)
{
auto* propertiesA = aData.customPaintWatchedProperties.get();
auto* propertiesB = bData.customPaintWatchedProperties.get();
auto& propertiesA = aData.customPaintWatchedProperties;
auto& propertiesB = bData.customPaintWatchedProperties;

if (UNLIKELY(propertiesA || propertiesB)) {
if (UNLIKELY(!propertiesA.isEmpty() || !propertiesB.isEmpty())) {
// FIXME: We should not need to use ComputedStyleExtractor here.
ComputedStyleExtractor extractor((Element*) nullptr);

for (auto* watchPropertiesMap : { propertiesA, propertiesB }) {
if (!watchPropertiesMap)
continue;

for (auto& name : *watchPropertiesMap) {
for (auto& watchPropertiesMap : { propertiesA, propertiesB }) {
for (auto& name : watchPropertiesMap) {
RefPtr<CSSValue> valueA;
RefPtr<CSSValue> valueB;
if (isCustomPropertyName(name)) {
@@ -188,7 +188,7 @@ inline StyleRareNonInheritedData::StyleRareNonInheritedData(const StyleRareNonIn
, justifyItems(o.justifyItems)
, justifySelf(o.justifySelf)
, customProperties(o.customProperties)
, customPaintWatchedProperties(o.customPaintWatchedProperties ? makeUnique<HashSet<AtomString>>(*o.customPaintWatchedProperties) : nullptr)
, customPaintWatchedProperties(o.customPaintWatchedProperties)
, rotate(o.rotate)
, scale(o.scale)
, translate(o.translate)
@@ -304,8 +304,7 @@ bool StyleRareNonInheritedData::operator==(const StyleRareNonInheritedData& o) c
&& justifyItems == o.justifyItems
&& justifySelf == o.justifySelf
&& customProperties == o.customProperties
&& ((customPaintWatchedProperties && o.customPaintWatchedProperties && *customPaintWatchedProperties == *o.customPaintWatchedProperties)
|| (!customPaintWatchedProperties && !o.customPaintWatchedProperties))
&& customPaintWatchedProperties == o.customPaintWatchedProperties
&& pageSizeType == o.pageSizeType
&& transformStyle3D == o.transformStyle3D
&& transformStyleForcedToFlat == o.transformStyleForcedToFlat
@@ -191,7 +191,7 @@ class StyleRareNonInheritedData : public RefCounted<StyleRareNonInheritedData> {
StyleSelfAlignmentData justifySelf;

DataRef<StyleCustomPropertyData> customProperties;
std::unique_ptr<HashSet<AtomString>> customPaintWatchedProperties;
HashSet<AtomString> customPaintWatchedProperties;

RefPtr<RotateTransformOperation> rotate;
RefPtr<ScaleTransformOperation> scale;

0 comments on commit 599eabc

Please sign in to comment.