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

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

Issue 673603002: Reland: Make the HTMLDocumentParser yield more aggressively (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebased Created 6 years, 1 month 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
Index: Source/core/html/parser/HTMLPreloadScanner.cpp
diff --git a/Source/core/html/parser/HTMLPreloadScanner.cpp b/Source/core/html/parser/HTMLPreloadScanner.cpp
index 6c988f0ff0d89fe86e5414b7b8fd28b61455bdbc..084de2ba37ccbdb11cbd84deb5ebf128ccc79851 100644
--- a/Source/core/html/parser/HTMLPreloadScanner.cpp
+++ b/Source/core/html/parser/HTMLPreloadScanner.cpp
@@ -374,6 +374,7 @@ TokenPreloadScanner::TokenPreloadScanner(const KURL& documentURL, PassRefPtr<Med
, m_inStyle(false)
, m_inPicture(false)
, m_isAppCacheEnabled(false)
+ , m_isCSPEnabled(false)
, m_templateCount(0)
, m_mediaValues(mediaValues)
{
@@ -386,7 +387,7 @@ TokenPreloadScanner::~TokenPreloadScanner()
TokenPreloadScannerCheckpoint TokenPreloadScanner::createCheckpoint()
{
TokenPreloadScannerCheckpoint checkpoint = m_checkpoints.size();
- m_checkpoints.append(Checkpoint(m_predictedBaseElementURL, m_inStyle, m_isAppCacheEnabled, m_templateCount));
+ m_checkpoints.append(Checkpoint(m_predictedBaseElementURL, m_inStyle, m_isAppCacheEnabled, m_isCSPEnabled, m_templateCount));
return checkpoint;
}
@@ -397,6 +398,7 @@ void TokenPreloadScanner::rewindTo(TokenPreloadScannerCheckpoint checkpointIndex
m_predictedBaseElementURL = checkpoint.predictedBaseElementURL;
m_inStyle = checkpoint.inStyle;
m_isAppCacheEnabled = checkpoint.isAppCacheEnabled;
+ m_isCSPEnabled = checkpoint.isCSPEnabled;
m_templateCount = checkpoint.templateCount;
m_cssScanner.reset();
m_checkpoints.clear();
@@ -419,6 +421,10 @@ void TokenPreloadScanner::scanCommon(const Token& token, const SegmentedString&
if (m_isAppCacheEnabled)
return;
+ // http://crbug.com/434230 Disable preload for documents with CSP <meta> tags
+ if (m_isCSPEnabled)
+ return;
+
switch (token.type()) {
case HTMLToken::Character: {
if (!m_inStyle)
@@ -466,6 +472,13 @@ void TokenPreloadScanner::scanCommon(const Token& token, const SegmentedString&
m_isAppCacheEnabled = true;
return;
}
+ if (match(tagImpl, metaTag)) {
+ const typename Token::Attribute* equivAttribute = token.getAttributeItem(http_equivAttr);
+ if (equivAttribute && equalIgnoringCase(String(equivAttribute->value), "content-security-policy")) {
+ m_isCSPEnabled = true;
+ return;
+ }
+ }
if (RuntimeEnabledFeatures::pictureEnabled() && (match(tagImpl, pictureTag))) {
m_inPicture = true;
« Source/core/html/parser/HTMLPreloadScanner.h ('K') | « Source/core/html/parser/HTMLPreloadScanner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698