Title: [259659] trunk/Source/WebCore
Revision
259659
Author
an...@apple.com
Date
2020-04-07 12:43:30 -0700 (Tue, 07 Apr 2020)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (259658 => 259659)


--- trunk/Source/WebCore/ChangeLog	2020-04-07 19:35:54 UTC (rev 259658)
+++ trunk/Source/WebCore/ChangeLog	2020-04-07 19:43:30 UTC (rev 259659)
@@ -1,3 +1,30 @@
+2020-04-07  Antti Koivisto  <an...@apple.com>
+
+        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):
+
 2020-04-07  Chris Dumez  <cdu...@apple.com>
 
         documentFragment.getElementById() should not work for empty-string IDs

Modified: trunk/Source/WebCore/animation/AnimationTimeline.cpp (259658 => 259659)


--- trunk/Source/WebCore/animation/AnimationTimeline.cpp	2020-04-07 19:35:54 UTC (rev 259658)
+++ trunk/Source/WebCore/animation/AnimationTimeline.cpp	2020-04-07 19:43:30 UTC (rev 259659)
@@ -334,9 +334,8 @@
     if (mode == Animation::AnimateSingleProperty) {
         auto transitionProperty = transition.property();
         if (transitionProperty != property) {
-            auto shorthand = shorthandForProperty(transitionProperty);
-            for (size_t i = 0; i < shorthand.length(); ++i) {
-                if (shorthand.properties()[i] == property)
+            for (auto longhand : shorthandForProperty(transitionProperty)) {
+                if (longhand == property)
                     return true;
             }
             return false;
@@ -360,9 +359,8 @@
         if (mode == Animation::AnimateSingleProperty) {
             auto property = animation.property();
             if (isShorthandCSSProperty(property)) {
-                auto shorthand = shorthandForProperty(property);
-                for (size_t j = 0; j < shorthand.length(); ++j)
-                    transitionProperties.add(shorthand.properties()[j]);
+                for (auto longhand : shorthandForProperty(property))
+                    transitionProperties.add(longhand);
             } else if (property != CSSPropertyInvalid)
                 transitionProperties.add(property);
         } else if (mode == Animation::AnimateAll) {

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (259658 => 259659)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2020-04-07 19:35:54 UTC (rev 259658)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2020-04-07 19:43:30 UTC (rev 259659)
@@ -2194,8 +2194,8 @@
     auto hasValidStyle = [&] {
         auto shorthand = shorthandForProperty(propertyID);
         if (shorthand.length()) {
-            for (size_t i = 0; i < shorthand.length(); ++i) {
-                if (!hasValidStyleForProperty(element, shorthand.properties()[i]))
+            for (auto longhand : shorthand) {
+                if (!hasValidStyleForProperty(element, longhand))
                     return false;
             }
             return true;

Modified: trunk/Source/WebCore/css/StyleProperties.cpp (259658 => 259659)


--- trunk/Source/WebCore/css/StyleProperties.cpp	2020-04-07 19:35:54 UTC (rev 259658)
+++ trunk/Source/WebCore/css/StyleProperties.cpp	2020-04-07 19:43:30 UTC (rev 259659)
@@ -833,12 +833,12 @@
     if (foundPropertyIndex != -1)
         return propertyAt(foundPropertyIndex).isImportant();
 
-    StylePropertyShorthand shorthand = shorthandForProperty(propertyID);
+    auto shorthand = shorthandForProperty(propertyID);
     if (!shorthand.length())
         return false;
 
-    for (unsigned i = 0; i < shorthand.length(); ++i) {
-        if (!propertyIsImportant(shorthand.properties()[i]))
+    for (auto longhand : shorthand) {
+        if (!propertyIsImportant(longhand))
             return false;
     }
     return true;
@@ -925,8 +925,8 @@
 
     removePropertiesInSet(shorthand.properties(), shorthand.length());
 
-    for (unsigned i = 0; i < shorthand.length(); ++i)
-        m_propertyVector.append(CSSProperty(shorthand.properties()[i], value.copyRef(), important));
+    for (auto longhand : shorthand)
+        m_propertyVector.append(CSSProperty(longhand, value.copyRef(), important));
 }
 
 bool MutableStyleProperties::setProperty(const CSSProperty& property, CSSProperty* slot)

Modified: trunk/Source/WebCore/css/StylePropertyShorthand.h (259658 => 259659)


--- trunk/Source/WebCore/css/StylePropertyShorthand.h	2020-04-07 19:35:54 UTC (rev 259658)
+++ trunk/Source/WebCore/css/StylePropertyShorthand.h	2020-04-07 19:43:30 UTC (rev 259659)
@@ -39,6 +39,9 @@
     {
     }
 
+    const CSSPropertyID* begin() const { return properties(); }
+    const CSSPropertyID* end() const { return properties() + length(); }
+
     const CSSPropertyID* properties() const { return m_properties; }
     const StylePropertyShorthand* propertiesForInitialization() const { return m_propertiesForInitialization; }
     unsigned length() const { return m_length; }

Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (259658 => 259659)


--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2020-04-07 19:35:54 UTC (rev 259658)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp	2020-04-07 19:43:30 UTC (rev 259659)
@@ -251,12 +251,8 @@
 
 void CSSPropertyParser::addExpandedPropertyForValue(CSSPropertyID property, Ref<CSSValue>&& value, bool important)
 {
-    const StylePropertyShorthand& shorthand = shorthandForProperty(property);
-    unsigned shorthandLength = shorthand.length();
-    ASSERT(shorthandLength);
-    const CSSPropertyID* longhands = shorthand.properties();
-    for (unsigned i = 0; i < shorthandLength; ++i)
-        addProperty(longhands[i], property, value.copyRef(), important);
+    for (auto longhand : shorthandForProperty(property))
+        addProperty(longhand, property, value.copyRef(), important);
 }
 
 bool CSSPropertyParser::parseValue(CSSPropertyID propertyID, bool important, const CSSParserTokenRange& range, const CSSParserContext& context, ParsedPropertyVector& parsedProperties, StyleRuleType ruleType)

Modified: trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp (259658 => 259659)


--- trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp	2020-04-07 19:35:54 UTC (rev 259658)
+++ trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp	2020-04-07 19:43:30 UTC (rev 259659)
@@ -795,13 +795,12 @@
             property->setAliases(WTFMove(aliasesArray));
         }
 
-        const StylePropertyShorthand& shorthand = shorthandForProperty(propertyID);
+        auto shorthand = shorthandForProperty(propertyID);
         if (shorthand.length()) {
             auto longhands = JSON::ArrayOf<String>::create();
-            for (unsigned j = 0; j < shorthand.length(); ++j) {
-                CSSPropertyID longhandID = shorthand.properties()[j];
-                if (isEnabledCSSProperty(longhandID))
-                    longhands->addItem(getPropertyNameString(longhandID));
+            for (auto longhand : shorthand) {
+                if (isEnabledCSSProperty(longhand))
+                    longhands->addItem(getPropertyNameString(longhand));
             }
             property->setLonghands(WTFMove(longhands));
         }

Modified: trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp (259658 => 259659)


--- trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp	2020-04-07 19:35:54 UTC (rev 259658)
+++ trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp	2020-04-07 19:43:30 UTC (rev 259659)
@@ -1761,15 +1761,14 @@
 
     for (size_t i = 0; i < animatableShorthandPropertiesCount; ++i) {
         CSSPropertyID propertyID = animatableShorthandProperties[i];
-        StylePropertyShorthand shorthand = shorthandForProperty(propertyID);
+        auto shorthand = shorthandForProperty(propertyID);
         if (!shorthand.length())
             continue;
 
         Vector<AnimationPropertyWrapperBase*> longhandWrappers;
         longhandWrappers.reserveInitialCapacity(shorthand.length());
-        const CSSPropertyID* properties = shorthand.properties();
-        for (unsigned j = 0; j < shorthand.length(); ++j) {
-            unsigned wrapperIndex = indexFromPropertyID(properties[j]);
+        for (auto longhand : shorthand) {
+            unsigned wrapperIndex = indexFromPropertyID(longhand);
             if (wrapperIndex == cInvalidPropertyWrapperIndex)
                 continue;
             ASSERT(m_propertyWrappers[wrapperIndex]);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to