blob: 59c505707216362d3a3b662a6a531398b8f5009e [file] [log] [blame]
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
{% from 'templates/macros.tmpl' import source_files_for_generated_file %}
{{source_files_for_generated_file(template_file, input_files)}}
#include "third_party/blink/renderer/core/css/cssom/cssom_keywords.h"
#include "third_party/blink/renderer/core/css/css_property_id_templates.h"
#include "third_party/blink/renderer/core/css/cssom/css_keyword_value.h"
#include "third_party/blink/renderer/platform/wtf/hash_map.h"
#include "third_party/blink/renderer/core/css/properties/css_parsing_utils.h"
namespace blink {
bool CSSOMKeywords::ValidKeywordForProperty(CSSPropertyID id,
const CSSKeywordValue& keyword) {
CSSValueID valueID = keyword.KeywordValueID();
if (!IsValidCSSValueID(valueID)) {
return false;
}
if (css_parsing_utils::IsCSSWideKeyword(valueID)) {
// TODO(crbug.com/1310761): Support CSS-wide keywords in custom props.
return id != CSSPropertyID::kVariable;
}
switch (id) {
{% for property in properties if property.keywordIDs and 'Keyword' in property.typedom_types %}
case CSSPropertyID::{{property.enum_key}}: {
switch (valueID) {
{% for keywordValueID in property.keywordIDs %}
case CSSValueID::{{keywordValueID}}:
{% endfor %}
return true;
default:
return false;
}
}
{% endfor %}
default:
return false;
}
}
} // namespace blink