| 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. | 17 // An invalid CSSPropertyDescriptor. |
| 18 { | 18 { |
| 19 {% for valid_api_method in valid_api_methods %} | 19 {% for api_methods in all_api_method_names %} |
| 20 nullptr, | 20 nullptr, |
| 21 {% endfor %} | 21 {% endfor %} |
| 22 }, | 22 }, |
| 23 // CSSPropertyDescriptors for all valid properties. | 23 // CSSPropertyDescriptors for all valid properties. |
| 24 {% for api_class in api_classes %} | 24 {% for api_class in api_classes %} |
| 25 { | 25 { |
| 26 {% for api_method in api_methods if api_method in api_class.api_methods %} | 26 {% for api_method_name in all_api_method_names %} |
| 27 {{api_class.classname}}::{{api_method}}, | 27 {% if api_method_name in api_class.methods_for_class %} |
| 28 {{api_class.classname}}::{{api_method_name}}, |
| 28 {% else %} | 29 {% else %} |
| 29 nullptr, | 30 nullptr, |
| 31 {% endif %} |
| 30 {% endfor %} | 32 {% endfor %} |
| 31 }, | 33 }, |
| 32 {% endfor %} | 34 {% endfor %} |
| 33 }; | 35 }; |
| 34 | 36 |
| 35 const CSSPropertyDescriptor& CSSPropertyDescriptor::get(CSSPropertyID id) { | 37 const CSSPropertyDescriptor& CSSPropertyDescriptor::get(CSSPropertyID id) { |
| 36 // TODO(aazzam): We are currently using hard-coded indexes for | 38 // TODO(aazzam): We are currently using hard-coded indexes for |
| 37 // cssPropertyDescriptor since we have only implemented a few properties. | 39 // cssPropertyDescriptor since we have only implemented a few properties. |
| 38 // Later, generate this switch statement, or alternatively return | 40 // Later, generate this switch statement, or alternatively return |
| 39 // cssPropertyDescriptors[id], and generate the cssPropertyDescriptors array | 41 // cssPropertyDescriptors[id], and generate the cssPropertyDescriptors array |
| 40 // 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. |
| 41 switch (id) { | 43 switch (id) { |
| 42 {% for api_class in api_classes %} | 44 {% for api_class in api_classes %} |
| 43 {% for property_id in api_class.property_ids %} | 45 {% for property_id in api_class.property_ids %} |
| 44 case {{property_id}}: | 46 case {{property_id}}: |
| 45 {% endfor %} | 47 {% endfor %} |
| 46 return cssPropertyDescriptors[{{api_class.index}}]; | 48 return cssPropertyDescriptors[{{api_class.index}}]; |
| 47 {% endfor %} | 49 {% endfor %} |
| 48 default: | 50 default: |
| 49 return cssPropertyDescriptors[0]; | 51 return cssPropertyDescriptors[0]; |
| 50 } | 52 } |
| 51 } | 53 } |
| 52 | 54 |
| 53 } // namespace blink | 55 } // namespace blink |
| OLD | NEW |