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 | |
5 #include "core/css/properties/CSSPropertyDescriptor.h" | 4 #include "core/css/properties/CSSPropertyDescriptor.h" |
6 | 5 |
7 #include "core/css/properties/CSSPropertyAPIPadding.h" | 6 {% for classname in classnames %} |
7 #include "core/css/properties/CSSPropertyAPI{{classname}}.h" | |
8 {% endfor %} | |
8 | 9 |
9 namespace blink { | 10 namespace blink { |
10 | 11 |
11 // Initialises a CSSPropertyDescriptor. When functions are added to | 12 // Initialises a CSSPropertyDescriptor. When functions are added to |
12 // CSSPropertyAPI, also add them to the struct initaliser below. | 13 // CSSPropertyAPI, also add them to the struct initaliser below. |
13 #define GET_DESCRIPTOR(X) \ | 14 #define GET_DESCRIPTOR(X) \ |
14 { X::parseSingleValue, true } | 15 { X::parseSingleValue, true } |
15 | 16 |
16 // Initialises an invalid CSSPropertyDescriptor. When functions are added to | 17 // Initialises an invalid CSSPropertyDescriptor. When functions are added to |
17 // CSSPropertyAPI, add a nullptr to represent their function pointers in the | 18 // CSSPropertyAPI, add a nullptr to represent their function pointers in the |
18 // struct initaliser. | 19 // struct initaliser. |
19 #define GET_INVALID_DESCRIPTOR() \ | 20 #define GET_INVALID_DESCRIPTOR() \ |
20 { nullptr, false } | 21 { nullptr, false } |
alancutter (OOO until 2018)
2016/12/12 00:00:04
We should avoid using macros in code templates giv
| |
21 | 22 |
22 static_assert( | 23 static_assert( |
23 std::is_pod<CSSPropertyDescriptor>::value, | 24 std::is_pod<CSSPropertyDescriptor>::value, |
24 "CSSPropertyDescriptor must be a POD to support using initializer lists."); | 25 "CSSPropertyDescriptor must be a POD to support using initializer lists."); |
25 | 26 |
26 static CSSPropertyDescriptor cssPropertyDescriptors[] = { | 27 static CSSPropertyDescriptor cssPropertyDescriptors[] = { |
27 GET_INVALID_DESCRIPTOR(), | 28 GET_INVALID_DESCRIPTOR(), |
28 GET_DESCRIPTOR(CSSPropertyAPIWebkitPaddingEnd), | 29 {% for property in properties %} |
29 GET_DESCRIPTOR(CSSPropertyAPIWebkitPaddingStart), | 30 GET_DESCRIPTOR(CSSPropertyAPI{{property['upper_camel_name']}}), |
30 GET_DESCRIPTOR(CSSPropertyAPIWebkitPaddingBefore), | 31 {% endfor %} |
31 GET_DESCRIPTOR(CSSPropertyAPIWebkitPaddingAfter), | |
32 }; | 32 }; |
33 | 33 |
34 const CSSPropertyDescriptor& CSSPropertyDescriptor::get(CSSPropertyID id) { | 34 const CSSPropertyDescriptor& CSSPropertyDescriptor::get(CSSPropertyID id) { |
35 // TODO(aazzam): We are currently using hard-coded indexes for | 35 // TODO(aazzam): We are currently using hard-coded indexes for |
36 // cssPropertyDescriptor since we have only implemented a few properties. | 36 // cssPropertyDescriptor since we have only implemented a few properties. |
37 // Later, generate this switch statement, or alternatively return | 37 // Later, generate this switch statement, or alternatively return |
38 // cssPropertyDescriptors[id], and generate the cssPropertyDescriptors array | 38 // cssPropertyDescriptors[id], and generate the cssPropertyDescriptors array |
39 // to hold invalid descriptors for methods which haven't been implemented yet. | 39 // to hold invalid descriptors for methods which haven't been implemented yet. |
40 switch (id) { | 40 switch (id) { |
41 case CSSPropertyWebkitPaddingEnd: | 41 {% for property in properties %} |
42 return cssPropertyDescriptors[1]; | 42 case CSSProperty{{property['upper_camel_name']}}: |
43 case CSSPropertyWebkitPaddingStart: | 43 return cssPropertyDescriptors[{{property['api_array_index']}}]; |
44 return cssPropertyDescriptors[2]; | 44 » {% endfor %} |
45 case CSSPropertyWebkitPaddingBefore: | |
46 return cssPropertyDescriptors[3]; | |
47 case CSSPropertyWebkitPaddingAfter: | |
48 return cssPropertyDescriptors[4]; | |
49 default: | 45 default: |
50 return cssPropertyDescriptors[0]; | 46 return cssPropertyDescriptors[0]; |
51 } | 47 } |
52 } | 48 } |
53 | 49 |
54 } // namespace blink | 50 } // namespace blink |
OLD | NEW |