| OLD | NEW |
| 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 28 matching lines...) Expand all Loading... |
| 39 #include "core/events/EventSender.h" | 39 #include "core/events/EventSender.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/FrameView.h" | 43 #include "core/frame/FrameView.h" |
| 44 #include "core/frame/LocalFrame.h" | 44 #include "core/frame/LocalFrame.h" |
| 45 #include "core/frame/SubresourceIntegrity.h" | 45 #include "core/frame/SubresourceIntegrity.h" |
| 46 #include "core/frame/csp/ContentSecurityPolicy.h" | 46 #include "core/frame/csp/ContentSecurityPolicy.h" |
| 47 #include "core/html/LinkManifest.h" | 47 #include "core/html/LinkManifest.h" |
| 48 #include "core/html/imports/LinkImport.h" | 48 #include "core/html/imports/LinkImport.h" |
| 49 #include "core/html/parser/CompactHTMLToken.h" |
| 49 #include "core/loader/FrameLoader.h" | 50 #include "core/loader/FrameLoader.h" |
| 50 #include "core/loader/FrameLoaderClient.h" | 51 #include "core/loader/FrameLoaderClient.h" |
| 51 #include "core/rendering/style/StyleInheritedData.h" | 52 #include "core/rendering/style/StyleInheritedData.h" |
| 52 #include "platform/RuntimeEnabledFeatures.h" | 53 #include "platform/RuntimeEnabledFeatures.h" |
| 53 #include "wtf/StdLibExtras.h" | 54 #include "wtf/StdLibExtras.h" |
| 54 | 55 |
| 55 namespace blink { | 56 namespace blink { |
| 56 | 57 |
| 57 using namespace HTMLNames; | 58 using namespace HTMLNames; |
| 58 | 59 |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 HTMLElement::attributeWillChange(name, oldValue, newValue); | 474 HTMLElement::attributeWillChange(name, oldValue, newValue); |
| 474 } | 475 } |
| 475 | 476 |
| 476 PassOwnPtrWillBeRawPtr<LinkStyle> LinkStyle::create(HTMLLinkElement* owner) | 477 PassOwnPtrWillBeRawPtr<LinkStyle> LinkStyle::create(HTMLLinkElement* owner) |
| 477 { | 478 { |
| 478 return adoptPtrWillBeNoop(new LinkStyle(owner)); | 479 return adoptPtrWillBeNoop(new LinkStyle(owner)); |
| 479 } | 480 } |
| 480 | 481 |
| 481 LinkStyle::LinkStyle(HTMLLinkElement* owner) | 482 LinkStyle::LinkStyle(HTMLLinkElement* owner) |
| 482 : LinkResource(owner) | 483 : LinkResource(owner) |
| 484 , m_token(adoptPtr(new HTMLToken)) |
| 485 , m_tokenizer(HTMLTokenizer::create(m_options)) |
| 486 , m_preloadScanner(adoptPtr(new CSSPreloadScanner)) |
| 487 , m_preloadLength(0) |
| 483 , m_disabledState(Unset) | 488 , m_disabledState(Unset) |
| 484 , m_pendingSheetType(None) | 489 , m_pendingSheetType(None) |
| 485 , m_loading(false) | 490 , m_loading(false) |
| 486 , m_firedLoad(false) | 491 , m_firedLoad(false) |
| 487 , m_loadedSheet(false) | 492 , m_loadedSheet(false) |
| 488 { | 493 { |
| 494 // The tokenizer uses RAWTEXTState to identify the origin of a request. |
| 495 // This state is also used while handling CSS prefetch in the html parser. |
| 496 m_tokenizer->setState(HTMLTokenizer::RAWTEXTState); |
| 489 } | 497 } |
| 490 | 498 |
| 491 LinkStyle::~LinkStyle() | 499 LinkStyle::~LinkStyle() |
| 492 { | 500 { |
| 493 #if !ENABLE(OILPAN) | 501 #if !ENABLE(OILPAN) |
| 494 if (m_sheet) | 502 if (m_sheet) |
| 495 m_sheet->clearOwnerNode(); | 503 m_sheet->clearOwnerNode(); |
| 496 #endif | 504 #endif |
| 497 } | 505 } |
| 498 | 506 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 styleSheet->parseAuthorStyleSheet(cachedStyleSheet, m_owner->document().secu
rityOrigin()); | 555 styleSheet->parseAuthorStyleSheet(cachedStyleSheet, m_owner->document().secu
rityOrigin()); |
| 548 | 556 |
| 549 m_loading = false; | 557 m_loading = false; |
| 550 styleSheet->notifyLoadedSheet(cachedStyleSheet); | 558 styleSheet->notifyLoadedSheet(cachedStyleSheet); |
| 551 styleSheet->checkLoaded(); | 559 styleSheet->checkLoaded(); |
| 552 | 560 |
| 553 if (styleSheet->isCacheable()) | 561 if (styleSheet->isCacheable()) |
| 554 const_cast<CSSStyleSheetResource*>(cachedStyleSheet)->saveParsedStyleShe
et(styleSheet); | 562 const_cast<CSSStyleSheetResource*>(cachedStyleSheet)->saveParsedStyleShe
et(styleSheet); |
| 555 } | 563 } |
| 556 | 564 |
| 565 void LinkStyle::dataReceived(const CSSStyleSheetResource* cachedStyleSheet) |
| 566 { |
| 567 // An absence of preload scanner means we are done with @import statements. |
| 568 if (!m_preloadScanner) |
| 569 return; |
| 570 |
| 571 PreloadRequestStream pendingPreloads; |
| 572 String sheetText = cachedStyleSheet->sheetText(); |
| 573 if (sheetText.length() == m_preloadLength) |
| 574 return; |
| 575 |
| 576 m_input.append(sheetText.substring(m_preloadLength)); |
| 577 |
| 578 while (m_tokenizer->nextToken(m_input.current(), *m_token)) { |
| 579 CompactHTMLToken token(m_token.get(), TextPosition(m_input.current().cur
rentLine(), m_input.current().currentColumn())); |
| 580 |
| 581 m_preloadScanner->scan(token.data(), m_input.current(), pendingPreloads)
; |
| 582 m_token->clear(); |
| 583 } |
| 584 |
| 585 m_preloadLength = sheetText.length(); |
| 586 |
| 587 OwnPtr<HTMLResourcePreloader> preloader = HTMLResourcePreloader::create(docu
ment()); |
| 588 preloader->takeAndPreload(pendingPreloads); |
| 589 if (m_preloadScanner->isDoneParsingImports()) { |
| 590 // Note: Although dataRecieved will be called for each packet of data |
| 591 // returned from the network, @import statements are always at the top |
| 592 // of the CSS file. As soon as we reach a part of the CSS file which |
| 593 // is not an @import we can delete our preloader and ignore the rest of |
| 594 // file. If we ever make CSS preloading more complicated (to look for |
| 595 // URLs other than @imports) we will need to re-think this logic. |
| 596 m_preloadScanner.clear(); |
| 597 m_tokenizer.clear(); |
| 598 m_token.clear(); |
| 599 } |
| 600 } |
| 601 |
| 557 bool LinkStyle::sheetLoaded() | 602 bool LinkStyle::sheetLoaded() |
| 558 { | 603 { |
| 559 if (!styleSheetIsLoading()) { | 604 if (!styleSheetIsLoading()) { |
| 560 removePendingSheet(); | 605 removePendingSheet(); |
| 561 return true; | 606 return true; |
| 562 } | 607 } |
| 563 return false; | 608 return false; |
| 564 } | 609 } |
| 565 | 610 |
| 566 void LinkStyle::notifyLoadedSheetAndAllCriticalSubresources(bool errorOccurred) | 611 void LinkStyle::notifyLoadedSheetAndAllCriticalSubresources(bool errorOccurred) |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 removePendingSheet(); | 796 removePendingSheet(); |
| 752 } | 797 } |
| 753 | 798 |
| 754 void LinkStyle::trace(Visitor* visitor) | 799 void LinkStyle::trace(Visitor* visitor) |
| 755 { | 800 { |
| 756 visitor->trace(m_sheet); | 801 visitor->trace(m_sheet); |
| 757 LinkResource::trace(visitor); | 802 LinkResource::trace(visitor); |
| 758 } | 803 } |
| 759 | 804 |
| 760 } // namespace blink | 805 } // namespace blink |
| OLD | NEW |