| Index: third_party/WebKit/Source/build/scripts/templates/CSSOMTypes.cpp.tmpl
|
| diff --git a/third_party/WebKit/Source/build/scripts/templates/CSSOMTypes.cpp.tmpl b/third_party/WebKit/Source/build/scripts/templates/CSSOMTypes.cpp.tmpl
|
| index 33b93b0688df90827abc2fb1fed72fcc57280e95..e97ab2b721683f1727fed19e50e423e9a8abddc0 100644
|
| --- a/third_party/WebKit/Source/build/scripts/templates/CSSOMTypes.cpp.tmpl
|
| +++ b/third_party/WebKit/Source/build/scripts/templates/CSSOMTypes.cpp.tmpl
|
| @@ -9,28 +9,53 @@
|
| #include "core/css/cssom/CSSKeywordValue.h"
|
| #include "core/css/cssom/CSSLengthValue.h"
|
| #include "core/css/cssom/CSSStyleValue.h"
|
| +#include "core/css/cssom/CSSNumberValue.h"
|
|
|
| namespace blink {
|
|
|
| +namespace {
|
| +
|
| +bool validNumberValue(CSSPropertyID id, double number) {
|
| + bool integerOnly;
|
| + bool negativeAllowed;
|
| + switch (id) {
|
| + {% for property_id, property in properties.items() if property.number_metadata %}
|
| + case {{property_id}}:
|
| + integerOnly = {{ property.number_metadata.integer }};
|
| + negativeAllowed = {{ property.number_metadata.allow_negative }};
|
| + break;
|
| + {% endfor %}
|
| + default:
|
| + return false;
|
| + }
|
| + if (!negativeAllowed && number < 0)
|
| + return false;
|
| + if (integerOnly && std::floor(std::abs(number)) != std::abs(number))
|
| + return false;
|
| + return true;
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| bool CSSOMTypes::propertyCanTake(CSSPropertyID id,
|
| const CSSStyleValue& styleValue) {
|
| - // Shortcut special case.
|
| - if (styleValue.type() == CSSStyleValue::SimpleLengthType ||
|
| - styleValue.type() == CSSStyleValue::CalcLengthType) {
|
| - if (toCSSLengthValue(styleValue).containsPercent() &&
|
| - !CSSPropertyMetadata::propertySupportsPercentage(id)) {
|
| + if (styleValue.type() == CSSStyleValue::KeywordType) {
|
| + // Keywords are handled differently.
|
| + return CSSOMKeywords::validKeywordForProperty(id, toCSSKeywordValue(styleValue));
|
| + } else if (styleValue.type() == CSSStyleValue::SimpleLengthType
|
| + || styleValue.type() == CSSStyleValue::CalcLengthType) {
|
| + if (toCSSLengthValue(styleValue).containsPercent()
|
| + && !CSSPropertyMetadata::propertySupportsPercentage(id)) {
|
| return false;
|
| }
|
| - } else if (styleValue.type() == CSSStyleValue::KeywordType) {
|
| - // Keywords are also handled differently.
|
| - return CSSOMKeywords::validKeywordForProperty(
|
| - id, toCSSKeywordValue(styleValue));
|
| + } else if (styleValue.type() == CSSStyleValue::NumberType) {
|
| + return validNumberValue(id, toCSSNumberValue(styleValue).value());
|
| } else if (styleValue.type() == CSSStyleValue::Unknown) {
|
| // The check happens later in this case.
|
| return true;
|
| }
|
|
|
| - return CSSOMTypes::propertyCanTakeType(id, styleValue.type());
|
| + return propertyCanTakeType(id, styleValue.type());
|
| }
|
|
|
| bool CSSOMTypes::propertyCanTakeType(CSSPropertyID id,
|
|
|