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

Unified Diff: Source/core/css/CSSPrimitiveValue.cpp

Issue 345903005: calc expressions should support time, angle and frequency values. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated patch Created 6 years, 5 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
« no previous file with comments | « Source/core/css/CSSPrimitiveValue.h ('k') | Source/core/css/parser/CSSPropertyParser.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/CSSPrimitiveValue.cpp
diff --git a/Source/core/css/CSSPrimitiveValue.cpp b/Source/core/css/CSSPrimitiveValue.cpp
index 6a9138e357af479f852bc40b66fa96d38ac229ab..0705f0745a4da47a8c3819574dde4472ce2e198d 100644
--- a/Source/core/css/CSSPrimitiveValue.cpp
+++ b/Source/core/css/CSSPrimitiveValue.cpp
@@ -143,7 +143,6 @@ StringToUnitTable createStringToUnitTable()
return table;
}
-
CSSPrimitiveValue::UnitType CSSPrimitiveValue::fromName(const String& unit)
{
DEFINE_STATIC_LOCAL(StringToUnitTable, unitTable, (createStringToUnitTable()));
@@ -216,6 +215,10 @@ CSSPrimitiveValue::UnitType CSSPrimitiveValue::primitiveType() const
return static_cast<UnitType>(m_primitiveUnitType);
switch (m_value.calc->category()) {
+ case CalcAngle:
+ return CSS_DEG;
+ case CalcFrequency:
+ return CSS_HZ;
case CalcNumber:
return CSS_NUMBER;
case CalcPercent:
@@ -226,6 +229,8 @@ CSSPrimitiveValue::UnitType CSSPrimitiveValue::primitiveType() const
return CSS_CALC_PERCENTAGE_WITH_NUMBER;
case CalcPercentLength:
return CSS_CALC_PERCENTAGE_WITH_LENGTH;
+ case CalcTime:
+ return CSS_MS;
case CalcOther:
return CSS_UNKNOWN;
}
@@ -535,9 +540,23 @@ void CSSPrimitiveValue::cleanup()
}
}
+double CSSPrimitiveValue::computeSeconds()
+{
+ ASSERT(isTime() || (isCalculated() && cssCalcValue()->category() == CalcTime));
+ UnitType currentType = isCalculated() ? cssCalcValue()->expressionNode()->primitiveType() : static_cast<UnitType>(m_primitiveUnitType);
+ if (currentType == CSS_S)
+ return getDoubleValue();
+ if (currentType == CSS_MS)
+ return getDoubleValue() / 1000;
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
double CSSPrimitiveValue::computeDegrees()
{
- switch (m_primitiveUnitType) {
+ ASSERT(isAngle() || (isCalculated() && cssCalcValue()->category() == CalcAngle));
+ UnitType currentType = isCalculated() ? cssCalcValue()->expressionNode()->primitiveType() : static_cast<UnitType>(m_primitiveUnitType);
+ switch (currentType) {
case CSS_DEG:
return getDoubleValue();
case CSS_RAD:
« no previous file with comments | « Source/core/css/CSSPrimitiveValue.h ('k') | Source/core/css/parser/CSSPropertyParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698