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

Side by Side Diff: Source/core/html/HTMLLinkElement.cpp

Issue 1060863003: Add initial link preload support (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix uninit member :/ Created 5 years, 8 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
« no previous file with comments | « Source/core/html/HTMLLinkElement.h ('k') | Source/core/html/LinkRelAttribute.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 void HTMLLinkElement::parseAttribute(const QualifiedName& name, const AtomicStri ng& value) 165 void HTMLLinkElement::parseAttribute(const QualifiedName& name, const AtomicStri ng& value)
166 { 166 {
167 if (name == relAttr) { 167 if (name == relAttr) {
168 m_relAttribute = LinkRelAttribute(value); 168 m_relAttribute = LinkRelAttribute(value);
169 process(); 169 process();
170 } else if (name == hrefAttr) { 170 } else if (name == hrefAttr) {
171 process(); 171 process();
172 } else if (name == typeAttr) { 172 } else if (name == typeAttr) {
173 m_type = value; 173 m_type = value;
174 process(); 174 process();
175 } else if (name == asAttr) {
176 m_as = value;
177 process();
175 } else if (name == sizesAttr) { 178 } else if (name == sizesAttr) {
176 m_sizes->setValue(value); 179 m_sizes->setValue(value);
177 parseSizesAttribute(value, m_iconSizes); 180 parseSizesAttribute(value, m_iconSizes);
178 process(); 181 process();
179 } else if (name == mediaAttr) { 182 } else if (name == mediaAttr) {
180 m_media = value.lower(); 183 m_media = value.lower();
181 process(); 184 process();
182 } else if (name == disabledAttr) { 185 } else if (name == disabledAttr) {
183 if (LinkStyle* link = linkStyle()) 186 if (LinkStyle* link = linkStyle())
184 link->setDisabledState(!value.isNull()); 187 link->setDisabledState(!value.isNull());
185 } else { 188 } else {
186 if (name == titleAttr) { 189 if (name == titleAttr) {
187 if (LinkStyle* link = linkStyle()) 190 if (LinkStyle* link = linkStyle())
188 link->setSheetTitle(value); 191 link->setSheetTitle(value);
189 } 192 }
190 193
191 HTMLElement::parseAttribute(name, value); 194 HTMLElement::parseAttribute(name, value);
192 } 195 }
193 } 196 }
194 197
195 bool HTMLLinkElement::shouldLoadLink() 198 bool HTMLLinkElement::shouldLoadLink()
196 { 199 {
197 return inDocument(); 200 return inDocument();
198 } 201 }
199 202
200 bool HTMLLinkElement::loadLink(const String& type, const KURL& url) 203 bool HTMLLinkElement::loadLink(const String& type, const String& as, const KURL& url)
201 { 204 {
202 return m_linkLoader.loadLink(m_relAttribute, fastGetAttribute(HTMLNames::cro ssoriginAttr), type, url, document()); 205 return m_linkLoader.loadLink(m_relAttribute, fastGetAttribute(HTMLNames::cro ssoriginAttr), type, as, url, document());
203 } 206 }
204 207
205 LinkResource* HTMLLinkElement::linkResourceToProcess() 208 LinkResource* HTMLLinkElement::linkResourceToProcess()
206 { 209 {
207 bool visible = inDocument() && !m_isInShadowTree; 210 bool visible = inDocument() && !m_isInShadowTree;
208 if (!visible) { 211 if (!visible) {
209 ASSERT(!linkStyle() || !linkStyle()->hasSheet()); 212 ASSERT(!linkStyle() || !linkStyle()->hasSheet());
210 return nullptr; 213 return nullptr;
211 } 214 }
212 215
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 // Only origins that are script accessible to it may access the styleshe et's rules. 686 // Only origins that are script accessible to it may access the styleshe et's rules.
684 sheet->setAllowRuleAccessFromOrigin(m_owner->document().securityOrigin() ); 687 sheet->setAllowRuleAccessFromOrigin(m_owner->document().securityOrigin() );
685 } 688 }
686 m_fetchFollowingCORS = false; 689 m_fetchFollowingCORS = false;
687 } 690 }
688 691
689 void LinkStyle::process() 692 void LinkStyle::process()
690 { 693 {
691 ASSERT(m_owner->shouldProcessStyle()); 694 ASSERT(m_owner->shouldProcessStyle());
692 String type = m_owner->typeValue().lower(); 695 String type = m_owner->typeValue().lower();
696 String as = m_owner->asValue().lower();
693 LinkRequestBuilder builder(m_owner); 697 LinkRequestBuilder builder(m_owner);
694 698
695 if (m_owner->relAttribute().iconType() != InvalidIcon && builder.url().isVal id() && !builder.url().isEmpty()) { 699 if (m_owner->relAttribute().iconType() != InvalidIcon && builder.url().isVal id() && !builder.url().isEmpty()) {
696 if (!m_owner->shouldLoadLink()) 700 if (!m_owner->shouldLoadLink())
697 return; 701 return;
698 if (!document().securityOrigin()->canDisplay(builder.url())) 702 if (!document().securityOrigin()->canDisplay(builder.url()))
699 return; 703 return;
700 if (!document().contentSecurityPolicy()->allowImageFromSource(builder.ur l())) 704 if (!document().contentSecurityPolicy()->allowImageFromSource(builder.ur l()))
701 return; 705 return;
702 if (document().frame() && document().frame()->loader().client()) 706 if (document().frame() && document().frame()->loader().client())
703 document().frame()->loader().client()->dispatchDidChangeIcons(m_owne r->relAttribute().iconType()); 707 document().frame()->loader().client()->dispatchDidChangeIcons(m_owne r->relAttribute().iconType());
704 } 708 }
705 709
706 if (!m_owner->loadLink(type, builder.url())) 710 if (!m_owner->loadLink(type, as, builder.url()))
707 return; 711 return;
708 712
709 if ((m_disabledState != Disabled) && (m_owner->relAttribute().isStyleSheet() || m_owner->relAttribute().isTransitionExitingStylesheet()) 713 if ((m_disabledState != Disabled) && (m_owner->relAttribute().isStyleSheet() || m_owner->relAttribute().isTransitionExitingStylesheet())
710 && shouldLoadResource() && builder.url().isValid()) { 714 && shouldLoadResource() && builder.url().isValid()) {
711 715
712 if (resource()) { 716 if (resource()) {
713 removePendingSheet(); 717 removePendingSheet();
714 clearResource(); 718 clearResource();
715 } 719 }
716 720
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 removePendingSheet(); 775 removePendingSheet();
772 } 776 }
773 777
774 DEFINE_TRACE(LinkStyle) 778 DEFINE_TRACE(LinkStyle)
775 { 779 {
776 visitor->trace(m_sheet); 780 visitor->trace(m_sheet);
777 LinkResource::trace(visitor); 781 LinkResource::trace(visitor);
778 } 782 }
779 783
780 } // namespace blink 784 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/html/HTMLLinkElement.h ('k') | Source/core/html/LinkRelAttribute.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698