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

Side by Side Diff: third_party/WebKit/Source/build/scripts/templates/CSSPropertyDescriptor.cpp.tmpl

Issue 2567473002: Made a generator for CSSPropertyDescriptor.cpp (Closed)
Patch Set: Created 4 years 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 unified diff | Download patch
OLDNEW
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 group in propertyGroups %}
7 #include "core/css/properties/CSSPropertyAPI{{group}}.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 }
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 %}
sashab 2016/12/08 23:56:35 Ahhhh this template file is so nice now ~^_^~
aazzam 2016/12/09 00:44:39 :D
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698