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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // Log href attribute before logging resource fetching in process(). | 96 // Log href attribute before logging resource fetching in process(). |
97 logUpdateAttributeIfIsolatedWorldAndInDocument("link", hrefAttr, oldValue, | 97 logUpdateAttributeIfIsolatedWorldAndInDocument("link", hrefAttr, oldValue, |
98 value); | 98 value); |
99 process(); | 99 process(); |
100 } else if (name == typeAttr) { | 100 } else if (name == typeAttr) { |
101 m_type = value; | 101 m_type = value; |
102 process(); | 102 process(); |
103 } else if (name == asAttr) { | 103 } else if (name == asAttr) { |
104 m_as = value; | 104 m_as = value; |
105 process(); | 105 process(); |
| 106 } else if (name == referrerpolicyAttr) { |
| 107 m_referrerPolicy = value; |
106 } else if (name == sizesAttr) { | 108 } else if (name == sizesAttr) { |
107 m_sizes->setValue(value); | 109 m_sizes->setValue(value); |
108 } else if (name == mediaAttr) { | 110 } else if (name == mediaAttr) { |
109 m_media = value.lower(); | 111 m_media = value.lower(); |
110 process(); | 112 process(); |
111 } else if (name == scopeAttr) { | 113 } else if (name == scopeAttr) { |
112 m_scope = value; | 114 m_scope = value; |
113 process(); | 115 process(); |
114 } else if (name == disabledAttr) { | 116 } else if (name == disabledAttr) { |
115 UseCounter::count(document(), UseCounter::HTMLLinkElementDisabled); | 117 UseCounter::count(document(), UseCounter::HTMLLinkElementDisabled); |
116 if (LinkStyle* link = linkStyle()) | 118 if (LinkStyle* link = linkStyle()) |
117 link->setDisabledState(!value.isNull()); | 119 link->setDisabledState(!value.isNull()); |
118 } else { | 120 } else { |
119 if (name == titleAttr) { | 121 if (name == titleAttr) { |
120 if (LinkStyle* link = linkStyle()) | 122 if (LinkStyle* link = linkStyle()) |
121 link->setSheetTitle(value, StyleEngine::UpdateActiveSheets); | 123 link->setSheetTitle(value, StyleEngine::UpdateActiveSheets); |
122 } | 124 } |
123 | 125 |
124 HTMLElement::parseAttribute(name, oldValue, value); | 126 HTMLElement::parseAttribute(name, oldValue, value); |
125 } | 127 } |
126 } | 128 } |
127 | 129 |
128 bool HTMLLinkElement::shouldLoadLink() { | 130 bool HTMLLinkElement::shouldLoadLink() { |
129 return isInDocumentTree() || (isConnected() && m_relAttribute.isStyleSheet()); | 131 return isInDocumentTree() || (isConnected() && m_relAttribute.isStyleSheet()); |
130 } | 132 } |
131 | 133 |
132 bool HTMLLinkElement::loadLink(const String& type, | 134 bool HTMLLinkElement::loadLink(const String& type, |
133 const String& as, | 135 const String& as, |
134 const String& media, | 136 const String& media, |
| 137 const String& referrerPolicy, |
135 const KURL& url) { | 138 const KURL& url) { |
136 return m_linkLoader->loadLink( | 139 return m_linkLoader->loadLink( |
137 m_relAttribute, | 140 m_relAttribute, |
138 crossOriginAttributeValue(fastGetAttribute(HTMLNames::crossoriginAttr)), | 141 crossOriginAttributeValue(fastGetAttribute(HTMLNames::crossoriginAttr)), |
139 type, as, media, url, document(), NetworkHintsInterfaceImpl()); | 142 type, as, media, referrerPolicy, url, document(), |
| 143 NetworkHintsInterfaceImpl()); |
140 } | 144 } |
141 | 145 |
142 LinkResource* HTMLLinkElement::linkResourceToProcess() { | 146 LinkResource* HTMLLinkElement::linkResourceToProcess() { |
143 if (!shouldLoadLink()) { | 147 if (!shouldLoadLink()) { |
144 DCHECK(!linkStyle() || !linkStyle()->hasSheet()); | 148 DCHECK(!linkStyle() || !linkStyle()->hasSheet()); |
145 return nullptr; | 149 return nullptr; |
146 } | 150 } |
147 | 151 |
148 if (!m_link) { | 152 if (!m_link) { |
149 if (m_relAttribute.isImport()) { | 153 if (m_relAttribute.isImport()) { |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 m_owner->document().getSecurityOrigin()); | 615 m_owner->document().getSecurityOrigin()); |
612 } | 616 } |
613 m_fetchFollowingCORS = false; | 617 m_fetchFollowingCORS = false; |
614 } | 618 } |
615 | 619 |
616 void LinkStyle::process() { | 620 void LinkStyle::process() { |
617 DCHECK(m_owner->shouldProcessStyle()); | 621 DCHECK(m_owner->shouldProcessStyle()); |
618 String type = m_owner->typeValue().lower(); | 622 String type = m_owner->typeValue().lower(); |
619 String as = m_owner->asValue().lower(); | 623 String as = m_owner->asValue().lower(); |
620 String media = m_owner->media().lower(); | 624 String media = m_owner->media().lower(); |
| 625 String referrerPolicy = m_owner->referrerPolicy().lower(); |
621 LinkRequestBuilder builder(m_owner); | 626 LinkRequestBuilder builder(m_owner); |
622 | 627 |
623 if (m_owner->relAttribute().getIconType() != InvalidIcon && | 628 if (m_owner->relAttribute().getIconType() != InvalidIcon && |
624 builder.url().isValid() && !builder.url().isEmpty()) { | 629 builder.url().isValid() && !builder.url().isEmpty()) { |
625 if (!m_owner->shouldLoadLink()) | 630 if (!m_owner->shouldLoadLink()) |
626 return; | 631 return; |
627 if (!document().getSecurityOrigin()->canDisplay(builder.url())) | 632 if (!document().getSecurityOrigin()->canDisplay(builder.url())) |
628 return; | 633 return; |
629 if (!document().contentSecurityPolicy()->allowImageFromSource( | 634 if (!document().contentSecurityPolicy()->allowImageFromSource( |
630 builder.url())) | 635 builder.url())) |
631 return; | 636 return; |
632 if (document().frame() && document().frame()->loader().client()) | 637 if (document().frame() && document().frame()->loader().client()) |
633 document().frame()->loader().client()->dispatchDidChangeIcons( | 638 document().frame()->loader().client()->dispatchDidChangeIcons( |
634 m_owner->relAttribute().getIconType()); | 639 m_owner->relAttribute().getIconType()); |
635 } | 640 } |
636 | 641 |
637 if (!m_owner->loadLink(type, as, media, builder.url())) | 642 if (!m_owner->loadLink(type, as, media, referrerPolicy, builder.url())) |
638 return; | 643 return; |
639 | 644 |
640 if (m_disabledState != Disabled && m_owner->relAttribute().isStyleSheet() && | 645 if (m_disabledState != Disabled && m_owner->relAttribute().isStyleSheet() && |
641 styleSheetTypeIsSupported(type) && shouldLoadResource() && | 646 styleSheetTypeIsSupported(type) && shouldLoadResource() && |
642 builder.url().isValid()) { | 647 builder.url().isValid()) { |
643 if (resource()) { | 648 if (resource()) { |
644 removePendingSheet(); | 649 removePendingSheet(); |
645 clearResource(); | 650 clearResource(); |
646 clearFetchFollowingCORS(); | 651 clearFetchFollowingCORS(); |
647 } | 652 } |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 removePendingSheet(); | 739 removePendingSheet(); |
735 } | 740 } |
736 | 741 |
737 DEFINE_TRACE(LinkStyle) { | 742 DEFINE_TRACE(LinkStyle) { |
738 visitor->trace(m_sheet); | 743 visitor->trace(m_sheet); |
739 LinkResource::trace(visitor); | 744 LinkResource::trace(visitor); |
740 ResourceOwner<StyleSheetResource>::trace(visitor); | 745 ResourceOwner<StyleSheetResource>::trace(visitor); |
741 } | 746 } |
742 | 747 |
743 } // namespace blink | 748 } // namespace blink |
OLD | NEW |