2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Simon Hausmann <hausmann@kde.org>
5 * Copyright (C) 2007, 2008, 2009, 2010 Apple 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 HTMLAnchorElement_h
25 #define HTMLAnchorElement_h
27 #include "HTMLNames.h"
28 #include "core/dom/DOMURLUtils.h"
29 #include "core/html/HTMLElement.h"
30 #include "platform/LinkHash.h"
34 // Link relation bitmask values.
35 // FIXME: Uncomment as the various link relations are implemented.
37 // RelationAlternate = 0x00000001,
38 // RelationArchives = 0x00000002,
39 // RelationAuthor = 0x00000004,
40 // RelationBoomark = 0x00000008,
41 // RelationExternal = 0x00000010,
42 // RelationFirst = 0x00000020,
43 // RelationHelp = 0x00000040,
44 // RelationIndex = 0x00000080,
45 // RelationLast = 0x00000100,
46 // RelationLicense = 0x00000200,
47 // RelationNext = 0x00000400,
48 // RelationNoFolow = 0x00000800,
49 RelationNoReferrer = 0x00001000,
50 // RelationPrev = 0x00002000,
51 // RelationSearch = 0x00004000,
52 // RelationSidebar = 0x00008000,
53 // RelationTag = 0x00010000,
54 // RelationUp = 0x00020000,
57 class HTMLAnchorElement : public HTMLElement, public DOMURLUtils {
59 static PassRefPtrWillBeRawPtr<HTMLAnchorElement> create(Document&);
61 virtual ~HTMLAnchorElement();
64 void setHref(const AtomicString&);
66 const AtomicString& name() const;
68 virtual KURL url() const OVERRIDE FINAL;
69 virtual void setURL(const KURL&) OVERRIDE FINAL;
71 virtual String input() const OVERRIDE FINAL;
72 virtual void setInput(const String&) OVERRIDE FINAL;
74 bool isLiveLink() const;
76 virtual bool willRespondToMouseClickEvents() OVERRIDE FINAL;
78 bool hasRel(uint32_t relation) const;
79 void setRel(const AtomicString&);
81 LinkHash visitedLinkHash() const;
82 void invalidateCachedVisitedLinkHash() { m_cachedVisitedLinkHash = 0; }
85 HTMLAnchorElement(const QualifiedName&, Document&);
87 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
88 virtual bool supportsFocus() const OVERRIDE;
91 virtual bool isMouseFocusable() const OVERRIDE;
92 virtual bool isKeyboardFocusable() const OVERRIDE;
93 virtual void defaultEventHandler(Event*) OVERRIDE FINAL;
94 virtual void setActive(bool = true) OVERRIDE FINAL;
95 virtual void accessKeyAction(bool sendMouseEvents) OVERRIDE FINAL;
96 virtual bool isURLAttribute(const Attribute&) const OVERRIDE FINAL;
97 virtual bool hasLegalLinkAttribute(const QualifiedName&) const OVERRIDE FINAL;
98 virtual bool canStartSelection() const OVERRIDE FINAL;
99 virtual short tabIndex() const OVERRIDE FINAL;
100 virtual bool draggable() const OVERRIDE FINAL;
101 virtual bool isInteractiveContent() const OVERRIDE FINAL;
103 void sendPings(const KURL& destinationURL);
104 AtomicString target() const;
105 void handleClick(Event*);
107 class PrefetchEventHandler;
108 PrefetchEventHandler* prefetchEventHandler();
110 uint32_t m_linkRelations;
111 OwnPtr<PrefetchEventHandler> m_prefetchEventHandler;
112 mutable LinkHash m_cachedVisitedLinkHash;
115 inline LinkHash HTMLAnchorElement::visitedLinkHash() const
117 if (!m_cachedVisitedLinkHash)
118 m_cachedVisitedLinkHash = WebCore::visitedLinkHash(document().baseURL(), fastGetAttribute(HTMLNames::hrefAttr));
119 return m_cachedVisitedLinkHash;
122 // Functions shared with the other anchor elements (i.e., SVG).
124 bool isEnterKeyKeydownEvent(Event*);
125 bool isLinkClick(Event*);
127 } // namespace WebCore
129 #endif // HTMLAnchorElement_h