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 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 RefPtrWillBeRawPtr<StyleSheetContents> styleSheet = StyleSheetContents::crea
te(href, parserContext); | 563 RefPtrWillBeRawPtr<StyleSheetContents> styleSheet = StyleSheetContents::crea
te(href, parserContext); |
564 | 564 |
565 if (m_sheet) | 565 if (m_sheet) |
566 clearSheet(); | 566 clearSheet(); |
567 | 567 |
568 m_sheet = CSSStyleSheet::create(styleSheet, m_owner); | 568 m_sheet = CSSStyleSheet::create(styleSheet, m_owner); |
569 m_sheet->setMediaQueries(MediaQuerySet::create(m_owner->media())); | 569 m_sheet->setMediaQueries(MediaQuerySet::create(m_owner->media())); |
570 m_sheet->setTitle(m_owner->title()); | 570 m_sheet->setTitle(m_owner->title()); |
571 setCrossOriginStylesheetStatus(m_sheet.get()); | 571 setCrossOriginStylesheetStatus(m_sheet.get()); |
572 | 572 |
573 styleSheet->parseAuthorStyleSheet(cachedStyleSheet, m_owner->document().secu
rityOrigin()); | 573 styleSheet->parseAuthorStyleSheet(cachedStyleSheet, m_owner->document().getS
ecurityOrigin()); |
574 | 574 |
575 m_loading = false; | 575 m_loading = false; |
576 styleSheet->notifyLoadedSheet(cachedStyleSheet); | 576 styleSheet->notifyLoadedSheet(cachedStyleSheet); |
577 styleSheet->checkLoaded(); | 577 styleSheet->checkLoaded(); |
578 | 578 |
579 if (styleSheet->isCacheable()) | 579 if (styleSheet->isCacheable()) |
580 const_cast<CSSStyleSheetResource*>(cachedStyleSheet)->saveParsedStyleShe
et(styleSheet); | 580 const_cast<CSSStyleSheetResource*>(cachedStyleSheet)->saveParsedStyleShe
et(styleSheet); |
581 clearResource(); | 581 clearResource(); |
582 } | 582 } |
583 | 583 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 if (m_disabledState == EnabledViaScript && m_owner->shouldProcessStyle()
) | 685 if (m_disabledState == EnabledViaScript && m_owner->shouldProcessStyle()
) |
686 process(); | 686 process(); |
687 } | 687 } |
688 } | 688 } |
689 | 689 |
690 void LinkStyle::setCrossOriginStylesheetStatus(CSSStyleSheet* sheet) | 690 void LinkStyle::setCrossOriginStylesheetStatus(CSSStyleSheet* sheet) |
691 { | 691 { |
692 if (m_fetchFollowingCORS && resource() && !resource()->errorOccurred()) { | 692 if (m_fetchFollowingCORS && resource() && !resource()->errorOccurred()) { |
693 // Record the security origin the CORS access check succeeded at, if cro
ss origin. | 693 // Record the security origin the CORS access check succeeded at, if cro
ss origin. |
694 // Only origins that are script accessible to it may access the styleshe
et's rules. | 694 // Only origins that are script accessible to it may access the styleshe
et's rules. |
695 sheet->setAllowRuleAccessFromOrigin(m_owner->document().securityOrigin()
); | 695 sheet->setAllowRuleAccessFromOrigin(m_owner->document().getSecurityOrigi
n()); |
696 } | 696 } |
697 m_fetchFollowingCORS = false; | 697 m_fetchFollowingCORS = false; |
698 } | 698 } |
699 | 699 |
700 void LinkStyle::process() | 700 void LinkStyle::process() |
701 { | 701 { |
702 ASSERT(m_owner->shouldProcessStyle()); | 702 ASSERT(m_owner->shouldProcessStyle()); |
703 String type = m_owner->typeValue().lower(); | 703 String type = m_owner->typeValue().lower(); |
704 String as = m_owner->asValue().lower(); | 704 String as = m_owner->asValue().lower(); |
705 LinkRequestBuilder builder(m_owner); | 705 LinkRequestBuilder builder(m_owner); |
706 | 706 |
707 if (m_owner->relAttribute().getIconType() != InvalidIcon && builder.url().is
Valid() && !builder.url().isEmpty()) { | 707 if (m_owner->relAttribute().getIconType() != InvalidIcon && builder.url().is
Valid() && !builder.url().isEmpty()) { |
708 if (!m_owner->shouldLoadLink()) | 708 if (!m_owner->shouldLoadLink()) |
709 return; | 709 return; |
710 if (!document().securityOrigin()->canDisplay(builder.url())) | 710 if (!document().getSecurityOrigin()->canDisplay(builder.url())) |
711 return; | 711 return; |
712 if (!document().contentSecurityPolicy()->allowImageFromSource(builder.ur
l())) | 712 if (!document().contentSecurityPolicy()->allowImageFromSource(builder.ur
l())) |
713 return; | 713 return; |
714 if (document().frame() && document().frame()->loader().client()) | 714 if (document().frame() && document().frame()->loader().client()) |
715 document().frame()->loader().client()->dispatchDidChangeIcons(m_owne
r->relAttribute().getIconType()); | 715 document().frame()->loader().client()->dispatchDidChangeIcons(m_owne
r->relAttribute().getIconType()); |
716 } | 716 } |
717 | 717 |
718 if (!m_owner->loadLink(type, as, builder.url())) | 718 if (!m_owner->loadLink(type, as, builder.url())) |
719 return; | 719 return; |
720 | 720 |
(...skipping 22 matching lines...) Expand all Loading... |
743 // that are not needed for the layout at the moment. | 743 // that are not needed for the layout at the moment. |
744 bool blocking = mediaQueryMatches && !m_owner->isAlternate() && m_owner-
>isCreatedByParser(); | 744 bool blocking = mediaQueryMatches && !m_owner->isAlternate() && m_owner-
>isCreatedByParser(); |
745 addPendingSheet(blocking ? Blocking : NonBlocking); | 745 addPendingSheet(blocking ? Blocking : NonBlocking); |
746 | 746 |
747 // Load stylesheets that are not needed for the layout immediately with
low priority. | 747 // Load stylesheets that are not needed for the layout immediately with
low priority. |
748 // When the link element is created by scripts, load the stylesheets asy
nchronously but in high priority. | 748 // When the link element is created by scripts, load the stylesheets asy
nchronously but in high priority. |
749 bool lowPriority = !mediaQueryMatches || m_owner->isAlternate(); | 749 bool lowPriority = !mediaQueryMatches || m_owner->isAlternate(); |
750 FetchRequest request = builder.build(lowPriority); | 750 FetchRequest request = builder.build(lowPriority); |
751 CrossOriginAttributeValue crossOrigin = crossOriginAttributeValue(m_owne
r->fastGetAttribute(HTMLNames::crossoriginAttr)); | 751 CrossOriginAttributeValue crossOrigin = crossOriginAttributeValue(m_owne
r->fastGetAttribute(HTMLNames::crossoriginAttr)); |
752 if (crossOrigin != CrossOriginAttributeNotSet) { | 752 if (crossOrigin != CrossOriginAttributeNotSet) { |
753 request.setCrossOriginAccessControl(document().securityOrigin(), cro
ssOrigin); | 753 request.setCrossOriginAccessControl(document().getSecurityOrigin(),
crossOrigin); |
754 setFetchFollowingCORS(); | 754 setFetchFollowingCORS(); |
755 } | 755 } |
756 setResource(CSSStyleSheetResource::fetch(request, document().fetcher()))
; | 756 setResource(CSSStyleSheetResource::fetch(request, document().fetcher()))
; |
757 | 757 |
758 if (m_loading && !resource()) { | 758 if (m_loading && !resource()) { |
759 // 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. | 759 // 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. |
760 // setCSSStyleSheet() can be called synchronuosly in setResource() a
nd thus resource() is null and |m_loading| is false in such cases even if the re
quest succeeds. | 760 // setCSSStyleSheet() can be called synchronuosly in setResource() a
nd thus resource() is null and |m_loading| is false in such cases even if the re
quest succeeds. |
761 m_loading = false; | 761 m_loading = false; |
762 removePendingSheet(); | 762 removePendingSheet(); |
763 notifyLoadedSheetAndAllCriticalSubresources(Node::ErrorOccurredLoadi
ngSubresource); | 763 notifyLoadedSheetAndAllCriticalSubresources(Node::ErrorOccurredLoadi
ngSubresource); |
(...skipping 22 matching lines...) Expand all Loading... |
786 } | 786 } |
787 | 787 |
788 DEFINE_TRACE(LinkStyle) | 788 DEFINE_TRACE(LinkStyle) |
789 { | 789 { |
790 visitor->trace(m_sheet); | 790 visitor->trace(m_sheet); |
791 LinkResource::trace(visitor); | 791 LinkResource::trace(visitor); |
792 ResourceOwner<StyleSheetResource>::trace(visitor); | 792 ResourceOwner<StyleSheetResource>::trace(visitor); |
793 } | 793 } |
794 | 794 |
795 } // namespace blink | 795 } // namespace blink |
OLD | NEW |