Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 #include "core/css/properties/CSSPropertyDescriptor.h" | 4 #include "core/css/properties/CSSPropertyDescriptor.h" |
| 5 | 5 |
| 6 {% for api_class in api_classes %} | 6 {% for api_class in api_classes %} |
| 7 #include "core/css/properties/{{api_class.classname}}.h" | 7 #include "core/css/properties/{{api_class.classname}}.h" |
| 8 {% endfor %} | 8 {% endfor %} |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 | 11 |
| 12 static_assert( | 12 static_assert( |
| 13 std::is_pod<CSSPropertyDescriptor>::value, | 13 std::is_pod<CSSPropertyDescriptor>::value, |
| 14 "CSSPropertyDescriptor must be a POD to support using initializer lists."); | 14 "CSSPropertyDescriptor must be a POD to support using initializer lists."); |
| 15 | 15 |
| 16 static CSSPropertyDescriptor cssPropertyDescriptors[] = { | 16 static CSSPropertyDescriptor cssPropertyDescriptors[] = { |
| 17 // An invalid CSSPropertyDescriptor. When functions are added to | 17 // An invalid CSSPropertyDescriptor. |
| 18 // CSSPropertyAPI, add a nullptr to represent their function pointers in the | 18 { |
| 19 // struct initaliser. | 19 {% for valid_api_method in valid_api_methods %} |
| 20 { nullptr, false }, | 20 nullptr, |
| 21 // When functions are added to CSSPropertyAPI, also add them to the struct | 21 {% endfor %} |
| 22 // initaliser below. | 22 }, |
| 23 // CSSPropertyDescriptors for all valid properties. | |
| 23 {% for api_class in api_classes %} | 24 {% for api_class in api_classes %} |
| 24 { {{api_class.classname}}::parseSingleValue, true }, | 25 { |
| 26 {% for valid_api_method in valid_api_methods %} | |
| 27 {% if valid_api_method in api_class.api_methods %} | |
| 28 {{ api_class.classname }}:: {{ valid_api_method }}, | |
|
ktyliu
2017/02/01 00:32:29
remove extra space after {{ and before }} ?
aazzam
2017/02/01 06:02:28
done :)
| |
| 29 {% else %} | |
| 30 nullptr, | |
| 31 {% endif %} | |
| 32 {% endfor %} | |
| 33 }, | |
| 25 {% endfor %} | 34 {% endfor %} |
| 26 }; | 35 }; |
| 27 | 36 |
| 28 const CSSPropertyDescriptor& CSSPropertyDescriptor::get(CSSPropertyID id) { | 37 const CSSPropertyDescriptor& CSSPropertyDescriptor::get(CSSPropertyID id) { |
| 29 // TODO(aazzam): We are currently using hard-coded indexes for | 38 // TODO(aazzam): We are currently using hard-coded indexes for |
| 30 // cssPropertyDescriptor since we have only implemented a few properties. | 39 // cssPropertyDescriptor since we have only implemented a few properties. |
| 31 // Later, generate this switch statement, or alternatively return | 40 // Later, generate this switch statement, or alternatively return |
| 32 // cssPropertyDescriptors[id], and generate the cssPropertyDescriptors array | 41 // cssPropertyDescriptors[id], and generate the cssPropertyDescriptors array |
| 33 // to hold invalid descriptors for methods which haven't been implemented yet. | 42 // to hold invalid descriptors for methods which haven't been implemented yet. |
| 34 switch (id) { | 43 switch (id) { |
| 35 {% for api_class in api_classes %} | 44 {% for api_class in api_classes %} |
| 36 {% for property_id in api_class.property_ids %} | 45 {% for property_id in api_class.property_ids %} |
| 37 case {{property_id}}: | 46 case {{property_id}}: |
| 38 {% endfor %} | 47 {% endfor %} |
| 39 return cssPropertyDescriptors[{{api_class.index}}]; | 48 return cssPropertyDescriptors[{{api_class.index}}]; |
| 40 {% endfor %} | 49 {% endfor %} |
| 41 default: | 50 default: |
| 42 return cssPropertyDescriptors[0]; | 51 return cssPropertyDescriptors[0]; |
| 43 } | 52 } |
| 44 } | 53 } |
| 45 | 54 |
| 46 } // namespace blink | 55 } // namespace blink |
| OLD | NEW |