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

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

Issue 2290983003: CSSStyleSheetResource should cache decoded text instead of raw bytes (Closed)
Patch Set: add dcheck 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 4218572b31a22db8d713a0e464814c9481653d25..9ee2db13e7c794667b5ddb8c68ac656f7171d98c 100644
--- a/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
@@ -426,17 +426,35 @@ 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();
+
+ if (disposition == ResourceIntegrityDisposition::NotChecked)
Charlie Harrison 2016/10/05 15:24:49 nit: A conditional branch just for a DCHECK isn't
kouhei (in TOK) 2016/10/06 12:02:36 Done.
+ DCHECK(!cachedStyleSheet->sheetText().isNull());
+
+ if (disposition == ResourceIntegrityDisposition::NotChecked &&
+ cachedStyleSheet->resourceBuffer()) {
+ if (SubresourceIntegrity::CheckSubresourceIntegrity(
+ *m_owner, cachedStyleSheet->resourceBuffer()->data(),
+ cachedStyleSheet->resourceBuffer()->size(), KURL(baseURL, href),
+ *cachedStyleSheet))
+ disposition = ResourceIntegrityDisposition::Passed;
+ else
+ disposition = ResourceIntegrityDisposition::Failed;
+
+ const_cast<CSSStyleSheetResource*>(cachedStyleSheet)
Charlie Harrison 2016/10/05 15:24:48 The const_cast is not ideal, but I can't think of
+ ->setIntegrityDisposition(disposition);
+ }
+
+ if (disposition == ResourceIntegrityDisposition::Failed) {
+ m_loading = false;
+ removePendingSheet();
+ notifyLoadedSheetAndAllCriticalSubresources(
+ Node::ErrorOccurredLoadingSubresource);
+ return;
+ }
}
CSSParserContext parserContext(m_owner->document(), nullptr, baseURL,

Powered by Google App Engine
This is Rietveld 408576698