Chromium Code Reviews| 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 17 matching lines...) Expand all Loading... | |
| 28 if (type == DimensionToken) { | 28 if (type == DimensionToken) { |
| 29 int length; | 29 int length; |
| 30 if (!CSSPrimitiveValue::isLength(startToken->unitType())) | 30 if (!CSSPrimitiveValue::isLength(startToken->unitType())) |
| 31 return false; | 31 return false; |
| 32 if (m_mediaValues->computeLength(startToken->numericValue(), startToken- >unitType(), length)) { | 32 if (m_mediaValues->computeLength(startToken->numericValue(), startToken- >unitType(), length)) { |
| 33 if (length > 0) { | 33 if (length > 0) { |
| 34 result = (unsigned)length; | 34 result = (unsigned)length; |
| 35 return true; | 35 return true; |
| 36 } | 36 } |
| 37 } | 37 } |
| 38 } | 38 } else if (type == FunctionToken) { |
|
eseidel
2014/04/20 21:27:43
This change has no effect, but OK. If the earlier
| |
| 39 if (type == FunctionToken) { | |
| 40 // FIXME - Handle calc() functions here! | 39 // FIXME - Handle calc() functions here! |
| 41 } | 40 } |
| 42 return false; | 41 return false; |
| 43 } | 42 } |
| 44 | 43 |
| 45 static void reverseSkipIrrelevantTokens(TokenIterator& token, TokenIterator star tToken) | 44 static void reverseSkipIrrelevantTokens(TokenIterator& token, TokenIterator star tToken) |
| 46 { | 45 { |
| 47 TokenIterator endToken = token; | 46 TokenIterator endToken = token; |
| 48 while (token != startToken && (token->type() == WhitespaceToken || token->ty pe() == CommentToken || token->type() == EOFToken)) | 47 while (token != startToken && (token->type() == WhitespaceToken || token->ty pe() == CommentToken || token->type() == EOFToken)) |
| 49 --token; | 48 --token; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 RefPtrWillBeRawPtr<MediaQuerySet> mediaCondition = MediaQueryParser::parseMe diaCondition(startToken, endToken); | 93 RefPtrWillBeRawPtr<MediaQuerySet> mediaCondition = MediaQueryParser::parseMe diaCondition(startToken, endToken); |
| 95 if (mediaCondition && mediaConditionMatches(mediaCondition)) { | 94 if (mediaCondition && mediaConditionMatches(mediaCondition)) { |
| 96 m_length = length; | 95 m_length = length; |
| 97 return true; | 96 return true; |
| 98 } | 97 } |
| 99 return false; | 98 return false; |
| 100 } | 99 } |
| 101 | 100 |
| 102 bool SizesAttributeParser::parse(Vector<MediaQueryToken>& tokens) | 101 bool SizesAttributeParser::parse(Vector<MediaQueryToken>& tokens) |
| 103 { | 102 { |
| 103 if (tokens.isEmpty()) | |
| 104 return false; | |
| 104 TokenIterator startToken = tokens.begin(); | 105 TokenIterator startToken = tokens.begin(); |
| 105 TokenIterator endToken; | 106 TokenIterator endToken; |
| 106 // Split on a comma token, and send the result tokens to be parsed as (media -condition, length) pairs | 107 // Split on a comma token, and send the result tokens to be parsed as (media -condition, length) pairs |
| 107 for (TokenIterator token = tokens.begin(); token != tokens.end(); ++token) { | 108 for (TokenIterator token = tokens.begin(); token != tokens.end(); ++token) { |
| 108 if (token->type() == CommaToken) { | 109 if (token->type() == CommaToken) { |
| 109 endToken = token; | 110 endToken = token; |
| 110 if (parseMediaConditionAndLength(startToken, endToken)) | 111 if (parseMediaConditionAndLength(startToken, endToken)) |
| 111 return true; | 112 return true; |
| 112 startToken = token; | 113 startToken = token; |
| 113 ++startToken; | 114 ++startToken; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 125 } | 126 } |
| 126 | 127 |
| 127 unsigned SizesAttributeParser::effectiveSizeDefaultValue() | 128 unsigned SizesAttributeParser::effectiveSizeDefaultValue() |
| 128 { | 129 { |
| 129 // Returning the equivalent of "100%" | 130 // Returning the equivalent of "100%" |
| 130 return m_mediaValues->viewportWidth(); | 131 return m_mediaValues->viewportWidth(); |
| 131 } | 132 } |
| 132 | 133 |
| 133 } // namespace | 134 } // namespace |
| 134 | 135 |
| OLD | NEW |