Created
March 9, 2018 04:52
-
-
Save darrnshn/319a0e079d55e817686976846c0517e7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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. | |
// Generated from template: | |
// core/css/templates/CSSOMTypes.cpp.tmpl | |
// and input files: | |
// ../../third_party/WebKit/Source/core/css/ComputedStyleFieldAliases.json5 | |
// ../../third_party/WebKit/Source/core/css/CSSProperties.json5 | |
#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 IsCSSStyleValueNumber(const CSSStyleValue& value) { | |
if (!value.IsNumericValue()) | |
return false; | |
return static_cast<const CSSNumericValue&>(value).Type(). | |
MatchesNumber(); | |
} | |
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::IsPropertySupported(CSSPropertyID id) { | |
switch (id) { | |
case CSSPropertyVariable: | |
case CSSPropertyAnimationDirection: | |
case CSSPropertyAnimationDuration: | |
case CSSPropertyTransitionDuration: | |
case CSSPropertyColor: | |
case CSSPropertyDirection: | |
case CSSPropertyFontStyle: | |
case CSSPropertyFontWeight: | |
case CSSPropertyBackfaceVisibility: | |
case CSSPropertyBackgroundColor: | |
case CSSPropertyBackgroundImage: | |
case CSSPropertyBorderBottomColor: | |
case CSSPropertyBorderBottomStyle: | |
case CSSPropertyBorderBottomWidth: | |
case CSSPropertyBorderCollapse: | |
case CSSPropertyBorderImageSource: | |
case CSSPropertyBorderLeftColor: | |
case CSSPropertyBorderLeftStyle: | |
case CSSPropertyBorderLeftWidth: | |
case CSSPropertyBorderRightColor: | |
case CSSPropertyBorderRightStyle: | |
case CSSPropertyBorderRightWidth: | |
case CSSPropertyBorderTopColor: | |
case CSSPropertyBorderTopStyle: | |
case CSSPropertyBorderTopWidth: | |
case CSSPropertyBottom: | |
case CSSPropertyBoxSizing: | |
case CSSPropertyCaretColor: | |
case CSSPropertyClear: | |
case CSSPropertyColumnRuleColor: | |
case CSSPropertyContent: | |
case CSSPropertyDisplay: | |
case CSSPropertyEmptyCells: | |
case CSSPropertyFloat: | |
case CSSPropertyHeight: | |
case CSSPropertyLeft: | |
case CSSPropertyLineHeight: | |
case CSSPropertyListStyleImage: | |
case CSSPropertyListStylePosition: | |
case CSSPropertyMarginBottom: | |
case CSSPropertyMarginLeft: | |
case CSSPropertyMarginRight: | |
case CSSPropertyMarginTop: | |
case CSSPropertyObjectPosition: | |
case CSSPropertyOpacity: | |
case CSSPropertyOutlineColor: | |
case CSSPropertyOutlineStyle: | |
case CSSPropertyOverflowAnchor: | |
case CSSPropertyOverflowX: | |
case CSSPropertyOverflowY: | |
case CSSPropertyPaddingBottom: | |
case CSSPropertyPaddingLeft: | |
case CSSPropertyPaddingRight: | |
case CSSPropertyPaddingTop: | |
case CSSPropertyPosition: | |
case CSSPropertyResize: | |
case CSSPropertyRight: | |
case CSSPropertyScrollPaddingBlockEnd: | |
case CSSPropertyScrollPaddingBlockStart: | |
case CSSPropertyScrollPaddingBottom: | |
case CSSPropertyScrollPaddingInlineEnd: | |
case CSSPropertyScrollPaddingInlineStart: | |
case CSSPropertyScrollPaddingLeft: | |
case CSSPropertyScrollPaddingRight: | |
case CSSPropertyScrollPaddingTop: | |
case CSSPropertyShapeOutside: | |
case CSSPropertyTextAlign: | |
case CSSPropertyTextDecorationColor: | |
case CSSPropertyTextDecorationStyle: | |
case CSSPropertyTextTransform: | |
case CSSPropertyTop: | |
case CSSPropertyTransform: | |
case CSSPropertyVerticalAlign: | |
case CSSPropertyVisibility: | |
case CSSPropertyWhiteSpace: | |
case CSSPropertyWidth: | |
case CSSPropertyZIndex: | |
return true; | |
default: | |
return false; | |
} | |
} | |
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; | |
} | |
if (value.GetType() == CSSStyleValue::kUnparsedType) { | |
return true; | |
} | |
switch (id) { | |
case CSSPropertyVariable: | |
return value.GetType() == CSSStyleValue::kUnparsedType; | |
case CSSPropertyAnimationDuration: | |
return ( | |
IsCSSStyleValueTime(value) | |
); | |
case CSSPropertyTransitionDuration: | |
return ( | |
IsCSSStyleValueTime(value) | |
); | |
case CSSPropertyFontWeight: | |
return ( | |
IsCSSStyleValueNumber(value) | |
); | |
case CSSPropertyBackgroundImage: | |
return ( | |
IsCSSStyleValueImage(value) | |
); | |
case CSSPropertyBorderBottomWidth: | |
return ( | |
IsCSSStyleValueLength(value) | |
); | |
case CSSPropertyBorderImageSource: | |
return ( | |
IsCSSStyleValueImage(value) | |
); | |
case CSSPropertyBorderLeftWidth: | |
return ( | |
IsCSSStyleValueLength(value) | |
); | |
case CSSPropertyBorderRightWidth: | |
return ( | |
IsCSSStyleValueLength(value) | |
); | |
case CSSPropertyBorderTopWidth: | |
return ( | |
IsCSSStyleValueLength(value) | |
); | |
case CSSPropertyBottom: | |
return ( | |
IsCSSStyleValueLength(value) | |
|| IsCSSStyleValuePercentage(value) | |
); | |
case CSSPropertyContent: | |
return ( | |
IsCSSStyleValueImage(value) | |
); | |
case CSSPropertyHeight: | |
return ( | |
IsCSSStyleValueLength(value) | |
|| IsCSSStyleValuePercentage(value) | |
); | |
case CSSPropertyLeft: | |
return ( | |
IsCSSStyleValueLength(value) | |
|| IsCSSStyleValuePercentage(value) | |
); | |
case CSSPropertyLineHeight: | |
return ( | |
IsCSSStyleValueLength(value) | |
|| IsCSSStyleValueNumber(value) | |
|| IsCSSStyleValuePercentage(value) | |
); | |
case CSSPropertyListStyleImage: | |
return ( | |
IsCSSStyleValueImage(value) | |
); | |
case CSSPropertyMarginBottom: | |
return ( | |
IsCSSStyleValueLength(value) | |
|| IsCSSStyleValuePercentage(value) | |
); | |
case CSSPropertyMarginLeft: | |
return ( | |
IsCSSStyleValueLength(value) | |
|| IsCSSStyleValuePercentage(value) | |
); | |
case CSSPropertyMarginRight: | |
return ( | |
IsCSSStyleValueLength(value) | |
|| IsCSSStyleValuePercentage(value) | |
); | |
case CSSPropertyMarginTop: | |
return ( | |
IsCSSStyleValueLength(value) | |
|| IsCSSStyleValuePercentage(value) | |
); | |
case CSSPropertyObjectPosition: | |
return ( | |
IsCSSStyleValuePosition(value) | |
); | |
case CSSPropertyOpacity: | |
return ( | |
IsCSSStyleValueNumber(value) | |
); | |
case CSSPropertyPaddingBottom: | |
return ( | |
IsCSSStyleValueLength(value) | |
|| IsCSSStyleValuePercentage(value) | |
); | |
case CSSPropertyPaddingLeft: | |
return ( | |
IsCSSStyleValueLength(value) | |
|| IsCSSStyleValuePercentage(value) | |
); | |
case CSSPropertyPaddingRight: | |
return ( | |
IsCSSStyleValueLength(value) | |
|| IsCSSStyleValuePercentage(value) | |
); | |
case CSSPropertyPaddingTop: | |
return ( | |
IsCSSStyleValueLength(value) | |
|| IsCSSStyleValuePercentage(value) | |
); | |
case CSSPropertyRight: | |
return ( | |
IsCSSStyleValueLength(value) | |
|| IsCSSStyleValuePercentage(value) | |
); | |
case CSSPropertyScrollPaddingBlockEnd: | |
return ( | |
IsCSSStyleValueLength(value) | |
|| IsCSSStyleValuePercentage(value) | |
); | |
case CSSPropertyScrollPaddingBlockStart: | |
return ( | |
IsCSSStyleValueLength(value) | |
|| IsCSSStyleValuePercentage(value) | |
); | |
case CSSPropertyScrollPaddingBottom: | |
return ( | |
IsCSSStyleValueLength(value) | |
|| IsCSSStyleValuePercentage(value) | |
); | |
case CSSPropertyScrollPaddingInlineEnd: | |
return ( | |
IsCSSStyleValueLength(value) | |
|| IsCSSStyleValuePercentage(value) | |
); | |
case CSSPropertyScrollPaddingInlineStart: | |
return ( | |
IsCSSStyleValueLength(value) | |
|| IsCSSStyleValuePercentage(value) | |
); | |
case CSSPropertyScrollPaddingLeft: | |
return ( | |
IsCSSStyleValueLength(value) | |
|| IsCSSStyleValuePercentage(value) | |
); | |
case CSSPropertyScrollPaddingRight: | |
return ( | |
IsCSSStyleValueLength(value) | |
|| IsCSSStyleValuePercentage(value) | |
); | |
case CSSPropertyScrollPaddingTop: | |
return ( | |
IsCSSStyleValueLength(value) | |
|| IsCSSStyleValuePercentage(value) | |
); | |
case CSSPropertyShapeOutside: | |
return ( | |
IsCSSStyleValueImage(value) | |
); | |
case CSSPropertyTop: | |
return ( | |
IsCSSStyleValueLength(value) | |
|| IsCSSStyleValuePercentage(value) | |
); | |
case CSSPropertyTransform: | |
return ( | |
IsCSSStyleValueTransform(value) | |
); | |
case CSSPropertyVerticalAlign: | |
return ( | |
IsCSSStyleValueLength(value) | |
|| IsCSSStyleValuePercentage(value) | |
); | |
case CSSPropertyWidth: | |
return ( | |
IsCSSStyleValueLength(value) | |
|| IsCSSStyleValuePercentage(value) | |
); | |
default: | |
return false; | |
} | |
} | |
} // namespace blink |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment