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

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

Issue 2377243002: Add support for CSSValue->CSSSimpleLength when it is a percentage. (Closed)
Patch Set: Update test expectations 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/CSSSimpleLength.cpp
diff --git a/third_party/WebKit/Source/core/css/cssom/CSSSimpleLength.cpp b/third_party/WebKit/Source/core/css/cssom/CSSSimpleLength.cpp
index 286446a87e2032af64fdd2ca8c986b0c96888c46..9596121a6671e1aa3a30ff8c3a2279a74a911be8 100644
--- a/third_party/WebKit/Source/core/css/cssom/CSSSimpleLength.cpp
+++ b/third_party/WebKit/Source/core/css/cssom/CSSSimpleLength.cpp
@@ -23,7 +23,9 @@ CSSSimpleLength* CSSSimpleLength::create(double value, const String& type, Excep
CSSSimpleLength* CSSSimpleLength::fromCSSValue(const CSSPrimitiveValue& value)
{
- DCHECK(value.isLength());
+ DCHECK(value.isLength() || value.isPercentage());
+ if (value.isPercentage())
+ return new CSSSimpleLength(value.getDoubleValue(), CSSPrimitiveValue::UnitType::Percentage);
return new CSSSimpleLength(value.getDoubleValue(), value.typeWithCalcResolved());
}
@@ -32,6 +34,13 @@ bool CSSSimpleLength::containsPercent() const
return lengthUnit() == CSSPrimitiveValue::UnitType::Percentage;
}
+String CSSSimpleLength::unit() const
+{
+ if (lengthUnit() == CSSPrimitiveValue::UnitType::Percentage)
+ return "percent";
+ return CSSPrimitiveValue::unitTypeToString(m_unit);
+}
+
CSSLengthValue* CSSSimpleLength::addInternal(const CSSLengthValue* other)
{
const CSSSimpleLength* o = toCSSSimpleLength(other);

Powered by Google App Engine
This is Rietveld 408576698