%{
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/core/css/{{file_basename}}.h"
#include <string.h>
#include "third_party/blink/public/mojom/use_counter/metrics/css_property_id.mojom-blink.h"
#include "third_party/blink/renderer/core/css/hash_tools.h"
#include "third_party/blink/renderer/core/css/parser/css_property_parser.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/wtf/text/ascii_ctype.h"
#include "third_party/blink/renderer/platform/wtf/text/atomic_string.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#ifdef _MSC_VER
// Disable the warnings from casting a 64-bit pointer to 32-bit long
// warning C4302: 'type cast': truncation from 'char (*)[28]' to 'long'
// warning C4311: 'type cast': pointer truncation from 'char (*)[18]' to 'long'
#pragma warning(disable : 4302 4311)
#endif
namespace blink {
%}
%struct-type
struct Property;
%omit-struct-type
%language=C++
%readonly-tables
%compare-strncmp
%define class-name {{class_name}}Hash
%define lookup-function-name findPropertyImpl
%define hash-function-name property_hash_function
%define slot-name name_offset
%define word-array-name property_word_list
%enum
%%
{{property_to_enum_map}}
%%
const Property* FindProperty(const char* str, unsigned int len) {
return {{class_name}}Hash::findPropertyImpl(str, len);
}
CSSPropertyID CssPropertyID(const ExecutionContext* execution_context,
const String& string)
{
return ResolveCSSPropertyID(UnresolvedCSSPropertyID(execution_context,
string));
}
mojom::blink::CSSSampleId GetCSSSampleId(CSSPropertyID id) {
switch (id) {
{% for key, value in css_sample_id_pairs: %}
case CSSPropertyID::{{key}}:
return mojom::blink::CSSSampleId::{{value}};
{% endfor %}
case CSSPropertyID::kVariable:
return mojom::blink::CSSSampleId::kVariable;
case CSSPropertyID::kInvalid:
return mojom::blink::CSSSampleId::kInvalid;
// IMPORTANT: Do not add a default case to ensure a compile error if we have
// a mismatch.
}
NOTREACHED_IN_MIGRATION();
}
int ResolveCSSPropertyAlias(int value) {
static constexpr uint16_t kLookupTable[] = {
{% for p in aliases: %}
{{p.aliased_enum_value}},
{% endfor %}
};
return kLookupTable[value - {{alias_offset}}];
}
} // namespace blink