| Index: Source/core/html/parser/HTMLPreloadScanner.cpp
|
| diff --git a/Source/core/html/parser/HTMLPreloadScanner.cpp b/Source/core/html/parser/HTMLPreloadScanner.cpp
|
| index 706fb0e51034b954e74e60534ba1610ac8e53691..4cf24d343d4710487a4e3823265229f09a760ee2 100644
|
| --- a/Source/core/html/parser/HTMLPreloadScanner.cpp
|
| +++ b/Source/core/html/parser/HTMLPreloadScanner.cpp
|
| @@ -106,6 +106,7 @@ public:
|
| StartTagScanner(const StringImpl* tagImpl, PassRefPtr<MediaValues> mediaValues)
|
| : m_tagImpl(tagImpl)
|
| , m_linkIsStyleSheet(false)
|
| + , m_linkIsImport(false)
|
| , m_matchedMediaAttribute(true)
|
| , m_inputIsImage(false)
|
| , m_imgSourceSize(0)
|
| @@ -193,14 +194,16 @@ private:
|
| }
|
| }
|
| } else if (match(m_tagImpl, linkTag)) {
|
| - if (match(attributeName, hrefAttr))
|
| + if (match(attributeName, hrefAttr)) {
|
| setUrlToLoad(attributeValue, DisallowURLReplacement);
|
| - else if (match(attributeName, relAttr))
|
| + } else if (match(attributeName, relAttr)) {
|
| m_linkIsStyleSheet = relAttributeIsStyleSheet(attributeValue);
|
| - else if (match(attributeName, mediaAttr))
|
| + m_linkIsImport = RuntimeEnabledFeatures::htmlImportsEnabled() && relAttributeIsImport(attributeValue);
|
| + } else if (match(attributeName, mediaAttr)) {
|
| m_matchedMediaAttribute = mediaAttributeMatches(*m_mediaValues, attributeValue);
|
| - else if (match(attributeName, crossoriginAttr))
|
| + } else if (match(attributeName, crossoriginAttr)) {
|
| setCrossOriginAllowed(attributeValue);
|
| + }
|
| } else if (match(m_tagImpl, inputTag)) {
|
| if (match(attributeName, srcAttr))
|
| setUrlToLoad(attributeValue, DisallowURLReplacement);
|
| @@ -209,10 +212,21 @@ private:
|
| }
|
| }
|
|
|
| + static bool relAttributeWillBeImmediatelyUsed(const LinkRelAttribute& rel)
|
| + {
|
| + return !rel.isAlternate() && rel.iconType() == InvalidIcon && !rel.isDNSPrefetch();
|
| + }
|
| +
|
| static bool relAttributeIsStyleSheet(const String& attributeValue)
|
| {
|
| LinkRelAttribute rel(attributeValue);
|
| - return rel.isStyleSheet() && !rel.isAlternate() && rel.iconType() == InvalidIcon && !rel.isDNSPrefetch();
|
| + return rel.isStyleSheet() && relAttributeWillBeImmediatelyUsed(rel);
|
| + }
|
| +
|
| + static bool relAttributeIsImport(const String& attributeValue)
|
| + {
|
| + LinkRelAttribute rel(attributeValue);
|
| + return rel.isImport() && relAttributeWillBeImmediatelyUsed(rel);
|
| }
|
|
|
| void setUrlToLoad(const String& value, URLReplacement replacement)
|
| @@ -243,6 +257,8 @@ private:
|
| return Resource::Image;
|
| if (match(m_tagImpl, linkTag) && m_linkIsStyleSheet)
|
| return Resource::CSSStyleSheet;
|
| + if (match(m_tagImpl, linkTag) && m_linkIsImport)
|
| + return Resource::ImportResource;
|
| ASSERT_NOT_REACHED();
|
| return Resource::Raw;
|
| }
|
| @@ -251,7 +267,7 @@ private:
|
| {
|
| if (m_urlToLoad.isEmpty())
|
| return false;
|
| - if (match(m_tagImpl, linkTag) && !m_linkIsStyleSheet)
|
| + if (match(m_tagImpl, linkTag) && !m_linkIsStyleSheet && !m_linkIsImport)
|
| return false;
|
| if (match(m_tagImpl, inputTag) && !m_inputIsImage)
|
| return false;
|
| @@ -282,6 +298,7 @@ private:
|
| ImageCandidate m_srcsetImageCandidate;
|
| String m_charset;
|
| bool m_linkIsStyleSheet;
|
| + bool m_linkIsImport;
|
| bool m_matchedMediaAttribute;
|
| bool m_inputIsImage;
|
| String m_imgSrcUrl;
|
|
|