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/SizesAttributeParser.h" | 5 #include "core/css/parser/SizesAttributeParser.h" |
6 | 6 |
7 #include "core/MediaTypeNames.h" | 7 #include "core/MediaTypeNames.h" |
8 #include "core/css/MediaQueryEvaluator.h" | 8 #include "core/css/MediaQueryEvaluator.h" |
9 #include "core/css/parser/CSSTokenizer.h" | 9 #include "core/css/parser/CSSTokenizer.h" |
10 #include "core/css/parser/SizesCalcParser.h" | 10 #include "core/css/parser/SizesCalcParser.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 SizesAttributeParser::SizesAttributeParser(MediaValues* mediaValues, | 14 SizesAttributeParser::SizesAttributeParser(MediaValues* mediaValues, |
15 const String& attribute) | 15 const String& attribute) |
16 : m_mediaValues(mediaValues), m_length(0), m_lengthWasSet(false) { | 16 : m_mediaValues(mediaValues), m_length(0), m_lengthWasSet(false) { |
17 ASSERT(m_mediaValues.get()); | 17 DCHECK(m_mediaValues.get()); |
18 m_isValid = parse(CSSTokenizer(attribute).tokenRange()); | 18 m_isValid = parse(CSSTokenizer(attribute).tokenRange()); |
19 } | 19 } |
20 | 20 |
21 float SizesAttributeParser::length() { | 21 float SizesAttributeParser::length() { |
22 if (m_isValid) | 22 if (m_isValid) |
23 return effectiveSize(); | 23 return effectiveSize(); |
24 return effectiveSizeDefaultValue(); | 24 return effectiveSizeDefaultValue(); |
25 } | 25 } |
26 | 26 |
27 bool SizesAttributeParser::calculateLengthInPixels(CSSParserTokenRange range, | 27 bool SizesAttributeParser::calculateLengthInPixels(CSSParserTokenRange range, |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 return m_length; | 96 return m_length; |
97 return effectiveSizeDefaultValue(); | 97 return effectiveSizeDefaultValue(); |
98 } | 98 } |
99 | 99 |
100 float SizesAttributeParser::effectiveSizeDefaultValue() { | 100 float SizesAttributeParser::effectiveSizeDefaultValue() { |
101 // Returning the equivalent of "100vw" | 101 // Returning the equivalent of "100vw" |
102 return clampTo<float>(m_mediaValues->viewportWidth()); | 102 return clampTo<float>(m_mediaValues->viewportWidth()); |
103 } | 103 } |
104 | 104 |
105 } // namespace blink | 105 } // namespace blink |
OLD | NEW |