2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-01-04 21:02:13 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_HTMLAnchorElement_h
|
|
|
|
#define mozilla_dom_HTMLAnchorElement_h
|
|
|
|
|
2013-05-30 00:43:41 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-07-10 13:56:47 +04:00
|
|
|
#include "mozilla/dom/Link.h"
|
2013-01-04 21:02:13 +04:00
|
|
|
#include "nsGenericHTMLElement.h"
|
|
|
|
#include "nsIDOMHTMLAnchorElement.h"
|
2014-03-11 16:04:26 +04:00
|
|
|
#include "nsDOMTokenList.h"
|
2013-01-04 21:02:13 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2014-03-18 08:48:20 +04:00
|
|
|
class EventChainPostVisitor;
|
2014-03-18 08:48:19 +04:00
|
|
|
class EventChainPreVisitor;
|
2013-01-04 21:02:13 +04:00
|
|
|
namespace dom {
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class HTMLAnchorElement final : public nsGenericHTMLElement,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsIDOMHTMLAnchorElement,
|
|
|
|
public Link
|
2013-01-04 21:02:13 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
using Element::GetText;
|
|
|
|
using Element::SetText;
|
|
|
|
|
2014-09-02 04:49:25 +04:00
|
|
|
explicit HTMLAnchorElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2013-01-04 21:02:13 +04:00
|
|
|
: nsGenericHTMLElement(aNodeInfo)
|
2015-01-07 08:39:46 +03:00
|
|
|
, Link(this)
|
2013-01-04 21:02:13 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2013-12-12 23:30:27 +04:00
|
|
|
// CC
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLAnchorElement,
|
|
|
|
nsGenericHTMLElement)
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual int32_t TabIndexDefault() override;
|
|
|
|
virtual bool Draggable() const override;
|
2013-01-04 21:02:13 +04:00
|
|
|
|
2015-01-20 23:39:28 +03:00
|
|
|
// Element
|
2015-05-29 12:23:08 +03:00
|
|
|
virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const override;
|
2015-01-20 23:39:28 +03:00
|
|
|
|
2013-01-04 21:02:13 +04:00
|
|
|
// nsIDOMHTMLAnchorElement
|
|
|
|
NS_DECL_NSIDOMHTMLANCHORELEMENT
|
|
|
|
|
|
|
|
// DOM memory reporter participant
|
|
|
|
NS_DECL_SIZEOF_EXCLUDING_THIS
|
|
|
|
|
|
|
|
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aCompileEventHandlers) override;
|
2013-01-04 21:02:13 +04:00
|
|
|
virtual void UnbindFromTree(bool aDeep = true,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aNullParent = true) override;
|
|
|
|
virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, int32_t *aTabIndex) override;
|
2013-01-04 21:02:13 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) override;
|
2014-03-18 08:48:20 +04:00
|
|
|
virtual nsresult PostHandleEvent(
|
2015-03-21 19:28:04 +03:00
|
|
|
EventChainPostVisitor& aVisitor) override;
|
|
|
|
virtual bool IsLink(nsIURI** aURI) const override;
|
|
|
|
virtual void GetLinkTarget(nsAString& aTarget) override;
|
|
|
|
virtual already_AddRefed<nsIURI> GetHrefURI() const override;
|
2013-01-04 21:02:13 +04:00
|
|
|
|
|
|
|
nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
|
|
|
const nsAString& aValue, bool aNotify)
|
|
|
|
{
|
|
|
|
return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify);
|
|
|
|
}
|
|
|
|
virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
|
|
|
nsIAtom* aPrefix, const nsAString& aValue,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aNotify) override;
|
2013-01-04 21:02:13 +04:00
|
|
|
virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aNotify) override;
|
2013-01-04 21:02:13 +04:00
|
|
|
virtual bool ParseAttribute(int32_t aNamespaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsAttrValue& aResult) override;
|
2013-01-04 21:02:13 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
|
2013-01-04 21:02:13 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual EventStates IntrinsicState() const override;
|
2013-01-04 21:02:13 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void OnDNSPrefetchDeferred() override;
|
|
|
|
virtual void OnDNSPrefetchRequested() override;
|
|
|
|
virtual bool HasDeferredDNSPrefetchRequest() override;
|
2013-01-04 21:02:13 +04:00
|
|
|
|
2013-01-04 21:02:13 +04:00
|
|
|
// WebIDL API
|
2015-11-23 23:05:26 +03:00
|
|
|
|
|
|
|
// The XPCOM GetHref is OK for us
|
2013-01-04 21:02:13 +04:00
|
|
|
void SetHref(const nsAString& aValue, mozilla::ErrorResult& rv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::href, aValue, rv);
|
|
|
|
}
|
|
|
|
// The XPCOM GetTarget is OK for us
|
|
|
|
void SetTarget(const nsAString& aValue, mozilla::ErrorResult& rv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::target, aValue, rv);
|
|
|
|
}
|
2015-02-13 04:27:39 +03:00
|
|
|
void GetDownload(DOMString& aValue)
|
2013-01-04 21:02:13 +04:00
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::download, aValue);
|
|
|
|
}
|
|
|
|
void SetDownload(const nsAString& aValue, mozilla::ErrorResult& rv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::download, aValue, rv);
|
|
|
|
}
|
|
|
|
// The XPCOM GetPing is OK for us
|
|
|
|
void SetPing(const nsAString& aValue, mozilla::ErrorResult& rv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::ping, aValue, rv);
|
|
|
|
}
|
2015-02-13 04:27:39 +03:00
|
|
|
void GetRel(DOMString& aValue)
|
2013-01-04 21:02:13 +04:00
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::rel, aValue);
|
|
|
|
}
|
|
|
|
void SetRel(const nsAString& aValue, mozilla::ErrorResult& rv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::rel, aValue, rv);
|
|
|
|
}
|
2015-12-01 03:13:03 +03:00
|
|
|
void SetReferrerPolicy(const nsAString& aValue, mozilla::ErrorResult& rv)
|
2015-06-06 01:25:24 +03:00
|
|
|
{
|
2015-12-01 03:13:03 +03:00
|
|
|
SetHTMLAttr(nsGkAtoms::referrerpolicy, aValue, rv);
|
2015-06-06 01:25:24 +03:00
|
|
|
}
|
2015-12-01 03:13:03 +03:00
|
|
|
void GetReferrerPolicy(nsAString& aReferrer)
|
2015-06-06 01:25:24 +03:00
|
|
|
{
|
2016-04-18 13:35:47 +03:00
|
|
|
GetEnumAttr(nsGkAtoms::referrerpolicy, EmptyCString().get(), aReferrer);
|
2015-06-06 01:25:24 +03:00
|
|
|
}
|
2014-03-11 16:04:26 +04:00
|
|
|
nsDOMTokenList* RelList();
|
2015-02-13 04:27:39 +03:00
|
|
|
void GetHreflang(DOMString& aValue)
|
2013-01-04 21:02:13 +04:00
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::hreflang, aValue);
|
|
|
|
}
|
|
|
|
void SetHreflang(const nsAString& aValue, mozilla::ErrorResult& rv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::hreflang, aValue, rv);
|
|
|
|
}
|
2015-02-13 04:27:39 +03:00
|
|
|
void GetType(DOMString& aValue)
|
2013-01-04 21:02:13 +04:00
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::type, aValue);
|
|
|
|
}
|
|
|
|
void SetType(const nsAString& aValue, mozilla::ErrorResult& rv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::type, aValue, rv);
|
|
|
|
}
|
|
|
|
// The XPCOM GetText is OK for us
|
|
|
|
void SetText(const nsAString& aValue, mozilla::ErrorResult& rv)
|
|
|
|
{
|
|
|
|
rv = SetText(aValue);
|
|
|
|
}
|
2013-09-04 21:05:10 +04:00
|
|
|
|
2013-12-12 23:30:27 +04:00
|
|
|
// Link::GetOrigin is OK for us
|
2013-09-04 21:05:10 +04:00
|
|
|
|
2015-11-23 23:05:26 +03:00
|
|
|
// Link::GetProtocol is OK for us
|
|
|
|
// Link::SetProtocol is OK for us
|
2014-07-12 03:30:27 +04:00
|
|
|
|
2013-12-12 23:30:27 +04:00
|
|
|
// Link::GetUsername is OK for us
|
|
|
|
// Link::SetUsername is OK for us
|
2013-09-04 21:05:10 +04:00
|
|
|
|
2014-07-12 03:30:27 +04:00
|
|
|
// Link::GetPassword is OK for us
|
|
|
|
// Link::SetPassword is OK for us
|
|
|
|
|
2015-11-23 23:05:26 +03:00
|
|
|
// Link::Link::GetHost is OK for us
|
|
|
|
// Link::Link::SetHost is OK for us
|
2014-07-12 03:30:27 +04:00
|
|
|
|
2015-11-23 23:05:26 +03:00
|
|
|
// Link::Link::GetHostname is OK for us
|
|
|
|
// Link::Link::SetHostname is OK for us
|
2014-07-12 03:30:27 +04:00
|
|
|
|
2015-11-23 23:05:26 +03:00
|
|
|
// Link::Link::GetPort is OK for us
|
|
|
|
// Link::Link::SetPort is OK for us
|
2014-07-12 03:30:27 +04:00
|
|
|
|
2015-11-23 23:05:26 +03:00
|
|
|
// Link::Link::GetPathname is OK for us
|
|
|
|
// Link::Link::SetPathname is OK for us
|
2014-07-12 03:30:27 +04:00
|
|
|
|
2015-11-23 23:05:26 +03:00
|
|
|
// Link::Link::GetSearch is OK for us
|
|
|
|
// Link::Link::SetSearch is OK for us
|
2014-07-12 03:30:27 +04:00
|
|
|
|
2015-11-23 23:05:26 +03:00
|
|
|
// Link::Link::GetHash is OK for us
|
|
|
|
// Link::Link::SetHash is OK for us
|
2013-09-04 21:05:10 +04:00
|
|
|
|
2013-01-04 21:02:13 +04:00
|
|
|
// The XPCOM URI decomposition attributes are fine for us
|
2015-02-13 04:27:39 +03:00
|
|
|
void GetCoords(DOMString& aValue)
|
2013-01-04 21:02:13 +04:00
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::coords, aValue);
|
|
|
|
}
|
|
|
|
void SetCoords(const nsAString& aValue, mozilla::ErrorResult& rv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::coords, aValue, rv);
|
|
|
|
}
|
2015-02-13 04:27:39 +03:00
|
|
|
void GetCharset(DOMString& aValue)
|
2013-01-04 21:02:13 +04:00
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::charset, aValue);
|
|
|
|
}
|
|
|
|
void SetCharset(const nsAString& aValue, mozilla::ErrorResult& rv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::charset, aValue, rv);
|
|
|
|
}
|
2015-02-13 04:27:39 +03:00
|
|
|
void GetName(DOMString& aValue)
|
2013-01-04 21:02:13 +04:00
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::name, aValue);
|
|
|
|
}
|
|
|
|
void SetName(const nsAString& aValue, mozilla::ErrorResult& rv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::name, aValue, rv);
|
|
|
|
}
|
2015-02-13 04:27:39 +03:00
|
|
|
void GetRev(DOMString& aValue)
|
2013-01-04 21:02:13 +04:00
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::rev, aValue);
|
|
|
|
}
|
|
|
|
void SetRev(const nsAString& aValue, mozilla::ErrorResult& rv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::rev, aValue, rv);
|
|
|
|
}
|
2015-02-13 04:27:39 +03:00
|
|
|
void GetShape(DOMString& aValue)
|
2013-01-04 21:02:13 +04:00
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::shape, aValue);
|
|
|
|
}
|
|
|
|
void SetShape(const nsAString& aValue, mozilla::ErrorResult& rv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::shape, aValue, rv);
|
|
|
|
}
|
2015-11-23 23:05:26 +03:00
|
|
|
void Stringify(nsAString& aResult)
|
2013-01-04 21:02:13 +04:00
|
|
|
{
|
2015-11-23 23:05:26 +03:00
|
|
|
GetHref(aResult);
|
2013-01-04 21:02:13 +04:00
|
|
|
}
|
|
|
|
|
2016-05-05 06:41:24 +03:00
|
|
|
static DOMTokenListSupportedToken sSupportedRelValues[];
|
|
|
|
|
2013-01-04 21:02:13 +04:00
|
|
|
protected:
|
2014-07-09 01:23:16 +04:00
|
|
|
virtual ~HTMLAnchorElement();
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsDOMTokenList > mRelList;
|
2013-01-04 21:02:13 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_HTMLAnchorElement_h
|