blob: 33d34d8b7eeb455469b3516855c4f00f37b1ba11 [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 "core/css/cssom/CSSOMTypes.h"
#include "core/css/cssom/CSSOMKeywords.h"
#include "core/css/cssom/CSSKeywordValue.h"
#include "core/css/cssom/CSSNumericValue.h"
#include "core/css/cssom/CSSStyleValue.h"
#include "core/css/cssom/CSSUnsupportedStyleValue.h"
#include "core/css/properties/CSSProperty.h"
namespace blink {
namespace {
bool IsCSSStyleValueLength(const CSSStyleValue& value) {
if (!value.IsNumericValue())
return false;
return static_cast<const CSSNumericValue&>(value).Type().
MatchesBaseType(CSSNumericValueType::BaseType::kLength);
}
bool IsCSSStyleValueTime(const CSSStyleValue& value) {
if (!value.IsNumericValue())
return false;
return static_cast<const CSSNumericValue&>(value).Type().
MatchesBaseType(CSSNumericValueType::BaseType::kTime);
}
bool IsCSSStyleValuePercentage(const CSSStyleValue& value) {
if (!value.IsNumericValue())
return false;
return static_cast<const CSSNumericValue&>(value).Type().
MatchesPercentage();
}
bool IsCSSStyleValueImage(const CSSStyleValue& value) {
return value.GetType() == CSSStyleValue::kURLImageType;
}
bool IsCSSStyleValueTransform(const CSSStyleValue& value) {
return value.GetType() == CSSStyleValue::kTransformType;
}
bool IsCSSStyleValuePosition(const CSSStyleValue& value) {
return value.GetType() == CSSStyleValue::kPositionType;
}
}
bool CSSOMTypes::PropertyCanTake(CSSPropertyID id,
const CSSStyleValue& value) {
if (value.GetType() == CSSStyleValue::kKeywordType) {
return CSSOMKeywords::ValidKeywordForProperty(
id, ToCSSKeywordValue(value));
}
if (value.GetType() == CSSStyleValue::kUnknownType) {
return ToCSSUnsupportedStyleValue(value).GetProperty() == id;
}
switch (id) {
case CSSPropertyVariable:
return value.GetType() == CSSStyleValue::kUnparsedType;
{% for property in properties if property.typedom_types %}
case {{property.property_id}}:
return (
{% for type in property.typedom_types %}
{{ "|| " if not loop.first }}IsCSSStyleValue{{type}}(value)
{% endfor %}
);
{% endfor %}
default:
return false;
}
}
} // namespace blink