2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2003, 2008, 2010 Apple Inc. All rights reserved.
5 * Copyright (C) 2011 Google Inc. All rights reserved.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
24 #ifndef HTMLLinkElement_h
25 #define HTMLLinkElement_h
27 #include "CSSStyleSheet.h"
28 #include "CachedResourceClient.h"
29 #include "CachedResourceHandle.h"
30 #include "DOMSettableTokenList.h"
31 #include "HTMLElement.h"
33 #include "LinkLoader.h"
34 #include "LinkLoaderClient.h"
35 #include "LinkRelAttribute.h"
40 class CachedCSSStyleSheet;
44 class HTMLLinkElement : public HTMLElement, public CachedResourceClient, public LinkLoaderClient {
46 static PassRefPtr<HTMLLinkElement> create(const QualifiedName&, Document*, bool createdByParser);
47 virtual ~HTMLLinkElement();
52 virtual String target() const;
56 StyleSheet* sheet() const;
58 // FIXME: This should be renamed isStyleSheetLoading as this is only used for stylesheets.
59 bool isLoading() const;
61 bool isDisabled() const { return m_disabledState == Disabled; }
62 bool isEnabledViaScript() const { return m_disabledState == EnabledViaScript; }
63 void setSizes(const String&);
64 DOMSettableTokenList* sizes() const;
67 virtual void parseMappedAttribute(Attribute*);
69 virtual bool shouldLoadLink();
71 static void processCallback(Node*);
73 virtual void insertedIntoDocument();
74 virtual void removedFromDocument();
76 // from CachedResourceClient
77 virtual void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet* sheet);
78 virtual bool sheetLoaded();
79 virtual void startLoadingDynamicSheet();
81 virtual void linkLoaded();
82 virtual void linkLoadingErrored();
84 bool isAlternate() const { return m_disabledState == Unset && m_relAttribute.m_isAlternate; }
86 void setDisabledState(bool);
88 virtual bool isURLAttribute(Attribute*) const;
91 virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
93 virtual void finishParsingChildren();
95 enum PendingSheetType { None, NonBlocking, Blocking };
96 void addPendingSheet(PendingSheetType);
97 void removePendingSheet();
100 HTMLLinkElement(const QualifiedName&, Document*, bool createdByParser);
102 LinkLoader m_linkLoader;
103 CachedResourceHandle<CachedCSSStyleSheet> m_cachedSheet;
104 RefPtr<CSSStyleSheet> m_sheet;
114 RefPtr<DOMSettableTokenList> m_sizes;
115 DisabledState m_disabledState;
116 LinkRelAttribute m_relAttribute;
118 bool m_createdByParser;
119 bool m_isInShadowTree;
121 PendingSheetType m_pendingSheetType;