Changeset 259659 in webkit


Ignore:
Timestamp:
Apr 7, 2020 12:43:30 PM (4 years ago)
Author:
Antti Koivisto
Message:

Make StylePropertyShorthand iterable
https://bugs.webkit.org/show_bug.cgi?id=210117

Reviewed by Darin Adler.

Enable modern for-loops.

  • animation/AnimationTimeline.cpp:

(WebCore::transitionMatchesProperty):
(WebCore::compileTransitionPropertiesInStyle):

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::updateStyleIfNeededForProperty):

  • css/StyleProperties.cpp:

(WebCore::StyleProperties::propertyIsImportant const):
(WebCore::MutableStyleProperties::setProperty):

  • css/StylePropertyShorthand.h:

(WebCore::StylePropertyShorthand::begin const):
(WebCore::StylePropertyShorthand::end const):

  • css/parser/CSSPropertyParser.cpp:

(WebCore::CSSPropertyParser::addExpandedPropertyForValue):

  • inspector/agents/InspectorCSSAgent.cpp:

(WebCore::InspectorCSSAgent::getSupportedCSSProperties):

  • page/animation/CSSPropertyAnimation.cpp:

(WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):

Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r259651 r259659  
     12020-04-07  Antti Koivisto  <antti@apple.com>
     2
     3        Make StylePropertyShorthand iterable
     4        https://bugs.webkit.org/show_bug.cgi?id=210117
     5
     6        Reviewed by Darin Adler.
     7
     8        Enable modern for-loops.
     9
     10        * animation/AnimationTimeline.cpp:
     11        (WebCore::transitionMatchesProperty):
     12        (WebCore::compileTransitionPropertiesInStyle):
     13        * css/CSSComputedStyleDeclaration.cpp:
     14        (WebCore::updateStyleIfNeededForProperty):
     15        * css/StyleProperties.cpp:
     16        (WebCore::StyleProperties::propertyIsImportant const):
     17        (WebCore::MutableStyleProperties::setProperty):
     18        * css/StylePropertyShorthand.h:
     19        (WebCore::StylePropertyShorthand::begin const):
     20        (WebCore::StylePropertyShorthand::end const):
     21        * css/parser/CSSPropertyParser.cpp:
     22        (WebCore::CSSPropertyParser::addExpandedPropertyForValue):
     23        * inspector/agents/InspectorCSSAgent.cpp:
     24        (WebCore::InspectorCSSAgent::getSupportedCSSProperties):
     25        * page/animation/CSSPropertyAnimation.cpp:
     26        (WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):
     27
    1282020-04-07  Chris Dumez  <cdumez@apple.com>
    229
  • trunk/Source/WebCore/animation/AnimationTimeline.cpp

    r258916 r259659  
    335335        auto transitionProperty = transition.property();
    336336        if (transitionProperty != property) {
    337             auto shorthand = shorthandForProperty(transitionProperty);
    338             for (size_t i = 0; i < shorthand.length(); ++i) {
    339                 if (shorthand.properties()[i] == property)
     337            for (auto longhand : shorthandForProperty(transitionProperty)) {
     338                if (longhand == property)
    340339                    return true;
    341340            }
     
    361360            auto property = animation.property();
    362361            if (isShorthandCSSProperty(property)) {
    363                 auto shorthand = shorthandForProperty(property);
    364                 for (size_t j = 0; j < shorthand.length(); ++j)
    365                     transitionProperties.add(shorthand.properties()[j]);
     362                for (auto longhand : shorthandForProperty(property))
     363                    transitionProperties.add(longhand);
    366364            } else if (property != CSSPropertyInvalid)
    367365                transitionProperties.add(property);
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r259585 r259659  
    21952195        auto shorthand = shorthandForProperty(propertyID);
    21962196        if (shorthand.length()) {
    2197             for (size_t i = 0; i < shorthand.length(); ++i) {
    2198                 if (!hasValidStyleForProperty(element, shorthand.properties()[i]))
     2197            for (auto longhand : shorthand) {
     2198                if (!hasValidStyleForProperty(element, longhand))
    21992199                    return false;
    22002200            }
  • trunk/Source/WebCore/css/StyleProperties.cpp

    r257697 r259659  
    834834        return propertyAt(foundPropertyIndex).isImportant();
    835835
    836     StylePropertyShorthand shorthand = shorthandForProperty(propertyID);
     836    auto shorthand = shorthandForProperty(propertyID);
    837837    if (!shorthand.length())
    838838        return false;
    839839
    840     for (unsigned i = 0; i < shorthand.length(); ++i) {
    841         if (!propertyIsImportant(shorthand.properties()[i]))
     840    for (auto longhand : shorthand) {
     841        if (!propertyIsImportant(longhand))
    842842            return false;
    843843    }
     
    926926    removePropertiesInSet(shorthand.properties(), shorthand.length());
    927927
    928     for (unsigned i = 0; i < shorthand.length(); ++i)
    929         m_propertyVector.append(CSSProperty(shorthand.properties()[i], value.copyRef(), important));
     928    for (auto longhand : shorthand)
     929        m_propertyVector.append(CSSProperty(longhand, value.copyRef(), important));
    930930}
    931931
  • trunk/Source/WebCore/css/StylePropertyShorthand.h

    r207479 r259659  
    4040    }
    4141
     42    const CSSPropertyID* begin() const { return properties(); }
     43    const CSSPropertyID* end() const { return properties() + length(); }
     44
    4245    const CSSPropertyID* properties() const { return m_properties; }
    4346    const StylePropertyShorthand* propertiesForInitialization() const { return m_propertiesForInitialization; }
  • trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp

    r258148 r259659  
    252252void CSSPropertyParser::addExpandedPropertyForValue(CSSPropertyID property, Ref<CSSValue>&& value, bool important)
    253253{
    254     const StylePropertyShorthand& shorthand = shorthandForProperty(property);
    255     unsigned shorthandLength = shorthand.length();
    256     ASSERT(shorthandLength);
    257     const CSSPropertyID* longhands = shorthand.properties();
    258     for (unsigned i = 0; i < shorthandLength; ++i)
    259         addProperty(longhands[i], property, value.copyRef(), important);
     254    for (auto longhand : shorthandForProperty(property))
     255        addProperty(longhand, property, value.copyRef(), important);
    260256}
    261257
  • trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp

    r257199 r259659  
    796796        }
    797797
    798         const StylePropertyShorthand& shorthand = shorthandForProperty(propertyID);
     798        auto shorthand = shorthandForProperty(propertyID);
    799799        if (shorthand.length()) {
    800800            auto longhands = JSON::ArrayOf<String>::create();
    801             for (unsigned j = 0; j < shorthand.length(); ++j) {
    802                 CSSPropertyID longhandID = shorthand.properties()[j];
    803                 if (isEnabledCSSProperty(longhandID))
    804                     longhands->addItem(getPropertyNameString(longhandID));
     801            for (auto longhand : shorthand) {
     802                if (isEnabledCSSProperty(longhand))
     803                    longhands->addItem(getPropertyNameString(longhand));
    805804            }
    806805            property->setLonghands(WTFMove(longhands));
  • trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp

    r259532 r259659  
    17621762    for (size_t i = 0; i < animatableShorthandPropertiesCount; ++i) {
    17631763        CSSPropertyID propertyID = animatableShorthandProperties[i];
    1764         StylePropertyShorthand shorthand = shorthandForProperty(propertyID);
     1764        auto shorthand = shorthandForProperty(propertyID);
    17651765        if (!shorthand.length())
    17661766            continue;
     
    17681768        Vector<AnimationPropertyWrapperBase*> longhandWrappers;
    17691769        longhandWrappers.reserveInitialCapacity(shorthand.length());
    1770         const CSSPropertyID* properties = shorthand.properties();
    1771         for (unsigned j = 0; j < shorthand.length(); ++j) {
    1772             unsigned wrapperIndex = indexFromPropertyID(properties[j]);
     1770        for (auto longhand : shorthand) {
     1771            unsigned wrapperIndex = indexFromPropertyID(longhand);
    17731772            if (wrapperIndex == cInvalidPropertyWrapperIndex)
    17741773                continue;
Note: See TracChangeset for help on using the changeset viewer.