Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / build / scripts / templates / CSSPropertyMetadata.cpp.tmpl
1 {% from 'macros.tmpl' import license %}
2 {{license()}}
3
4 #include "config.h"
5 #include "core/css/CSSPropertyMetadata.h"
6
7 #include "platform/RuntimeEnabledFeatures.h"
8 #include "wtf/BitArray.h"
9
10 namespace blink {
11 {% for flag, function_name in switches %}
12
13 bool CSSPropertyMetadata::{{function_name}}(CSSPropertyID property)
14 {
15     switch(property) {
16     case CSSPropertyInvalid:
17         ASSERT_NOT_REACHED();
18         return false;
19     {% for property_id, property in properties.items() if property[flag] %}
20     case {{property_id}}:
21     {% endfor %}
22         return true;
23     default:
24         return false;
25     }
26 }
27 {% endfor %}
28
29 bool CSSPropertyMetadata::isEnabledProperty(CSSPropertyID property)
30 {
31     static BitArray<numCSSProperties>* enabledProperties = 0;
32     if (!enabledProperties) {
33         enabledProperties = new BitArray<numCSSProperties>(true); // All bits sets to 1.
34         {% for property_id, property in properties.items() if property.runtime_flag %}
35         if (!RuntimeEnabledFeatures::{{property.runtime_flag|lower_first}}Enabled())
36             enabledProperties->clear({{property_id}} - {{first_enum_value}});
37         {% endfor %}
38         {% for property_id, property in properties.items() if property.is_internal %}
39         enabledProperties->clear({{property_id}} - {{first_enum_value}});
40         {% endfor %}
41     }
42     return enabledProperties->get(property - {{first_enum_value}});
43 }
44
45 void CSSPropertyMetadata::filterEnabledCSSPropertiesIntoVector(const CSSPropertyID* properties, size_t propertyCount, Vector<CSSPropertyID>& outVector)
46 {
47     for (unsigned i = 0; i < propertyCount; i++) {
48         CSSPropertyID property = properties[i];
49         if (isEnabledProperty(property))
50             outVector.append(property);
51     }
52 }
53
54 } // namespace blink