| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 if (LinkStyle* link = linkStyle()) | 127 if (LinkStyle* link = linkStyle()) |
| 128 link->setSheetTitle(value); | 128 link->setSheetTitle(value); |
| 129 } | 129 } |
| 130 | 130 |
| 131 HTMLElement::parseAttribute(name, oldValue, value); | 131 HTMLElement::parseAttribute(name, oldValue, value); |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 | 134 |
| 135 bool HTMLLinkElement::shouldLoadLink() | 135 bool HTMLLinkElement::shouldLoadLink() |
| 136 { | 136 { |
| 137 return inShadowIncludingDocument(); | 137 return isConnected(); |
| 138 } | 138 } |
| 139 | 139 |
| 140 bool HTMLLinkElement::loadLink(const String& type, const String& as, const Strin
g& media, const KURL& url) | 140 bool HTMLLinkElement::loadLink(const String& type, const String& as, const Strin
g& media, const KURL& url) |
| 141 { | 141 { |
| 142 return m_linkLoader->loadLink(m_relAttribute, crossOriginAttributeValue(fast
GetAttribute(HTMLNames::crossoriginAttr)), type, as, media, url, document(), Net
workHintsInterfaceImpl()); | 142 return m_linkLoader->loadLink(m_relAttribute, crossOriginAttributeValue(fast
GetAttribute(HTMLNames::crossoriginAttr)), type, as, media, url, document(), Net
workHintsInterfaceImpl()); |
| 143 } | 143 } |
| 144 | 144 |
| 145 LinkResource* HTMLLinkElement::linkResourceToProcess() | 145 LinkResource* HTMLLinkElement::linkResourceToProcess() |
| 146 { | 146 { |
| 147 bool visible = inShadowIncludingDocument() && !m_isInShadowTree; | 147 bool visible = isConnected() && !m_isInShadowTree; |
| 148 if (!visible) { | 148 if (!visible) { |
| 149 ASSERT(!linkStyle() || !linkStyle()->hasSheet()); | 149 ASSERT(!linkStyle() || !linkStyle()->hasSheet()); |
| 150 return nullptr; | 150 return nullptr; |
| 151 } | 151 } |
| 152 | 152 |
| 153 if (!m_link) { | 153 if (!m_link) { |
| 154 if (m_relAttribute.isImport()) { | 154 if (m_relAttribute.isImport()) { |
| 155 m_link = LinkImport::create(this); | 155 m_link = LinkImport::create(this); |
| 156 } else if (m_relAttribute.isManifest()) { | 156 } else if (m_relAttribute.isManifest()) { |
| 157 m_link = LinkManifest::create(this); | 157 m_link = LinkManifest::create(this); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 void HTMLLinkElement::process() | 195 void HTMLLinkElement::process() |
| 196 { | 196 { |
| 197 if (LinkResource* link = linkResourceToProcess()) | 197 if (LinkResource* link = linkResourceToProcess()) |
| 198 link->process(); | 198 link->process(); |
| 199 } | 199 } |
| 200 | 200 |
| 201 Node::InsertionNotificationRequest HTMLLinkElement::insertedInto(ContainerNode*
insertionPoint) | 201 Node::InsertionNotificationRequest HTMLLinkElement::insertedInto(ContainerNode*
insertionPoint) |
| 202 { | 202 { |
| 203 HTMLElement::insertedInto(insertionPoint); | 203 HTMLElement::insertedInto(insertionPoint); |
| 204 logAddElementIfIsolatedWorldAndInDocument("link", relAttr, hrefAttr); | 204 logAddElementIfIsolatedWorldAndInDocument("link", relAttr, hrefAttr); |
| 205 if (!insertionPoint->inShadowIncludingDocument()) | 205 if (!insertionPoint->isConnected()) |
| 206 return InsertionDone; | 206 return InsertionDone; |
| 207 | 207 |
| 208 m_isInShadowTree = isInShadowTree(); | 208 m_isInShadowTree = isInShadowTree(); |
| 209 if (m_isInShadowTree) { | 209 if (m_isInShadowTree) { |
| 210 String message = "HTML element <link> is ignored in shadow tree."; | 210 String message = "HTML element <link> is ignored in shadow tree."; |
| 211 document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, War
ningMessageLevel, message)); | 211 document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, War
ningMessageLevel, message)); |
| 212 return InsertionDone; | 212 return InsertionDone; |
| 213 } | 213 } |
| 214 | 214 |
| 215 document().styleEngine().addStyleSheetCandidateNode(this); | 215 document().styleEngine().addStyleSheetCandidateNode(this); |
| 216 | 216 |
| 217 process(); | 217 process(); |
| 218 | 218 |
| 219 if (m_link) | 219 if (m_link) |
| 220 m_link->ownerInserted(); | 220 m_link->ownerInserted(); |
| 221 | 221 |
| 222 return InsertionDone; | 222 return InsertionDone; |
| 223 } | 223 } |
| 224 | 224 |
| 225 void HTMLLinkElement::removedFrom(ContainerNode* insertionPoint) | 225 void HTMLLinkElement::removedFrom(ContainerNode* insertionPoint) |
| 226 { | 226 { |
| 227 HTMLElement::removedFrom(insertionPoint); | 227 HTMLElement::removedFrom(insertionPoint); |
| 228 if (!insertionPoint->inShadowIncludingDocument()) | 228 if (!insertionPoint->isConnected()) |
| 229 return; | 229 return; |
| 230 | 230 |
| 231 m_linkLoader->released(); | 231 m_linkLoader->released(); |
| 232 | 232 |
| 233 if (m_isInShadowTree) { | 233 if (m_isInShadowTree) { |
| 234 ASSERT(!linkStyle() || !linkStyle()->hasSheet()); | 234 ASSERT(!linkStyle() || !linkStyle()->hasSheet()); |
| 235 return; | 235 return; |
| 236 } | 236 } |
| 237 document().styleEngine().removeStyleSheetCandidateNode(this); | 237 document().styleEngine().removeStyleSheetCandidateNode(this); |
| 238 | 238 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 | 433 |
| 434 enum StyleSheetCacheStatus { | 434 enum StyleSheetCacheStatus { |
| 435 StyleSheetNewEntry, | 435 StyleSheetNewEntry, |
| 436 StyleSheetInDiskCache, | 436 StyleSheetInDiskCache, |
| 437 StyleSheetInMemoryCache, | 437 StyleSheetInMemoryCache, |
| 438 StyleSheetCacheStatusCount, | 438 StyleSheetCacheStatusCount, |
| 439 }; | 439 }; |
| 440 | 440 |
| 441 void LinkStyle::setCSSStyleSheet(const String& href, const KURL& baseURL, const
String& charset, const CSSStyleSheetResource* cachedStyleSheet) | 441 void LinkStyle::setCSSStyleSheet(const String& href, const KURL& baseURL, const
String& charset, const CSSStyleSheetResource* cachedStyleSheet) |
| 442 { | 442 { |
| 443 if (!m_owner->inShadowIncludingDocument()) { | 443 if (!m_owner->isConnected()) { |
| 444 ASSERT(!m_sheet); | 444 ASSERT(!m_sheet); |
| 445 return; | 445 return; |
| 446 } | 446 } |
| 447 | 447 |
| 448 // See the comment in PendingScript.cpp about why this check is necessary | 448 // See the comment in PendingScript.cpp about why this check is necessary |
| 449 // here, instead of in the resource fetcher. https://crbug.com/500701. | 449 // here, instead of in the resource fetcher. https://crbug.com/500701. |
| 450 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)) { | 450 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)) { |
| 451 m_loading = false; | 451 m_loading = false; |
| 452 removePendingSheet(); | 452 removePendingSheet(); |
| 453 notifyLoadedSheetAndAllCriticalSubresources(Node::ErrorOccurredLoadingSu
bresource); | 453 notifyLoadedSheetAndAllCriticalSubresources(Node::ErrorOccurredLoadingSu
bresource); |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 } | 722 } |
| 723 | 723 |
| 724 DEFINE_TRACE(LinkStyle) | 724 DEFINE_TRACE(LinkStyle) |
| 725 { | 725 { |
| 726 visitor->trace(m_sheet); | 726 visitor->trace(m_sheet); |
| 727 LinkResource::trace(visitor); | 727 LinkResource::trace(visitor); |
| 728 ResourceOwner<StyleSheetResource>::trace(visitor); | 728 ResourceOwner<StyleSheetResource>::trace(visitor); |
| 729 } | 729 } |
| 730 | 730 |
| 731 } // namespace blink | 731 } // namespace blink |
| OLD | NEW |