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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 m_sourceSize = SizesAttributeParser(m_mediaValues, String()).len
gth(); |
121 return; | 121 return; |
122 } | 122 } |
123 if ( !match(m_tagImpl, inputTag) | 123 if ( !match(m_tagImpl, inputTag) |
124 && !match(m_tagImpl, linkTag) | 124 && !match(m_tagImpl, linkTag) |
125 && !match(m_tagImpl, scriptTag)) | 125 && !match(m_tagImpl, scriptTag)) |
126 m_tagImpl = 0; | 126 m_tagImpl = 0; |
127 } | 127 } |
128 | 128 |
129 enum URLReplacement { | 129 enum URLReplacement { |
130 AllowURLReplacement, | 130 AllowURLReplacement, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 if (match(attributeName, srcAttr) && m_imgSrcUrl.isNull()) { | 190 if (match(attributeName, srcAttr) && m_imgSrcUrl.isNull()) { |
191 m_imgSrcUrl = attributeValue; | 191 m_imgSrcUrl = attributeValue; |
192 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devicePi
xelRatio(), m_sourceSize, attributeValue, m_srcsetImageCandidate), AllowURLRepla
cement); | 192 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devicePi
xelRatio(), m_sourceSize, attributeValue, m_srcsetImageCandidate), AllowURLRepla
cement); |
193 } else if (match(attributeName, crossoriginAttr)) { | 193 } else if (match(attributeName, crossoriginAttr)) { |
194 setCrossOriginAllowed(attributeValue); | 194 setCrossOriginAllowed(attributeValue); |
195 } else if (match(attributeName, srcsetAttr) && m_srcsetImageCandidate.is
Empty()) { | 195 } else if (match(attributeName, srcsetAttr) && m_srcsetImageCandidate.is
Empty()) { |
196 m_srcsetAttributeValue = attributeValue; | 196 m_srcsetAttributeValue = attributeValue; |
197 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_mediaValu
es->devicePixelRatio(), m_sourceSize, attributeValue); | 197 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); | 198 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) { | 199 } else if (RuntimeEnabledFeatures::pictureSizesEnabled() && match(attrib
uteName, sizesAttr) && !m_sourceSizeSet) { |
200 m_sourceSize = SizesAttributeParser::findEffectiveSize(attributeValu
e, m_mediaValues); | 200 m_sourceSize = SizesAttributeParser(m_mediaValues, attributeValue).l
ength(); |
201 m_sourceSizeSet = true; | 201 m_sourceSizeSet = true; |
202 if (!m_srcsetImageCandidate.isEmpty()) { | 202 if (!m_srcsetImageCandidate.isEmpty()) { |
203 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_media
Values->devicePixelRatio(), m_sourceSize, m_srcsetAttributeValue); | 203 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); | 204 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devi
cePixelRatio(), m_sourceSize, m_imgSrcUrl, m_srcsetImageCandidate), AllowURLRepl
acement); |
205 } | 205 } |
206 } | 206 } |
207 } | 207 } |
208 | 208 |
209 template<typename NameType> | 209 template<typename NameType> |
210 void processLinkAttribute(const NameType& attributeName, const String& attri
buteValue) | 210 void processLinkAttribute(const NameType& attributeName, const String& attri
buteValue) |
(...skipping 21 matching lines...) Expand all Loading... |
232 | 232 |
233 template<typename NameType> | 233 template<typename NameType> |
234 void processSourceAttribute(const NameType& attributeName, const String& att
ributeValue) | 234 void processSourceAttribute(const NameType& attributeName, const String& att
ributeValue) |
235 { | 235 { |
236 if (!RuntimeEnabledFeatures::pictureEnabled()) | 236 if (!RuntimeEnabledFeatures::pictureEnabled()) |
237 return; | 237 return; |
238 if (match(attributeName, srcsetAttr) && m_srcsetImageCandidate.isEmpty()
) { | 238 if (match(attributeName, srcsetAttr) && m_srcsetImageCandidate.isEmpty()
) { |
239 m_srcsetAttributeValue = attributeValue; | 239 m_srcsetAttributeValue = attributeValue; |
240 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_mediaValu
es->devicePixelRatio(), m_sourceSize, attributeValue); | 240 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_mediaValu
es->devicePixelRatio(), m_sourceSize, attributeValue); |
241 } else if (match(attributeName, sizesAttr) && !m_sourceSizeSet) { | 241 } else if (match(attributeName, sizesAttr) && !m_sourceSizeSet) { |
242 m_sourceSize = SizesAttributeParser::findEffectiveSize(attributeValu
e, m_mediaValues); | 242 m_sourceSize = SizesAttributeParser(m_mediaValues, attributeValue).l
ength(); |
243 m_sourceSizeSet = true; | 243 m_sourceSizeSet = true; |
244 if (!m_srcsetImageCandidate.isEmpty()) { | 244 if (!m_srcsetImageCandidate.isEmpty()) { |
245 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_media
Values->devicePixelRatio(), m_sourceSize, m_srcsetAttributeValue); | 245 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_media
Values->devicePixelRatio(), m_sourceSize, m_srcsetAttributeValue); |
246 } | 246 } |
247 } else if (match(attributeName, mediaAttr)) { | 247 } else if (match(attributeName, mediaAttr)) { |
248 // FIXME - Don't match media multiple times. | 248 // FIXME - Don't match media multiple times. |
249 m_matchedMediaAttribute = mediaAttributeMatches(*m_mediaValues, attr
ibuteValue); | 249 m_matchedMediaAttribute = mediaAttributeMatches(*m_mediaValues, attr
ibuteValue); |
250 } | 250 } |
251 | 251 |
252 } | 252 } |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 if (m_token.type() == HTMLToken::StartTag) | 500 if (m_token.type() == HTMLToken::StartTag) |
501 m_tokenizer->updateStateFor(attemptStaticStringCreation(m_token.name
(), Likely8Bit)); | 501 m_tokenizer->updateStateFor(attemptStaticStringCreation(m_token.name
(), Likely8Bit)); |
502 m_scanner.scan(m_token, m_source, requests); | 502 m_scanner.scan(m_token, m_source, requests); |
503 m_token.clear(); | 503 m_token.clear(); |
504 } | 504 } |
505 | 505 |
506 preloader->takeAndPreload(requests); | 506 preloader->takeAndPreload(requests); |
507 } | 507 } |
508 | 508 |
509 } | 509 } |
OLD | NEW |