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 #ifndef CSSPropertyAPI_h | |
6 #define CSSPropertyAPI_h | |
7 | |
8 #include "core/CSSPropertyNames.h" | |
9 #include "wtf/Allocator.h" | |
10 | |
11 namespace blink { | |
12 | |
13 class CSSValue; | |
14 class CSSParserContext; | |
15 class CSSParserTokenRange; | |
16 | |
17 // We will use this API to represent all functions used for property-specific | |
18 // logic inside the blink style engine. All specific properties are subclasses | |
19 // of CSSPropertyAPI. | |
20 // | |
21 // To add a new implementation of this API for a property: | |
22 // - Make a class that implements CSSPropertyAPI. | |
23 // - For each method that you wish to implement in this class, add this method | |
24 // name to the api_methods flag in CSSProperties.json5. | |
25 // - Implement these methods in the .cpp file. | |
26 // | |
27 // To add new functions to this API: | |
28 // - Add the function to the struct below. | |
29 // - Add the function name to the valid_values field for api_methods in | |
30 // CSSProperties.json5. | |
31 class CSSPropertyAPI { | |
32 STATIC_ONLY(CSSPropertyAPI); | |
33 | |
34 public: | |
35 // Parses a single CSS property and returns the corresponding CSSValue. If the | |
36 // input is invalid it returns nullptr. | |
37 static const CSSValue* parseSingleValue(CSSParserTokenRange&, | |
38 const CSSParserContext*) { | |
39 // No code should reach here, since properties either have their own | |
40 // implementations of this method or store nullptr in their descriptor. | |
41 NOTREACHED(); | |
42 return nullptr; | |
43 } | |
44 | |
45 static bool parseShorthand(bool, | |
46 CSSParserTokenRange&, | |
47 const CSSParserContext*) { | |
48 // No code should reach here, since properties either have their own | |
49 // implementations of this method or store nullptr in their descriptor. | |
50 NOTREACHED(); | |
51 return false; | |
52 } | |
53 }; | |
54 | |
55 } // namespace blink | |
56 | |
57 #endif // CSSPropertyAPI_h | |
OLD | NEW |