Chromium Code Reviews| 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 // TODO(shend): can we put these in a blink::detail namespace? | |
|
meade_UTC10
2017/02/22 07:00:02
That'd be nice! I think Stuart was working on some
| |
| 19 | |
| 20 template <class T> | |
| 21 T cssValueIDToPlatformEnumGenerated(CSSValueID); | |
| 22 | |
| 23 {% for enum_name, mapping in mappings.items() %} | |
| 24 template <> | |
| 25 inline {{enum_name}} cssValueIDToPlatformEnumGenerated(CSSValueID v) { | |
| 26 switch (v) { | |
| 27 {% for cs_value, css_value in mapping['mapping']: %} | |
| 28 case {{css_value}}: | |
| 29 return {{enum_name}}::{{cs_value}}; | |
| 30 {% endfor %} | |
| 31 default: | |
| 32 NOTREACHED(); | |
| 33 return {{enum_name}}::{{mapping['default_value']}}; | |
| 34 } | |
| 35 } | |
| 36 | |
| 37 inline CSSValueID platformEnumToCSSValueIDGenerated({{enum_name}} v) { | |
| 38 switch (v) { | |
| 39 {% for cs_value, css_value in mapping['mapping']: %} | |
| 40 case {{enum_name}}::{{cs_value}}: | |
| 41 return {{css_value}}; | |
| 42 {% endfor %} | |
| 43 default: | |
| 44 NOTREACHED(); | |
| 45 return CSSValueNone; | |
| 46 } | |
| 47 } | |
| 48 | |
| 49 {% endfor %} | |
| 50 | |
| 51 } // namespace blink | |
| OLD | NEW |