blob: 5baf4c07819e329a017b5988ee41433da4d63875 [file] [log] [blame]
{% from 'macros.tmpl' import license, print_if %}
{{license()}}
#ifndef ComputedStyleBase_h
#define ComputedStyleBase_h
#include "core/style/ComputedStyleConstants.h"
#include "core/CoreExport.h"
{% for path in include_paths %}
#include "{{path}}"
{% endfor %}
{# Each field template has macros that we can call to generate specific
aspects of the field (e.g. getters, setters).
#}
{% import 'fields/keyword.tmpl' as keyword %}
{% import 'fields/flag.tmpl' as flag %}
{% import 'fields/monotonic_flag.tmpl' as monotonic_flag %}
{% import 'fields/storage_only.tmpl' as storage_only %}
{% set field_templates = {
'keyword': keyword, 'flag': flag, 'monotonic_flag': monotonic_flag, 'storage_only': storage_only
} %}
namespace blink {
// The generated portion of ComputedStyle. For more info, see the header comment
// in ComputedStyle.h.
class CORE_EXPORT ComputedStyleBase {
public:
inline bool independentInheritedEqual(const ComputedStyleBase& o) const {
return (
{% for field in fields if field.is_inherited and field.is_independent %}
{{field.name}} == o.{{field.name}}{{print_if(not loop.last, ' &&')}}
{% endfor %}
);
}
inline bool nonIndependentInheritedEqual(const ComputedStyleBase& o) const {
return (
{% for field in fields if field.is_inherited and not field.is_independent %}
{{field.name}} == o.{{field.name}}{{print_if(not loop.last, ' &&')}}
{% endfor %}
);
}
inline bool inheritedEqual(const ComputedStyleBase& o) const {
return independentInheritedEqual(o) && nonIndependentInheritedEqual(o);
}
inline bool nonInheritedEqual(const ComputedStyleBase& o) const {
return (
{% for field in fields if field.is_property and not field.is_inherited %}
{{field.name}} == o.{{field.name}}{{print_if(not loop.last, ' &&')}}
{% endfor %}
);
}
enum IsAtShadowBoundary {
AtShadowBoundary,
NotAtShadowBoundary,
};
void inheritFrom(const ComputedStyleBase& inheritParent,
IsAtShadowBoundary isAtShadowBoundary = NotAtShadowBoundary);
void copyNonInheritedFromCached(const ComputedStyleBase& other);
// Copies the values of any independent inherited properties from the parent
// style that are marked as inherited by this style.
void propagateIndependentInheritedProperties(
const ComputedStyleBase& parentStyle);
// Fields.
// TODO(sashab): Remove initialFoo() static methods and update callers to
// use resetFoo(), which can be more efficient.
{% for field in fields %}
// {{field.property_name}}
{{field_templates[field.field_template].decl_methods(field)|indent(2)}}
{% endfor %}
protected:
// Constructor and destructor are protected so that only the parent class ComputedStyle
// can instantiate this class.
ALWAYS_INLINE ComputedStyleBase() :
{% for field in fields %}
{{field.name}}(static_cast<unsigned>({{field.default_value}})){{print_if(not loop.last, ',')}}
{% endfor %}
{}
~ComputedStyleBase() = default;
// Storage.
{% for field in fields %}
unsigned {{field.name}} : {{field.size}}; // {{field.type_name}}
{% endfor %}
};
} // namespace blink
#endif // ComputedStyleBase_h