This directory contains implementations for CSS property APIs, as well as Utils files containing functions commonly used by the property APIs.
CSSPropertyAPI is the base class which all property implementations are derived from. It contains all the methods that can be called on a property API, and a default implementation for each. The .cpp implementation files for CSSPropertyAPI are split between the generated code (CSSPropertyAPI.cpp) and the hand written code (CSSPropertyAPIBaseCustom.cpp).
The methods that are overriden from the base class by a property API depends on the functionality required by that property. Methods may have a working default implementation in the base class, or may assert that this default implementation is not reached.
A derived CSS property API (CSSPropertyAPI<Property/GroupName>) represents a single CSS property or a group of CSS properties that share implementation logic. Property groups can be determined from CSSProperties.json5. Properties that are a part of a group define the group class name as ‘api_class’ here.
Examples:
CSSPropertyAPILineHeight
class is used only by the line-height
propertyCSSPropertyAPIImageSource
class is shared by the border-image-source
and -webkit-mask-box-image-source
properties.Shorthand properties only exist in the context of parsing and serialization. Therefore only a subset of methods may be implemented by shorthand properties, e.g. ParseShorthand.
Shorthand property APIs are named like CSSShorthandPropertyAPI<ShorthandProperty>
TODO(rjwright): write this section
CSSPropertyAPI<Property/GroupName>.cpp
#include "core/css/properties/CSSPropertyAPI<Property/GroupName>.h"
(this will be a generated file).core/css/CSSProperties.json5
. Ensure that you include the ‘api_class’ flag and the ‘api_methods’ flag so that the API files are generated correctly (see CSSProperties.json5 for more details)blink_core_sources
target's sources
parametercss_properties
target's outputs
parameterSee this example CL, which converts the existing line-height property to use the CSSPropertyAPI design. This new line-height property API only implements the ParseSingleValue method, using CSSPropertyFontUtils.cpp to access shared font logic.
Eventually, all logic pertaining to a single property will be found only within its CSS property API where possible.
Currently (September 1 2017) the code base is in a transitional state and property specific logic is still scattered around the code base. See Project Ribbon tracking bug and design doc for details of progress.