| 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 { | 159 { |
| 160 return new HTMLLinkElement(document, createdByParser); | 160 return new HTMLLinkElement(document, createdByParser); |
| 161 } | 161 } |
| 162 | 162 |
| 163 HTMLLinkElement::~HTMLLinkElement() | 163 HTMLLinkElement::~HTMLLinkElement() |
| 164 { | 164 { |
| 165 #if !ENABLE(OILPAN) | 165 #if !ENABLE(OILPAN) |
| 166 m_sizes->setObserver(nullptr); | 166 m_sizes->setObserver(nullptr); |
| 167 m_relList->setObserver(nullptr); | 167 m_relList->setObserver(nullptr); |
| 168 m_link.clear(); | 168 m_link.clear(); |
| 169 if (inDocument()) | 169 if (inShadowIncludingDocument()) |
| 170 document().styleEngine().removeStyleSheetCandidateNode(this); | 170 document().styleEngine().removeStyleSheetCandidateNode(this); |
| 171 linkLoadEventSender().cancelEvent(this); | 171 linkLoadEventSender().cancelEvent(this); |
| 172 #endif | 172 #endif |
| 173 } | 173 } |
| 174 | 174 |
| 175 void HTMLLinkElement::parseAttribute(const QualifiedName& name, const AtomicStri
ng& oldValue, const AtomicString& value) | 175 void HTMLLinkElement::parseAttribute(const QualifiedName& name, const AtomicStri
ng& oldValue, const AtomicString& value) |
| 176 { | 176 { |
| 177 if (name == relAttr) { | 177 if (name == relAttr) { |
| 178 m_relAttribute = LinkRelAttribute(value); | 178 m_relAttribute = LinkRelAttribute(value); |
| 179 m_relList->setRelValues(value); | 179 m_relList->setRelValues(value); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 205 if (LinkStyle* link = linkStyle()) | 205 if (LinkStyle* link = linkStyle()) |
| 206 link->setSheetTitle(value); | 206 link->setSheetTitle(value); |
| 207 } | 207 } |
| 208 | 208 |
| 209 HTMLElement::parseAttribute(name, oldValue, value); | 209 HTMLElement::parseAttribute(name, oldValue, value); |
| 210 } | 210 } |
| 211 } | 211 } |
| 212 | 212 |
| 213 bool HTMLLinkElement::shouldLoadLink() | 213 bool HTMLLinkElement::shouldLoadLink() |
| 214 { | 214 { |
| 215 return inDocument(); | 215 return inShadowIncludingDocument(); |
| 216 } | 216 } |
| 217 | 217 |
| 218 bool HTMLLinkElement::loadLink(const String& type, const String& as, const Strin
g& media, const KURL& url) | 218 bool HTMLLinkElement::loadLink(const String& type, const String& as, const Strin
g& media, const KURL& url) |
| 219 { | 219 { |
| 220 return m_linkLoader->loadLink(m_relAttribute, crossOriginAttributeValue(fast
GetAttribute(HTMLNames::crossoriginAttr)), type, as, media, url, document(), Net
workHintsInterfaceImpl()); | 220 return m_linkLoader->loadLink(m_relAttribute, crossOriginAttributeValue(fast
GetAttribute(HTMLNames::crossoriginAttr)), type, as, media, url, document(), Net
workHintsInterfaceImpl()); |
| 221 } | 221 } |
| 222 | 222 |
| 223 LinkResource* HTMLLinkElement::linkResourceToProcess() | 223 LinkResource* HTMLLinkElement::linkResourceToProcess() |
| 224 { | 224 { |
| 225 bool visible = inDocument() && !m_isInShadowTree; | 225 bool visible = inShadowIncludingDocument() && !m_isInShadowTree; |
| 226 if (!visible) { | 226 if (!visible) { |
| 227 ASSERT(!linkStyle() || !linkStyle()->hasSheet()); | 227 ASSERT(!linkStyle() || !linkStyle()->hasSheet()); |
| 228 return nullptr; | 228 return nullptr; |
| 229 } | 229 } |
| 230 | 230 |
| 231 if (!m_link) { | 231 if (!m_link) { |
| 232 if (m_relAttribute.isImport()) { | 232 if (m_relAttribute.isImport()) { |
| 233 m_link = LinkImport::create(this); | 233 m_link = LinkImport::create(this); |
| 234 } else if (m_relAttribute.isManifest()) { | 234 } else if (m_relAttribute.isManifest()) { |
| 235 m_link = LinkManifest::create(this); | 235 m_link = LinkManifest::create(this); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 void HTMLLinkElement::process() | 273 void HTMLLinkElement::process() |
| 274 { | 274 { |
| 275 if (LinkResource* link = linkResourceToProcess()) | 275 if (LinkResource* link = linkResourceToProcess()) |
| 276 link->process(); | 276 link->process(); |
| 277 } | 277 } |
| 278 | 278 |
| 279 Node::InsertionNotificationRequest HTMLLinkElement::insertedInto(ContainerNode*
insertionPoint) | 279 Node::InsertionNotificationRequest HTMLLinkElement::insertedInto(ContainerNode*
insertionPoint) |
| 280 { | 280 { |
| 281 HTMLElement::insertedInto(insertionPoint); | 281 HTMLElement::insertedInto(insertionPoint); |
| 282 logAddElementIfIsolatedWorldAndInDocument("link", relAttr, hrefAttr); | 282 logAddElementIfIsolatedWorldAndInDocument("link", relAttr, hrefAttr); |
| 283 if (!insertionPoint->inDocument()) | 283 if (!insertionPoint->inShadowIncludingDocument()) |
| 284 return InsertionDone; | 284 return InsertionDone; |
| 285 | 285 |
| 286 m_isInShadowTree = isInShadowTree(); | 286 m_isInShadowTree = isInShadowTree(); |
| 287 if (m_isInShadowTree) { | 287 if (m_isInShadowTree) { |
| 288 String message = "HTML element <link> is ignored in shadow tree."; | 288 String message = "HTML element <link> is ignored in shadow tree."; |
| 289 document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, War
ningMessageLevel, message)); | 289 document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, War
ningMessageLevel, message)); |
| 290 return InsertionDone; | 290 return InsertionDone; |
| 291 } | 291 } |
| 292 | 292 |
| 293 document().styleEngine().addStyleSheetCandidateNode(this); | 293 document().styleEngine().addStyleSheetCandidateNode(this); |
| 294 | 294 |
| 295 process(); | 295 process(); |
| 296 | 296 |
| 297 if (m_link) | 297 if (m_link) |
| 298 m_link->ownerInserted(); | 298 m_link->ownerInserted(); |
| 299 | 299 |
| 300 return InsertionDone; | 300 return InsertionDone; |
| 301 } | 301 } |
| 302 | 302 |
| 303 void HTMLLinkElement::removedFrom(ContainerNode* insertionPoint) | 303 void HTMLLinkElement::removedFrom(ContainerNode* insertionPoint) |
| 304 { | 304 { |
| 305 HTMLElement::removedFrom(insertionPoint); | 305 HTMLElement::removedFrom(insertionPoint); |
| 306 if (!insertionPoint->inDocument()) | 306 if (!insertionPoint->inShadowIncludingDocument()) |
| 307 return; | 307 return; |
| 308 | 308 |
| 309 m_linkLoader->released(); | 309 m_linkLoader->released(); |
| 310 | 310 |
| 311 if (m_isInShadowTree) { | 311 if (m_isInShadowTree) { |
| 312 ASSERT(!linkStyle() || !linkStyle()->hasSheet()); | 312 ASSERT(!linkStyle() || !linkStyle()->hasSheet()); |
| 313 return; | 313 return; |
| 314 } | 314 } |
| 315 document().styleEngine().removeStyleSheetCandidateNode(this); | 315 document().styleEngine().removeStyleSheetCandidateNode(this); |
| 316 | 316 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 | 507 |
| 508 enum StyleSheetCacheStatus { | 508 enum StyleSheetCacheStatus { |
| 509 StyleSheetNewEntry, | 509 StyleSheetNewEntry, |
| 510 StyleSheetInDiskCache, | 510 StyleSheetInDiskCache, |
| 511 StyleSheetInMemoryCache, | 511 StyleSheetInMemoryCache, |
| 512 StyleSheetCacheStatusCount, | 512 StyleSheetCacheStatusCount, |
| 513 }; | 513 }; |
| 514 | 514 |
| 515 void LinkStyle::setCSSStyleSheet(const String& href, const KURL& baseURL, const
String& charset, const CSSStyleSheetResource* cachedStyleSheet) | 515 void LinkStyle::setCSSStyleSheet(const String& href, const KURL& baseURL, const
String& charset, const CSSStyleSheetResource* cachedStyleSheet) |
| 516 { | 516 { |
| 517 if (!m_owner->inDocument()) { | 517 if (!m_owner->inShadowIncludingDocument()) { |
| 518 ASSERT(!m_sheet); | 518 ASSERT(!m_sheet); |
| 519 return; | 519 return; |
| 520 } | 520 } |
| 521 | 521 |
| 522 // See the comment in PendingScript.cpp about why this check is necessary | 522 // See the comment in PendingScript.cpp about why this check is necessary |
| 523 // here, instead of in the resource fetcher. https://crbug.com/500701. | 523 // here, instead of in the resource fetcher. https://crbug.com/500701. |
| 524 if (!cachedStyleSheet->errorOccurred() && m_owner->fastHasAttribute(HTMLName
s::integrityAttr) && cachedStyleSheet->resourceBuffer() && !SubresourceIntegrity
::CheckSubresourceIntegrity(*m_owner, cachedStyleSheet->resourceBuffer()->data()
, cachedStyleSheet->resourceBuffer()->size(), KURL(baseURL, href), *cachedStyleS
heet)) { | 524 if (!cachedStyleSheet->errorOccurred() && m_owner->fastHasAttribute(HTMLName
s::integrityAttr) && cachedStyleSheet->resourceBuffer() && !SubresourceIntegrity
::CheckSubresourceIntegrity(*m_owner, cachedStyleSheet->resourceBuffer()->data()
, cachedStyleSheet->resourceBuffer()->size(), KURL(baseURL, href), *cachedStyleS
heet)) { |
| 525 m_loading = false; | 525 m_loading = false; |
| 526 removePendingSheet(); | 526 removePendingSheet(); |
| 527 notifyLoadedSheetAndAllCriticalSubresources(Node::ErrorOccurredLoadingSu
bresource); | 527 notifyLoadedSheetAndAllCriticalSubresources(Node::ErrorOccurredLoadingSu
bresource); |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 } | 793 } |
| 794 | 794 |
| 795 DEFINE_TRACE(LinkStyle) | 795 DEFINE_TRACE(LinkStyle) |
| 796 { | 796 { |
| 797 visitor->trace(m_sheet); | 797 visitor->trace(m_sheet); |
| 798 LinkResource::trace(visitor); | 798 LinkResource::trace(visitor); |
| 799 ResourceOwner<StyleSheetResource>::trace(visitor); | 799 ResourceOwner<StyleSheetResource>::trace(visitor); |
| 800 } | 800 } |
| 801 | 801 |
| 802 } // namespace blink | 802 } // namespace blink |
| OLD | NEW |