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

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: Renamed according to comments. Created 6 years, 7 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
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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 HTMLElement::trace(visitor); 429 HTMLElement::trace(visitor);
430 } 430 }
431 431
432 PassOwnPtrWillBeRawPtr<LinkStyle> LinkStyle::create(HTMLLinkElement* owner) 432 PassOwnPtrWillBeRawPtr<LinkStyle> LinkStyle::create(HTMLLinkElement* owner)
433 { 433 {
434 return adoptPtrWillBeNoop(new LinkStyle(owner)); 434 return adoptPtrWillBeNoop(new LinkStyle(owner));
435 } 435 }
436 436
437 LinkStyle::LinkStyle(HTMLLinkElement* owner) 437 LinkStyle::LinkStyle(HTMLLinkElement* owner)
438 : LinkResource(owner) 438 : LinkResource(owner)
439 , m_preloadScanner(adoptPtr(new CSSPreloadScanner))
440 , m_preloadInput(adoptPtr(new SegmentedString))
439 , m_disabledState(Unset) 441 , m_disabledState(Unset)
440 , m_pendingSheetType(None) 442 , m_pendingSheetType(None)
441 , m_loading(false) 443 , m_loading(false)
442 , m_firedLoad(false) 444 , m_firedLoad(false)
443 , m_loadedSheet(false) 445 , m_loadedSheet(false)
444 { 446 {
445 } 447 }
446 448
447 LinkStyle::~LinkStyle() 449 LinkStyle::~LinkStyle()
448 { 450 {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 styleSheet->parseAuthorStyleSheet(cachedStyleSheet, m_owner->document().secu rityOrigin()); 497 styleSheet->parseAuthorStyleSheet(cachedStyleSheet, m_owner->document().secu rityOrigin());
496 498
497 m_loading = false; 499 m_loading = false;
498 styleSheet->notifyLoadedSheet(cachedStyleSheet); 500 styleSheet->notifyLoadedSheet(cachedStyleSheet);
499 styleSheet->checkLoaded(); 501 styleSheet->checkLoaded();
500 502
501 if (styleSheet->isCacheable()) 503 if (styleSheet->isCacheable())
502 const_cast<CSSStyleSheetResource*>(cachedStyleSheet)->saveParsedStyleShe et(styleSheet); 504 const_cast<CSSStyleSheetResource*>(cachedStyleSheet)->saveParsedStyleShe et(styleSheet);
503 } 505 }
504 506
507 void LinkStyle::dataReceived(const CSSStyleSheetResource* cachedStyleSheet, cons t char* data, int length)
508 {
509 if (!m_preloadScanner)
510 return;
511
512 PreloadRequestStream pendingPreloads;
513 m_preloadInput->append(SegmentedString(data));
abarth-chromium 2014/06/26 16:37:59 Why don't we need to use |length| on this line?
514 m_preloadScanner->scan(data, *m_preloadInput, pendingPreloads);
515 HTMLResourcePreloader m_preloader(&document());
516 m_preloader.takeAndPreload(pendingPreloads);
517
518 if (m_preloadScanner->isDoneParsingImports()) {
eseidel 2014/05/28 23:52:52 Could you explain the magic here a bit more? // N
519 m_preloadScanner.clear();
520 m_preloadInput.clear();
521 }
522 }
523
505 bool LinkStyle::sheetLoaded() 524 bool LinkStyle::sheetLoaded()
506 { 525 {
507 if (!styleSheetIsLoading()) { 526 if (!styleSheetIsLoading()) {
508 removePendingSheet(); 527 removePendingSheet();
509 return true; 528 return true;
510 } 529 }
511 return false; 530 return false;
512 } 531 }
513 532
514 void LinkStyle::notifyLoadedSheetAndAllCriticalSubresources(bool errorOccurred) 533 void LinkStyle::notifyLoadedSheetAndAllCriticalSubresources(bool errorOccurred)
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 removePendingSheet(RemovePendingSheetNotifyLater); 723 removePendingSheet(RemovePendingSheetNotifyLater);
705 } 724 }
706 725
707 void LinkStyle::trace(Visitor* visitor) 726 void LinkStyle::trace(Visitor* visitor)
708 { 727 {
709 visitor->trace(m_sheet); 728 visitor->trace(m_sheet);
710 LinkResource::trace(visitor); 729 LinkResource::trace(visitor);
711 } 730 }
712 731
713 } // namespace WebCore 732 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698