Chromium Code Reviews| Index: Source/core/html/HTMLLinkElement.cpp |
| diff --git a/Source/core/html/HTMLLinkElement.cpp b/Source/core/html/HTMLLinkElement.cpp |
| index 5b1e253e9ae9ad5a0940b25817d3fca1bca46862..0f693fb47db4f5a224248607c0d769229cf0ef88 100644 |
| --- a/Source/core/html/HTMLLinkElement.cpp |
| +++ b/Source/core/html/HTMLLinkElement.cpp |
| @@ -476,6 +476,8 @@ PassOwnPtrWillBeRawPtr<LinkStyle> LinkStyle::create(HTMLLinkElement* owner) |
| LinkStyle::LinkStyle(HTMLLinkElement* owner) |
| : LinkResource(owner) |
| + , m_preloadScanner(adoptPtr(new CSSPreloadScanner)) |
| + , m_preloadInput(adoptPtr(new SegmentedString)) |
| , m_disabledState(Unset) |
| , m_pendingSheetType(None) |
| , m_loading(false) |
| @@ -542,6 +544,29 @@ 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_preloadScanner) |
| + return; |
| + |
| + PreloadRequestStream pendingPreloads; |
| + m_preloadInput->append(SegmentedString(String(data, length))); |
|
abarth-chromium
2014/07/29 16:43:52
How can you take a const char* and make a String o
|
| + m_preloadScanner->scan(data, *m_preloadInput, pendingPreloads); |
| + |
| + OwnPtr<HTMLResourcePreloader> preloader = HTMLResourcePreloader::create(document()); |
| + preloader->takeAndPreload(pendingPreloads); |
| + if (m_preloadScanner->isDoneParsingImports()) { |
| + // Note: Although dataRecieved will be called for each packet of data |
| + // returned from the network, @import statements are always at the top |
| + // of the CSS file. As soon as we reach a part of the CSS file which |
| + // is not an @import we can delete our preloader and ignore the rest of |
| + // file. If we ever make CSS preloading more complicated (to look for |
| + // URLs other than @imports) we will need to re-think this logic. |
| + m_preloadScanner.clear(); |
| + m_preloadInput.clear(); |
| + } |
| +} |
| + |
| bool LinkStyle::sheetLoaded() |
| { |
| if (!styleSheetIsLoading()) { |