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

Side by Side Diff: Source/core/html/parser/HTMLPreloadScanner.cpp

Issue 976263002: HTML Imports: Teach preloader about HTML Imports. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: update Created 5 years, 6 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 unified diff | Download patch
OLDNEW
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 MediaQueryEvaluator mediaQueryEvaluator(mediaValues); 105 MediaQueryEvaluator mediaQueryEvaluator(mediaValues);
106 return mediaQueryEvaluator.eval(mediaQueries.get()); 106 return mediaQueryEvaluator.eval(mediaQueries.get());
107 } 107 }
108 108
109 class TokenPreloadScanner::StartTagScanner { 109 class TokenPreloadScanner::StartTagScanner {
110 public: 110 public:
111 StartTagScanner(const StringImpl* tagImpl, PassRefPtr<MediaValues> mediaValu es) 111 StartTagScanner(const StringImpl* tagImpl, PassRefPtr<MediaValues> mediaValu es)
112 : m_tagImpl(tagImpl) 112 : m_tagImpl(tagImpl)
113 , m_linkIsStyleSheet(false) 113 , m_linkIsStyleSheet(false)
114 , m_linkIsPreconnect(false) 114 , m_linkIsPreconnect(false)
115 , m_linkIsImport(false)
115 , m_matchedMediaAttribute(true) 116 , m_matchedMediaAttribute(true)
116 , m_inputIsImage(false) 117 , m_inputIsImage(false)
117 , m_sourceSize(0) 118 , m_sourceSize(0)
118 , m_sourceSizeSet(false) 119 , m_sourceSizeSet(false)
119 , m_isCORSEnabled(false) 120 , m_isCORSEnabled(false)
120 , m_defer(FetchRequest::NoDefer) 121 , m_defer(FetchRequest::NoDefer)
121 , m_allowCredentials(DoNotAllowStoredCredentials) 122 , m_allowCredentials(DoNotAllowStoredCredentials)
122 , m_mediaValues(mediaValues) 123 , m_mediaValues(mediaValues)
123 { 124 {
124 ASSERT(m_mediaValues->isCached()); 125 ASSERT(m_mediaValues->isCached());
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_media Values->devicePixelRatio(), m_sourceSize, m_srcsetAttributeValue); 224 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_media Values->devicePixelRatio(), m_sourceSize, m_srcsetAttributeValue);
224 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devi cePixelRatio(), m_sourceSize, m_imgSrcUrl, m_srcsetImageCandidate), AllowURLRepl acement); 225 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devi cePixelRatio(), m_sourceSize, m_imgSrcUrl, m_srcsetImageCandidate), AllowURLRepl acement);
225 } 226 }
226 } 227 }
227 } 228 }
228 229
229 template<typename NameType> 230 template<typename NameType>
230 void processLinkAttribute(const NameType& attributeName, const String& attri buteValue) 231 void processLinkAttribute(const NameType& attributeName, const String& attri buteValue)
231 { 232 {
232 // FIXME - Don't set rel/media/crossorigin multiple times. 233 // FIXME - Don't set rel/media/crossorigin multiple times.
233 if (match(attributeName, hrefAttr)) { 234 if (match(attributeName, hrefAttr)) {
Yoav Weiss 2015/06/09 07:53:40 Should we look into the async attribute here as we
yoichio 2015/06/11 04:27:44 The async attribute for import means that we execu
234 setUrlToLoad(attributeValue, DisallowURLReplacement); 235 setUrlToLoad(attributeValue, DisallowURLReplacement);
235 } else if (match(attributeName, relAttr)) { 236 } else if (match(attributeName, relAttr)) {
236 LinkRelAttribute rel(attributeValue); 237 LinkRelAttribute rel(attributeValue);
237 m_linkIsStyleSheet = rel.isStyleSheet() && !rel.isAlternate() && rel .iconType() == InvalidIcon && !rel.isDNSPrefetch(); 238 m_linkIsStyleSheet = rel.isStyleSheet() && !rel.isAlternate() && rel .iconType() == InvalidIcon && !rel.isDNSPrefetch();
238 m_linkIsPreconnect = rel.isPreconnect(); 239 m_linkIsPreconnect = rel.isPreconnect();
240 m_linkIsImport = rel.isImport();
239 } else if (match(attributeName, mediaAttr)) { 241 } else if (match(attributeName, mediaAttr)) {
240 m_matchedMediaAttribute = mediaAttributeMatches(*m_mediaValues, attr ibuteValue); 242 m_matchedMediaAttribute = mediaAttributeMatches(*m_mediaValues, attr ibuteValue);
241 } else if (match(attributeName, crossoriginAttr)) { 243 } else if (match(attributeName, crossoriginAttr)) {
242 setCrossOriginAllowed(attributeValue); 244 setCrossOriginAllowed(attributeValue);
243 } 245 }
244 } 246 }
245 247
246 template<typename NameType> 248 template<typename NameType>
247 void processInputAttribute(const NameType& attributeName, const String& attr ibuteValue) 249 void processInputAttribute(const NameType& attributeName, const String& attr ibuteValue)
248 { 250 {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 Resource::Type resourceType() const 323 Resource::Type resourceType() const
322 { 324 {
323 if (match(m_tagImpl, scriptTag)) 325 if (match(m_tagImpl, scriptTag))
324 return Resource::Script; 326 return Resource::Script;
325 if (match(m_tagImpl, imgTag) || match(m_tagImpl, videoTag) || (match(m_t agImpl, inputTag) && m_inputIsImage)) 327 if (match(m_tagImpl, imgTag) || match(m_tagImpl, videoTag) || (match(m_t agImpl, inputTag) && m_inputIsImage))
326 return Resource::Image; 328 return Resource::Image;
327 if (match(m_tagImpl, linkTag) && m_linkIsStyleSheet) 329 if (match(m_tagImpl, linkTag) && m_linkIsStyleSheet)
328 return Resource::CSSStyleSheet; 330 return Resource::CSSStyleSheet;
329 if (m_linkIsPreconnect) 331 if (m_linkIsPreconnect)
330 return Resource::Raw; 332 return Resource::Raw;
333 if (match(m_tagImpl, linkTag) && m_linkIsImport)
334 return Resource::ImportResource;
331 ASSERT_NOT_REACHED(); 335 ASSERT_NOT_REACHED();
332 return Resource::Raw; 336 return Resource::Raw;
333 } 337 }
334 338
335 bool shouldPreconnect() const 339 bool shouldPreconnect() const
336 { 340 {
337 return match(m_tagImpl, linkTag) && m_linkIsPreconnect && !m_urlToLoad.i sEmpty(); 341 return match(m_tagImpl, linkTag) && m_linkIsPreconnect && !m_urlToLoad.i sEmpty();
338 } 342 }
339 343
340 bool shouldPreload() const 344 bool shouldPreload() const
341 { 345 {
342 if (m_urlToLoad.isEmpty()) 346 if (m_urlToLoad.isEmpty())
343 return false; 347 return false;
344 if (match(m_tagImpl, linkTag) && !m_linkIsStyleSheet) 348 if (match(m_tagImpl, linkTag) && !m_linkIsStyleSheet && !m_linkIsImport)
345 return false; 349 return false;
346 if (match(m_tagImpl, inputTag) && !m_inputIsImage) 350 if (match(m_tagImpl, inputTag) && !m_inputIsImage)
347 return false; 351 return false;
348 return true; 352 return true;
349 } 353 }
350 354
351 bool isCORSEnabled() const 355 bool isCORSEnabled() const
352 { 356 {
353 return m_isCORSEnabled; 357 return m_isCORSEnabled;
354 } 358 }
(...skipping 21 matching lines...) Expand all
376 { 380 {
377 return m_defer; 381 return m_defer;
378 } 382 }
379 383
380 const StringImpl* m_tagImpl; 384 const StringImpl* m_tagImpl;
381 String m_urlToLoad; 385 String m_urlToLoad;
382 ImageCandidate m_srcsetImageCandidate; 386 ImageCandidate m_srcsetImageCandidate;
383 String m_charset; 387 String m_charset;
384 bool m_linkIsStyleSheet; 388 bool m_linkIsStyleSheet;
385 bool m_linkIsPreconnect; 389 bool m_linkIsPreconnect;
390 bool m_linkIsImport;
386 bool m_matchedMediaAttribute; 391 bool m_matchedMediaAttribute;
387 bool m_inputIsImage; 392 bool m_inputIsImage;
388 String m_imgSrcUrl; 393 String m_imgSrcUrl;
389 String m_srcsetAttributeValue; 394 String m_srcsetAttributeValue;
390 float m_sourceSize; 395 float m_sourceSize;
391 bool m_sourceSizeSet; 396 bool m_sourceSizeSet;
392 bool m_isCORSEnabled; 397 bool m_isCORSEnabled;
393 FetchRequest::DeferOption m_defer; 398 FetchRequest::DeferOption m_defer;
394 StoredCredentials m_allowCredentials; 399 StoredCredentials m_allowCredentials;
395 RefPtr<MediaValues> m_mediaValues; 400 RefPtr<MediaValues> m_mediaValues;
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 mediaValues = givenMediaValues; 614 mediaValues = givenMediaValues;
610 else 615 else
611 mediaValues = MediaValuesCached::create(*document); 616 mediaValues = MediaValuesCached::create(*document);
612 ASSERT(mediaValues->isSafeToSendToAnotherThread()); 617 ASSERT(mediaValues->isSafeToSendToAnotherThread());
613 defaultViewportMinWidth = document->viewportDefaultMinWidth(); 618 defaultViewportMinWidth = document->viewportDefaultMinWidth();
614 viewportMetaZeroValuesQuirk = document->settings() && document->settings()-> viewportMetaZeroValuesQuirk(); 619 viewportMetaZeroValuesQuirk = document->settings() && document->settings()-> viewportMetaZeroValuesQuirk();
615 viewportMetaEnabled = document->settings() && document->settings()->viewport MetaEnabled(); 620 viewportMetaEnabled = document->settings() && document->settings()->viewport MetaEnabled();
616 } 621 }
617 622
618 } 623 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698