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

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: fixed some formatting 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 api_class in api_classes %}
7 #include "core/css/properties/{{api_class.classname}}.h"
8 {% endfor %}
8 9
9 namespace blink { 10 namespace blink {
10 11
11 // Initialises a CSSPropertyDescriptor. When functions are added to
12 // CSSPropertyAPI, also add them to the struct initaliser below.
13 #define GET_DESCRIPTOR(X) \
14 { X::parseSingleValue, true }
15
16 // Initialises an invalid CSSPropertyDescriptor. When functions are added to
17 // CSSPropertyAPI, add a nullptr to represent their function pointers in the
18 // struct initaliser.
19 #define GET_INVALID_DESCRIPTOR() \
20 { nullptr, false }
21
22 static_assert( 12 static_assert(
23 std::is_pod<CSSPropertyDescriptor>::value, 13 std::is_pod<CSSPropertyDescriptor>::value,
24 "CSSPropertyDescriptor must be a POD to support using initializer lists."); 14 "CSSPropertyDescriptor must be a POD to support using initializer lists.");
25 15
26 static CSSPropertyDescriptor cssPropertyDescriptors[] = { 16 static CSSPropertyDescriptor cssPropertyDescriptors[] = {
27 GET_INVALID_DESCRIPTOR(), GET_DESCRIPTOR(CSSPropertyAPIWebkitPadding), 17 // Initialises an invalid CSSPropertyDescriptor. When functions are added to
18 // CSSPropertyAPI, add a nullptr to represent their function pointers in the
19 // struct initaliser.
20 { nullptr, false },
21 {% for api_class in api_classes %}
22
23 // Initialises a CSSPropertyDescriptor. When functions are added to
24 // CSSPropertyAPI, also add them to the struct initaliser below.
alancutter (OOO until 2018) 2016/12/13 22:35:22 These two comments need to be reworded for their n
aazzam 2016/12/13 22:48:57 I changed them a bit, does it sound better now?
25 { {{api_class.classname}}::parseSingleValue, true }
26 {% endfor %}
28 }; 27 };
29 28
30 const CSSPropertyDescriptor& CSSPropertyDescriptor::get(CSSPropertyID id) { 29 const CSSPropertyDescriptor& CSSPropertyDescriptor::get(CSSPropertyID id) {
31 // TODO(aazzam): We are currently using hard-coded indexes for 30 // TODO(aazzam): We are currently using hard-coded indexes for
32 // cssPropertyDescriptor since we have only implemented a few properties. 31 // cssPropertyDescriptor since we have only implemented a few properties.
33 // Later, generate this switch statement, or alternatively return 32 // Later, generate this switch statement, or alternatively return
34 // cssPropertyDescriptors[id], and generate the cssPropertyDescriptors array 33 // cssPropertyDescriptors[id], and generate the cssPropertyDescriptors array
35 // to hold invalid descriptors for methods which haven't been implemented yet. 34 // to hold invalid descriptors for methods which haven't been implemented yet.
36 switch (id) { 35 switch (id) {
37 case CSSPropertyWebkitPaddingEnd: 36 {% for api_class in api_classes %}
38 return cssPropertyDescriptors[1]; 37 {% for property_id in api_class.property_ids %}
39 case CSSPropertyWebkitPaddingStart: 38 case {{property_id}}:
40 return cssPropertyDescriptors[1]; 39 {% endfor %}
41 case CSSPropertyWebkitPaddingBefore: 40 return cssPropertyDescriptors[{{api_class.index}}];
42 return cssPropertyDescriptors[1]; 41 » {% endfor %}
43 case CSSPropertyWebkitPaddingAfter:
44 return cssPropertyDescriptors[1];
45 default: 42 default:
46 return cssPropertyDescriptors[0]; 43 return cssPropertyDescriptors[0];
47 } 44 }
48 } 45 }
49 46
50 } // namespace blink 47 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/build/scripts/make_css_property_descriptor.py ('k') | third_party/WebKit/Source/core/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698