{% from 'templates/macros.tmpl' import license, print_if, source_files_for_generated_file %}
{{license()}}
{{source_files_for_generated_file(template_file, input_files)}}
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_COMPUTED_STYLE_BASE_CONSTANTS_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_COMPUTED_STYLE_BASE_CONSTANTS_H_
#include <stdint.h>
#include <iosfwd>
#include "base/dcheck_is_on.h"
#include "third_party/blink/renderer/core/core_export.h"
namespace blink {
// TODO(sashab): Move these enums to their own namespace, or add a CSS prefix,
// for consistency and to prevent name conflicts.
{% for enum in enums %}
enum class {{enum.type_name}} : {{"unsigned" if enum.set_type or enum.values|length > 256 else "uint8_t"}} {
{% for value in enum.values %}
{% if enum.set_type == 'multi' %}
{% set flag = " = " ~ (0 if loop.first else 2**(loop.index0 - 1)) %}
{% elif enum.set_type == 'bitset' %}
{% set flag = " = " ~ 2**(loop.index0) %}
{% endif %}
{{value}}{{flag}},
{% endfor %}
{% if not enum.set_type %}
kMaxEnumValue = {{enum.values|last}},
{% endif %}
};
{% if enum.set_type %}
static const int k{{enum.type_name}}Bits = {{enum.values|length - (1 if enum.set_type == 'multi' else 0)}};
{% for op in ('|', '^', '&') %}
inline {{enum.type_name}} operator{{op}}({{enum.type_name}} a, {{enum.type_name}} b) {
return static_cast<{{enum.type_name}}>(
static_cast<unsigned>(a) {{op}} static_cast<unsigned>(b)
);
}
inline {{enum.type_name}}& operator{{op}}=({{enum.type_name}}& a, {{enum.type_name}} b) {
return a = a {{op}} b;
}
{% endfor %}
inline {{enum.type_name}} operator~({{enum.type_name}} x) {
return static_cast<{{enum.type_name}}>(~static_cast<unsigned>(x));
}
{% endif %}
{% endfor %}
#if DCHECK_IS_ON()
{% for enum in enums %}
{% if not enum.set_type or enum.set_type == 'multi' %}
CORE_EXPORT std::ostream& operator<<(std::ostream&, const {{enum.type_name}});
{% endif %}
{% endfor %}
#endif
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_COMPUTED_STYLE_BASE_CONSTANTS_H_