#ifndef HTMLAnchorElement_h
#define HTMLAnchorElement_h
#include "HTMLNames.h"
#include "core/dom/DOMURLUtils.h"
#include "core/html/HTMLElement.h"
#include "platform/LinkHash.h"
namespace WebCore {
enum {
RelationNoReferrer = 0x00001000,
};
class HTMLAnchorElement : public HTMLElement, public DOMURLUtils {
public:
static PassRefPtr<HTMLAnchorElement> create(Document&);
static PassRefPtr<HTMLAnchorElement> create(const QualifiedName&, Document&);
virtual ~HTMLAnchorElement();
KURL href() const;
void setHref(const AtomicString&);
const AtomicString& name() const;
virtual KURL url() const OVERRIDE FINAL;
virtual void setURL(const KURL&) OVERRIDE FINAL;
virtual String input() const OVERRIDE FINAL;
virtual void setInput(const String&) OVERRIDE FINAL;
String text();
bool isLiveLink() const;
virtual bool willRespondToMouseClickEvents() OVERRIDE FINAL;
bool hasRel(uint32_t relation) const;
void setRel(const AtomicString&);
LinkHash visitedLinkHash() const;
void invalidateCachedVisitedLinkHash() { m_cachedVisitedLinkHash = 0; }
protected:
HTMLAnchorElement(const QualifiedName&, Document&);
virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
private:
virtual bool supportsFocus() const OVERRIDE;
virtual bool isMouseFocusable() const OVERRIDE;
virtual bool isKeyboardFocusable() const OVERRIDE;
virtual void defaultEventHandler(Event*) OVERRIDE FINAL;
virtual void setActive(bool = true) OVERRIDE FINAL;
virtual void accessKeyAction(bool sendMouseEvents) OVERRIDE FINAL;
virtual bool isURLAttribute(const Attribute&) const OVERRIDE FINAL;
virtual bool hasLegalLinkAttribute(const QualifiedName&) const OVERRIDE FINAL;
virtual bool canStartSelection() const OVERRIDE FINAL;
virtual short tabIndex() const OVERRIDE FINAL;
virtual bool draggable() const OVERRIDE FINAL;
virtual bool isInteractiveContent() const OVERRIDE FINAL;
void sendPings(const KURL& destinationURL);
AtomicString target() const;
void handleClick(Event*);
enum EventType {
MouseEventWithoutShiftKey,
MouseEventWithShiftKey,
NonMouseEvent,
};
static EventType eventType(Event*);
bool treatLinkAsLiveForEventType(EventType) const;
Element* rootEditableElementForSelectionOnMouseDown() const;
void setRootEditableElementForSelectionOnMouseDown(Element*);
void clearRootEditableElementForSelectionOnMouseDown();
class PrefetchEventHandler;
PrefetchEventHandler* prefetchEventHandler();
bool m_hasRootEditableElementForSelectionOnMouseDown : 1;
bool m_wasShiftKeyDownOnMouseDown : 1;
uint32_t m_linkRelations : 30;
OwnPtr<PrefetchEventHandler> m_prefetchEventHandler;
mutable LinkHash m_cachedVisitedLinkHash;
};
inline LinkHash HTMLAnchorElement::visitedLinkHash() const
{
if (!m_cachedVisitedLinkHash)
m_cachedVisitedLinkHash = WebCore::visitedLinkHash(document().baseURL(), fastGetAttribute(HTMLNames::hrefAttr));
return m_cachedVisitedLinkHash;
}
bool isEnterKeyKeydownEvent(Event*);
bool isLinkClick(Event*);
}
#endif