Chromium Code Reviews| 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..6f9fde0a0c83bfc09ce34ee3830f5bfc8a0b2783 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); |
|
meade_UTC10
2016/09/22 05:34:35
Shouldn't fixed lengths become CSSSimpleLengths? (
rjwright
2016/09/23 04:50:03
This is not even reached so I just removed it.
|
| + 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); |