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 "config.h" | 5 #include "config.h" |
6 #include "SizesAttributeParser.h" | 6 #include "SizesAttributeParser.h" |
7 | 7 |
8 #include "MediaTypeNames.h" | 8 #include "MediaTypeNames.h" |
9 #include "core/css/MediaQueryEvaluator.h" | 9 #include "core/css/MediaQueryEvaluator.h" |
10 #include "core/css/parser/MediaQueryTokenizer.h" | 10 #include "core/css/parser/MediaQueryTokenizer.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } else if (token->blockType() == MediaQueryToken::BlockStart) { | 65 } else if (token->blockType() == MediaQueryToken::BlockStart) { |
66 --blockLevel; | 66 --blockLevel; |
67 if (!blockLevel) | 67 if (!blockLevel) |
68 break; | 68 break; |
69 } | 69 } |
70 | 70 |
71 --token; | 71 --token; |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
75 bool SizesAttributeParser::mediaConditionMatches(PassRefPtr<MediaQuerySet> media
Condition) | 75 bool SizesAttributeParser::mediaConditionMatches(PassRefPtrWillBeRawPtr<MediaQue
rySet> mediaCondition) |
76 { | 76 { |
77 // FIXME: How do I handle non-screen media types here? | 77 // FIXME: How do I handle non-screen media types here? |
78 MediaQueryEvaluator mediaQueryEvaluator(MediaTypeNames::screen, *m_mediaValu
es); | 78 MediaQueryEvaluator mediaQueryEvaluator(MediaTypeNames::screen, *m_mediaValu
es); |
79 return mediaQueryEvaluator.eval(mediaCondition.get()); | 79 return mediaQueryEvaluator.eval(mediaCondition.get()); |
80 } | 80 } |
81 | 81 |
82 bool SizesAttributeParser::parseMediaConditionAndLength(TokenIterator startToken
, TokenIterator endToken) | 82 bool SizesAttributeParser::parseMediaConditionAndLength(TokenIterator startToken
, TokenIterator endToken) |
83 { | 83 { |
84 TokenIterator lengthTokenStart; | 84 TokenIterator lengthTokenStart; |
85 TokenIterator lengthTokenEnd; | 85 TokenIterator lengthTokenEnd; |
86 | 86 |
87 reverseSkipIrrelevantTokens(endToken, startToken); | 87 reverseSkipIrrelevantTokens(endToken, startToken); |
88 lengthTokenEnd = endToken; | 88 lengthTokenEnd = endToken; |
89 reverseSkipUntilComponentStart(endToken, startToken); | 89 reverseSkipUntilComponentStart(endToken, startToken); |
90 lengthTokenStart = endToken; | 90 lengthTokenStart = endToken; |
91 unsigned length; | 91 unsigned length; |
92 if (!calculateLengthInPixels(lengthTokenStart, lengthTokenEnd, length)) | 92 if (!calculateLengthInPixels(lengthTokenStart, lengthTokenEnd, length)) |
93 return false; | 93 return false; |
94 RefPtr<MediaQuerySet> mediaCondition = MediaQueryParser::parseMediaCondition
(startToken, endToken); | 94 RefPtrWillBeRawPtr<MediaQuerySet> mediaCondition = MediaQueryParser::parseMe
diaCondition(startToken, endToken); |
95 if (mediaCondition && mediaConditionMatches(mediaCondition)) { | 95 if (mediaCondition && mediaConditionMatches(mediaCondition)) { |
96 m_length = length; | 96 m_length = length; |
97 return true; | 97 return true; |
98 } | 98 } |
99 return false; | 99 return false; |
100 } | 100 } |
101 | 101 |
102 bool SizesAttributeParser::parse(Vector<MediaQueryToken>& tokens) | 102 bool SizesAttributeParser::parse(Vector<MediaQueryToken>& tokens) |
103 { | 103 { |
104 TokenIterator startToken = tokens.begin(); | 104 TokenIterator startToken = tokens.begin(); |
(...skipping 20 matching lines...) Expand all Loading... |
125 } | 125 } |
126 | 126 |
127 unsigned SizesAttributeParser::effectiveSizeDefaultValue() | 127 unsigned SizesAttributeParser::effectiveSizeDefaultValue() |
128 { | 128 { |
129 // Returning the equivalent of "100%" | 129 // Returning the equivalent of "100%" |
130 return m_mediaValues->viewportWidth(); | 130 return m_mediaValues->viewportWidth(); |
131 } | 131 } |
132 | 132 |
133 } // namespace | 133 } // namespace |
134 | 134 |
OLD | NEW |