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

Unified Diff: third_party/WebKit/Source/core/html/HTMLLinkElement.cpp

Issue 2290983003: CSSStyleSheetResource should cache decoded text instead of raw bytes (Closed)
Patch Set: rebased Created 4 years, 2 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
Index: third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp b/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
index 504686de214bf997b3a697c97e01525c5c10d951..a27a6472c4f8e94e1e0fe0c212804be928e867b0 100644
--- a/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
@@ -429,17 +429,37 @@ void LinkStyle::setCSSStyleSheet(
// See the comment in PendingScript.cpp about why this check is necessary
// here, instead of in the resource fetcher. https://crbug.com/500701.
if (!cachedStyleSheet->errorOccurred() &&
- m_owner->fastHasAttribute(HTMLNames::integrityAttr) &&
- cachedStyleSheet->resourceBuffer() &&
- !SubresourceIntegrity::CheckSubresourceIntegrity(
- *m_owner, cachedStyleSheet->resourceBuffer()->data(),
- cachedStyleSheet->resourceBuffer()->size(), KURL(baseURL, href),
- *cachedStyleSheet)) {
- m_loading = false;
- removePendingSheet();
- notifyLoadedSheetAndAllCriticalSubresources(
- Node::ErrorOccurredLoadingSubresource);
- return;
+ !m_owner->fastGetAttribute(HTMLNames::integrityAttr).isEmpty() &&
+ !cachedStyleSheet->integrityMetadata().isEmpty()) {
+ ResourceIntegrityDisposition disposition =
+ cachedStyleSheet->integrityDisposition();
+
+ DCHECK(disposition != ResourceIntegrityDisposition::NotChecked ||
+ !cachedStyleSheet->sheetText().isNull());
+
+ if (disposition == ResourceIntegrityDisposition::NotChecked &&
+ !cachedStyleSheet->loadFailedOrCanceled()) {
+ DCHECK(cachedStyleSheet->resourceBuffer());
+ if (SubresourceIntegrity::CheckSubresourceIntegrity(
+ *m_owner, cachedStyleSheet->resourceBuffer()->data(),
+ cachedStyleSheet->resourceBuffer()->size(), KURL(baseURL, href),
+ *cachedStyleSheet))
+ disposition = ResourceIntegrityDisposition::Passed;
+ else
+ disposition = ResourceIntegrityDisposition::Failed;
+
+ // TODO(kouhei): Remove this const_cast crbug.com/653502
+ const_cast<CSSStyleSheetResource*>(cachedStyleSheet)
+ ->setIntegrityDisposition(disposition);
+ }
+
+ if (disposition == ResourceIntegrityDisposition::Failed) {
+ m_loading = false;
+ removePendingSheet();
+ notifyLoadedSheetAndAllCriticalSubresources(
+ Node::ErrorOccurredLoadingSubresource);
+ return;
+ }
}
CSSParserContext parserContext(m_owner->document(), nullptr, baseURL,
« no previous file with comments | « third_party/WebKit/Source/core/fetch/Resource.cpp ('k') | third_party/WebKit/Source/core/inspector/InspectorPageAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698