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-02-08 16:50:30 +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_HTMLLinkElement_h
|
|
|
|
#define mozilla_dom_HTMLLinkElement_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"
|
2014-05-21 21:08:12 +04:00
|
|
|
#include "ImportManager.h"
|
2013-02-08 16:50:30 +04:00
|
|
|
#include "nsGenericHTMLElement.h"
|
|
|
|
#include "nsIDOMHTMLLinkElement.h"
|
|
|
|
#include "nsStyleLinkElement.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
2014-03-18 08:48:20 +04:00
|
|
|
class EventChainPostVisitor;
|
2014-03-18 08:48:19 +04:00
|
|
|
class EventChainPreVisitor;
|
2013-02-08 16:50:30 +04:00
|
|
|
namespace dom {
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class HTMLLinkElement final : public nsGenericHTMLElement,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsIDOMHTMLLinkElement,
|
|
|
|
public nsStyleLinkElement,
|
|
|
|
public Link
|
2013-02-08 16:50:30 +04:00
|
|
|
{
|
|
|
|
public:
|
2014-09-02 04:49:25 +04:00
|
|
|
explicit HTMLLinkElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
2013-02-08 16:50:30 +04:00
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
// CC
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLLinkElement,
|
|
|
|
nsGenericHTMLElement)
|
|
|
|
|
|
|
|
// nsIDOMHTMLLinkElement
|
|
|
|
NS_DECL_NSIDOMHTMLLINKELEMENT
|
|
|
|
|
|
|
|
// DOM memory reporter participant
|
|
|
|
NS_DECL_SIZEOF_EXCLUDING_THIS
|
|
|
|
|
2013-08-08 09:26:32 +04:00
|
|
|
void LinkAdded();
|
|
|
|
void LinkRemoved();
|
2013-02-08 16:50:30 +04:00
|
|
|
|
2014-05-21 21:08:12 +04:00
|
|
|
void UpdateImport();
|
|
|
|
|
2013-02-08 16:50:30 +04:00
|
|
|
// nsIDOMEventTarget
|
2016-10-21 05:11:07 +03:00
|
|
|
virtual nsresult GetEventTargetParent(
|
|
|
|
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;
|
2013-02-08 16:50:30 +04:00
|
|
|
|
|
|
|
// nsINode
|
2017-04-20 22:57:48 +03:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult,
|
|
|
|
bool aPreallocateChildren) const override;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-02-08 16:50:30 +04:00
|
|
|
|
|
|
|
// nsIContent
|
|
|
|
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aCompileEventHandlers) override;
|
2013-02-08 16:50:30 +04:00
|
|
|
virtual void UnbindFromTree(bool aDeep = true,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aNullParent = true) override;
|
2015-12-01 20:22:20 +03:00
|
|
|
virtual nsresult BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
2017-03-16 21:50:41 +03:00
|
|
|
const nsAttrValueOrString* aValue,
|
2015-12-01 20:22:20 +03:00
|
|
|
bool aNotify) override;
|
2015-09-23 04:19:49 +03:00
|
|
|
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
|
|
|
const nsAttrValue* aValue,
|
|
|
|
bool aNotify) override;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsLink(nsIURI** aURI) const override;
|
|
|
|
virtual already_AddRefed<nsIURI> GetHrefURI() const override;
|
2013-02-08 16:50:30 +04:00
|
|
|
|
|
|
|
// Element
|
|
|
|
virtual bool ParseAttribute(int32_t aNamespaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsAttrValue& aResult) override;
|
|
|
|
virtual void GetLinkTarget(nsAString& aTarget) override;
|
|
|
|
virtual EventStates IntrinsicState() const override;
|
2013-02-08 16:50:30 +04:00
|
|
|
|
|
|
|
void CreateAndDispatchEvent(nsIDocument* aDoc, const nsAString& aEventName);
|
|
|
|
|
2015-12-01 20:22:20 +03:00
|
|
|
virtual void OnDNSPrefetchDeferred() override;
|
|
|
|
virtual void OnDNSPrefetchRequested() override;
|
|
|
|
virtual bool HasDeferredDNSPrefetchRequest() override;
|
|
|
|
|
2013-02-08 16:50:30 +04:00
|
|
|
// WebIDL
|
2013-03-17 18:42:59 +04:00
|
|
|
bool Disabled();
|
|
|
|
void SetDisabled(bool aDisabled);
|
2013-02-08 16:50:30 +04:00
|
|
|
// XPCOM GetHref is fine.
|
|
|
|
void SetHref(const nsAString& aHref, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::href, aHref, aRv);
|
|
|
|
}
|
2014-09-06 06:42:33 +04:00
|
|
|
void GetCrossOrigin(nsAString& aResult)
|
2013-02-08 16:50:30 +04:00
|
|
|
{
|
2014-09-06 06:42:33 +04:00
|
|
|
// Null for both missing and invalid defaults is ok, since we
|
|
|
|
// always parse to an enum value, so we don't need an invalid
|
|
|
|
// default, and we _want_ the missing default to be null.
|
|
|
|
GetEnumAttr(nsGkAtoms::crossorigin, nullptr, aResult);
|
|
|
|
}
|
|
|
|
void SetCrossOrigin(const nsAString& aCrossOrigin, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
SetOrRemoveNullableStringAttr(nsGkAtoms::crossorigin, aCrossOrigin, aError);
|
2013-02-08 16:50:30 +04:00
|
|
|
}
|
|
|
|
// XPCOM GetRel is fine.
|
|
|
|
void SetRel(const nsAString& aRel, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::rel, aRel, aRv);
|
|
|
|
}
|
2014-03-11 16:04:26 +04:00
|
|
|
nsDOMTokenList* RelList();
|
2013-02-08 16:50:30 +04:00
|
|
|
// XPCOM GetMedia is fine.
|
|
|
|
void SetMedia(const nsAString& aMedia, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::media, aMedia, aRv);
|
|
|
|
}
|
|
|
|
// XPCOM GetHreflang is fine.
|
|
|
|
void SetHreflang(const nsAString& aHreflang, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::hreflang, aHreflang, aRv);
|
|
|
|
}
|
2016-02-12 01:50:42 +03:00
|
|
|
nsDOMTokenList* Sizes()
|
2014-04-17 15:50:54 +04:00
|
|
|
{
|
|
|
|
return GetTokenList(nsGkAtoms::sizes);
|
|
|
|
}
|
2013-02-08 16:50:30 +04:00
|
|
|
// XPCOM GetType is fine.
|
|
|
|
void SetType(const nsAString& aType, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::type, aType, aRv);
|
|
|
|
}
|
|
|
|
// XPCOM GetCharset is fine.
|
|
|
|
void SetCharset(const nsAString& aCharset, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::charset, aCharset, aRv);
|
|
|
|
}
|
|
|
|
// XPCOM GetRev is fine.
|
|
|
|
void SetRev(const nsAString& aRev, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::rev, aRev, aRv);
|
|
|
|
}
|
|
|
|
// XPCOM GetTarget is fine.
|
|
|
|
void SetTarget(const nsAString& aTarget, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::target, aTarget, aRv);
|
|
|
|
}
|
2015-08-13 06:19:11 +03:00
|
|
|
void GetIntegrity(nsAString& aIntegrity) const
|
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::integrity, aIntegrity);
|
|
|
|
}
|
|
|
|
void SetIntegrity(const nsAString& aIntegrity, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::integrity, aIntegrity, aRv);
|
|
|
|
}
|
2016-06-24 05:38:47 +03:00
|
|
|
void SetReferrerPolicy(const nsAString& aReferrer, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::referrerpolicy, aReferrer, aError);
|
|
|
|
}
|
|
|
|
void GetReferrerPolicy(nsAString& aReferrer)
|
|
|
|
{
|
|
|
|
GetEnumAttr(nsGkAtoms::referrerpolicy, EmptyCString().get(), aReferrer);
|
|
|
|
}
|
|
|
|
mozilla::net::ReferrerPolicy GetLinkReferrerPolicy() override
|
|
|
|
{
|
|
|
|
return GetReferrerPolicyAsEnum();
|
|
|
|
}
|
2013-02-08 16:50:30 +04:00
|
|
|
|
2014-05-21 21:08:12 +04:00
|
|
|
already_AddRefed<nsIDocument> GetImport();
|
|
|
|
already_AddRefed<ImportLoader> GetImportLoader()
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
return RefPtr<ImportLoader>(mImportLoader).forget();
|
2014-05-21 21:08:12 +04:00
|
|
|
}
|
|
|
|
|
2015-10-15 22:12:00 +03:00
|
|
|
virtual CORSMode GetCORSMode() const override;
|
2017-04-15 18:55:05 +03:00
|
|
|
|
|
|
|
virtual void NodeInfoChanged(nsIDocument* aOldDoc) final override
|
|
|
|
{
|
|
|
|
ClearHasPendingLinkUpdate();
|
|
|
|
nsGenericHTMLElement::NodeInfoChanged(aOldDoc);
|
|
|
|
}
|
|
|
|
|
2013-02-08 16:50:30 +04:00
|
|
|
protected:
|
2014-07-09 01:23:16 +04:00
|
|
|
virtual ~HTMLLinkElement();
|
|
|
|
|
2013-02-08 16:50:30 +04:00
|
|
|
// nsStyleLinkElement
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual already_AddRefed<nsIURI> GetStyleSheetURL(bool* aIsInline) override;
|
2013-02-08 16:50:30 +04:00
|
|
|
virtual void GetStyleSheetInfo(nsAString& aTitle,
|
|
|
|
nsAString& aType,
|
|
|
|
nsAString& aMedia,
|
|
|
|
bool* aIsScoped,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool* aIsAlternate) override;
|
2013-02-08 16:50:30 +04:00
|
|
|
protected:
|
2016-05-21 06:13:17 +03:00
|
|
|
RefPtr<nsDOMTokenList> mRelList;
|
2015-12-01 20:22:20 +03:00
|
|
|
|
2014-05-21 21:08:12 +04:00
|
|
|
private:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ImportLoader> mImportLoader;
|
2013-02-08 16:50:30 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_HTMLLinkElement_h
|