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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 else | 129 else |
130 parseSizes(value.characters16(), value.length(), iconSizes); | 130 parseSizes(value.characters16(), value.length(), iconSizes); |
131 } | 131 } |
132 | 132 |
133 inline HTMLLinkElement::HTMLLinkElement(Document& document, bool createdByParser
) | 133 inline HTMLLinkElement::HTMLLinkElement(Document& document, bool createdByParser
) |
134 : HTMLElement(linkTag, document) | 134 : HTMLElement(linkTag, document) |
135 , m_linkLoader(this) | 135 , m_linkLoader(this) |
136 , m_sizes(DOMSettableTokenList::create()) | 136 , m_sizes(DOMSettableTokenList::create()) |
137 , m_createdByParser(createdByParser) | 137 , m_createdByParser(createdByParser) |
138 , m_isInShadowTree(false) | 138 , m_isInShadowTree(false) |
139 , m_beforeLoadRecurseCount(0) | |
140 { | 139 { |
141 ScriptWrappable::init(this); | 140 ScriptWrappable::init(this); |
142 } | 141 } |
143 | 142 |
144 PassRefPtr<HTMLLinkElement> HTMLLinkElement::create(Document& document, bool cre
atedByParser) | 143 PassRefPtr<HTMLLinkElement> HTMLLinkElement::create(Document& document, bool cre
atedByParser) |
145 { | 144 { |
146 return adoptRef(new HTMLLinkElement(document, createdByParser)); | 145 return adoptRef(new HTMLLinkElement(document, createdByParser)); |
147 } | 146 } |
148 | 147 |
149 HTMLLinkElement::~HTMLLinkElement() | 148 HTMLLinkElement::~HTMLLinkElement() |
(...skipping 19 matching lines...) Expand all Loading... |
169 } else if (name == sizesAttr) { | 168 } else if (name == sizesAttr) { |
170 m_sizes->setValue(value); | 169 m_sizes->setValue(value); |
171 parseSizesAttribute(value, m_iconSizes); | 170 parseSizesAttribute(value, m_iconSizes); |
172 process(); | 171 process(); |
173 } else if (name == mediaAttr) { | 172 } else if (name == mediaAttr) { |
174 m_media = value.string().lower(); | 173 m_media = value.string().lower(); |
175 process(); | 174 process(); |
176 } else if (name == disabledAttr) { | 175 } else if (name == disabledAttr) { |
177 if (LinkStyle* link = linkStyle()) | 176 if (LinkStyle* link = linkStyle()) |
178 link->setDisabledState(!value.isNull()); | 177 link->setDisabledState(!value.isNull()); |
179 } else if (name == onbeforeloadAttr) | 178 } else { |
180 setAttributeEventListener(EventTypeNames::beforeload, createAttributeEve
ntListener(this, name, value)); | |
181 else { | |
182 if (name == titleAttr) { | 179 if (name == titleAttr) { |
183 if (LinkStyle* link = linkStyle()) | 180 if (LinkStyle* link = linkStyle()) |
184 link->setSheetTitle(value); | 181 link->setSheetTitle(value); |
185 } | 182 } |
186 | 183 |
187 HTMLElement::parseAttribute(name, value); | 184 HTMLElement::parseAttribute(name, value); |
188 } | 185 } |
189 } | 186 } |
190 | 187 |
191 bool HTMLLinkElement::shouldLoadLink() | 188 bool HTMLLinkElement::shouldLoadLink() |
192 { | 189 { |
193 bool continueLoad = true; | 190 return inDocument(); |
194 RefPtr<Document> originalDocument(document()); | |
195 int recursionRank = ++m_beforeLoadRecurseCount; | |
196 if (!dispatchBeforeLoadEvent(getNonEmptyURLAttribute(hrefAttr))) | |
197 continueLoad = false; | |
198 | |
199 // A beforeload handler might have removed us from the document or changed t
he document. | |
200 if (continueLoad && (!inDocument() || document() != originalDocument)) | |
201 continueLoad = false; | |
202 | |
203 // If the beforeload handler recurses into the link element by mutating it,
we should only | |
204 // let the latest (innermost) mutation occur. | |
205 if (recursionRank != m_beforeLoadRecurseCount) | |
206 continueLoad = false; | |
207 | |
208 if (recursionRank == 1) | |
209 m_beforeLoadRecurseCount = 0; | |
210 | |
211 return continueLoad; | |
212 } | 191 } |
213 | 192 |
214 bool HTMLLinkElement::loadLink(const String& type, const KURL& url) | 193 bool HTMLLinkElement::loadLink(const String& type, const KURL& url) |
215 { | 194 { |
216 return m_linkLoader.loadLink(m_relAttribute, fastGetAttribute(HTMLNames::cro
ssoriginAttr), type, url, document()); | 195 return m_linkLoader.loadLink(m_relAttribute, fastGetAttribute(HTMLNames::cro
ssoriginAttr), type, url, document()); |
217 } | 196 } |
218 | 197 |
219 LinkResource* HTMLLinkElement::linkResourceToProcess() | 198 LinkResource* HTMLLinkElement::linkResourceToProcess() |
220 { | 199 { |
221 bool visible = inDocument() && !m_isInShadowTree; | 200 bool visible = inDocument() && !m_isInShadowTree; |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 void LinkStyle::ownerRemoved() | 697 void LinkStyle::ownerRemoved() |
719 { | 698 { |
720 if (m_sheet) | 699 if (m_sheet) |
721 clearSheet(); | 700 clearSheet(); |
722 | 701 |
723 if (styleSheetIsLoading()) | 702 if (styleSheetIsLoading()) |
724 removePendingSheet(RemovePendingSheetNotifyLater); | 703 removePendingSheet(RemovePendingSheetNotifyLater); |
725 } | 704 } |
726 | 705 |
727 } // namespace WebCore | 706 } // namespace WebCore |
OLD | NEW |