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

Unified Diff: third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp

Issue 2018353002: Avoid downloading unsupported `<source>` types in HTMLPreloadScanner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix CSS preloading issue tests revealed Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/parser/HTMLPreloadScannerTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp b/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp
index e3ffd2fb0983ad5e8d71ec9b855c0007d27b35b7..ef293014a6c087b9d85b5ceffade2a731f940e48 100644
--- a/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp
+++ b/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp
@@ -139,11 +139,10 @@ public:
StartTagScanner(const StringImpl* tagImpl, MediaValuesCached* mediaValues)
: m_tagImpl(tagImpl)
, m_linkIsStyleSheet(false)
- , m_linkTypeIsMissingOrSupportedStyleSheet(true)
, m_linkIsPreconnect(false)
, m_linkIsPreload(false)
, m_linkIsImport(false)
- , m_matchedMediaAttribute(true)
+ , m_matched(true)
, m_inputIsImage(false)
, m_sourceSize(0)
, m_sourceSizeSet(false)
@@ -192,7 +191,7 @@ public:
void handlePictureSourceURL(PictureData& pictureData)
{
- if (match(m_tagImpl, sourceTag) && m_matchedMediaAttribute && pictureData.sourceURL.isEmpty()) {
+ if (match(m_tagImpl, sourceTag) && m_matched && pictureData.sourceURL.isEmpty()) {
pictureData.sourceURL = m_srcsetImageCandidate.toString();
pictureData.sourceSizeSet = m_sourceSizeSet;
pictureData.sourceSize = m_sourceSize;
@@ -211,7 +210,7 @@ public:
if (isLinkRelPreload()) {
requestType = PreloadRequest::RequestTypeLinkRelPreload;
}
- if (!shouldPreload() || !m_matchedMediaAttribute) {
+ if (!shouldPreload()) {
return nullptr;
}
}
@@ -307,13 +306,13 @@ private:
m_linkIsPreload = rel.isLinkPreload();
m_linkIsImport = rel.isImport();
} else if (match(attributeName, mediaAttr)) {
- m_matchedMediaAttribute = mediaAttributeMatches(*m_mediaValues, attributeValue);
+ m_matched &= mediaAttributeMatches(*m_mediaValues, attributeValue);
} else if (match(attributeName, crossoriginAttr)) {
setCrossOrigin(attributeValue);
} else if (match(attributeName, asAttr)) {
m_asAttributeValue = attributeValue;
} else if (match(attributeName, typeAttr)) {
- m_linkTypeIsMissingOrSupportedStyleSheet = MIMETypeRegistry::isSupportedStyleSheetMIMEType(ContentType(attributeValue).type());
+ m_matched &= MIMETypeRegistry::isSupportedStyleSheetMIMEType(ContentType(attributeValue).type());
}
}
@@ -341,7 +340,9 @@ private:
}
} else if (match(attributeName, mediaAttr)) {
// FIXME - Don't match media multiple times.
- m_matchedMediaAttribute = mediaAttributeMatches(*m_mediaValues, attributeValue);
+ m_matched &= mediaAttributeMatches(*m_mediaValues, attributeValue);
+ } else if (match(attributeName, typeAttr)) {
+ m_matched &= MIMETypeRegistry::isSupportedImagePrefixedMIMEType(ContentType(attributeValue).type());
}
}
@@ -427,9 +428,9 @@ private:
{
if (m_urlToLoad.isEmpty())
return false;
- if (match(m_tagImpl, linkTag) && !m_linkIsStyleSheet && !m_linkIsImport && !m_linkIsPreload)
+ if (!m_matched)
return false;
- if (match(m_tagImpl, linkTag) && m_linkIsStyleSheet && !m_linkTypeIsMissingOrSupportedStyleSheet)
+ if (match(m_tagImpl, linkTag) && !m_linkIsStyleSheet && !m_linkIsImport && !m_linkIsPreload)
return false;
if (match(m_tagImpl, inputTag) && !m_inputIsImage)
return false;
@@ -456,11 +457,10 @@ private:
ImageCandidate m_srcsetImageCandidate;
String m_charset;
bool m_linkIsStyleSheet;
- bool m_linkTypeIsMissingOrSupportedStyleSheet;
bool m_linkIsPreconnect;
bool m_linkIsPreload;
bool m_linkIsImport;
- bool m_matchedMediaAttribute;
+ bool m_matched;
bool m_inputIsImage;
String m_imgSrcUrl;
String m_srcsetAttributeValue;
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/parser/HTMLPreloadScannerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698