Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(540)

Unified Diff: Source/core/css/parser/SizesAttributeParser.cpp

Issue 236713005: Use SizesAttributeParser to get the right srcset resource (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@sizes_parser8
Patch Set: Fixed review comments Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/css/parser/SizesAttributeParser.cpp
diff --git a/Source/core/css/parser/SizesAttributeParser.cpp b/Source/core/css/parser/SizesAttributeParser.cpp
index 4fd32365b7f52f793a534c9e60553c2585ab4ed0..0fd76d3d3c10099f0d15a32098e0dfbea7f6d66e 100644
--- a/Source/core/css/parser/SizesAttributeParser.cpp
+++ b/Source/core/css/parser/SizesAttributeParser.cpp
@@ -27,18 +27,16 @@ bool SizesAttributeParser::calculateLengthInPixels(TokenIterator startToken, Tok
MediaQueryTokenType type = startToken->type();
if (type == DimensionToken) {
int length;
- if (!CSSPrimitiveValue::isLength(startToken->unitType()))
eseidel 2014/04/20 22:06:21 I think this previous early-return based version w
- return false;
- if (m_mediaValues->computeLength(startToken->numericValue(), startToken->unitType(), length)) {
+ if (CSSPrimitiveValue::isLength(startToken->unitType())
+ && m_mediaValues->computeLength(startToken->numericValue(), startToken->unitType(), length)) {
if (length > 0) {
result = (unsigned)length;
return true;
}
}
+ return false;
}
- if (type == FunctionToken) {
- // FIXME - Handle calc() functions here!
- }
+ // FIXME - Handle calc() FunctionToken here!
return false;
}
@@ -101,6 +99,8 @@ bool SizesAttributeParser::parseMediaConditionAndLength(TokenIterator startToken
bool SizesAttributeParser::parse(Vector<MediaQueryToken>& tokens)
{
+ if (tokens.isEmpty())
+ return false;
TokenIterator startToken = tokens.begin();
TokenIterator endToken;
// Split on a comma token, and send the result tokens to be parsed as (media-condition, length) pairs

Powered by Google App Engine
This is Rietveld 408576698