[webkit-changes] [WebKit/WebKit] bd076e: Add an iterator for the StyleProperties family of ...

Sam Weinig noreply at github.com
Sun Dec 4 08:46:55 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: bd076ef181ed44bc115636d4c4fa1fe70b2f0348
      https://github.com/WebKit/WebKit/commit/bd076ef181ed44bc115636d4c4fa1fe70b2f0348
  Author: Sam Weinig <weinig at apple.com>
  Date:   2022-12-04 (Sun, 04 Dec 2022)

  Changed paths:
    M Source/WTF/wtf/Vector.h
    M Source/WebCore/animation/KeyframeEffect.cpp
    M Source/WebCore/css/CSSKeyframeRule.cpp
    M Source/WebCore/css/CSSValueList.cpp
    M Source/WebCore/css/CSSValueList.h
    M Source/WebCore/css/ComputedStyleExtractor.cpp
    M Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp
    M Source/WebCore/css/StyleProperties.cpp
    M Source/WebCore/css/StyleProperties.h
    M Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp
    M Source/WebCore/css/typedom/DeclaredStylePropertyMap.cpp
    M Source/WebCore/css/typedom/InlineStylePropertyMap.cpp
    M Source/WebCore/editing/EditingStyle.cpp
    M Source/WebCore/editing/Editor.cpp
    M Source/WebCore/page/PageSerializer.cpp
    M Source/WebCore/style/ElementRuleCollector.cpp
    M Source/WebCore/style/PropertyCascade.cpp
    M Source/WebCore/style/StyleResolver.cpp

  Log Message:
  -----------
  Add an iterator for the StyleProperties family of classes
https://bugs.webkit.org/show_bug.cgi?id=248546
rdar://102823936

Reviewed by Antoine Quint.

Add iterator support for StyleProperties, ImmutableStyleProperties
and MutableStyleProperties to allow iterating through the stored
properties using for-in as well generic algorithms.

* Source/WTF/wtf/Vector.h:
(WTF::Mapper::map):
(WTF::CompactMapper::compactMap):
(WTF::copyToVectorSpecialization):
Use a universal reference to allow iterators that return temporaries
(like the one for StyleProperties) to work with the mapping code.

* Source/WebCore/animation/KeyframeEffect.cpp:
(WebCore::KeyframeEffect::computeHasImplicitKeyframeForAcceleratedProperty):
(WebCore::KeyframeEffect::computeHasKeyframeComposingAcceleratedProperty):
Adopt range-based for loop using the new iterator.

* Source/WebCore/css/CSSValueList.cpp:
(WebCore::CSSValueList::removeAll):
(WebCore::CSSValueList::hasValue const):
* Source/WebCore/css/CSSValueList.h:
Remove versions of removeAll() and hasValue() taking a nullable CSSValue*,
and replace them with overloads that take either a CSSValue& or a CSSValueID.
The CSSValueID allows us to check use without allocation or pool lookup.

* Source/WebCore/css/ComputedStyleExtractor.cpp:
(WebCore::ComputedStyleExtractor::fontVariantShorthandValue):
(WebCore::ComputedStyleExtractor::getCSSPropertyValuesForShorthandProperties):
(WebCore::ComputedStyleExtractor::getCSSPropertyValuesForGridShorthand):
Adopt range-based for loop using existing shorthand iterator support. Use
isValueID helper to simplify a condition.

* Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp:
(WebCore::PropertySetCSSStyleDeclaration::length const):
Adopt range-based for loop using the new iterator.

* Source/WebCore/css/StyleProperties.cpp:
(WebCore::MutableStyleProperties::MutableStyleProperties):
(WebCore::StyleProperties::commonShorthandChecks const):
(WebCore::StyleProperties::asTextInternal const):
(WebCore::MutableStyleProperties::mergeAndOverrideOnConflict):
(WebCore::StyleProperties::traverseSubresources const):
* Source/WebCore/css/StyleProperties.h:
(WebCore::StyleProperties::Iterator::Iterator):
(WebCore::StyleProperties::Iterator::operator* const):
(WebCore::StyleProperties::Iterator::operator++):
(WebCore::StyleProperties::Iterator::operator== const):
(WebCore::StyleProperties::Iterator::operator!= const):
(WebCore::StyleProperties::begin const):
(WebCore::StyleProperties::end):
(WebCore::StyleProperties::size const):
Adds and adopts iterator support. The two subclasses of StyleProperties
overload begin() to allow specialization when the concrete type is known.

* Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:
(WebCore::CSSPropertyParserHelpers::consumeTouchAction):
(WebCore::CSSPropertyParserHelpers::consumeTextDecorationLine):
Adopt template consumeIdent and update for new reference taking hasValue().

* Source/WebCore/css/typedom/DeclaredStylePropertyMap.cpp:
(WebCore::DeclaredStylePropertyMap::entries const):
Adopt WTF::map() now that it can be used due to iterator for StyleProperties.

* Source/WebCore/editing/EditingStyle.cpp:
(WebCore::applyTextDecorationChangeToValueList):
Update for new hasValue/removeValue interfaces.

(WebCore::EditingStyle::removeStyleAddedByNode):
Use auto (which is going to infer Ref now rather than RefPtr) and update
uses to pass non-null references.

(WebCore::EditingStyle::removeStyleConflictingWithStyleOfNode):
Adopt range-based for loop using the new iterator.

(WebCore::EditingStyle::conflictsWithInlineStyleOfElement const):
Adopt range-based for loop using the new iterator.

* Source/WebCore/editing/Editor.cpp:
(WebCore::Editor::fontAttributesAtSelectionStart):
Adopt new CSSValueID overloads of hasValue.

* Source/WebCore/page/PageSerializer.cpp:
(WebCore::PageSerializer::retrieveResourcesForProperties):
Adopt range-based for loop using the new iterator.

* Source/WebCore/style/ElementRuleCollector.cpp:
(WebCore::Style::ElementRuleCollector::addMatchedProperties):
Adopt range-based for loop using the new iterator.

* Source/WebCore/style/PropertyCascade.cpp:
(WebCore::Style::PropertyCascade::addMatch):
(WebCore::Style::hasImportantProperties):
Adopt range-based for loop using the new iterator.

* Source/WebCore/style/StyleResolver.cpp:
(WebCore::Style::Resolver::styleForKeyframe):
Adopt range-based for loop using the new iterator.

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




More information about the webkit-changes mailing list