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

Unified Diff: third_party/WebKit/Source/build/scripts/templates/CSSPrimitiveValueUnitTrie.cpp.tmpl

Issue 1938343002: Generate a series of nested switch statements to parse CSSPrimitiveValue units. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove extra imports Created 4 years, 7 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/CSSPrimitiveValueUnitTrie.cpp.tmpl
diff --git a/third_party/WebKit/Source/build/scripts/templates/CSSPrimitiveValueUnitTrie.cpp.tmpl b/third_party/WebKit/Source/build/scripts/templates/CSSPrimitiveValueUnitTrie.cpp.tmpl
new file mode 100644
index 0000000000000000000000000000000000000000..f7d6bc7f720a12d43b0bd9a10b064e947e27f22f
--- /dev/null
+++ b/third_party/WebKit/Source/build/scripts/templates/CSSPrimitiveValueUnitTrie.cpp.tmpl
@@ -0,0 +1,36 @@
+{% from 'macros.tmpl' import trie_length_switch %}
+// Copyright 2016 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.
+
+#include "core/css/CSSPrimitiveValueUnitTrie.h"
+#include "core/css/CSSPrimitiveValue.h"
+
+namespace blink {
+
+namespace {
+
+template<typename CharacterType>
+CSSPrimitiveValue::UnitType cssPrimitiveValueUnitFromTrie(const CharacterType* data, unsigned length)
+{
+ DCHECK(data);
+ DCHECK(length);
+ {% macro trie_return_statement(unit_name) %}CSSPrimitiveValue::UnitType::{{unit_name}}{% endmacro %}
+ {{ trie_length_switch(length_tries, trie_return_statement, trie_return_statement(default_value), True) | indent(4) }}
+ return {{ trie_return_statement(default_value) }};
Timothy Loh 2016/05/13 06:54:48 I think it's clearer to just return CSSPrimitiveVa
+}
+
+} // namespace
+
+CSSPrimitiveValue::UnitType lookupCSSPrimitiveValueUnit(const LChar* characters8, unsigned length)
+{
+ return cssPrimitiveValueUnitFromTrie(characters8, length);
+}
+
+CSSPrimitiveValue::UnitType lookupCSSPrimitiveValueUnit(const UChar* characters16, unsigned length)
+{
+ return cssPrimitiveValueUnitFromTrie(characters16, length);
+}
+
+} // namespace blink
+
« no previous file with comments | « third_party/WebKit/Source/build/scripts/make_css_primitive_value_unit_trie.py ('k') | third_party/WebKit/Source/core/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698