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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 { | 358 { |
359 dispatchEvent(Event::create(EventTypeNames::webkitprerenderdomcontentloaded)
); | 359 dispatchEvent(Event::create(EventTypeNames::webkitprerenderdomcontentloaded)
); |
360 } | 360 } |
361 | 361 |
362 bool HTMLLinkElement::sheetLoaded() | 362 bool HTMLLinkElement::sheetLoaded() |
363 { | 363 { |
364 ASSERT(linkStyle()); | 364 ASSERT(linkStyle()); |
365 return linkStyle()->sheetLoaded(); | 365 return linkStyle()->sheetLoaded(); |
366 } | 366 } |
367 | 367 |
368 void HTMLLinkElement::notifyLoadedSheetAndAllCriticalSubresources(bool errorOccu
rred) | 368 void HTMLLinkElement::notifyLoadedSheetAndAllCriticalSubresources(LoadedSheetErr
orStatus errorStatus) |
369 { | 369 { |
370 ASSERT(linkStyle()); | 370 ASSERT(linkStyle()); |
371 linkStyle()->notifyLoadedSheetAndAllCriticalSubresources(errorOccurred); | 371 linkStyle()->notifyLoadedSheetAndAllCriticalSubresources(errorStatus); |
372 } | 372 } |
373 | 373 |
374 void HTMLLinkElement::dispatchPendingLoadEvents() | 374 void HTMLLinkElement::dispatchPendingLoadEvents() |
375 { | 375 { |
376 linkLoadEventSender().dispatchPendingEvents(); | 376 linkLoadEventSender().dispatchPendingEvents(); |
377 } | 377 } |
378 | 378 |
379 void HTMLLinkElement::dispatchPendingEvent(LinkEventSender* eventSender) | 379 void HTMLLinkElement::dispatchPendingEvent(LinkEventSender* eventSender) |
380 { | 380 { |
381 ASSERT_UNUSED(eventSender, eventSender == &linkLoadEventSender()); | 381 ASSERT_UNUSED(eventSender, eventSender == &linkLoadEventSender()); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 void LinkStyle::setCSSStyleSheet(const String& href, const KURL& baseURL, const
String& charset, const CSSStyleSheetResource* cachedStyleSheet) | 509 void LinkStyle::setCSSStyleSheet(const String& href, const KURL& baseURL, const
String& charset, const CSSStyleSheetResource* cachedStyleSheet) |
510 { | 510 { |
511 if (!m_owner->inDocument()) { | 511 if (!m_owner->inDocument()) { |
512 ASSERT(!m_sheet); | 512 ASSERT(!m_sheet); |
513 return; | 513 return; |
514 } | 514 } |
515 | 515 |
516 if (!cachedStyleSheet->errorOccurred() && !SubresourceIntegrity::CheckSubres
ourceIntegrity(*m_owner, cachedStyleSheet->sheetText(), KURL(baseURL, href), cac
hedStyleSheet->mimeType(), *cachedStyleSheet)) { | 516 if (!cachedStyleSheet->errorOccurred() && !SubresourceIntegrity::CheckSubres
ourceIntegrity(*m_owner, cachedStyleSheet->sheetText(), KURL(baseURL, href), cac
hedStyleSheet->mimeType(), *cachedStyleSheet)) { |
517 m_loading = false; | 517 m_loading = false; |
518 removePendingSheet(); | 518 removePendingSheet(); |
519 notifyLoadedSheetAndAllCriticalSubresources(true); | 519 notifyLoadedSheetAndAllCriticalSubresources(Node::ErrorOccurredLoadingSu
bresource); |
520 return; | 520 return; |
521 } | 521 } |
522 | 522 |
523 // Completing the sheet load may cause scripts to execute. | 523 // Completing the sheet load may cause scripts to execute. |
524 RefPtrWillBeRawPtr<Node> protector(m_owner.get()); | 524 RefPtrWillBeRawPtr<Node> protector(m_owner.get()); |
525 | 525 |
526 CSSParserContext parserContext(m_owner->document(), 0, baseURL, charset); | 526 CSSParserContext parserContext(m_owner->document(), 0, baseURL, charset); |
527 | 527 |
528 if (RefPtrWillBeRawPtr<StyleSheetContents> restoredSheet = const_cast<CSSSty
leSheetResource*>(cachedStyleSheet)->restoreParsedStyleSheet(parserContext)) { | 528 if (RefPtrWillBeRawPtr<StyleSheetContents> restoredSheet = const_cast<CSSSty
leSheetResource*>(cachedStyleSheet)->restoreParsedStyleSheet(parserContext)) { |
529 ASSERT(restoredSheet->isCacheable()); | 529 ASSERT(restoredSheet->isCacheable()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 | 563 |
564 bool LinkStyle::sheetLoaded() | 564 bool LinkStyle::sheetLoaded() |
565 { | 565 { |
566 if (!styleSheetIsLoading()) { | 566 if (!styleSheetIsLoading()) { |
567 removePendingSheet(); | 567 removePendingSheet(); |
568 return true; | 568 return true; |
569 } | 569 } |
570 return false; | 570 return false; |
571 } | 571 } |
572 | 572 |
573 void LinkStyle::notifyLoadedSheetAndAllCriticalSubresources(bool errorOccurred) | 573 void LinkStyle::notifyLoadedSheetAndAllCriticalSubresources(Node::LoadedSheetErr
orStatus errorStatus) |
574 { | 574 { |
575 if (m_firedLoad) | 575 if (m_firedLoad) |
576 return; | 576 return; |
577 m_loadedSheet = !errorOccurred; | 577 m_loadedSheet = (errorStatus == Node::NoErrorLoadingSubresource); |
578 if (m_owner) | 578 if (m_owner) |
579 m_owner->scheduleEvent(); | 579 m_owner->scheduleEvent(); |
580 m_firedLoad = true; | 580 m_firedLoad = true; |
581 } | 581 } |
582 | 582 |
583 void LinkStyle::startLoadingDynamicSheet() | 583 void LinkStyle::startLoadingDynamicSheet() |
584 { | 584 { |
585 ASSERT(m_pendingSheetType < Blocking); | 585 ASSERT(m_pendingSheetType < Blocking); |
586 addPendingSheet(Blocking); | 586 addPendingSheet(Blocking); |
587 } | 587 } |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 // Load stylesheets that are not needed for the rendering immediately wi
th low priority. | 736 // Load stylesheets that are not needed for the rendering immediately wi
th low priority. |
737 FetchRequest request = builder.build(blocking); | 737 FetchRequest request = builder.build(blocking); |
738 AtomicString crossOriginMode = m_owner->fastGetAttribute(HTMLNames::cros
soriginAttr); | 738 AtomicString crossOriginMode = m_owner->fastGetAttribute(HTMLNames::cros
soriginAttr); |
739 if (!crossOriginMode.isNull()) { | 739 if (!crossOriginMode.isNull()) { |
740 request.setCrossOriginAccessControl(document().securityOrigin(), cro
ssOriginMode); | 740 request.setCrossOriginAccessControl(document().securityOrigin(), cro
ssOriginMode); |
741 setFetchFollowingCORS(); | 741 setFetchFollowingCORS(); |
742 } | 742 } |
743 setResource(document().fetcher()->fetchCSSStyleSheet(request)); | 743 setResource(document().fetcher()->fetchCSSStyleSheet(request)); |
744 | 744 |
745 if (!resource()) { | 745 if (!resource()) { |
746 // The request may have been denied if (for example) the stylesheet
is local and the document is remote. | 746 // The request may have been denied if (for example) the stylesheet
is local and the document is remote, or if there was a Content Security Policy F
ailure. |
747 m_loading = false; | 747 m_loading = false; |
748 removePendingSheet(); | 748 removePendingSheet(); |
| 749 notifyLoadedSheetAndAllCriticalSubresources(Node::ErrorOccurredLoadi
ngSubresource); |
749 } | 750 } |
750 } else if (m_sheet) { | 751 } else if (m_sheet) { |
751 // we no longer contain a stylesheet, e.g. perhaps rel or type was chang
ed | 752 // we no longer contain a stylesheet, e.g. perhaps rel or type was chang
ed |
752 RefPtrWillBeRawPtr<StyleSheet> removedSheet = m_sheet.get(); | 753 RefPtrWillBeRawPtr<StyleSheet> removedSheet = m_sheet.get(); |
753 clearSheet(); | 754 clearSheet(); |
754 document().removedStyleSheet(removedSheet.get()); | 755 document().removedStyleSheet(removedSheet.get()); |
755 } | 756 } |
756 } | 757 } |
757 | 758 |
758 void LinkStyle::setSheetTitle(const String& title) | 759 void LinkStyle::setSheetTitle(const String& title) |
(...skipping 11 matching lines...) Expand all Loading... |
770 removePendingSheet(); | 771 removePendingSheet(); |
771 } | 772 } |
772 | 773 |
773 DEFINE_TRACE(LinkStyle) | 774 DEFINE_TRACE(LinkStyle) |
774 { | 775 { |
775 visitor->trace(m_sheet); | 776 visitor->trace(m_sheet); |
776 LinkResource::trace(visitor); | 777 LinkResource::trace(visitor); |
777 } | 778 } |
778 | 779 |
779 } // namespace blink | 780 } // namespace blink |
OLD | NEW |