OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/css/parser/SizesCalcParser.h" | 5 #include "core/css/parser/SizesCalcParser.h" |
6 | 6 |
7 #include "core/css/MediaValues.h" | 7 #include "core/css/MediaValues.h" |
8 #include "core/css/parser/CSSParserToken.h" | 8 #include "core/css/parser/CSSParserToken.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
11 | 11 |
12 SizesCalcParser::SizesCalcParser(CSSParserTokenRange range, | 12 SizesCalcParser::SizesCalcParser(CSSParserTokenRange range, |
13 MediaValues* mediaValues) | 13 MediaValues* mediaValues) |
14 : m_mediaValues(mediaValues), m_result(0) { | 14 : m_mediaValues(mediaValues), m_result(0) { |
15 m_isValid = calcToReversePolishNotation(range) && calculate(); | 15 m_isValid = calcToReversePolishNotation(range) && calculate(); |
16 } | 16 } |
17 | 17 |
18 float SizesCalcParser::result() const { | 18 float SizesCalcParser::result() const { |
19 ASSERT(m_isValid); | 19 DCHECK(m_isValid); |
20 return m_result; | 20 return m_result; |
21 } | 21 } |
22 | 22 |
23 static bool operatorPriority(UChar cc, bool& highPriority) { | 23 static bool operatorPriority(UChar cc, bool& highPriority) { |
24 if (cc == '+' || cc == '-') | 24 if (cc == '+' || cc == '-') |
25 highPriority = false; | 25 highPriority = false; |
26 else if (cc == '*' || cc == '/') | 26 else if (cc == '*' || cc == '/') |
27 highPriority = true; | 27 highPriority = true; |
28 else | 28 else |
29 return false; | 29 return false; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 if (stack.isEmpty()) | 123 if (stack.isEmpty()) |
124 return false; | 124 return false; |
125 // Pop the left parenthesis from the stack, but not onto the output | 125 // Pop the left parenthesis from the stack, but not onto the output |
126 // queue. | 126 // queue. |
127 stack.pop_back(); | 127 stack.pop_back(); |
128 break; | 128 break; |
129 case WhitespaceToken: | 129 case WhitespaceToken: |
130 case EOFToken: | 130 case EOFToken: |
131 break; | 131 break; |
132 case CommentToken: | 132 case CommentToken: |
133 ASSERT_NOT_REACHED(); | 133 NOTREACHED(); |
134 case CDOToken: | 134 case CDOToken: |
135 case CDCToken: | 135 case CDCToken: |
136 case AtKeywordToken: | 136 case AtKeywordToken: |
137 case HashToken: | 137 case HashToken: |
138 case UrlToken: | 138 case UrlToken: |
139 case BadUrlToken: | 139 case BadUrlToken: |
140 case PercentageToken: | 140 case PercentageToken: |
141 case IncludeMatchToken: | 141 case IncludeMatchToken: |
142 case DashMatchToken: | 142 case DashMatchToken: |
143 case PrefixMatchToken: | 143 case PrefixMatchToken: |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 } | 227 } |
228 } | 228 } |
229 if (stack.size() == 1 && stack.back().isLength) { | 229 if (stack.size() == 1 && stack.back().isLength) { |
230 m_result = std::max(clampTo<float>(stack.back().value), (float)0.0); | 230 m_result = std::max(clampTo<float>(stack.back().value), (float)0.0); |
231 return true; | 231 return true; |
232 } | 232 } |
233 return false; | 233 return false; |
234 } | 234 } |
235 | 235 |
236 } // namespace blink | 236 } // namespace blink |
OLD | NEW |