Chromium Code Reviews| Index: third_party/WebKit/Source/build/scripts/templates/CSSValueIDMappingsGenerated.h.tmpl |
| diff --git a/third_party/WebKit/Source/build/scripts/templates/CSSValueIDMappingsGenerated.h.tmpl b/third_party/WebKit/Source/build/scripts/templates/CSSValueIDMappingsGenerated.h.tmpl |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ab26eb32a227bb46308ff3d386d2f71b1ce6a822 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/build/scripts/templates/CSSValueIDMappingsGenerated.h.tmpl |
| @@ -0,0 +1,51 @@ |
| +{% from 'macros.tmpl' import license %} |
| +{{license()}} |
| + |
| +#include "base/logging.h" |
| +#include "core/CSSValueKeywords.h" |
| +#include "core/ComputedStyleBaseConstants.h" |
| +{% for path in include_paths %} |
| +#include "{{path}}" |
| +{% endfor %} |
| + |
| +namespace blink { |
| + |
| +// TODO(shend): most enum values are stored contiguously so we just need |
| +// a subtraction and static_cast. This is much faster than switches. |
| + |
| +// Do not use these functions directly, use the non-generated versions |
| +// in CSSValueMappings.h |
| +// 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
|
| + |
| +template <class T> |
| +T cssValueIDToPlatformEnumGenerated(CSSValueID); |
| + |
| +{% for enum_name, mapping in mappings.items() %} |
| +template <> |
| +inline {{enum_name}} cssValueIDToPlatformEnumGenerated(CSSValueID v) { |
| + switch (v) { |
| + {% for cs_value, css_value in mapping['mapping']: %} |
| + case {{css_value}}: |
| + return {{enum_name}}::{{cs_value}}; |
| + {% endfor %} |
| + default: |
| + NOTREACHED(); |
| + return {{enum_name}}::{{mapping['default_value']}}; |
| + } |
| +} |
| + |
| +inline CSSValueID platformEnumToCSSValueIDGenerated({{enum_name}} v) { |
| + switch (v) { |
| + {% for cs_value, css_value in mapping['mapping']: %} |
| + case {{enum_name}}::{{cs_value}}: |
| + return {{css_value}}; |
| + {% endfor %} |
| + default: |
| + NOTREACHED(); |
| + return CSSValueNone; |
| + } |
| +} |
| + |
| +{% endfor %} |
| + |
| +} // namespace blink |