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

Unified Diff: third_party/WebKit/Source/core/css/CSSValueIDMappings.h

Issue 2702173002: Generate mappings between CSSValueID and ComputedStyle enums. (Closed)
Patch Set: Forgot case 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
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSPrimitiveValueMappings.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/CSSValueIDMappings.h
diff --git a/third_party/WebKit/Source/core/css/CSSValueIDMappings.h b/third_party/WebKit/Source/core/css/CSSValueIDMappings.h
new file mode 100644
index 0000000000000000000000000000000000000000..ce922e3cd2d94724c2c75a0948635785b339d706
--- /dev/null
+++ b/third_party/WebKit/Source/core/css/CSSValueIDMappings.h
@@ -0,0 +1,70 @@
+// Copyright (c) 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CSSValueIDMappings_h
+#define CSSValueIDMappings_h
+
+#include "core/CSSValueIDMappingsGenerated.h"
+
+namespace blink {
+
+template <class T>
+T cssValueIDToPlatformEnum(CSSValueID v) {
+ // By default, we use the generated mappings. For special cases, we
+ // specialize.
+ return detail::cssValueIDToPlatformEnumGenerated<T>(v);
+}
+
+template <class T>
+inline CSSValueID platformEnumToCSSValueID(T v) {
+ // By default, we use the generated mappings. For special cases, we overload.
+ return detail::platformEnumToCSSValueIDGenerated(v);
+}
+
+template <>
+inline UnicodeBidi cssValueIDToPlatformEnum(CSSValueID v) {
+ if (v == CSSValueWebkitIsolate)
+ return UnicodeBidi::kIsolate;
+ if (v == CSSValueWebkitIsolateOverride)
+ return UnicodeBidi::kIsolateOverride;
+ if (v == CSSValueWebkitPlaintext)
+ return UnicodeBidi::kPlaintext;
+ return detail::cssValueIDToPlatformEnumGenerated<UnicodeBidi>(v);
+}
+
+template <>
+inline ETextAlign cssValueIDToPlatformEnum(CSSValueID v) {
+ if (v == CSSValueWebkitAuto) // Legacy -webkit-auto. Eqiuvalent to start.
+ return ETextAlign::kStart;
+ if (v == CSSValueInternalCenter)
+ return ETextAlign::kCenter;
+ return detail::cssValueIDToPlatformEnumGenerated<ETextAlign>(v);
+}
+
+template <>
+inline WritingMode cssValueIDToPlatformEnum(CSSValueID v) {
+ switch (v) {
+ case CSSValueHorizontalTb:
+ case CSSValueLr:
+ case CSSValueLrTb:
+ case CSSValueRl:
+ case CSSValueRlTb:
+ return WritingMode::kHorizontalTb;
+ case CSSValueVerticalRl:
+ case CSSValueTb:
+ case CSSValueTbRl:
+ return WritingMode::kVerticalRl;
+ case CSSValueVerticalLr:
+ return WritingMode::kVerticalLr;
+ default:
+ break;
+ }
+
+ NOTREACHED();
+ return WritingMode::kHorizontalTb;
+}
+
+} // namespace blink
+
+#endif
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSPrimitiveValueMappings.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698