Chromium Code Reviews| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 return mediaQueryEvaluator.eval(mediaQueries.get()); | 101 return mediaQueryEvaluator.eval(mediaQueries.get()); |
| 102 } | 102 } |
| 103 | 103 |
| 104 class TokenPreloadScanner::StartTagScanner { | 104 class TokenPreloadScanner::StartTagScanner { |
| 105 public: | 105 public: |
| 106 StartTagScanner(const StringImpl* tagImpl, PassRefPtr<MediaValues> mediaValu es) | 106 StartTagScanner(const StringImpl* tagImpl, PassRefPtr<MediaValues> mediaValu es) |
| 107 : m_tagImpl(tagImpl) | 107 : m_tagImpl(tagImpl) |
| 108 , m_linkIsStyleSheet(false) | 108 , m_linkIsStyleSheet(false) |
| 109 , m_matchedMediaAttribute(true) | 109 , m_matchedMediaAttribute(true) |
| 110 , m_inputIsImage(false) | 110 , m_inputIsImage(false) |
| 111 , m_imgSourceSize(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, inputTag) | 118 || match(m_tagImpl, sourceTag)) { |
| 119 if (RuntimeEnabledFeatures::pictureSizesEnabled()) | |
| 120 m_sourceSize = SizesAttributeParser::findEffectiveSize(String(), m_mediaValues); | |
| 121 return; | |
| 122 } | |
| 123 if ( !match(m_tagImpl, inputTag) | |
| 119 && !match(m_tagImpl, linkTag) | 124 && !match(m_tagImpl, linkTag) |
| 120 && !match(m_tagImpl, scriptTag)) | 125 && !match(m_tagImpl, scriptTag)) |
| 121 m_tagImpl = 0; | 126 m_tagImpl = 0; |
| 122 if (RuntimeEnabledFeatures::pictureSizesEnabled()) | |
| 123 m_imgSourceSize = SizesAttributeParser::findEffectiveSize(String(), m_mediaValues); | |
| 124 } | 127 } |
| 125 | 128 |
| 126 enum URLReplacement { | 129 enum URLReplacement { |
| 127 AllowURLReplacement, | 130 AllowURLReplacement, |
| 128 DisallowURLReplacement | 131 DisallowURLReplacement |
| 129 }; | 132 }; |
| 130 | 133 |
| 131 void processAttributes(const HTMLToken::AttributeList& attributes) | 134 void processAttributes(const HTMLToken::AttributeList& attributes) |
| 132 { | 135 { |
| 133 ASSERT(isMainThread()); | 136 ASSERT(isMainThread()); |
| 134 if (!m_tagImpl) | 137 if (!m_tagImpl) |
| 135 return; | 138 return; |
| 136 for (HTMLToken::AttributeList::const_iterator iter = attributes.begin(); iter != attributes.end(); ++iter) { | 139 for (HTMLToken::AttributeList::const_iterator iter = attributes.begin(); iter != attributes.end(); ++iter) { |
| 137 AtomicString attributeName(iter->name); | 140 AtomicString attributeName(iter->name); |
| 138 String attributeValue = StringImpl::create8BitIfPossible(iter->value ); | 141 String attributeValue = StringImpl::create8BitIfPossible(iter->value ); |
| 139 processAttribute(attributeName, attributeValue); | 142 processAttribute(attributeName, attributeValue); |
| 140 } | 143 } |
| 141 } | 144 } |
| 142 | 145 |
| 143 void processAttributes(const Vector<CompactHTMLToken::Attribute>& attributes ) | 146 void processAttributes(const Vector<CompactHTMLToken::Attribute>& attributes ) |
| 144 { | 147 { |
| 145 if (!m_tagImpl) | 148 if (!m_tagImpl) |
| 146 return; | 149 return; |
| 147 for (Vector<CompactHTMLToken::Attribute>::const_iterator iter = attribut es.begin(); iter != attributes.end(); ++iter) | 150 for (Vector<CompactHTMLToken::Attribute>::const_iterator iter = attribut es.begin(); iter != attributes.end(); ++iter) |
| 148 processAttribute(iter->name, iter->value); | 151 processAttribute(iter->name, iter->value); |
| 149 } | 152 } |
| 150 | 153 |
| 154 void handlePictureSourceURL(Vector<Parent>& pictureParentStack) | |
| 155 { | |
| 156 if (pictureParentStack.isEmpty() || !match(pictureParentStack.last().tag Impl, pictureTag)) | |
| 157 return; | |
| 158 | |
| 159 Parent& parent = pictureParentStack.last(); | |
| 160 if (match(m_tagImpl, sourceTag) && m_matchedMediaAttribute && parent.sou rceURL.isEmpty()) | |
| 161 parent.sourceURL = m_srcsetImageCandidate.toString(); | |
| 162 else if (match(m_tagImpl, imgTag) && !parent.sourceURL.isEmpty()) | |
| 163 setUrlToLoad(parent.sourceURL, AllowURLReplacement); | |
| 164 } | |
| 165 | |
| 151 PassOwnPtr<PreloadRequest> createPreloadRequest(const KURL& predictedBaseURL , const SegmentedString& source) | 166 PassOwnPtr<PreloadRequest> createPreloadRequest(const KURL& predictedBaseURL , const SegmentedString& source) |
| 152 { | 167 { |
| 153 if (!shouldPreload() || !m_matchedMediaAttribute) | 168 if (!shouldPreload() || !m_matchedMediaAttribute) |
| 154 return nullptr; | 169 return nullptr; |
| 155 | 170 |
| 156 TRACE_EVENT_INSTANT1("net", "PreloadRequest", "url", m_urlToLoad.ascii() ); | 171 TRACE_EVENT_INSTANT1("net", "PreloadRequest", "url", m_urlToLoad.ascii() ); |
| 157 TextPosition position = TextPosition(source.currentLine(), source.curren tColumn()); | 172 TextPosition position = TextPosition(source.currentLine(), source.curren tColumn()); |
| 158 OwnPtr<PreloadRequest> request = PreloadRequest::create(initiatorFor(m_t agImpl), position, m_urlToLoad, predictedBaseURL, resourceType()); | 173 OwnPtr<PreloadRequest> request = PreloadRequest::create(initiatorFor(m_t agImpl), position, m_urlToLoad, predictedBaseURL, resourceType()); |
| 159 if (isCORSEnabled()) | 174 if (isCORSEnabled()) |
| 160 request->setCrossOriginEnabled(allowStoredCredentials()); | 175 request->setCrossOriginEnabled(allowStoredCredentials()); |
| 161 request->setCharset(charset()); | 176 request->setCharset(charset()); |
| 162 return request.release(); | 177 return request.release(); |
| 163 } | 178 } |
| 164 | 179 |
| 165 private: | 180 private: |
| 166 template<typename NameType> | 181 template<typename NameType> |
| 182 void processScriptAttribute(const NameType& attributeName, const String& att ributeValue) | |
| 183 { | |
| 184 // FIXME - What should happen if we have multiple crossOrigin attributes with different values? | |
|
eseidel
2014/05/21 22:44:18
I figured last one, but it looks like first does:
| |
| 185 if (match(attributeName, srcAttr)) | |
| 186 setUrlToLoad(attributeValue, DisallowURLReplacement); | |
| 187 else if (match(attributeName, crossoriginAttr)) | |
| 188 setCrossOriginAllowed(attributeValue); | |
| 189 } | |
| 190 | |
| 191 template<typename NameType> | |
| 192 void processImgAttribute(const NameType& attributeName, const String& attrib uteValue) | |
| 193 { | |
| 194 if (match(attributeName, srcAttr) && m_imgSrcUrl.isNull()) { | |
| 195 m_imgSrcUrl = attributeValue; | |
| 196 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devicePi xelRatio(), m_sourceSize, attributeValue, m_srcsetImageCandidate), AllowURLRepla cement); | |
| 197 } else if (match(attributeName, crossoriginAttr)) { | |
| 198 setCrossOriginAllowed(attributeValue); | |
| 199 } else if (match(attributeName, srcsetAttr) && m_srcsetImageCandidate.is Empty()) { | |
| 200 m_srcsetAttributeValue = attributeValue; | |
| 201 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_mediaValu es->devicePixelRatio(), m_sourceSize, attributeValue); | |
| 202 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devicePi xelRatio(), m_sourceSize, m_imgSrcUrl, m_srcsetImageCandidate), AllowURLReplacem ent); | |
| 203 } else if (RuntimeEnabledFeatures::pictureSizesEnabled() && match(attrib uteName, sizesAttr) && !m_sourceSizeSet) { | |
| 204 m_sourceSize = SizesAttributeParser::findEffectiveSize(attributeValu e, m_mediaValues); | |
| 205 m_sourceSizeSet = true; | |
| 206 if (!m_srcsetImageCandidate.isEmpty()) { | |
| 207 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_media Values->devicePixelRatio(), m_sourceSize, m_srcsetAttributeValue); | |
| 208 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devi cePixelRatio(), m_sourceSize, m_imgSrcUrl, m_srcsetImageCandidate), AllowURLRepl acement); | |
| 209 } | |
| 210 } | |
| 211 } | |
| 212 | |
| 213 template<typename NameType> | |
| 214 void processLinkAttribute(const NameType& attributeName, const String& attri buteValue) | |
| 215 { | |
| 216 // FIXME - What should happen if we have multiple rel/media/crossOrigin attributes of the same name, with different values? | |
| 217 if (match(attributeName, hrefAttr)) | |
| 218 setUrlToLoad(attributeValue, DisallowURLReplacement); | |
| 219 else if (match(attributeName, relAttr)) | |
| 220 m_linkIsStyleSheet = relAttributeIsStyleSheet(attributeValue); | |
| 221 else if (match(attributeName, mediaAttr)) | |
| 222 m_matchedMediaAttribute = mediaAttributeMatches(*m_mediaValues, attr ibuteValue); | |
| 223 else if (match(attributeName, crossoriginAttr)) | |
| 224 setCrossOriginAllowed(attributeValue); | |
| 225 } | |
| 226 | |
| 227 template<typename NameType> | |
| 228 void processInputAttribute(const NameType& attributeName, const String& attr ibuteValue) | |
| 229 { | |
| 230 // FIXME - What should happen if we have multiple type attributes with d ifferent values? | |
| 231 if (match(attributeName, srcAttr)) | |
| 232 setUrlToLoad(attributeValue, DisallowURLReplacement); | |
| 233 else if (match(attributeName, typeAttr)) | |
| 234 m_inputIsImage = equalIgnoringCase(attributeValue, InputTypeNames::i mage); | |
| 235 } | |
| 236 | |
| 237 template<typename NameType> | |
| 238 void processSourceAttribute(const NameType& attributeName, const String& att ributeValue) | |
| 239 { | |
| 240 if (!RuntimeEnabledFeatures::pictureEnabled()) | |
| 241 return; | |
| 242 if (match(attributeName, srcsetAttr) && m_srcsetImageCandidate.isEmpty() ) { | |
| 243 m_srcsetAttributeValue = attributeValue; | |
| 244 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_mediaValu es->devicePixelRatio(), m_sourceSize, attributeValue); | |
| 245 } else if (match(attributeName, sizesAttr) && !m_sourceSizeSet) { | |
| 246 m_sourceSize = SizesAttributeParser::findEffectiveSize(attributeValu e, m_mediaValues); | |
| 247 m_sourceSizeSet = true; | |
| 248 if (!m_srcsetImageCandidate.isEmpty()) { | |
| 249 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_media Values->devicePixelRatio(), m_sourceSize, m_srcsetAttributeValue); | |
| 250 } | |
| 251 } else if (match(attributeName, mediaAttr)) { | |
| 252 // FIXME - What should happen if we have multiple media attributes?? ? | |
| 253 m_matchedMediaAttribute = mediaAttributeMatches(*m_mediaValues, attr ibuteValue); | |
| 254 } | |
| 255 | |
| 256 } | |
| 257 | |
| 258 template<typename NameType> | |
| 167 void processAttribute(const NameType& attributeName, const String& attribute Value) | 259 void processAttribute(const NameType& attributeName, const String& attribute Value) |
| 168 { | 260 { |
| 169 if (match(attributeName, charsetAttr)) | 261 if (match(attributeName, charsetAttr)) |
| 170 m_charset = attributeValue; | 262 m_charset = attributeValue; |
| 171 | 263 |
| 172 if (match(m_tagImpl, scriptTag)) { | 264 if (match(m_tagImpl, scriptTag)) |
| 173 if (match(attributeName, srcAttr)) | 265 processScriptAttribute(attributeName, attributeValue); |
| 174 setUrlToLoad(attributeValue, DisallowURLReplacement); | 266 else if (match(m_tagImpl, imgTag)) |
| 175 else if (match(attributeName, crossoriginAttr)) | 267 processImgAttribute(attributeName, attributeValue); |
| 176 setCrossOriginAllowed(attributeValue); | 268 else if (match(m_tagImpl, linkTag)) |
| 177 } else if (match(m_tagImpl, imgTag)) { | 269 processLinkAttribute(attributeName, attributeValue); |
| 178 if (match(attributeName, srcAttr) && m_imgSrcUrl.isNull()) { | 270 else if (match(m_tagImpl, inputTag)) |
| 179 m_imgSrcUrl = attributeValue; | 271 processInputAttribute(attributeName, attributeValue); |
| 180 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devi cePixelRatio(), m_imgSourceSize, attributeValue, m_srcsetImageCandidate), AllowU RLReplacement); | 272 else if (match(m_tagImpl, sourceTag)) |
| 181 } else if (match(attributeName, crossoriginAttr)) { | 273 processSourceAttribute(attributeName, attributeValue); |
| 182 setCrossOriginAllowed(attributeValue); | |
| 183 } else if (match(attributeName, srcsetAttr) && m_srcsetImageCandidat e.isEmpty()) { | |
| 184 m_imgSrcsetAttributeValue = attributeValue; | |
| 185 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_media Values->devicePixelRatio(), m_imgSourceSize, attributeValue); | |
| 186 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devi cePixelRatio(), m_imgSourceSize, m_imgSrcUrl, m_srcsetImageCandidate), AllowURLR eplacement); | |
| 187 } else if (RuntimeEnabledFeatures::pictureSizesEnabled() && match(at tributeName, sizesAttr) && !m_sourceSizeSet) { | |
| 188 m_imgSourceSize = SizesAttributeParser::findEffectiveSize(attrib uteValue, m_mediaValues); | |
| 189 m_sourceSizeSet = true; | |
| 190 if (!m_srcsetImageCandidate.isEmpty()) { | |
| 191 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_m ediaValues->devicePixelRatio(), m_imgSourceSize, m_imgSrcsetAttributeValue); | |
| 192 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues-> devicePixelRatio(), m_imgSourceSize, m_imgSrcUrl, m_srcsetImageCandidate), Allow URLReplacement); | |
| 193 } | |
| 194 } | |
| 195 } else if (match(m_tagImpl, linkTag)) { | |
| 196 if (match(attributeName, hrefAttr)) | |
| 197 setUrlToLoad(attributeValue, DisallowURLReplacement); | |
| 198 else if (match(attributeName, relAttr)) | |
| 199 m_linkIsStyleSheet = relAttributeIsStyleSheet(attributeValue); | |
| 200 else if (match(attributeName, mediaAttr)) | |
| 201 m_matchedMediaAttribute = mediaAttributeMatches(*m_mediaValues, attributeValue); | |
| 202 else if (match(attributeName, crossoriginAttr)) | |
| 203 setCrossOriginAllowed(attributeValue); | |
| 204 } else if (match(m_tagImpl, inputTag)) { | |
| 205 if (match(attributeName, srcAttr)) | |
| 206 setUrlToLoad(attributeValue, DisallowURLReplacement); | |
| 207 else if (match(attributeName, typeAttr)) | |
| 208 m_inputIsImage = equalIgnoringCase(attributeValue, InputTypeName s::image); | |
| 209 } | |
| 210 } | 274 } |
| 211 | 275 |
| 212 static bool relAttributeIsStyleSheet(const String& attributeValue) | 276 static bool relAttributeIsStyleSheet(const String& attributeValue) |
| 213 { | 277 { |
| 214 LinkRelAttribute rel(attributeValue); | 278 LinkRelAttribute rel(attributeValue); |
| 215 return rel.isStyleSheet() && !rel.isAlternate() && rel.iconType() == Inv alidIcon && !rel.isDNSPrefetch(); | 279 return rel.isStyleSheet() && !rel.isAlternate() && rel.iconType() == Inv alidIcon && !rel.isDNSPrefetch(); |
| 216 } | 280 } |
| 217 | 281 |
| 218 void setUrlToLoad(const String& value, URLReplacement replacement) | 282 void setUrlToLoad(const String& value, URLReplacement replacement) |
| 219 { | 283 { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 } | 342 } |
| 279 | 343 |
| 280 const StringImpl* m_tagImpl; | 344 const StringImpl* m_tagImpl; |
| 281 String m_urlToLoad; | 345 String m_urlToLoad; |
| 282 ImageCandidate m_srcsetImageCandidate; | 346 ImageCandidate m_srcsetImageCandidate; |
| 283 String m_charset; | 347 String m_charset; |
| 284 bool m_linkIsStyleSheet; | 348 bool m_linkIsStyleSheet; |
| 285 bool m_matchedMediaAttribute; | 349 bool m_matchedMediaAttribute; |
| 286 bool m_inputIsImage; | 350 bool m_inputIsImage; |
| 287 String m_imgSrcUrl; | 351 String m_imgSrcUrl; |
| 288 String m_imgSrcsetAttributeValue; | 352 String m_srcsetAttributeValue; |
| 289 unsigned m_imgSourceSize; | 353 unsigned m_sourceSize; |
| 290 bool m_sourceSizeSet; | 354 bool m_sourceSizeSet; |
| 291 bool m_isCORSEnabled; | 355 bool m_isCORSEnabled; |
| 292 StoredCredentials m_allowCredentials; | 356 StoredCredentials m_allowCredentials; |
| 293 RefPtr<MediaValues> m_mediaValues; | 357 RefPtr<MediaValues> m_mediaValues; |
| 294 }; | 358 }; |
| 295 | 359 |
| 296 TokenPreloadScanner::TokenPreloadScanner(const KURL& documentURL, PassRefPtr<Med iaValues> mediaValues) | 360 TokenPreloadScanner::TokenPreloadScanner(const KURL& documentURL, PassRefPtr<Med iaValues> mediaValues) |
| 297 : m_documentURL(documentURL) | 361 : m_documentURL(documentURL) |
| 298 , m_inStyle(false) | 362 , m_inStyle(false) |
| 299 , m_templateCount(0) | 363 , m_templateCount(0) |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 326 void TokenPreloadScanner::scan(const HTMLToken& token, const SegmentedString& so urce, PreloadRequestStream& requests) | 390 void TokenPreloadScanner::scan(const HTMLToken& token, const SegmentedString& so urce, PreloadRequestStream& requests) |
| 327 { | 391 { |
| 328 scanCommon(token, source, requests); | 392 scanCommon(token, source, requests); |
| 329 } | 393 } |
| 330 | 394 |
| 331 void TokenPreloadScanner::scan(const CompactHTMLToken& token, const SegmentedStr ing& source, PreloadRequestStream& requests) | 395 void TokenPreloadScanner::scan(const CompactHTMLToken& token, const SegmentedStr ing& source, PreloadRequestStream& requests) |
| 332 { | 396 { |
| 333 scanCommon(token, source, requests); | 397 scanCommon(token, source, requests); |
| 334 } | 398 } |
| 335 | 399 |
| 400 static bool startNesting(const StringImpl* tagImpl) | |
|
eseidel
2014/05/21 22:44:18
Can you give this a more descriptive name?
| |
| 401 { | |
| 402 if (match(tagImpl, sourceTag) | |
| 403 || match(tagImpl, imgTag) | |
| 404 || match(tagImpl, areaTag) | |
| 405 || match(tagImpl, baseTag) | |
| 406 || match(tagImpl, brTag) | |
| 407 || match(tagImpl, colTag) | |
| 408 || match(tagImpl, hrTag) | |
| 409 || match(tagImpl, inputTag) | |
| 410 || match(tagImpl, linkTag) | |
| 411 || match(tagImpl, metaTag) | |
| 412 || match(tagImpl, paramTag) | |
| 413 || match(tagImpl, commandTag) | |
| 414 || match(tagImpl, keygenTag)) | |
| 415 return false; | |
| 416 return true; | |
| 417 } | |
| 418 | |
| 336 template<typename Token> | 419 template<typename Token> |
| 337 void TokenPreloadScanner::scanCommon(const Token& token, const SegmentedString& source, PreloadRequestStream& requests) | 420 void TokenPreloadScanner::scanCommon(const Token& token, const SegmentedString& source, PreloadRequestStream& requests) |
| 338 { | 421 { |
| 339 switch (token.type()) { | 422 switch (token.type()) { |
| 340 case HTMLToken::Character: { | 423 case HTMLToken::Character: { |
| 341 if (!m_inStyle) | 424 if (!m_inStyle) |
| 342 return; | 425 return; |
| 343 m_cssScanner.scan(token.data(), source, requests); | 426 m_cssScanner.scan(token.data(), source, requests); |
| 344 return; | 427 return; |
| 345 } | 428 } |
| 346 case HTMLToken::EndTag: { | 429 case HTMLToken::EndTag: { |
| 347 const StringImpl* tagImpl = tagImplFor(token.data()); | 430 const StringImpl* tagImpl = tagImplFor(token.data()); |
| 348 if (match(tagImpl, templateTag)) { | 431 if (match(tagImpl, templateTag)) { |
| 349 if (m_templateCount) | 432 if (m_templateCount) |
| 350 --m_templateCount; | 433 --m_templateCount; |
| 351 return; | 434 return; |
| 352 } | 435 } |
| 436 if (!m_pictureParentStack.isEmpty() && startNesting(tagImpl) && m_pictur eParentStack.last().tagImpl == tagImpl) | |
| 437 m_pictureParentStack.removeLast(); | |
| 353 if (match(tagImpl, styleTag)) { | 438 if (match(tagImpl, styleTag)) { |
| 354 if (m_inStyle) | 439 if (m_inStyle) |
| 355 m_cssScanner.reset(); | 440 m_cssScanner.reset(); |
| 356 m_inStyle = false; | 441 m_inStyle = false; |
| 357 } | 442 } |
| 358 return; | 443 return; |
| 359 } | 444 } |
| 360 case HTMLToken::StartTag: { | 445 case HTMLToken::StartTag: { |
| 361 if (m_templateCount) | 446 if (m_templateCount) |
| 362 return; | 447 return; |
| 363 const StringImpl* tagImpl = tagImplFor(token.data()); | 448 const StringImpl* tagImpl = tagImplFor(token.data()); |
| 449 if (RuntimeEnabledFeatures::pictureEnabled() | |
| 450 && ((match(tagImpl, pictureTag)) || (!m_pictureParentStack.isEmpty() && startNesting(tagImpl)))) { | |
| 451 m_pictureParentStack.append(Parent(tagImpl)); | |
| 452 } | |
| 364 if (match(tagImpl, templateTag)) { | 453 if (match(tagImpl, templateTag)) { |
| 365 ++m_templateCount; | 454 ++m_templateCount; |
| 366 return; | 455 return; |
| 367 } | 456 } |
| 368 if (match(tagImpl, styleTag)) { | 457 if (match(tagImpl, styleTag)) { |
| 369 m_inStyle = true; | 458 m_inStyle = true; |
| 370 return; | 459 return; |
| 371 } | 460 } |
| 372 if (match(tagImpl, baseTag)) { | 461 if (match(tagImpl, baseTag)) { |
| 373 // The first <base> element is the one that wins. | 462 // The first <base> element is the one that wins. |
| 374 if (!m_predictedBaseElementURL.isEmpty()) | 463 if (!m_predictedBaseElementURL.isEmpty()) |
| 375 return; | 464 return; |
| 376 updatePredictedBaseURL(token); | 465 updatePredictedBaseURL(token); |
| 377 return; | 466 return; |
| 378 } | 467 } |
| 379 | 468 |
| 380 StartTagScanner scanner(tagImpl, m_mediaValues); | 469 StartTagScanner scanner(tagImpl, m_mediaValues); |
| 381 scanner.processAttributes(token.attributes()); | 470 scanner.processAttributes(token.attributes()); |
| 471 scanner.handlePictureSourceURL(m_pictureParentStack); | |
| 382 OwnPtr<PreloadRequest> request = scanner.createPreloadRequest(m_predicte dBaseElementURL, source); | 472 OwnPtr<PreloadRequest> request = scanner.createPreloadRequest(m_predicte dBaseElementURL, source); |
| 383 if (request) | 473 if (request) |
| 384 requests.append(request.release()); | 474 requests.append(request.release()); |
| 385 return; | 475 return; |
| 386 } | 476 } |
| 387 default: { | 477 default: { |
| 388 return; | 478 return; |
| 389 } | 479 } |
| 390 } | 480 } |
| 391 } | 481 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 429 if (m_token.type() == HTMLToken::StartTag) | 519 if (m_token.type() == HTMLToken::StartTag) |
| 430 m_tokenizer->updateStateFor(attemptStaticStringCreation(m_token.name (), Likely8Bit)); | 520 m_tokenizer->updateStateFor(attemptStaticStringCreation(m_token.name (), Likely8Bit)); |
| 431 m_scanner.scan(m_token, m_source, requests); | 521 m_scanner.scan(m_token, m_source, requests); |
| 432 m_token.clear(); | 522 m_token.clear(); |
| 433 } | 523 } |
| 434 | 524 |
| 435 preloader->takeAndPreload(requests); | 525 preloader->takeAndPreload(requests); |
| 436 } | 526 } |
| 437 | 527 |
| 438 } | 528 } |
| OLD | NEW |