| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 String trimmedType = ContentType(type).type(); | 74 String trimmedType = ContentType(type).type(); |
| 75 return trimmedType.isEmpty() || MIMETypeRegistry::isSupportedStyleSheetMIMET
ype(trimmedType); | 75 return trimmedType.isEmpty() || MIMETypeRegistry::isSupportedStyleSheetMIMET
ype(trimmedType); |
| 76 } | 76 } |
| 77 | 77 |
| 78 inline HTMLLinkElement::HTMLLinkElement(Document& document, bool createdByParser
) | 78 inline HTMLLinkElement::HTMLLinkElement(Document& document, bool createdByParser
) |
| 79 : HTMLElement(linkTag, document) | 79 : HTMLElement(linkTag, document) |
| 80 , m_linkLoader(LinkLoader::create(this)) | 80 , m_linkLoader(LinkLoader::create(this)) |
| 81 , m_sizes(DOMTokenList::create(this)) | 81 , m_sizes(DOMTokenList::create(this)) |
| 82 , m_relList(RelList::create(this)) | 82 , m_relList(RelList::create(this)) |
| 83 , m_createdByParser(createdByParser) | 83 , m_createdByParser(createdByParser) |
| 84 , m_isInShadowTree(false) | |
| 85 { | 84 { |
| 86 } | 85 } |
| 87 | 86 |
| 88 HTMLLinkElement* HTMLLinkElement::create(Document& document, bool createdByParse
r) | 87 HTMLLinkElement* HTMLLinkElement::create(Document& document, bool createdByParse
r) |
| 89 { | 88 { |
| 90 return new HTMLLinkElement(document, createdByParser); | 89 return new HTMLLinkElement(document, createdByParser); |
| 91 } | 90 } |
| 92 | 91 |
| 93 HTMLLinkElement::~HTMLLinkElement() | 92 HTMLLinkElement::~HTMLLinkElement() |
| 94 { | 93 { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 return isConnected(); | 136 return isConnected(); |
| 138 } | 137 } |
| 139 | 138 |
| 140 bool HTMLLinkElement::loadLink(const String& type, const String& as, const Strin
g& media, const KURL& url) | 139 bool HTMLLinkElement::loadLink(const String& type, const String& as, const Strin
g& media, const KURL& url) |
| 141 { | 140 { |
| 142 return m_linkLoader->loadLink(m_relAttribute, crossOriginAttributeValue(fast
GetAttribute(HTMLNames::crossoriginAttr)), type, as, media, url, document(), Net
workHintsInterfaceImpl()); | 141 return m_linkLoader->loadLink(m_relAttribute, crossOriginAttributeValue(fast
GetAttribute(HTMLNames::crossoriginAttr)), type, as, media, url, document(), Net
workHintsInterfaceImpl()); |
| 143 } | 142 } |
| 144 | 143 |
| 145 LinkResource* HTMLLinkElement::linkResourceToProcess() | 144 LinkResource* HTMLLinkElement::linkResourceToProcess() |
| 146 { | 145 { |
| 147 bool visible = isConnected() && !m_isInShadowTree; | 146 bool visible = isConnected() && !isInShadowTree(); |
| 148 if (!visible) { | 147 if (!visible) { |
| 149 ASSERT(!linkStyle() || !linkStyle()->hasSheet()); | 148 ASSERT(!linkStyle() || !linkStyle()->hasSheet()); |
| 150 return nullptr; | 149 return nullptr; |
| 151 } | 150 } |
| 152 | 151 |
| 153 if (!m_link) { | 152 if (!m_link) { |
| 154 if (m_relAttribute.isImport()) { | 153 if (m_relAttribute.isImport()) { |
| 155 m_link = LinkImport::create(this); | 154 m_link = LinkImport::create(this); |
| 156 } else if (m_relAttribute.isManifest()) { | 155 } else if (m_relAttribute.isManifest()) { |
| 157 m_link = LinkManifest::create(this); | 156 m_link = LinkManifest::create(this); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 link->process(); | 197 link->process(); |
| 199 } | 198 } |
| 200 | 199 |
| 201 Node::InsertionNotificationRequest HTMLLinkElement::insertedInto(ContainerNode*
insertionPoint) | 200 Node::InsertionNotificationRequest HTMLLinkElement::insertedInto(ContainerNode*
insertionPoint) |
| 202 { | 201 { |
| 203 HTMLElement::insertedInto(insertionPoint); | 202 HTMLElement::insertedInto(insertionPoint); |
| 204 logAddElementIfIsolatedWorldAndInDocument("link", relAttr, hrefAttr); | 203 logAddElementIfIsolatedWorldAndInDocument("link", relAttr, hrefAttr); |
| 205 if (!insertionPoint->isConnected()) | 204 if (!insertionPoint->isConnected()) |
| 206 return InsertionDone; | 205 return InsertionDone; |
| 207 | 206 |
| 208 m_isInShadowTree = isInShadowTree(); | 207 if (isInShadowTree()) { |
| 209 if (m_isInShadowTree) { | |
| 210 String message = "HTML element <link> is ignored in shadow tree."; | 208 String message = "HTML element <link> is ignored in shadow tree."; |
| 211 document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, War
ningMessageLevel, message)); | 209 document().addConsoleMessage(ConsoleMessage::create(JSMessageSource, War
ningMessageLevel, message)); |
| 212 return InsertionDone; | 210 return InsertionDone; |
| 213 } | 211 } |
| 214 | 212 |
| 215 document().styleEngine().addStyleSheetCandidateNode(this); | 213 document().styleEngine().addStyleSheetCandidateNode(this); |
| 216 | 214 |
| 217 process(); | 215 process(); |
| 218 | 216 |
| 219 if (m_link) | 217 if (m_link) |
| 220 m_link->ownerInserted(); | 218 m_link->ownerInserted(); |
| 221 | 219 |
| 222 return InsertionDone; | 220 return InsertionDone; |
| 223 } | 221 } |
| 224 | 222 |
| 225 void HTMLLinkElement::removedFrom(ContainerNode* insertionPoint) | 223 void HTMLLinkElement::removedFrom(ContainerNode* insertionPoint) |
| 226 { | 224 { |
| 225 // Store the result of isInShadowTree() here before Node::removedFrom(..) cl
ears the flags. |
| 226 bool wasInShadowTree = isInShadowTree(); |
| 227 HTMLElement::removedFrom(insertionPoint); | 227 HTMLElement::removedFrom(insertionPoint); |
| 228 if (!insertionPoint->isConnected()) | 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 (wasInShadowTree) { |
| 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 |
| 239 StyleSheet* removedSheet = sheet(); | 239 StyleSheet* removedSheet = sheet(); |
| 240 | 240 |
| 241 if (m_link) | 241 if (m_link) |
| 242 m_link->ownerRemoved(); | 242 m_link->ownerRemoved(); |
| 243 | 243 |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 } | 728 } |
| 729 | 729 |
| 730 DEFINE_TRACE(LinkStyle) | 730 DEFINE_TRACE(LinkStyle) |
| 731 { | 731 { |
| 732 visitor->trace(m_sheet); | 732 visitor->trace(m_sheet); |
| 733 LinkResource::trace(visitor); | 733 LinkResource::trace(visitor); |
| 734 ResourceOwner<StyleSheetResource>::trace(visitor); | 734 ResourceOwner<StyleSheetResource>::trace(visitor); |
| 735 } | 735 } |
| 736 | 736 |
| 737 } // namespace blink | 737 } // namespace blink |
| OLD | NEW |