Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Unified Diff: third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp

Issue 2096133002: [Typed OM] Add support for properties which take numbers in CSSProperties.in (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync to head Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/css/cssom/InlineStylePropertyMap.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp
diff --git a/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp b/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp
index e710d8f8a8a0b94a98fc72d57939bc72020111fd..edb693bbf13173ad65fe6b18cdf76c147446f3e2 100644
--- a/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp
+++ b/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp
@@ -5,6 +5,7 @@
#include "core/css/cssom/StyleValueFactory.h"
#include "core/css/CSSValue.h"
+#include "core/css/cssom/CSSNumberValue.h"
#include "core/css/cssom/CSSSimpleLength.h"
#include "core/css/cssom/CSSStyleValue.h"
#include "core/css/cssom/CSSTransformValue.h"
@@ -12,31 +13,60 @@
namespace blink {
-CSSStyleValueVector StyleValueFactory::cssValueToStyleValueVector(CSSPropertyID propertyID, const CSSValue& value)
+namespace {
+
+CSSStyleValue* styleValueForProperty(CSSPropertyID propertyID, const CSSValue& value)
{
- CSSStyleValueVector styleValueVector;
+ switch (propertyID) {
+ case CSSPropertyTransform:
+ return CSSTransformValue::fromCSSValue(value);
+ default:
+ // TODO(meade): Implement other complex properties.
+ break;
+ }
if (value.isPrimitiveValue()) {
const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
- if (primitiveValue.isLength() && !primitiveValue.isCalculated()) {
- styleValueVector.append(CSSSimpleLength::create(primitiveValue.getDoubleValue(), primitiveValue.typeWithCalcResolved()));
- return styleValueVector;
- }
+ if (primitiveValue.isLength() && !primitiveValue.isCalculated())
+ return CSSSimpleLength::create(primitiveValue.getDoubleValue(), primitiveValue.typeWithCalcResolved());
+ if (primitiveValue.isNumber())
+ return CSSNumberValue::create(primitiveValue.getDoubleValue());
}
- CSSStyleValue* styleValue = nullptr;
- switch (propertyID) {
- case CSSPropertyTransform:
- styleValue = CSSTransformValue::fromCSSValue(value);
- if (styleValue)
- styleValueVector.append(styleValue);
+ return nullptr;
+}
+
+CSSStyleValueVector unsupportedCSSValue(const CSSValue& value)
+{
+ CSSStyleValueVector styleValueVector;
+ styleValueVector.append(CSSUnsupportedStyleValue::create(value.cssText()));
+ return styleValueVector;
+}
+
+} // namespace
+
+CSSStyleValueVector StyleValueFactory::cssValueToStyleValueVector(CSSPropertyID propertyID, const CSSValue& value)
+{
+ CSSStyleValueVector styleValueVector;
+ CSSStyleValue* styleValue = styleValueForProperty(propertyID, value);
+ if (styleValue) {
+ styleValueVector.append(styleValue);
return styleValueVector;
- default:
- // TODO(meade): Implement the rest.
- break;
}
- styleValueVector.append(CSSUnsupportedStyleValue::create(value.cssText()));
+ if (!value.isValueList()) {
+ return unsupportedCSSValue(value);
+ }
+
+ // If it's a list, we can try it as a list valued property.
+ const CSSValueList& cssValueList = toCSSValueList(value);
+ for (const Member<const CSSValue> innerValue : cssValueList) {
+ styleValue = styleValueForProperty(propertyID, *innerValue);
+ if (!styleValue) {
+ return unsupportedCSSValue(value);
+ }
+ styleValueVector.append(styleValue);
+ }
return styleValueVector;
}
« no previous file with comments | « third_party/WebKit/Source/core/css/cssom/InlineStylePropertyMap.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698