• 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  *           (C) 2000 Simon Hausmann <hausmann@kde.org>
5  * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
6  *
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.
11  *
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.
16  *
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.
21  *
22  */
23 
24 #ifndef HTMLAnchorElement_h
25 #define HTMLAnchorElement_h
26 
27 #include "HTMLElement.h"
28 
29 namespace WebCore {
30 
31 // Link relation bitmask values.
32 // FIXME: Uncomment as the various link relations are implemented.
33 enum {
34 //     RelationAlternate   = 0x00000001,
35 //     RelationArchives    = 0x00000002,
36 //     RelationAuthor      = 0x00000004,
37 //     RelationBoomark     = 0x00000008,
38 //     RelationExternal    = 0x00000010,
39 //     RelationFirst       = 0x00000020,
40 //     RelationHelp        = 0x00000040,
41 //     RelationIndex       = 0x00000080,
42 //     RelationLast        = 0x00000100,
43 //     RelationLicense     = 0x00000200,
44 //     RelationNext        = 0x00000400,
45 //     RelationNoFolow    = 0x00000800,
46     RelationNoReferrer     = 0x00001000,
47 //     RelationPrev        = 0x00002000,
48 //     RelationSearch      = 0x00004000,
49 //     RelationSidebar     = 0x00008000,
50 //     RelationTag         = 0x00010000,
51 //     RelationUp          = 0x00020000,
52 };
53 
54 class HTMLAnchorElement : public HTMLElement {
55 public:
56     static PassRefPtr<HTMLAnchorElement> create(Document*);
57     static PassRefPtr<HTMLAnchorElement> create(const QualifiedName&, Document*);
58 
59     KURL href() const;
60     void setHref(const AtomicString&);
61 
62     const AtomicString& name() const;
63 
64     String hash() const;
65     void setHash(const String&);
66 
67     String host() const;
68     void setHost(const String&);
69 
70     String hostname() const;
71     void setHostname(const String&);
72 
73     String pathname() const;
74     void setPathname(const String&);
75 
76     String port() const;
77     void setPort(const String&);
78 
79     String protocol() const;
80     void setProtocol(const String&);
81 
82     String search() const;
83     void setSearch(const String&);
84 
85     String origin() const;
86 
87     String getParameter(const String&) const;
88 
89     String text() const;
90 
91     String toString() const;
92 
93     bool isLiveLink() const;
94 
95     bool hasRel(uint32_t relation) const;
96     void setRel(const String&);
97 
98 protected:
99     HTMLAnchorElement(const QualifiedName&, Document*);
100 
101     virtual void parseMappedAttribute(Attribute*);
102 
103 private:
104     virtual bool supportsFocus() const;
105     virtual bool isMouseFocusable() const;
106     virtual bool isKeyboardFocusable(KeyboardEvent*) const;
107     virtual void defaultEventHandler(Event*);
108     virtual void setActive(bool active = true, bool pause = false);
109     virtual void accessKeyAction(bool fullAction);
110     virtual bool isURLAttribute(Attribute*) const;
111     virtual bool canStartSelection() const;
112     virtual String target() const;
113     virtual short tabIndex() const;
114     virtual bool draggable() const;
115 
116     void sendPings(const KURL& destinationURL);
117 
118     enum EventType {
119         MouseEventWithoutShiftKey,
120         MouseEventWithShiftKey,
121         NonMouseEvent,
122     };
123     static EventType eventType(Event*);
124     bool treatLinkAsLiveForEventType(EventType) const;
125 
126     RefPtr<Element> m_rootEditableElementForSelectionOnMouseDown;
127     bool m_wasShiftKeyDownOnMouseDown;
128     uint32_t m_linkRelations;
129 };
130 
131 // Functions shared with the other anchor elements (SVG and WML).
132 
133 bool isEnterKeyKeydownEvent(Event*);
134 bool isMiddleMouseButtonEvent(Event*);
135 bool isLinkClick(Event*);
136 void handleLinkClick(Event*, Document*, const String& url, const String& target, bool hideReferrer = false);
137 
138 } // namespace WebCore
139 
140 #endif // HTMLAnchorElement_h
141