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

Unified 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 side-by-side diff with in-line comments
Download patch
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
« 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