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

Side by Side 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, 9 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 unified diff | Download patch
« no previous file with comments | « Source/core/html/HTMLLinkElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. 5 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
6 * Copyright (C) 2009 Rob Buis (rwlbuis@gmail.com) 6 * Copyright (C) 2009 Rob Buis (rwlbuis@gmail.com)
7 * Copyright (C) 2011 Google Inc. All rights reserved. 7 * Copyright (C) 2011 Google Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 26 matching lines...) Expand all
37 #include "core/events/Event.h" 37 #include "core/events/Event.h"
38 #include "core/events/EventSender.h" 38 #include "core/events/EventSender.h"
39 #include "core/dom/StyleEngine.h" 39 #include "core/dom/StyleEngine.h"
40 #include "core/fetch/CSSStyleSheetResource.h" 40 #include "core/fetch/CSSStyleSheetResource.h"
41 #include "core/fetch/FetchRequest.h" 41 #include "core/fetch/FetchRequest.h"
42 #include "core/fetch/ResourceFetcher.h" 42 #include "core/fetch/ResourceFetcher.h"
43 #include "core/frame/ContentSecurityPolicy.h" 43 #include "core/frame/ContentSecurityPolicy.h"
44 #include "core/frame/FrameView.h" 44 #include "core/frame/FrameView.h"
45 #include "core/frame/LocalFrame.h" 45 #include "core/frame/LocalFrame.h"
46 #include "core/html/imports/LinkImport.h" 46 #include "core/html/imports/LinkImport.h"
47 #include "core/html/parser/CSSPreloadScanner.h"
47 #include "core/loader/FrameLoader.h" 48 #include "core/loader/FrameLoader.h"
48 #include "core/loader/FrameLoaderClient.h" 49 #include "core/loader/FrameLoaderClient.h"
50 #include "platform/text/SegmentedString.h"
49 #include "wtf/StdLibExtras.h" 51 #include "wtf/StdLibExtras.h"
50 52
51 namespace WebCore { 53 namespace WebCore {
52 54
53 using namespace HTMLNames; 55 using namespace HTMLNames;
54 56
55 static LinkEventSender& linkLoadEventSender() 57 static LinkEventSender& linkLoadEventSender()
56 { 58 {
57 DEFINE_STATIC_LOCAL(LinkEventSender, sharedLoadEventSender, (EventTypeNames: :load)); 59 DEFINE_STATIC_LOCAL(LinkEventSender, sharedLoadEventSender, (EventTypeNames: :load));
58 return sharedLoadEventSender; 60 return sharedLoadEventSender;
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 return adoptPtr(new LinkStyle(owner)); 364 return adoptPtr(new LinkStyle(owner));
363 } 365 }
364 366
365 LinkStyle::LinkStyle(HTMLLinkElement* owner) 367 LinkStyle::LinkStyle(HTMLLinkElement* owner)
366 : LinkResource(owner) 368 : LinkResource(owner)
367 , m_disabledState(Unset) 369 , m_disabledState(Unset)
368 , m_pendingSheetType(None) 370 , m_pendingSheetType(None)
369 , m_loading(false) 371 , m_loading(false)
370 , m_firedLoad(false) 372 , m_firedLoad(false)
371 , m_loadedSheet(false) 373 , m_loadedSheet(false)
374 , m_isPreloadScanning(true)
372 { 375 {
373 } 376 }
374 377
375 LinkStyle::~LinkStyle() 378 LinkStyle::~LinkStyle()
376 { 379 {
377 if (m_sheet) 380 if (m_sheet)
378 m_sheet->clearOwnerNode(); 381 m_sheet->clearOwnerNode();
379 } 382 }
380 383
381 Document& LinkStyle::document() 384 Document& LinkStyle::document()
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 styleSheet->parseAuthorStyleSheet(cachedStyleSheet, m_owner->document().secu rityOrigin()); 424 styleSheet->parseAuthorStyleSheet(cachedStyleSheet, m_owner->document().secu rityOrigin());
422 425
423 m_loading = false; 426 m_loading = false;
424 styleSheet->notifyLoadedSheet(cachedStyleSheet); 427 styleSheet->notifyLoadedSheet(cachedStyleSheet);
425 styleSheet->checkLoaded(); 428 styleSheet->checkLoaded();
426 429
427 if (styleSheet->isCacheable()) 430 if (styleSheet->isCacheable())
428 const_cast<CSSStyleSheetResource*>(cachedStyleSheet)->saveParsedStyleShe et(styleSheet); 431 const_cast<CSSStyleSheetResource*>(cachedStyleSheet)->saveParsedStyleShe et(styleSheet);
429 } 432 }
430 433
434 void LinkStyle::dataReceived(const CSSStyleSheetResource* cachedStyleSheet, cons t char* data, int length)
435 {
436 if (m_isPreloadScanning) {
437 m_isPreloadScanning = false;
abarth-chromium 2014/03/05 00:27:35 Why do we only scan the first chunk? What if |len
438 CSSPreloadScanner m_preloadScanner;
439 PreloadRequestStream pendingPreloads;
440 m_preloadScanner.scan(data, SegmentedString(data), pendingPreloads);
441
442 HTMLResourcePreloader m_preloader(&document());
443 m_preloader.takeAndPreload(pendingPreloads);
444 }
445 }
446
431 bool LinkStyle::sheetLoaded() 447 bool LinkStyle::sheetLoaded()
432 { 448 {
433 if (!styleSheetIsLoading()) { 449 if (!styleSheetIsLoading()) {
434 removePendingSheet(); 450 removePendingSheet();
435 return true; 451 return true;
436 } 452 }
437 return false; 453 return false;
438 } 454 }
439 455
440 void LinkStyle::notifyLoadedSheetAndAllCriticalSubresources(bool errorOccurred) 456 void LinkStyle::notifyLoadedSheetAndAllCriticalSubresources(bool errorOccurred)
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 void LinkStyle::ownerRemoved() 642 void LinkStyle::ownerRemoved()
627 { 643 {
628 if (m_sheet) 644 if (m_sheet)
629 clearSheet(); 645 clearSheet();
630 646
631 if (styleSheetIsLoading()) 647 if (styleSheetIsLoading())
632 removePendingSheet(RemovePendingSheetNotifyLater); 648 removePendingSheet(RemovePendingSheetNotifyLater);
633 } 649 }
634 650
635 } // namespace WebCore 651 } // namespace WebCore
OLDNEW
« 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