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) |
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 static_assert(CSSPropertyVariable == {{first_enum_value - 1}}, "CSSPrope
rtyVariable should directly precede first_enum_value."); |
| 40 if (!RuntimeEnabledFeatures::cssVariablesEnabled()) |
| 41 enabledProperties->clear(0); |
35 {% for property_id, property in properties.items() if property.runtime_f
lag %} | 42 {% for property_id, property in properties.items() if property.runtime_f
lag %} |
36 if (!RuntimeEnabledFeatures::{{property.runtime_flag|lower_first}}Enable
d()) | 43 if (!RuntimeEnabledFeatures::{{property.runtime_flag|lower_first}}Enable
d()) |
37 enabledProperties->clear({{property_id}} - {{first_enum_value}}); | 44 enabledProperties->clear({{property_id}} - {{first_enum_value - 1}})
; |
38 {% endfor %} | 45 {% endfor %} |
39 {% for property_id, property in properties.items() if property.is_intern
al %} | 46 {% for property_id, property in properties.items() if property.is_intern
al %} |
40 enabledProperties->clear({{property_id}} - {{first_enum_value}}); | 47 enabledProperties->clear({{property_id}} - {{first_enum_value - 1}}); |
41 {% endfor %} | 48 {% endfor %} |
42 } | 49 } |
43 return enabledProperties->get(property - {{first_enum_value}}); | 50 return enabledProperties->get(property - {{first_enum_value - 1}}); |
44 } | 51 } |
45 | 52 |
46 void CSSPropertyMetadata::filterEnabledCSSPropertiesIntoVector(const CSSProperty
ID* properties, size_t propertyCount, Vector<CSSPropertyID>& outVector) | 53 void CSSPropertyMetadata::filterEnabledCSSPropertiesIntoVector(const CSSProperty
ID* properties, size_t propertyCount, Vector<CSSPropertyID>& outVector) |
47 { | 54 { |
48 for (unsigned i = 0; i < propertyCount; i++) { | 55 for (unsigned i = 0; i < propertyCount; i++) { |
49 CSSPropertyID property = properties[i]; | 56 CSSPropertyID property = properties[i]; |
50 if (isEnabledProperty(property)) | 57 if (isEnabledProperty(property)) |
51 outVector.append(property); | 58 outVector.append(property); |
52 } | 59 } |
53 } | 60 } |
54 | 61 |
55 } // namespace blink | 62 } // namespace blink |
OLD | NEW |