OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "core/css/properties/CSSPropertyDescriptor.h" |
| 6 |
| 7 #include "core/css/properties/CSSPropertyAPIPadding.h" |
| 8 |
| 9 namespace blink { |
| 10 |
| 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( |
| 23 std::is_pod<CSSPropertyDescriptor>::value, |
| 24 "CSSPropertyDescriptor must be a POD to support using initializer lists."); |
| 25 |
| 26 static CSSPropertyDescriptor cssPropertyDescriptors[] = { |
| 27 GET_INVALID_DESCRIPTOR(), GET_DESCRIPTOR(CSSPropertyAPIWebkitPadding), |
| 28 }; |
| 29 |
| 30 const CSSPropertyDescriptor& CSSPropertyDescriptor::get(CSSPropertyID id) { |
| 31 // TODO(aazzam): We are currently using hard-coded indexes for |
| 32 // cssPropertyDescriptor since we have only implemented a few properties. |
| 33 // Later, generate this switch statement, or alternatively return |
| 34 // cssPropertyDescriptors[id], and generate the cssPropertyDescriptors array |
| 35 // to hold invalid descriptors for methods which haven't been implemented yet. |
| 36 switch (id) { |
| 37 case CSSPropertyWebkitPaddingEnd: |
| 38 return cssPropertyDescriptors[1]; |
| 39 case CSSPropertyWebkitPaddingStart: |
| 40 return cssPropertyDescriptors[1]; |
| 41 case CSSPropertyWebkitPaddingBefore: |
| 42 return cssPropertyDescriptors[1]; |
| 43 case CSSPropertyWebkitPaddingAfter: |
| 44 return cssPropertyDescriptors[1]; |
| 45 default: |
| 46 return cssPropertyDescriptors[0]; |
| 47 } |
| 48 } |
| 49 |
| 50 } // namespace blink |
OLD | NEW |