blob: e1478ded441fa3fa65c4c32cd9b484e6ffdb6233 [file] [log] [blame]
* Copyright (C) 1999 Lars Knoll (
* (C) 1999 Antti Koivisto (
* (C) 2000 Simon Hausmann <>
* Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* Library General Public License for more details.
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
#include "base/optional.h"
#include "third_party/blink/public/platform/web_impression.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/html/html_element.h"
#include "third_party/blink/renderer/core/html/rel_list.h"
#include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/url/dom_url_utils.h"
#include "third_party/blink/renderer/platform/link_hash.h"
namespace blink {
// Link relation bitmask values.
// FIXME: Uncomment as the various link relations are implemented.
enum {
// RelationAlternate = 0x00000001,
// RelationArchives = 0x00000002,
// RelationAuthor = 0x00000004,
// RelationBoomark = 0x00000008,
// RelationExternal = 0x00000010,
// RelationFirst = 0x00000020,
// RelationHelp = 0x00000040,
// RelationIndex = 0x00000080,
// RelationLast = 0x00000100,
// RelationLicense = 0x00000200,
// RelationNext = 0x00000400,
// RelationNoFolow = 0x00000800,
kRelationNoReferrer = 0x00001000,
// RelationPrev = 0x00002000,
// RelationSearch = 0x00004000,
// RelationSidebar = 0x00008000,
// RelationTag = 0x00010000,
// RelationUp = 0x00020000,
kRelationNoOpener = 0x00040000,
kRelationOpener = 0x00080000
class CORE_EXPORT HTMLAnchorElement : public HTMLElement, public DOMURLUtils {
HTMLAnchorElement(Document& document);
HTMLAnchorElement(const QualifiedName&, Document&);
~HTMLAnchorElement() override;
KURL Href() const;
void SetHref(const AtomicString&);
const AtomicString& GetName() const;
// Returns the anchor's |target| attribute, unless it is empty, in which case
// the BaseTarget from the document is returned.
const AtomicString& GetEffectiveTarget() const;
KURL Url() const final;
void SetURL(const KURL&) final;
String Input() const final;
void SetInput(const String&) final;
bool IsLiveLink() const final;
bool WillRespondToMouseClickEvents() final;
bool HasRel(uint32_t relation) const;
void SetRel(const AtomicString&);
DOMTokenList& relList() const {
return static_cast<DOMTokenList&>(*rel_list_);
LinkHash VisitedLinkHash() const;
void InvalidateCachedVisitedLinkHash() { cached_visited_link_hash_ = 0; }
// Returns whether this element is a valid impression declaration tag. This is
// determined by looking at the presence of required attributes.
bool HasImpression() const;
// Returns the WebImpression struct with all data declared by impression
// related attributes on |this|. If the impression attributes do not contain
// allowed values, base::nullopt is returned.
base::Optional<WebImpression> GetImpressionForNavigation() const;
void SendPings(const KURL& destination_url) const;
void Trace(Visitor*) const override;
void ParseAttribute(const AttributeModificationParams&) override;
bool SupportsFocus() const override;
void AttributeChanged(const AttributeModificationParams&) override;
bool ShouldHaveFocusAppearance() const final;
bool IsMouseFocusable() const override;
bool IsKeyboardFocusable() const override;
void DefaultEventHandler(Event&) final;
bool HasActivationBehavior() const override;
void SetActive(bool active) final;
void AccessKeyAction(bool send_mouse_events) final;
bool IsURLAttribute(const Attribute&) const final;
bool HasLegalLinkAttribute(const QualifiedName&) const final;
bool CanStartSelection() const final;
int DefaultTabIndex() const final;
bool draggable() const final;
bool IsInteractiveContent() const final;
InsertionNotificationRequest InsertedInto(ContainerNode&) override;
void HandleClick(Event&);
unsigned link_relations_ : 31;
mutable LinkHash cached_visited_link_hash_;
Member<RelList> rel_list_;
inline LinkHash HTMLAnchorElement::VisitedLinkHash() const {
if (!cached_visited_link_hash_) {
cached_visited_link_hash_ = blink::VisitedLinkHash(
GetDocument().BaseURL(), FastGetAttribute(html_names::kHrefAttr));
return cached_visited_link_hash_;
// Functions shared with the other anchor elements (i.e., SVG).
bool IsEnterKeyKeydownEvent(Event&);
bool IsLinkClick(Event&);
} // namespace blink