Index: Source/core/html/parser/HTMLPreloadScanner.cpp |
diff --git a/Source/core/html/parser/HTMLPreloadScanner.cpp b/Source/core/html/parser/HTMLPreloadScanner.cpp |
index 1b21bc89b4408a9bbe189b2d614297b7651b7a3c..08fe987f5d53ccd22b4c15b0022c7adf7062710d 100644 |
--- a/Source/core/html/parser/HTMLPreloadScanner.cpp |
+++ b/Source/core/html/parser/HTMLPreloadScanner.cpp |
@@ -111,6 +111,7 @@ public: |
, m_sourceSize(0) |
, m_sourceSizeSet(false) |
, m_isCORSEnabled(false) |
+ , m_execAsync(false) |
, m_allowCredentials(DoNotAllowStoredCredentials) |
, m_mediaValues(mediaValues) |
{ |
@@ -170,6 +171,7 @@ public: |
if (isCORSEnabled()) |
request->setCrossOriginEnabled(allowStoredCredentials()); |
request->setCharset(charset()); |
+ request->setExecAsync(m_execAsync); |
return request.release(); |
} |
@@ -182,6 +184,10 @@ private: |
setUrlToLoad(attributeValue, DisallowURLReplacement); |
else if (match(attributeName, crossoriginAttr)) |
setCrossOriginAllowed(attributeValue); |
+ else if (match(attributeName, asyncAttr)) |
+ setExecAsync(true); |
+ else if (match(attributeName, deferAttr)) |
+ setExecAsync(true); |
} |
template<typename NameType> |
@@ -337,6 +343,16 @@ private: |
m_allowCredentials = DoNotAllowStoredCredentials; |
} |
+ void setExecAsync(const bool execAsync) |
+ { |
+ m_execAsync = execAsync; |
+ } |
+ |
+ bool execAsync() const |
+ { |
+ return m_execAsync; |
+ } |
+ |
const StringImpl* m_tagImpl; |
String m_urlToLoad; |
ImageCandidate m_srcsetImageCandidate; |
@@ -349,6 +365,7 @@ private: |
unsigned m_sourceSize; |
bool m_sourceSizeSet; |
bool m_isCORSEnabled; |
+ bool m_execAsync; |
StoredCredentials m_allowCredentials; |
RefPtr<MediaValues> m_mediaValues; |
}; |
@@ -357,6 +374,7 @@ TokenPreloadScanner::TokenPreloadScanner(const KURL& documentURL, PassRefPtr<Med |
: m_documentURL(documentURL) |
, m_inStyle(false) |
, m_inPicture(false) |
+ , m_isBeforeBody(true) |
, m_templateCount(0) |
, m_mediaValues(mediaValues) |
{ |
@@ -369,7 +387,7 @@ TokenPreloadScanner::~TokenPreloadScanner() |
TokenPreloadScannerCheckpoint TokenPreloadScanner::createCheckpoint() |
{ |
TokenPreloadScannerCheckpoint checkpoint = m_checkpoints.size(); |
- m_checkpoints.append(Checkpoint(m_predictedBaseElementURL, m_inStyle, m_templateCount)); |
+ m_checkpoints.append(Checkpoint(m_predictedBaseElementURL, m_inStyle, m_isBeforeBody, m_templateCount)); |
return checkpoint; |
} |
@@ -379,8 +397,10 @@ void TokenPreloadScanner::rewindTo(TokenPreloadScannerCheckpoint checkpointIndex |
const Checkpoint& checkpoint = m_checkpoints[checkpointIndex]; |
m_predictedBaseElementURL = checkpoint.predictedBaseElementURL; |
m_inStyle = checkpoint.inStyle; |
+ m_isBeforeBody = checkpoint.isBeforeBody; |
m_templateCount = checkpoint.templateCount; |
m_cssScanner.reset(); |
+ m_cssScanner.setIsBeforeBody(m_isBeforeBody); |
m_checkpoints.clear(); |
} |
@@ -433,6 +453,10 @@ void TokenPreloadScanner::scanCommon(const Token& token, const SegmentedString& |
m_inStyle = true; |
return; |
} |
+ if (m_isBeforeBody && match(tagImpl, bodyTag)) { |
+ m_isBeforeBody = false; |
+ m_cssScanner.setIsBeforeBody(m_isBeforeBody); |
+ } |
if (match(tagImpl, baseTag)) { |
// The first <base> element is the one that wins. |
if (!m_predictedBaseElementURL.isEmpty()) |
@@ -451,8 +475,10 @@ void TokenPreloadScanner::scanCommon(const Token& token, const SegmentedString& |
if (m_inPicture) |
scanner.handlePictureSourceURL(m_pictureSourceURL); |
OwnPtr<PreloadRequest> request = scanner.createPreloadRequest(m_predictedBaseElementURL, source); |
- if (request) |
+ if (request) { |
+ request->setIsBeforeBody(m_isBeforeBody); |
requests.append(request.release()); |
+ } |
return; |
} |
default: { |