Chromium Code Reviews| Index: third_party/WebKit/Source/build/scripts/templates/CSSPropertyDescriptor.cpp.tmpl |
| diff --git a/third_party/WebKit/Source/core/css/properties/CSSPropertyDescriptor.cpp b/third_party/WebKit/Source/build/scripts/templates/CSSPropertyDescriptor.cpp.tmpl |
| similarity index 53% |
| rename from third_party/WebKit/Source/core/css/properties/CSSPropertyDescriptor.cpp |
| rename to third_party/WebKit/Source/build/scripts/templates/CSSPropertyDescriptor.cpp.tmpl |
| index 10e77269e06fa28cae33f81168acd26bb1825f7b..dc28589064d4e35f4a3eb894881a5a45ff986b30 100644 |
| --- a/third_party/WebKit/Source/core/css/properties/CSSPropertyDescriptor.cpp |
| +++ b/third_party/WebKit/Source/build/scripts/templates/CSSPropertyDescriptor.cpp.tmpl |
| @@ -1,30 +1,28 @@ |
| // Copyright 2016 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| - |
| #include "core/css/properties/CSSPropertyDescriptor.h" |
| -#include "core/css/properties/CSSPropertyAPIPadding.h" |
| +{% for api_class in api_classes %} |
| +#include "core/css/properties/{{api_class.classname}}.h" |
| +{% endfor %} |
| namespace blink { |
| -// Initialises a CSSPropertyDescriptor. When functions are added to |
| -// CSSPropertyAPI, also add them to the struct initaliser below. |
| -#define GET_DESCRIPTOR(X) \ |
| - { X::parseSingleValue, true } |
| - |
| -// Initialises an invalid CSSPropertyDescriptor. When functions are added to |
| -// CSSPropertyAPI, add a nullptr to represent their function pointers in the |
| -// struct initaliser. |
| -#define GET_INVALID_DESCRIPTOR() \ |
| - { nullptr, false } |
| - |
| static_assert( |
| std::is_pod<CSSPropertyDescriptor>::value, |
| "CSSPropertyDescriptor must be a POD to support using initializer lists."); |
| static CSSPropertyDescriptor cssPropertyDescriptors[] = { |
| - GET_INVALID_DESCRIPTOR(), GET_DESCRIPTOR(CSSPropertyAPIWebkitPadding), |
| + // An invalid CSSPropertyDescriptor. When functions are added to |
| + // CSSPropertyAPI, add a nullptr to represent their function pointers in the |
| + // struct initaliser. |
| + { nullptr, false }, |
| + {% for api_class in api_classes %} |
| + // For each class we add a CSSPropertyDescriptor to the array. When functions |
| + // are added to CSSPropertyAPI, also add them to the struct initaliser below. |
|
sashab
2016/12/13 23:10:38
These comments - \o/
|
| + { {{api_class.classname}}::parseSingleValue, true } |
| + {% endfor %} |
| }; |
| const CSSPropertyDescriptor& CSSPropertyDescriptor::get(CSSPropertyID id) { |
| @@ -34,14 +32,12 @@ const CSSPropertyDescriptor& CSSPropertyDescriptor::get(CSSPropertyID id) { |
| // cssPropertyDescriptors[id], and generate the cssPropertyDescriptors array |
| // to hold invalid descriptors for methods which haven't been implemented yet. |
| switch (id) { |
| - case CSSPropertyWebkitPaddingEnd: |
| - return cssPropertyDescriptors[1]; |
| - case CSSPropertyWebkitPaddingStart: |
| - return cssPropertyDescriptors[1]; |
| - case CSSPropertyWebkitPaddingBefore: |
| - return cssPropertyDescriptors[1]; |
| - case CSSPropertyWebkitPaddingAfter: |
| - return cssPropertyDescriptors[1]; |
| + {% for api_class in api_classes %} |
| + {% for property_id in api_class.property_ids %} |
| + case {{property_id}}: |
| + {% endfor %} |
| + return cssPropertyDescriptors[{{api_class.index}}]; |
| + {% endfor %} |
|
sashab
2016/12/13 23:10:38
Careful with your indenting here -- it's not ideal
aazzam
2016/12/13 23:27:53
done :)
|
| default: |
| return cssPropertyDescriptors[0]; |
| } |