| {% 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 "third_party/blink/public/mojom/use_counter/css_property_id.mojom-blink.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/assertions.h" |
| |
| namespace WTF { |
| class AtomicString; |
| class String; |
| } |
| |
| namespace blink { |
| |
| class ExecutionContext; |
| |
| enum class CSSPropertyID { |
| kInvalid = 0, |
| kVariable = 1, |
| {{property_enums}} |
| }; |
| |
| const CSSPropertyID kCSSPropertyAliasList[] = { |
| {{property_aliases}} |
| }; |
| |
| const int kIntFirstCSSProperty = {{first_property_id}}; |
| const CSSPropertyID firstCSSProperty = static_cast<CSSPropertyID>(kIntFirstCSSProperty); |
| const int numCSSProperties = {{properties_count}}; |
| const int kIntLastCSSProperty = {{last_property_id}}; |
| const CSSPropertyID lastCSSProperty = static_cast<CSSPropertyID>(kIntLastCSSProperty); |
| const CSSPropertyID lastUnresolvedCSSProperty = static_cast<CSSPropertyID>({{last_unresolved_property_id}}); |
| const int numCSSPropertyIDs = static_cast<int>(lastUnresolvedCSSProperty) + 1; |
| const size_t maxCSSPropertyNameLength = {{max_name_length}}; |
| |
| inline int GetCSSPropertyIDIndex(CSSPropertyID id) { |
| DCHECK_GE(id, firstCSSProperty); |
| DCHECK_LE(id, lastCSSProperty); |
| return static_cast<int>(id) - kIntFirstCSSProperty; |
| } |
| |
| inline bool isCSSPropertyIDWithName(CSSPropertyID id) |
| { |
| return id >= firstCSSProperty && id <= lastUnresolvedCSSProperty; |
| } |
| |
| 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); |
| } |
| |
| inline CSSPropertyID resolveCSSPropertyID(CSSPropertyID id) |
| { |
| return convertToCSSPropertyID(static_cast<int>(id) & ~{{alias_offset}}); |
| } |
| |
| inline bool isPropertyAlias(CSSPropertyID id) { return static_cast<int>(id) & {{alias_offset}}; } |
| |
| CSSPropertyID CORE_EXPORT unresolvedCSSPropertyID(const ExecutionContext*, const WTF::String&); |
| |
| 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_ |