Index: Source/core/css/parser/SizesCalcParser.cpp |
diff --git a/Source/core/css/parser/SizesCalcParser.cpp b/Source/core/css/parser/SizesCalcParser.cpp |
index 31ace70f751e6e737cc4aa96857db34e9927476f..f008e9dfe011a29e66400a3ee44dfe0fe8a76869 100644 |
--- a/Source/core/css/parser/SizesCalcParser.cpp |
+++ b/Source/core/css/parser/SizesCalcParser.cpp |
@@ -10,12 +10,20 @@ |
namespace blink { |
-bool SizesCalcParser::parse(MediaQueryTokenIterator start, MediaQueryTokenIterator end, PassRefPtr<MediaValues> mediaValues, unsigned& result) |
+SizesCalcParser::SizesCalcParser(MediaQueryTokenIterator start, MediaQueryTokenIterator end, PassRefPtr<MediaValues> mediaValues) |
+ : m_mediaValues(mediaValues) |
+ , m_viewportDependant(false) |
+ , m_result(0) |
{ |
- SizesCalcParser parser(mediaValues); |
- if (!parser.calcToReversePolishNotation(start, end)) |
- return false; |
- return parser.calculate(result); |
+ m_isValid = calcToReversePolishNotation(start, end); |
+ if (m_isValid) |
+ m_isValid = calculate(); |
+} |
+ |
+unsigned SizesCalcParser::result() |
+{ |
+ ASSERT(m_isValid); |
+ return m_result; |
} |
static bool operatorPriority(UChar cc, bool& highPriority) |
@@ -93,6 +101,7 @@ bool SizesCalcParser::calcToReversePolishNotation(MediaQueryTokenIterator start, |
appendNumber(*it); |
break; |
case DimensionToken: |
+ m_viewportDependant = m_viewportDependant || CSSPrimitiveValue::isViewportPercentageLength(it->unitType()); |
if (!CSSPrimitiveValue::isLength(it->unitType()) || !appendLength(*it)) |
return false; |
break; |
@@ -193,7 +202,7 @@ static bool operateOnStack(Vector<SizesCalcValue>& stack, UChar operation) |
return true; |
} |
-bool SizesCalcParser::calculate(unsigned& result) |
+bool SizesCalcParser::calculate() |
{ |
Vector<SizesCalcValue> stack; |
for (Vector<SizesCalcValue>::iterator it = m_valueList.begin(); it != m_valueList.end(); ++it) { |
@@ -205,7 +214,7 @@ bool SizesCalcParser::calculate(unsigned& result) |
} |
} |
if (stack.size() == 1 && stack.last().isLength) { |
- result = clampTo<unsigned>(stack.last().value); |
+ m_result = clampTo<unsigned>(stack.last().value); |
return true; |
} |
return false; |