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

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: Do it properly Created 3 years, 10 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 // 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
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