summaryrefslogtreecommitdiff
path: root/Source/WebCore/css/CSSCalculationValue.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2013-09-13 12:51:20 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-19 20:50:05 +0200
commitd441d6f39bb846989d95bcf5caf387b42414718d (patch)
treee367e64a75991c554930278175d403c072de6bb8 /Source/WebCore/css/CSSCalculationValue.cpp
parent0060b2994c07842f4c59de64b5e3e430525c4b90 (diff)
downloadqtwebkit-d441d6f39bb846989d95bcf5caf387b42414718d.tar.gz
Import Qt5x2 branch of QtWebkit for Qt 5.2
Importing a new snapshot of webkit. Change-Id: I2d01ad12cdc8af8cb015387641120a9d7ea5f10c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Source/WebCore/css/CSSCalculationValue.cpp')
-rw-r--r--Source/WebCore/css/CSSCalculationValue.cpp62
1 files changed, 36 insertions, 26 deletions
diff --git a/Source/WebCore/css/CSSCalculationValue.cpp b/Source/WebCore/css/CSSCalculationValue.cpp
index 1c158cc2c..dca177991 100644
--- a/Source/WebCore/css/CSSCalculationValue.cpp
+++ b/Source/WebCore/css/CSSCalculationValue.cpp
@@ -34,7 +34,6 @@
#include "CSSValueList.h"
#include "Length.h"
#include "StyleResolver.h"
-#include "WebCoreMemoryInstrumentation.h"
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
@@ -67,6 +66,7 @@ static CalculationCategory unitCategory(CSSPrimitiveValue::UnitTypes type)
case CSSPrimitiveValue::CSS_PT:
case CSSPrimitiveValue::CSS_PC:
case CSSPrimitiveValue::CSS_REMS:
+ case CSSPrimitiveValue::CSS_CHS:
return CalcLength;
#if ENABLE(CSS_VARIABLES)
case CSSPrimitiveValue::CSS_VARIABLE_NAME:
@@ -80,7 +80,7 @@ static CalculationCategory unitCategory(CSSPrimitiveValue::UnitTypes type)
static String buildCssText(const String& expression)
{
StringBuilder result;
- result.append("-webkit-calc");
+ result.append("calc");
bool expressionHasSingleTerm = expression[0] != '(';
if (expressionHasSingleTerm)
result.append('(');
@@ -95,6 +95,11 @@ String CSSCalcValue::customCssText() const
return buildCssText(m_expression->customCssText());
}
+bool CSSCalcValue::equals(const CSSCalcValue& other) const
+{
+ return compareCSSValuePtr(m_expression, other.m_expression);
+}
+
#if ENABLE(CSS_VARIABLES)
String CSSCalcValue::customSerializeResolvingVariables(const HashMap<AtomicString, String>& variables) const
{
@@ -107,11 +112,6 @@ bool CSSCalcValue::hasVariableReference() const
}
#endif
-void CSSCalcValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
-{
- MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
-}
-
double CSSCalcValue::clampToPermittedRange(double value) const
{
return m_nonNegative && value < 0 ? 0 : value;
@@ -122,7 +122,7 @@ double CSSCalcValue::doubleValue() const
return clampToPermittedRange(m_expression->doubleValue());
}
-double CSSCalcValue::computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
+double CSSCalcValue::computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
{
return clampToPermittedRange(m_expression->computeLengthPx(currentStyle, rootStyle, multiplier, computingFontSize));
}
@@ -162,7 +162,7 @@ public:
}
#endif
- virtual PassOwnPtr<CalcExpressionNode> toCalcValue(RenderStyle* style, RenderStyle* rootStyle, double zoom) const
+ virtual PassOwnPtr<CalcExpressionNode> toCalcValue(const RenderStyle* style, const RenderStyle* rootStyle, double zoom) const
{
switch (m_category) {
case CalcNumber:
@@ -203,7 +203,7 @@ public:
return 0;
}
- virtual double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
+ virtual double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
{
switch (m_category) {
case CalcLength:
@@ -223,11 +223,15 @@ public:
return 0;
}
- virtual void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const OVERRIDE
+ virtual bool equals(const CSSCalcExpressionNode& other) const
{
- MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
- info.addMember(m_value);
+ if (type() != other.type())
+ return false;
+
+ return compareCSSValuePtr(m_value, static_cast<const CSSCalcPrimitiveValue&>(other).m_value);
}
+
+ virtual Type type() const { return CssCalcPrimitiveValue; }
private:
explicit CSSCalcPrimitiveValue(CSSPrimitiveValue* value, bool isInteger)
@@ -298,7 +302,7 @@ public:
return !doubleValue();
}
- virtual PassOwnPtr<CalcExpressionNode> toCalcValue(RenderStyle* style, RenderStyle* rootStyle, double zoom) const
+ virtual PassOwnPtr<CalcExpressionNode> toCalcValue(const RenderStyle* style, const RenderStyle* rootStyle, double zoom) const
{
OwnPtr<CalcExpressionNode> left(m_leftSide->toCalcValue(style, rootStyle, zoom));
if (!left)
@@ -314,20 +318,13 @@ public:
return evaluate(m_leftSide->doubleValue(), m_rightSide->doubleValue());
}
- virtual double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
+ virtual double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
{
const double leftValue = m_leftSide->computeLengthPx(currentStyle, rootStyle, multiplier, computingFontSize);
const double rightValue = m_rightSide->computeLengthPx(currentStyle, rootStyle, multiplier, computingFontSize);
return evaluate(leftValue, rightValue);
}
- virtual void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const OVERRIDE
- {
- MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
- info.addMember(m_leftSide);
- info.addMember(m_rightSide);
- }
-
static String buildCssText(const String& leftExpression, const String& rightExpression, CalcOperator op)
{
StringBuilder result;
@@ -359,6 +356,19 @@ public:
}
#endif
+ virtual bool equals(const CSSCalcExpressionNode& exp) const
+ {
+ if (type() != exp.type())
+ return false;
+
+ const CSSCalcBinaryOperation& other = static_cast<const CSSCalcBinaryOperation&>(exp);
+ return compareCSSValuePtr(m_leftSide, other.m_leftSide)
+ && compareCSSValuePtr(m_rightSide, other.m_rightSide)
+ && m_operator == other.m_operator;
+ }
+
+ virtual Type type() const { return CssCalcBinaryOperation; }
+
private:
CSSCalcBinaryOperation(PassRefPtr<CSSCalcExpressionNode> leftSide, PassRefPtr<CSSCalcExpressionNode> rightSide, CalcOperator op, CalculationCategory category)
: CSSCalcExpressionNode(category, leftSide->isInteger() && rightSide->isInteger())
@@ -407,7 +417,7 @@ public:
unsigned index = 0;
Value result;
bool ok = parseValueExpression(tokens, 0, &index, &result);
- ASSERT(index <= tokens->size());
+ ASSERT_WITH_SECURITY_IMPLICATION(index <= tokens->size());
if (!ok || index != tokens->size())
return 0;
return result.value;
@@ -488,7 +498,7 @@ private:
return false;
}
- ASSERT(*index <= tokens->size());
+ ASSERT_WITH_SECURITY_IMPLICATION(*index <= tokens->size());
return true;
}
@@ -515,7 +525,7 @@ private:
return false;
}
- ASSERT(*index <= tokens->size());
+ ASSERT_WITH_SECURITY_IMPLICATION(*index <= tokens->size());
return true;
}
@@ -530,7 +540,7 @@ PassRefPtr<CSSCalcValue> CSSCalcValue::create(CSSParserString name, CSSParserVal
CSSCalcExpressionNodeParser parser;
RefPtr<CSSCalcExpressionNode> expression;
- if (equalIgnoringCase(name, "-webkit-calc("))
+ if (equalIgnoringCase(name, "calc(") || equalIgnoringCase(name, "-webkit-calc("))
expression = parser.parseCalc(parserValueList);
// FIXME calc (http://webkit.org/b/16662) Add parsing for min and max here