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

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

Issue 2222863002: [Typed-OM] Enable getting CSSURLImageValue from stylemap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@CSSProperties_Image
Patch Set: Remove backgroundImage test from unsupported-properties, simplify test to get from StyleMap Created 4 years, 4 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
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..acd32707855ea5efe193d94dcd02c03ab1d2ed70 100644
--- a/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp
+++ b/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp
@@ -4,40 +4,77 @@
#include "core/css/cssom/StyleValueFactory.h"
+#include "core/css/CSSImageValue.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"
+#include "core/css/cssom/CSSURLImageValue.h"
#include "core/css/cssom/CSSUnsupportedStyleValue.h"
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 styleValueVector;
- default:
- // TODO(meade): Implement the rest.
- break;
+ if (value.isImageValue()) {
+ const CSSImageValue& imageValue = toCSSImageValue(value);
+ return CSSURLImageValue::create(imageValue.valueWithURLMadeAbsolute());
}
+ 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;
+ }
+
+ 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 CSSValue* innerValue : cssValueList) {
+ styleValue = styleValueForProperty(propertyID, *innerValue);
+ if (!styleValue) {
+ return unsupportedCSSValue(value);
+ }
+ styleValueVector.append(styleValue);
+ }
+ return styleValueVector;
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698