| 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 "platform/wtf/Allocator.h" | 9 #include "platform/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 // Base class for property APIs that contain logic for handling individual |
| 18 // logic inside the blink style engine. All specific properties are subclasses | 18 // properties. |
| 19 // of CSSPropertyAPI. | 19 // The methods declared here are standard methods among property APIs, and can |
| 20 // be called on a particular property API through a CSSPropertyDescriptor |
| 21 // object. |
| 22 // Note that not all methods are implemented by all property APIs. Methods that |
| 23 // are not implemented on a property API will return nullptr when accessed |
| 24 // through a CSSPropertyDescriptor. |
| 25 // See the api_methods field on properties defined in CSSProperties.json5 for a |
| 26 // definition of which methods are implemented on a property. |
| 20 // | 27 // |
| 21 // To add a new implementation of this API for a property: | 28 // Status (5th May 2017): Eventually, all property specific logic will be |
| 22 // - Make a class that implements CSSPropertyAPI. | 29 // contained within property APIs that inherit from CSSPropertyAPI. |
| 23 // - For each method that you wish to implement in this class, add this method | 30 // Currently, the code base is in a transitional state and property specific |
| 24 // name to the api_methods flag in CSSProperties.json5. | 31 // logic is still scattered around the code base. |
| 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 class CSSPropertyAPI { |
| 32 STATIC_ONLY(CSSPropertyAPI); | 33 STATIC_ONLY(CSSPropertyAPI); |
| 33 | 34 |
| 34 public: | 35 public: |
| 35 {% for api_method_name in ordered_api_method_names %} | 36 {% for api_method_name in ordered_api_method_names %} |
| 36 {% set api_method = all_api_methods[api_method_name] %} | 37 {% set api_method = all_api_methods[api_method_name] %} |
| 37 {% if api_method.description %} | 38 {% if api_method.description %} |
| 38 // {{api_method.description}} | 39 // {{api_method.description}} |
| 39 {% endif %} | 40 {% endif %} |
| 40 static {{api_method.return_type}} {{api_method_name}}{{api_method.parameters}}
; | 41 static {{api_method.return_type}} {{api_method_name}}{{api_method.parameters}}
; |
| 41 {% endfor %} | 42 {% endfor %} |
| 42 }; | 43 }; |
| 43 | 44 |
| 44 } // namespace blink | 45 } // namespace blink |
| 45 | 46 |
| 46 #endif // CSSPropertyAPI_h | 47 #endif // CSSPropertyAPI_h |
| OLD | NEW |