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

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 { nullptr, false },
alancutter (OOO until 2018) 2016/12/13 05:55:34 This should probably have a comment explaining wha
aazzam 2016/12/13 21:47:52 done :)
18 {% for api_class in api_classes %}
19 { {{api_class.classname}}::parseSingleValue, true }
20 {% endfor %}
28 }; 21 };
29 22
30 const CSSPropertyDescriptor& CSSPropertyDescriptor::get(CSSPropertyID id) { 23 const CSSPropertyDescriptor& CSSPropertyDescriptor::get(CSSPropertyID id) {
31 // TODO(aazzam): We are currently using hard-coded indexes for 24 // TODO(aazzam): We are currently using hard-coded indexes for
32 // cssPropertyDescriptor since we have only implemented a few properties. 25 // cssPropertyDescriptor since we have only implemented a few properties.
33 // Later, generate this switch statement, or alternatively return 26 // Later, generate this switch statement, or alternatively return
34 // cssPropertyDescriptors[id], and generate the cssPropertyDescriptors array 27 // cssPropertyDescriptors[id], and generate the cssPropertyDescriptors array
35 // to hold invalid descriptors for methods which haven't been implemented yet. 28 // to hold invalid descriptors for methods which haven't been implemented yet.
36 switch (id) { 29 switch (id) {
37 case CSSPropertyWebkitPaddingEnd: 30 {% for api_class in api_classes %}
38 return cssPropertyDescriptors[1]; 31 {% for property_id in api_class.property_ids %}
39 case CSSPropertyWebkitPaddingStart: 32 case {{property_id}}:
40 return cssPropertyDescriptors[1]; 33 {% endfor %}
41 case CSSPropertyWebkitPaddingBefore: 34 return cssPropertyDescriptors[{{api_class.index}}];
42 return cssPropertyDescriptors[1]; 35 » {% endfor %}
43 case CSSPropertyWebkitPaddingAfter:
44 return cssPropertyDescriptors[1];
45 default: 36 default:
46 return cssPropertyDescriptors[0]; 37 return cssPropertyDescriptors[0];
47 } 38 }
48 } 39 }
49 40
50 } // namespace blink 41 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698