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 &url, 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 static void tokenizeRelAttribute(const AtomicString& value, bool& stylesheet, bool& alternate, bool& icon, bool& dnsPrefetch); 97 98 virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const; 99 100 virtual void finishParsingChildren(); 101 102 protected: 103 CachedResourceHandle<CachedCSSStyleSheet> m_cachedSheet; 104 RefPtr<CSSStyleSheet> m_sheet; 105 KURL m_url; 106 String m_type; 107 String m_media; 108 int m_disabledState; // 0=unset(default), 1=enabled via script, 2=disabled 109 bool m_loading; 110 bool m_alternate; 111 bool m_isStyleSheet; 112 bool m_isIcon; 113 bool m_isDNSPrefetch; 114 bool m_createdByParser; 115 }; 116 117 } //namespace 118 119 #endif 120