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 "core/CoreExport.h"
28 #include "core/HTMLNames.h"
29 #include "core/dom/DOMURLUtils.h"
30 #include "core/dom/Document.h"
31 #include "core/html/HTMLElement.h"
32 #include "platform/LinkHash.h"
36 // Link relation bitmask values.
37 // FIXME: Uncomment as the various link relations are implemented.
39 // RelationAlternate = 0x00000001,
40 // RelationArchives = 0x00000002,
41 // RelationAuthor = 0x00000004,
42 // RelationBoomark = 0x00000008,
43 // RelationExternal = 0x00000010,
44 // RelationFirst = 0x00000020,
45 // RelationHelp = 0x00000040,
46 // RelationIndex = 0x00000080,
47 // RelationLast = 0x00000100,
48 // RelationLicense = 0x00000200,
49 // RelationNext = 0x00000400,
50 // RelationNoFolow = 0x00000800,
51 RelationNoReferrer
= 0x00001000,
52 // RelationPrev = 0x00002000,
53 // RelationSearch = 0x00004000,
54 // RelationSidebar = 0x00008000,
55 // RelationTag = 0x00010000,
56 // RelationUp = 0x00020000,
59 class CORE_EXPORT HTMLAnchorElement
: public HTMLElement
, public DOMURLUtils
{
60 DEFINE_WRAPPERTYPEINFO();
62 static PassRefPtrWillBeRawPtr
<HTMLAnchorElement
> create(Document
&);
64 ~HTMLAnchorElement() override
;
67 void setHref(const AtomicString
&);
69 const AtomicString
& name() const;
71 KURL
url() const final
;
72 void setURL(const KURL
&) final
;
74 String
input() const final
;
75 void setInput(const String
&) final
;
77 bool isLiveLink() const final
;
79 bool willRespondToMouseClickEvents() final
;
81 bool hasRel(uint32_t relation
) const;
82 void setRel(const AtomicString
&);
84 LinkHash
visitedLinkHash() const;
85 void invalidateCachedVisitedLinkHash() { m_cachedVisitedLinkHash
= 0; }
87 void sendPings(const KURL
& destinationURL
) const;
90 HTMLAnchorElement(const QualifiedName
&, Document
&);
92 void attributeWillChange(const QualifiedName
&, const AtomicString
& oldValue
, const AtomicString
& newValue
) override
;
93 void parseAttribute(const QualifiedName
&, const AtomicString
&) override
;
94 bool supportsFocus() const override
;
97 bool shouldHaveFocusAppearance() const final
;
98 void dispatchFocusEvent(Element
* oldFocusedElement
, WebFocusType
, InputDeviceCapabilities
* sourceCapabilities
) override
;
99 void dispatchBlurEvent(Element
* newFocusedElement
, WebFocusType
, InputDeviceCapabilities
* sourceCapabilities
) override
;
100 bool isMouseFocusable() const override
;
101 bool isKeyboardFocusable() const override
;
102 void defaultEventHandler(Event
*) final
;
103 void setActive(bool = true) final
;
104 void accessKeyAction(bool sendMouseEvents
) final
;
105 bool isURLAttribute(const Attribute
&) const final
;
106 bool hasLegalLinkAttribute(const QualifiedName
&) const final
;
107 bool canStartSelection() const final
;
108 short tabIndex() const final
;
109 bool draggable() const final
;
110 bool isInteractiveContent() const final
;
111 InsertionNotificationRequest
insertedInto(ContainerNode
*) override
;
112 void handleClick(Event
*);
114 uint32_t m_linkRelations
;
115 mutable LinkHash m_cachedVisitedLinkHash
;
116 bool m_wasFocusedByMouse
;
119 inline LinkHash
HTMLAnchorElement::visitedLinkHash() const
121 if (!m_cachedVisitedLinkHash
)
122 m_cachedVisitedLinkHash
= blink::visitedLinkHash(document().baseURL(), fastGetAttribute(HTMLNames::hrefAttr
));
123 return m_cachedVisitedLinkHash
;
126 // Functions shared with the other anchor elements (i.e., SVG).
128 bool isEnterKeyKeydownEvent(Event
*);
129 bool isLinkClick(Event
*);
133 #endif // HTMLAnchorElement_h