| 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 27 matching lines...) Expand all Loading... |
| 38 #include "core/frame/Settings.h" | 38 #include "core/frame/Settings.h" |
| 39 #include "core/frame/SubresourceIntegrity.h" | 39 #include "core/frame/SubresourceIntegrity.h" |
| 40 #include "core/html/CrossOriginAttribute.h" | 40 #include "core/html/CrossOriginAttribute.h" |
| 41 #include "core/html/HTMLImageElement.h" | 41 #include "core/html/HTMLImageElement.h" |
| 42 #include "core/html/HTMLMetaElement.h" | 42 #include "core/html/HTMLMetaElement.h" |
| 43 #include "core/html/LinkRelAttribute.h" | 43 #include "core/html/LinkRelAttribute.h" |
| 44 #include "core/html/parser/HTMLParserIdioms.h" | 44 #include "core/html/parser/HTMLParserIdioms.h" |
| 45 #include "core/html/parser/HTMLSrcsetParser.h" | 45 #include "core/html/parser/HTMLSrcsetParser.h" |
| 46 #include "core/html/parser/HTMLTokenizer.h" | 46 #include "core/html/parser/HTMLTokenizer.h" |
| 47 #include "core/loader/LinkLoader.h" | 47 #include "core/loader/LinkLoader.h" |
| 48 #include "platform/ContentType.h" |
| 49 #include "platform/MIMETypeRegistry.h" |
| 48 #include "platform/RuntimeEnabledFeatures.h" | 50 #include "platform/RuntimeEnabledFeatures.h" |
| 49 #include "platform/TraceEvent.h" | 51 #include "platform/TraceEvent.h" |
| 50 #include "wtf/MainThread.h" | 52 #include "wtf/MainThread.h" |
| 51 | 53 |
| 52 namespace blink { | 54 namespace blink { |
| 53 | 55 |
| 54 using namespace HTMLNames; | 56 using namespace HTMLNames; |
| 55 | 57 |
| 56 static bool match(const StringImpl* impl, const QualifiedName& qName) | 58 static bool match(const StringImpl* impl, const QualifiedName& qName) |
| 57 { | 59 { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 MediaQueryEvaluator mediaQueryEvaluator(mediaValues); | 111 MediaQueryEvaluator mediaQueryEvaluator(mediaValues); |
| 110 return mediaQueryEvaluator.eval(mediaQueries.get()); | 112 return mediaQueryEvaluator.eval(mediaQueries.get()); |
| 111 } | 113 } |
| 112 | 114 |
| 113 class TokenPreloadScanner::StartTagScanner { | 115 class TokenPreloadScanner::StartTagScanner { |
| 114 STACK_ALLOCATED(); | 116 STACK_ALLOCATED(); |
| 115 public: | 117 public: |
| 116 StartTagScanner(const StringImpl* tagImpl, PassRefPtrWillBeRawPtr<MediaValue
s> mediaValues) | 118 StartTagScanner(const StringImpl* tagImpl, PassRefPtrWillBeRawPtr<MediaValue
s> mediaValues) |
| 117 : m_tagImpl(tagImpl) | 119 : m_tagImpl(tagImpl) |
| 118 , m_linkIsStyleSheet(false) | 120 , m_linkIsStyleSheet(false) |
| 121 , m_linkTypeIsMissingOrSupportedStyleSheet(true) |
| 119 , m_linkIsPreconnect(false) | 122 , m_linkIsPreconnect(false) |
| 120 , m_linkIsPreload(false) | 123 , m_linkIsPreload(false) |
| 121 , m_linkIsImport(false) | 124 , m_linkIsImport(false) |
| 122 , m_matchedMediaAttribute(true) | 125 , m_matchedMediaAttribute(true) |
| 123 , m_inputIsImage(false) | 126 , m_inputIsImage(false) |
| 124 , m_sourceSize(0) | 127 , m_sourceSize(0) |
| 125 , m_sourceSizeSet(false) | 128 , m_sourceSizeSet(false) |
| 126 , m_defer(FetchRequest::NoDefer) | 129 , m_defer(FetchRequest::NoDefer) |
| 127 , m_crossOrigin(CrossOriginAttributeNotSet) | 130 , m_crossOrigin(CrossOriginAttributeNotSet) |
| 128 , m_mediaValues(mediaValues) | 131 , m_mediaValues(mediaValues) |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 m_linkIsStyleSheet = rel.isStyleSheet() && !rel.isAlternate() && rel
.iconType() == InvalidIcon && !rel.isDNSPrefetch(); | 276 m_linkIsStyleSheet = rel.isStyleSheet() && !rel.isAlternate() && rel
.iconType() == InvalidIcon && !rel.isDNSPrefetch(); |
| 274 m_linkIsPreconnect = rel.isPreconnect(); | 277 m_linkIsPreconnect = rel.isPreconnect(); |
| 275 m_linkIsPreload = rel.isLinkPreload(); | 278 m_linkIsPreload = rel.isLinkPreload(); |
| 276 m_linkIsImport = rel.isImport(); | 279 m_linkIsImport = rel.isImport(); |
| 277 } else if (match(attributeName, mediaAttr)) { | 280 } else if (match(attributeName, mediaAttr)) { |
| 278 m_matchedMediaAttribute = mediaAttributeMatches(*m_mediaValues, attr
ibuteValue); | 281 m_matchedMediaAttribute = mediaAttributeMatches(*m_mediaValues, attr
ibuteValue); |
| 279 } else if (match(attributeName, crossoriginAttr)) { | 282 } else if (match(attributeName, crossoriginAttr)) { |
| 280 setCrossOrigin(attributeValue); | 283 setCrossOrigin(attributeValue); |
| 281 } else if (match(attributeName, asAttr)) { | 284 } else if (match(attributeName, asAttr)) { |
| 282 m_asAttributeValue = attributeValue; | 285 m_asAttributeValue = attributeValue; |
| 286 } else if (match(attributeName, typeAttr)) { |
| 287 m_linkTypeIsMissingOrSupportedStyleSheet = MIMETypeRegistry::isSuppo
rtedStyleSheetMIMEType(ContentType(attributeValue).type()); |
| 283 } | 288 } |
| 284 } | 289 } |
| 285 | 290 |
| 286 template<typename NameType> | 291 template<typename NameType> |
| 287 void processInputAttribute(const NameType& attributeName, const String& attr
ibuteValue) | 292 void processInputAttribute(const NameType& attributeName, const String& attr
ibuteValue) |
| 288 { | 293 { |
| 289 // FIXME - Don't set type multiple times. | 294 // FIXME - Don't set type multiple times. |
| 290 if (match(attributeName, srcAttr)) | 295 if (match(attributeName, srcAttr)) |
| 291 setUrlToLoad(attributeValue, DisallowURLReplacement); | 296 setUrlToLoad(attributeValue, DisallowURLReplacement); |
| 292 else if (match(attributeName, typeAttr)) | 297 else if (match(attributeName, typeAttr)) |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 { | 390 { |
| 386 return match(m_tagImpl, linkTag) && m_linkIsPreload && !m_urlToLoad.isEm
pty(); | 391 return match(m_tagImpl, linkTag) && m_linkIsPreload && !m_urlToLoad.isEm
pty(); |
| 387 } | 392 } |
| 388 | 393 |
| 389 bool shouldPreload() const | 394 bool shouldPreload() const |
| 390 { | 395 { |
| 391 if (m_urlToLoad.isEmpty()) | 396 if (m_urlToLoad.isEmpty()) |
| 392 return false; | 397 return false; |
| 393 if (match(m_tagImpl, linkTag) && !m_linkIsStyleSheet && !m_linkIsImport
&& !m_linkIsPreload) | 398 if (match(m_tagImpl, linkTag) && !m_linkIsStyleSheet && !m_linkIsImport
&& !m_linkIsPreload) |
| 394 return false; | 399 return false; |
| 400 if (match(m_tagImpl, linkTag) && m_linkIsStyleSheet && !m_linkTypeIsMiss
ingOrSupportedStyleSheet) |
| 401 return false; |
| 395 if (match(m_tagImpl, inputTag) && !m_inputIsImage) | 402 if (match(m_tagImpl, inputTag) && !m_inputIsImage) |
| 396 return false; | 403 return false; |
| 397 return true; | 404 return true; |
| 398 } | 405 } |
| 406 |
| 399 void setCrossOrigin(const String& corsSetting) | 407 void setCrossOrigin(const String& corsSetting) |
| 400 { | 408 { |
| 401 m_crossOrigin = crossOriginAttributeValue(corsSetting); | 409 m_crossOrigin = crossOriginAttributeValue(corsSetting); |
| 402 } | 410 } |
| 403 | 411 |
| 404 void setDefer(FetchRequest::DeferOption defer) | 412 void setDefer(FetchRequest::DeferOption defer) |
| 405 { | 413 { |
| 406 m_defer = defer; | 414 m_defer = defer; |
| 407 } | 415 } |
| 408 | 416 |
| 409 bool defer() const | 417 bool defer() const |
| 410 { | 418 { |
| 411 return m_defer; | 419 return m_defer; |
| 412 } | 420 } |
| 413 | 421 |
| 414 const StringImpl* m_tagImpl; | 422 const StringImpl* m_tagImpl; |
| 415 String m_urlToLoad; | 423 String m_urlToLoad; |
| 416 ImageCandidate m_srcsetImageCandidate; | 424 ImageCandidate m_srcsetImageCandidate; |
| 417 String m_charset; | 425 String m_charset; |
| 418 bool m_linkIsStyleSheet; | 426 bool m_linkIsStyleSheet; |
| 427 bool m_linkTypeIsMissingOrSupportedStyleSheet; |
| 419 bool m_linkIsPreconnect; | 428 bool m_linkIsPreconnect; |
| 420 bool m_linkIsPreload; | 429 bool m_linkIsPreload; |
| 421 bool m_linkIsImport; | 430 bool m_linkIsImport; |
| 422 bool m_matchedMediaAttribute; | 431 bool m_matchedMediaAttribute; |
| 423 bool m_inputIsImage; | 432 bool m_inputIsImage; |
| 424 String m_imgSrcUrl; | 433 String m_imgSrcUrl; |
| 425 String m_srcsetAttributeValue; | 434 String m_srcsetAttributeValue; |
| 426 String m_asAttributeValue; | 435 String m_asAttributeValue; |
| 427 float m_sourceSize; | 436 float m_sourceSize; |
| 428 bool m_sourceSizeSet; | 437 bool m_sourceSizeSet; |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 else | 691 else |
| 683 mediaValues = MediaValuesCached::create(*document); | 692 mediaValues = MediaValuesCached::create(*document); |
| 684 ASSERT(mediaValues->isSafeToSendToAnotherThread()); | 693 ASSERT(mediaValues->isSafeToSendToAnotherThread()); |
| 685 defaultViewportMinWidth = document->viewportDefaultMinWidth(); | 694 defaultViewportMinWidth = document->viewportDefaultMinWidth(); |
| 686 viewportMetaZeroValuesQuirk = document->settings() && document->settings()->
viewportMetaZeroValuesQuirk(); | 695 viewportMetaZeroValuesQuirk = document->settings() && document->settings()->
viewportMetaZeroValuesQuirk(); |
| 687 viewportMetaEnabled = document->settings() && document->settings()->viewport
MetaEnabled(); | 696 viewportMetaEnabled = document->settings() && document->settings()->viewport
MetaEnabled(); |
| 688 referrerPolicy = ReferrerPolicyDefault; | 697 referrerPolicy = ReferrerPolicyDefault; |
| 689 } | 698 } |
| 690 | 699 |
| 691 } | 700 } |
| OLD | NEW |