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

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

Issue 2373233002: Add fromCSSValue methods to LengthValue subclasses, remove extra method in CSSSimpleLength. (Closed)
Patch Set: Created 4 years, 3 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 301b91445f3f9b312605ce644b8d9f8c9efa3f53..61eabc0b866a73137ea240f1c91155ea1287643c 100644
--- a/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp
+++ b/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp
@@ -4,9 +4,12 @@
#include "core/css/cssom/StyleValueFactory.h"
+#include "core/css/CSSCalculationValue.h"
rjwright 2016/09/29 05:34:42 I don't think any of these extra includes are need
meade_UTC10 2016/09/29 05:53:13 Done.
#include "core/css/CSSImageValue.h"
#include "core/css/CSSValue.h"
+#include "core/css/cssom/CSSCalcLength.h"
#include "core/css/cssom/CSSNumberValue.h"
+#include "core/css/cssom/CSSOMTypes.h"
#include "core/css/cssom/CSSSimpleLength.h"
#include "core/css/cssom/CSSStyleValue.h"
#include "core/css/cssom/CSSStyleVariableReferenceValue.h"
@@ -19,6 +22,16 @@ namespace blink {
namespace {
+CSSStyleValue* styleValueForPrimitiveValue(CSSPropertyID propertyID, const CSSPrimitiveValue& primitiveValue)
rjwright 2016/09/29 05:34:42 propertyID isn't used
meade_UTC10 2016/09/29 05:53:13 Done.
+{
+ if (primitiveValue.isNumber())
+ return CSSNumberValue::create(primitiveValue.getDoubleValue());
+ if (primitiveValue.isLength())
+ return CSSSimpleLength::fromCSSValue(primitiveValue);
+
+ return nullptr;
+}
+
CSSStyleValue* styleValueForProperty(CSSPropertyID propertyID, const CSSValue& value)
{
switch (propertyID) {
@@ -29,22 +42,12 @@ CSSStyleValue* styleValueForProperty(CSSPropertyID propertyID, const CSSValue& v
break;
}
- if (value.isPrimitiveValue()) {
- const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
- if (primitiveValue.isLength() && !primitiveValue.isCalculated())
- return CSSSimpleLength::create(primitiveValue.getDoubleValue(), primitiveValue.typeWithCalcResolved());
- if (primitiveValue.isNumber())
- return CSSNumberValue::create(primitiveValue.getDoubleValue());
- }
-
- if (value.isVariableReferenceValue()) {
+ if (value.isPrimitiveValue())
+ return styleValueForPrimitiveValue(propertyID, toCSSPrimitiveValue(value));
+ if (value.isVariableReferenceValue())
return CSSUnparsedValue::fromCSSValue(toCSSVariableReferenceValue(value));
- }
-
- if (value.isImageValue()) {
- const CSSImageValue& imageValue = toCSSImageValue(value);
- return CSSURLImageValue::create(imageValue.valueWithURLMadeAbsolute());
- }
+ if (value.isImageValue())
+ return CSSURLImageValue::create(toCSSImageValue(value).valueWithURLMadeAbsolute());
return nullptr;
}

Powered by Google App Engine
This is Rietveld 408576698