summaryrefslogtreecommitdiff
path: root/Source/WebCore/css/CSSCalculationValue.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-03-12 14:11:15 +0100
committerSimon Hausmann <simon.hausmann@nokia.com>2012-03-12 14:11:15 +0100
commitdd91e772430dc294e3bf478c119ef8d43c0a3358 (patch)
tree6f33ce4d5872a5691e0291eb45bf6ab373a5f567 /Source/WebCore/css/CSSCalculationValue.cpp
parentad0d549d4cc13433f77c1ac8f0ab379c83d93f28 (diff)
downloadqtwebkit-dd91e772430dc294e3bf478c119ef8d43c0a3358.tar.gz
Imported WebKit commit 3db4eb1820ac8fb03065d7ea73a4d9db1e8fea1a (http://svn.webkit.org/repository/webkit/trunk@110422)
This includes build fixes for the latest qtbase/qtdeclarative as well as the final QML2 API.
Diffstat (limited to 'Source/WebCore/css/CSSCalculationValue.cpp')
-rwxr-xr-xSource/WebCore/css/CSSCalculationValue.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/Source/WebCore/css/CSSCalculationValue.cpp b/Source/WebCore/css/CSSCalculationValue.cpp
index 87fa73782..7828c6542 100755
--- a/Source/WebCore/css/CSSCalculationValue.cpp
+++ b/Source/WebCore/css/CSSCalculationValue.cpp
@@ -114,6 +114,25 @@ public:
return m_value->cssText();
}
+ virtual PassOwnPtr<CalcExpressionNode> toCalcValue(RenderStyle* style, RenderStyle* rootStyle, double zoom) const
+ {
+ switch (m_category) {
+ case CalcNumber:
+ return adoptPtr(new CalcExpressionNumber(m_value->getFloatValue()));
+ case CalcLength:
+ return adoptPtr(new CalcExpressionNumber(m_value->computeLength<float>(style, rootStyle, zoom)));
+ case CalcPercent:
+ case CalcPercentLength:
+ return adoptPtr(new CalcExpressionLength(CSSStyleSelector::convertToFloatLength(m_value.get(), style, rootStyle, zoom)));
+ // Only types that could be part of a Length expression can be converted
+ // to a CalcExpressionNode. CalcPercentNumber makes no sense as a Length.
+ case CalcPercentNumber:
+ case CalcOther:
+ ASSERT_NOT_REACHED();
+ }
+ return nullptr;
+ }
+
virtual double doubleValue() const
{
switch (m_category) {
@@ -208,6 +227,17 @@ public:
return !doubleValue();
}
+ virtual PassOwnPtr<CalcExpressionNode> toCalcValue(RenderStyle* style, RenderStyle* rootStyle, double zoom) const
+ {
+ OwnPtr<CalcExpressionNode> left(m_leftSide->toCalcValue(style, rootStyle, zoom));
+ if (!left)
+ return nullptr;
+ OwnPtr<CalcExpressionNode> right(m_rightSide->toCalcValue(style, rootStyle, zoom));
+ if (!right)
+ return nullptr;
+ return adoptPtr(new CalcExpressionBinaryOperation(left.release(), right.release(), m_operator));
+ }
+
virtual double doubleValue() const
{
return evaluate(m_leftSide->doubleValue(), m_rightSide->doubleValue());