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