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

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

Issue 2312293003: [CSSTypedOM] Computed StylePropertyMap use ComputedStyle for Lengths (Closed)
Patch Set: Fixed unit test 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/CSSCalcLength.cpp
diff --git a/third_party/WebKit/Source/core/css/cssom/CSSCalcLength.cpp b/third_party/WebKit/Source/core/css/cssom/CSSCalcLength.cpp
index 4d1b56531ffb75d5eccf8ff7a707a615844f0faa..ea0b681c99627cbf3284abed712702f95814f4f9 100644
--- a/third_party/WebKit/Source/core/css/cssom/CSSCalcLength.cpp
+++ b/third_party/WebKit/Source/core/css/cssom/CSSCalcLength.cpp
@@ -68,6 +68,24 @@ CSSCalcLength* CSSCalcLength::create(const CSSCalcDictionary& dictionary, Except
return result;
}
+CSSCalcLength* CSSCalcLength::fromLength(const Length* length)
+{
+ DCHECK(length->isSpecified());
+ PixelsAndPercent values = length->getPixelsAndPercent();
+ CSSCalcLength* result = new CSSCalcLength();
+ if (length->isFixed()) {
+ result->set(values.pixels, CSSPrimitiveValue::UnitType::Pixels);
+ return result;
+ }
+ if (length->isPercent()) {
+ result->set(values.percent, CSSPrimitiveValue::UnitType::Percentage);
+ return result;
+ }
+ result->set(values.pixels, CSSPrimitiveValue::UnitType::Pixels);
+ result->set(values.percent, CSSPrimitiveValue::UnitType::Percentage);
+ return result;
+}
+
bool CSSCalcLength::containsPercent() const
{
return has(CSSPrimitiveValue::UnitType::Percentage);

Powered by Google App Engine
This is Rietveld 408576698