Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: third_party/WebKit/Source/build/scripts/templates/CSSValueIDMappingsGenerated.h.tmpl

Issue 2702173002: Generate mappings between CSSValueID and ComputedStyle enums. (Closed)
Patch Set: Forgot case Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/build/scripts/make_computed_style_base.py ('k') | third_party/WebKit/Source/core/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698