OLD | NEW |
(Empty) | |
| 1 {% from 'macros.tmpl' import license %} |
| 2 {{license()}} |
| 3 |
| 4 #include "base/logging.h" |
| 5 #include "core/CSSValueKeywords.h" |
| 6 #include "core/ComputedStyleBaseConstants.h" |
| 7 {% for path in include_paths %} |
| 8 #include "{{path}}" |
| 9 {% endfor %} |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 // TODO(shend): most enum values are stored contiguously so we just need |
| 14 // a subtraction and static_cast. This is much faster than switches. |
| 15 |
| 16 // Do not use these functions directly, use the non-generated versions |
| 17 // in CSSValueMappings.h |
| 18 |
| 19 namespace detail { |
| 20 |
| 21 template <class T> |
| 22 T cssValueIDToPlatformEnumGenerated(CSSValueID); |
| 23 |
| 24 {% for enum_name, mapping in mappings.items() %} |
| 25 template <> |
| 26 inline {{enum_name}} cssValueIDToPlatformEnumGenerated(CSSValueID v) { |
| 27 switch (v) { |
| 28 {% for cs_value, css_value in mapping['mapping']: %} |
| 29 case {{css_value}}: |
| 30 return {{enum_name}}::{{cs_value}}; |
| 31 {% endfor %} |
| 32 default: |
| 33 NOTREACHED(); |
| 34 return {{enum_name}}::{{mapping['default_value']}}; |
| 35 } |
| 36 } |
| 37 |
| 38 inline CSSValueID platformEnumToCSSValueIDGenerated({{enum_name}} v) { |
| 39 switch (v) { |
| 40 {% for cs_value, css_value in mapping['mapping']: %} |
| 41 case {{enum_name}}::{{cs_value}}: |
| 42 return {{css_value}}; |
| 43 {% endfor %} |
| 44 default: |
| 45 NOTREACHED(); |
| 46 return CSSValueNone; |
| 47 } |
| 48 } |
| 49 |
| 50 {% endfor %} |
| 51 } // namespace detail |
| 52 |
| 53 } // namespace blink |
OLD | NEW |