Chromium Code Reviews| 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..1391fd5376dab25085b892f37458b2c9ed7b87ff 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(); |
|
esprehn
2014/08/01 14:06:44
m_isValid = calcToReversePolishNotation(start, end
|
| +} |
| + |
| +unsigned SizesCalcParser::result() const |
| +{ |
| + 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; |