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

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

Issue 2371673002: [CSS Typed OM] Implement support for CSSValue -> CSSCalcLength (Closed)
Patch Set: sync to head Created 4 years, 2 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 788e10e6f7cb21ece391c2ea39862c1e94dbfd4a..2e63bcbf5e752fa36dc5e8a4bb060841dd1cc635 100644
--- a/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp
+++ b/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp
@@ -6,7 +6,9 @@
#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"
@@ -20,9 +22,17 @@ namespace blink {
namespace {
CSSStyleValue* styleValueForPrimitiveValue(
+ CSSPropertyID propertyID,
const CSSPrimitiveValue& primitiveValue) {
if (primitiveValue.isNumber())
return CSSNumberValue::create(primitiveValue.getDoubleValue());
+ if (primitiveValue.isCalculated()) {
+ // NOTE: Won't work for non-length units. Perhaps check on propertyID?
+ if (CSSOMTypes::propertyCanTakeType(propertyID,
+ CSSStyleValue::CalcLengthType))
+ return CSSCalcLength::fromCSSValue(primitiveValue);
+ return nullptr;
+ }
if (primitiveValue.isLength() || primitiveValue.isPercentage())
return CSSSimpleLength::fromCSSValue(primitiveValue);
@@ -40,7 +50,7 @@ CSSStyleValue* styleValueForProperty(CSSPropertyID propertyID,
}
if (value.isPrimitiveValue())
- return styleValueForPrimitiveValue(toCSSPrimitiveValue(value));
+ return styleValueForPrimitiveValue(propertyID, toCSSPrimitiveValue(value));
if (value.isVariableReferenceValue())
return CSSUnparsedValue::fromCSSValue(toCSSVariableReferenceValue(value));
if (value.isImageValue())

Powered by Google App Engine
This is Rietveld 408576698