| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/ | 3 * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/ |
| 4 * Copyright (C) 2010 Google Inc. All Rights Reserved. | 4 * Copyright (C) 2010 Google Inc. All Rights Reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 , m_matchedMediaAttribute(true) | 109 , m_matchedMediaAttribute(true) |
| 110 , m_inputIsImage(false) | 110 , m_inputIsImage(false) |
| 111 , m_sourceSize(0) | 111 , m_sourceSize(0) |
| 112 , m_sourceSizeSet(false) | 112 , m_sourceSizeSet(false) |
| 113 , m_isCORSEnabled(false) | 113 , m_isCORSEnabled(false) |
| 114 , m_allowCredentials(DoNotAllowStoredCredentials) | 114 , m_allowCredentials(DoNotAllowStoredCredentials) |
| 115 , m_mediaValues(mediaValues) | 115 , m_mediaValues(mediaValues) |
| 116 { | 116 { |
| 117 if (match(m_tagImpl, imgTag) | 117 if (match(m_tagImpl, imgTag) |
| 118 || match(m_tagImpl, sourceTag)) { | 118 || match(m_tagImpl, sourceTag)) { |
| 119 if (RuntimeEnabledFeatures::pictureSizesEnabled()) | 119 if (RuntimeEnabledFeatures::pictureSizesEnabled()) { |
| 120 m_sourceSize = SizesAttributeParser::findEffectiveSize(String(),
m_mediaValues); | 120 SizesAttributeParser parser = SizesAttributeParser(m_mediaValues
, String()); |
| 121 m_sourceSize = parser.length(); |
| 122 } |
| 121 return; | 123 return; |
| 122 } | 124 } |
| 123 if ( !match(m_tagImpl, inputTag) | 125 if ( !match(m_tagImpl, inputTag) |
| 124 && !match(m_tagImpl, linkTag) | 126 && !match(m_tagImpl, linkTag) |
| 125 && !match(m_tagImpl, scriptTag)) | 127 && !match(m_tagImpl, scriptTag)) |
| 126 m_tagImpl = 0; | 128 m_tagImpl = 0; |
| 127 } | 129 } |
| 128 | 130 |
| 129 enum URLReplacement { | 131 enum URLReplacement { |
| 130 AllowURLReplacement, | 132 AllowURLReplacement, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 if (match(attributeName, srcAttr) && m_imgSrcUrl.isNull()) { | 192 if (match(attributeName, srcAttr) && m_imgSrcUrl.isNull()) { |
| 191 m_imgSrcUrl = attributeValue; | 193 m_imgSrcUrl = attributeValue; |
| 192 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devicePi
xelRatio(), m_sourceSize, attributeValue, m_srcsetImageCandidate), AllowURLRepla
cement); | 194 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devicePi
xelRatio(), m_sourceSize, attributeValue, m_srcsetImageCandidate), AllowURLRepla
cement); |
| 193 } else if (match(attributeName, crossoriginAttr)) { | 195 } else if (match(attributeName, crossoriginAttr)) { |
| 194 setCrossOriginAllowed(attributeValue); | 196 setCrossOriginAllowed(attributeValue); |
| 195 } else if (match(attributeName, srcsetAttr) && m_srcsetImageCandidate.is
Empty()) { | 197 } else if (match(attributeName, srcsetAttr) && m_srcsetImageCandidate.is
Empty()) { |
| 196 m_srcsetAttributeValue = attributeValue; | 198 m_srcsetAttributeValue = attributeValue; |
| 197 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_mediaValu
es->devicePixelRatio(), m_sourceSize, attributeValue); | 199 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_mediaValu
es->devicePixelRatio(), m_sourceSize, attributeValue); |
| 198 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devicePi
xelRatio(), m_sourceSize, m_imgSrcUrl, m_srcsetImageCandidate), AllowURLReplacem
ent); | 200 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devicePi
xelRatio(), m_sourceSize, m_imgSrcUrl, m_srcsetImageCandidate), AllowURLReplacem
ent); |
| 199 } else if (RuntimeEnabledFeatures::pictureSizesEnabled() && match(attrib
uteName, sizesAttr) && !m_sourceSizeSet) { | 201 } else if (RuntimeEnabledFeatures::pictureSizesEnabled() && match(attrib
uteName, sizesAttr) && !m_sourceSizeSet) { |
| 200 m_sourceSize = SizesAttributeParser::findEffectiveSize(attributeValu
e, m_mediaValues); | 202 SizesAttributeParser parser = SizesAttributeParser(m_mediaValues, at
tributeValue); |
| 203 m_sourceSize = parser.length(); |
| 201 m_sourceSizeSet = true; | 204 m_sourceSizeSet = true; |
| 202 if (!m_srcsetImageCandidate.isEmpty()) { | 205 if (!m_srcsetImageCandidate.isEmpty()) { |
| 203 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_media
Values->devicePixelRatio(), m_sourceSize, m_srcsetAttributeValue); | 206 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_media
Values->devicePixelRatio(), m_sourceSize, m_srcsetAttributeValue); |
| 204 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devi
cePixelRatio(), m_sourceSize, m_imgSrcUrl, m_srcsetImageCandidate), AllowURLRepl
acement); | 207 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devi
cePixelRatio(), m_sourceSize, m_imgSrcUrl, m_srcsetImageCandidate), AllowURLRepl
acement); |
| 205 } | 208 } |
| 206 } | 209 } |
| 207 } | 210 } |
| 208 | 211 |
| 209 template<typename NameType> | 212 template<typename NameType> |
| 210 void processLinkAttribute(const NameType& attributeName, const String& attri
buteValue) | 213 void processLinkAttribute(const NameType& attributeName, const String& attri
buteValue) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 232 | 235 |
| 233 template<typename NameType> | 236 template<typename NameType> |
| 234 void processSourceAttribute(const NameType& attributeName, const String& att
ributeValue) | 237 void processSourceAttribute(const NameType& attributeName, const String& att
ributeValue) |
| 235 { | 238 { |
| 236 if (!RuntimeEnabledFeatures::pictureEnabled()) | 239 if (!RuntimeEnabledFeatures::pictureEnabled()) |
| 237 return; | 240 return; |
| 238 if (match(attributeName, srcsetAttr) && m_srcsetImageCandidate.isEmpty()
) { | 241 if (match(attributeName, srcsetAttr) && m_srcsetImageCandidate.isEmpty()
) { |
| 239 m_srcsetAttributeValue = attributeValue; | 242 m_srcsetAttributeValue = attributeValue; |
| 240 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_mediaValu
es->devicePixelRatio(), m_sourceSize, attributeValue); | 243 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_mediaValu
es->devicePixelRatio(), m_sourceSize, attributeValue); |
| 241 } else if (match(attributeName, sizesAttr) && !m_sourceSizeSet) { | 244 } else if (match(attributeName, sizesAttr) && !m_sourceSizeSet) { |
| 242 m_sourceSize = SizesAttributeParser::findEffectiveSize(attributeValu
e, m_mediaValues); | 245 SizesAttributeParser parser = SizesAttributeParser(m_mediaValues, at
tributeValue); |
| 246 m_sourceSize = parser.length(); |
| 243 m_sourceSizeSet = true; | 247 m_sourceSizeSet = true; |
| 244 if (!m_srcsetImageCandidate.isEmpty()) { | 248 if (!m_srcsetImageCandidate.isEmpty()) { |
| 245 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_media
Values->devicePixelRatio(), m_sourceSize, m_srcsetAttributeValue); | 249 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_media
Values->devicePixelRatio(), m_sourceSize, m_srcsetAttributeValue); |
| 246 } | 250 } |
| 247 } else if (match(attributeName, mediaAttr)) { | 251 } else if (match(attributeName, mediaAttr)) { |
| 248 // FIXME - Don't match media multiple times. | 252 // FIXME - Don't match media multiple times. |
| 249 m_matchedMediaAttribute = mediaAttributeMatches(*m_mediaValues, attr
ibuteValue); | 253 m_matchedMediaAttribute = mediaAttributeMatches(*m_mediaValues, attr
ibuteValue); |
| 250 } | 254 } |
| 251 | 255 |
| 252 } | 256 } |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 if (m_token.type() == HTMLToken::StartTag) | 504 if (m_token.type() == HTMLToken::StartTag) |
| 501 m_tokenizer->updateStateFor(attemptStaticStringCreation(m_token.name
(), Likely8Bit)); | 505 m_tokenizer->updateStateFor(attemptStaticStringCreation(m_token.name
(), Likely8Bit)); |
| 502 m_scanner.scan(m_token, m_source, requests); | 506 m_scanner.scan(m_token, m_source, requests); |
| 503 m_token.clear(); | 507 m_token.clear(); |
| 504 } | 508 } |
| 505 | 509 |
| 506 preloader->takeAndPreload(requests); | 510 preloader->takeAndPreload(requests); |
| 507 } | 511 } |
| 508 | 512 |
| 509 } | 513 } |
| OLD | NEW |