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

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

Issue 166633002: Prefetch @import files from CSS files. Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Prefetching now handled just like for other resources. Created 6 years, 10 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 | « Source/core/html/HTMLLinkElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLLinkElement.cpp
diff --git a/Source/core/html/HTMLLinkElement.cpp b/Source/core/html/HTMLLinkElement.cpp
index fbb7a1a97986d7c41135cd2e37e4d288f299d37b..3aec952231469c05250df7dd17f572f4fd653d52 100644
--- a/Source/core/html/HTMLLinkElement.cpp
+++ b/Source/core/html/HTMLLinkElement.cpp
@@ -44,8 +44,10 @@
#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
#include "core/html/imports/LinkImport.h"
+#include "core/html/parser/CSSPreloadScanner.h"
#include "core/loader/FrameLoader.h"
#include "core/loader/FrameLoaderClient.h"
+#include "platform/text/SegmentedString.h"
#include "wtf/StdLibExtras.h"
namespace WebCore {
@@ -369,6 +371,7 @@ LinkStyle::LinkStyle(HTMLLinkElement* owner)
, m_loading(false)
, m_firedLoad(false)
, m_loadedSheet(false)
+ , m_isPreloadScanning(true)
{
}
@@ -428,6 +431,19 @@ void LinkStyle::setCSSStyleSheet(const String& href, const KURL& baseURL, const
const_cast<CSSStyleSheetResource*>(cachedStyleSheet)->saveParsedStyleSheet(styleSheet);
}
+void LinkStyle::dataReceived(const CSSStyleSheetResource* cachedStyleSheet, const char* data, int length)
+{
+ if (m_isPreloadScanning) {
+ m_isPreloadScanning = false;
abarth-chromium 2014/03/05 00:27:35 Why do we only scan the first chunk? What if |len
+ CSSPreloadScanner m_preloadScanner;
+ PreloadRequestStream pendingPreloads;
+ m_preloadScanner.scan(data, SegmentedString(data), pendingPreloads);
+
+ HTMLResourcePreloader m_preloader(&document());
+ m_preloader.takeAndPreload(pendingPreloads);
+ }
+}
+
bool LinkStyle::sheetLoaded()
{
if (!styleSheetIsLoading()) {
« no previous file with comments | « Source/core/html/HTMLLinkElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698