{% from 'templates/macros.tmpl' import license %}
{{license()}}
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_PROPERTY_NAMES_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_PROPERTY_NAMES_H_
#include <stddef.h>
#include "base/check_op.h"
#include "third_party/blink/public/mojom/use_counter/metrics/css_property_id.mojom-blink-forward.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/hash_functions.h"
#include "third_party/blink/renderer/platform/wtf/hash_traits.h"
namespace WTF {
class AtomicString;
class String;
} // namespace WTF
namespace blink {
class ExecutionContext;
enum class CSSPropertyID {
kInvalid = 0,
kVariable = 1,
{{property_enums}}
};
const CSSPropertyID kCSSPropertyAliasList[] = {
{{property_aliases}}
};
const CSSPropertyID kCSSComputableProperties[] = {
{{computable_properties}}
};
// The lowest CSSPropertyID excluding kInvalid and kVariable.
const int kIntFirstCSSProperty = {{first_property_id}};
const CSSPropertyID kFirstCSSProperty =
static_cast<CSSPropertyID>(kIntFirstCSSProperty);
// The number of unresolved CSS properties excluding kInvalid and kVariable.
const int kNumCSSProperties = {{properties_count}};
// The highest resolved CSSPropertyID.
const int kIntLastCSSProperty = {{last_property_id}};
const CSSPropertyID kLastCSSProperty =
static_cast<CSSPropertyID>(kIntLastCSSProperty);
// The highest unresolved CSSPropertyID.
const CSSPropertyID kLastUnresolvedCSSProperty =
static_cast<CSSPropertyID>({{last_unresolved_property_id}});
const CSSPropertyID kFirstHighPriorityCSSProperty = kFirstCSSProperty;
const CSSPropertyID kLastHighPriorityCSSProperty = CSSPropertyID::{{last_high_priority_property_id}};
// 1 + <The highest unresolved CSSPropertyID>.
const int kNumCSSPropertyIDs = static_cast<int>(kLastUnresolvedCSSProperty) + 1;
const size_t kMaxCSSPropertyNameLength = {{max_name_length}};
constexpr size_t kCSSPropertyIDBitLength = {{property_id_bit_length}};
constexpr size_t kMaxShorthandExpansion = {{max_shorthand_expansion}};
static_assert((static_cast<size_t>(1) << kCSSPropertyIDBitLength) >
static_cast<size_t>(kLastUnresolvedCSSProperty),
"kCSSPropertyIDBitLength has enough bits");
// These are basically just change-detector tests, so that we do not
// accidentally add new high-priority properties or break the code generator.
static_assert(CSSPropertyID::kColorScheme == kFirstHighPriorityCSSProperty);
static_assert(CSSPropertyID::kZoom == kLastHighPriorityCSSProperty);
static_assert((static_cast<int>(kLastHighPriorityCSSProperty) -
static_cast<int>(kFirstHighPriorityCSSProperty)) == 42,
"There should a low number of high-priority properties");
inline int GetCSSPropertyIDIndex(CSSPropertyID id) {
DCHECK_GE(id, kFirstCSSProperty);
DCHECK_LE(id, kLastCSSProperty);
return static_cast<int>(id) - kIntFirstCSSProperty;
}
constexpr bool IsHighPriority(CSSPropertyID id) {
return id >= kFirstHighPriorityCSSProperty &&
id <= kLastHighPriorityCSSProperty;
}
inline bool IsCSSPropertyIDWithName(CSSPropertyID id)
{
return id >= kFirstCSSProperty && id <= kLastUnresolvedCSSProperty;
}
inline bool IsValidCSSPropertyID(CSSPropertyID id)
{
return id != CSSPropertyID::kInvalid;
}
inline CSSPropertyID ConvertToCSSPropertyID(int value)
{
DCHECK_GE(value, static_cast<int>(CSSPropertyID::kInvalid));
DCHECK_LE(value, kIntLastCSSProperty);
return static_cast<CSSPropertyID>(value);
}
int CORE_EXPORT ResolveCSSPropertyAlias(int value);
inline bool IsPropertyAlias(CSSPropertyID id) {
return static_cast<int>(id) >= {{alias_offset}};
}
inline CSSPropertyID ResolveCSSPropertyID(CSSPropertyID id)
{
int int_id = static_cast<int>(id);
if (IsPropertyAlias(id))
int_id = ResolveCSSPropertyAlias(int_id);
return ConvertToCSSPropertyID(int_id);
}
CSSPropertyID CORE_EXPORT CssPropertyID(const ExecutionContext*,
const WTF::String&);
class CSSPropertyIDList {
STACK_ALLOCATED();
public:
class Iterator {
STACK_ALLOCATED();
public:
Iterator(int id) : id_(id) {}
CSSPropertyID operator*() const { return ConvertToCSSPropertyID(id_); }
Iterator& operator++() {
id_++;
return *this;
}
bool operator!=(const Iterator& i) const { return id_ != i.id_; }
private:
int id_;
};
Iterator begin() const { return Iterator(kIntFirstCSSProperty); }
Iterator end() const { return Iterator(kIntLastCSSProperty + 1); }
};
mojom::blink::CSSSampleId CORE_EXPORT GetCSSSampleId(CSSPropertyID id);
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_PROPERTY_NAMES_H_