• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
4  * Copyright (C) 2003, 2008 Apple Inc. All rights reserved.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB.  If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef HTMLLinkElement_h
24 #define HTMLLinkElement_h
25 
26 #include "CSSStyleSheet.h"
27 #include "CachedResourceClient.h"
28 #include "CachedResourceHandle.h"
29 #include "HTMLElement.h"
30 
31 namespace WebCore {
32 
33 class CachedCSSStyleSheet;
34 class KURL;
35 
36 class HTMLLinkElement : public HTMLElement, public CachedResourceClient {
37 public:
38     HTMLLinkElement(const QualifiedName&, Document*, bool createdByParser);
39     ~HTMLLinkElement();
40 
endTagRequirement()41     virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; }
tagPriority()42     virtual int tagPriority() const { return 0; }
43 
44     bool disabled() const;
45     void setDisabled(bool);
46 
47     String charset() const;
48     void setCharset(const String&);
49 
50     KURL href() const;
51     void setHref(const String&);
52 
53     String hreflang() const;
54     void setHreflang(const String&);
55 
56     String media() const;
57     void setMedia(const String&);
58 
59     String rel() const;
60     void setRel(const String&);
61 
62     String rev() const;
63     void setRev(const String&);
64 
65     virtual String target() const;
66     void setTarget(const String&);
67 
68     String type() const;
69     void setType(const String&);
70 
71     StyleSheet* sheet() const;
72 
73     // overload from HTMLElement
74     virtual void parseMappedAttribute(MappedAttribute*);
75 
76     void process();
77 
78     virtual void insertedIntoDocument();
79     virtual void removedFromDocument();
80 
81     // from CachedResourceClient
82     virtual void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet* sheet);
83     bool isLoading() const;
84     virtual bool sheetLoaded();
85 
isAlternate()86     bool isAlternate() const { return m_disabledState == 0 && m_alternate; }
isDisabled()87     bool isDisabled() const { return m_disabledState == 2; }
isEnabledViaScript()88     bool isEnabledViaScript() const { return m_disabledState == 1; }
isIcon()89     bool isIcon() const { return m_isIcon; }
90 
disabledState()91     int disabledState() { return m_disabledState; }
92     void setDisabledState(bool _disabled);
93 
94     virtual bool isURLAttribute(Attribute*) const;
95 
96 #ifdef ANDROID_APPLE_TOUCH_ICON
97     static void tokenizeRelAttribute(const AtomicString& value, bool& stylesheet, bool& alternate, bool& icon, bool& touchIcon, bool& precomposedTouchIcon, bool& dnsPrefetch);
98 #else
99     static void tokenizeRelAttribute(const AtomicString& value, bool& stylesheet, bool& alternate, bool& icon, bool& dnsPrefetch);
100 #endif
101 
102     virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
103 
104     virtual void finishParsingChildren();
105 
106 #ifdef ANDROID_INSTRUMENT
107     // Overridden to resolve the ambiguous
108     void* operator new(size_t size);
109     void* operator new[](size_t size);
110     void operator delete(void* p, size_t size);
111     void operator delete[](void* p, size_t size);
112 #endif
113 
114 protected:
115     CachedResourceHandle<CachedCSSStyleSheet> m_cachedSheet;
116     RefPtr<CSSStyleSheet> m_sheet;
117     KURL m_url;
118     String m_type;
119     String m_media;
120     int m_disabledState; // 0=unset(default), 1=enabled via script, 2=disabled
121     bool m_loading;
122     bool m_alternate;
123     bool m_isStyleSheet;
124     bool m_isIcon;
125 #ifdef ANDROID_APPLE_TOUCH_ICON
126     bool m_isTouchIcon;
127     bool m_isPrecomposedTouchIcon;
128 #endif
129     bool m_isDNSPrefetch;
130     bool m_createdByParser;
131 };
132 
133 } //namespace
134 
135 #endif
136