Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 {% from 'macros.tmpl' import license %} | 1 {% from 'macros.tmpl' import license %} |
| 2 {{license()}} | 2 {{license()}} |
| 3 | 3 |
| 4 #include "config.h" | 4 #include "config.h" |
| 5 #include "core/css/CSSPropertyMetadata.h" | 5 #include "core/css/CSSPropertyMetadata.h" |
| 6 | 6 |
| 7 #include "platform/RuntimeEnabledFeatures.h" | 7 #include "platform/RuntimeEnabledFeatures.h" |
| 8 #include "wtf/BitArray.h" | 8 #include "wtf/BitArray.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 {% for flag, function_name in switches %} | 11 {% for flag, function_name in switches %} |
| 12 | 12 |
| 13 bool CSSPropertyMetadata::{{function_name}}(CSSPropertyID property) | 13 bool CSSPropertyMetadata::{{function_name}}(CSSPropertyID property) |
| 14 { | 14 { |
| 15 switch(property) { | 15 switch(property) { |
| 16 case CSSPropertyInvalid: | 16 case CSSPropertyInvalid: |
| 17 ASSERT_NOT_REACHED(); | 17 ASSERT_NOT_REACHED(); |
| 18 return false; | 18 return false; |
| 19 {% for property_id, property in properties.items() if property[flag] %} | 19 {% for property_id, property in properties.items() if property[flag] %} |
| 20 case {{property_id}}: | 20 case {{property_id}}: |
| 21 {% endfor %} | 21 {% endfor %} |
| 22 return true; | 22 return true; |
| 23 default: | 23 default: |
| 24 return false; | 24 return false; |
| 25 } | 25 } |
| 26 } | 26 } |
| 27 {% endfor %} | 27 {% endfor %} |
| 28 | 28 |
| 29 // There is one more valid property ID than the total count of CSS properties | |
| 30 // because of custom properties. | |
| 31 static const int numValidPropertyIDs = numCSSProperties + 1; | |
| 32 | |
| 29 bool CSSPropertyMetadata::isEnabledProperty(CSSPropertyID unresolvedProperty) | 33 bool CSSPropertyMetadata::isEnabledProperty(CSSPropertyID unresolvedProperty) |
|
Timothy Loh
2015/11/14 02:21:05
Where are we calling into here from? It looks like
leviw_travelin_and_unemployed
2015/11/17 01:25:07
That's right, and we check this when trying to set
| |
| 30 { | 34 { |
| 31 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); | 35 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); |
| 32 static BitArray<numCSSProperties>* enabledProperties = 0; | 36 static BitArray<numValidPropertyIDs>* enabledProperties = 0; |
| 33 if (!enabledProperties) { | 37 if (!enabledProperties) { |
| 34 enabledProperties = new BitArray<numCSSProperties>(true); // All bits se ts to 1. | 38 enabledProperties = new BitArray<numValidPropertyIDs>(true); // All bits sets to 1. |
| 39 if (!RuntimeEnabledFeatures::cssVariablesEnabled()) | |
| 40 enabledProperties->clear(0); | |
| 35 {% for property_id, property in properties.items() if property.runtime_f lag %} | 41 {% for property_id, property in properties.items() if property.runtime_f lag %} |
| 36 if (!RuntimeEnabledFeatures::{{property.runtime_flag|lower_first}}Enable d()) | 42 if (!RuntimeEnabledFeatures::{{property.runtime_flag|lower_first}}Enable d()) |
| 37 enabledProperties->clear({{property_id}} - {{first_enum_value}}); | 43 enabledProperties->clear({{property_id}} - {{first_enum_value - 1}}) ; |
| 38 {% endfor %} | 44 {% endfor %} |
| 39 {% for property_id, property in properties.items() if property.is_intern al %} | 45 {% for property_id, property in properties.items() if property.is_intern al %} |
| 40 enabledProperties->clear({{property_id}} - {{first_enum_value}}); | 46 enabledProperties->clear({{property_id}} - {{first_enum_value - 1}}); |
| 41 {% endfor %} | 47 {% endfor %} |
| 42 } | 48 } |
| 43 return enabledProperties->get(property - {{first_enum_value}}); | 49 return enabledProperties->get(property - {{first_enum_value}}); |
| 44 } | 50 } |
| 45 | 51 |
| 46 void CSSPropertyMetadata::filterEnabledCSSPropertiesIntoVector(const CSSProperty ID* properties, size_t propertyCount, Vector<CSSPropertyID>& outVector) | 52 void CSSPropertyMetadata::filterEnabledCSSPropertiesIntoVector(const CSSProperty ID* properties, size_t propertyCount, Vector<CSSPropertyID>& outVector) |
| 47 { | 53 { |
| 48 for (unsigned i = 0; i < propertyCount; i++) { | 54 for (unsigned i = 0; i < propertyCount; i++) { |
| 49 CSSPropertyID property = properties[i]; | 55 CSSPropertyID property = properties[i]; |
| 50 if (isEnabledProperty(property)) | 56 if (isEnabledProperty(property)) |
| 51 outVector.append(property); | 57 outVector.append(property); |
| 52 } | 58 } |
| 53 } | 59 } |
| 54 | 60 |
| 55 } // namespace blink | 61 } // namespace blink |
| OLD | NEW |