2013-02-08 04:50:30 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* 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-29 13:43:41 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-07-10 02:56:47 -07:00
|
|
|
#include "mozilla/dom/Link.h"
|
2014-05-21 10:08:12 -07:00
|
|
|
#include "ImportManager.h"
|
2013-02-08 04:50:30 -08:00
|
|
|
#include "nsGenericHTMLElement.h"
|
|
|
|
#include "nsIDOMHTMLLinkElement.h"
|
|
|
|
#include "nsStyleLinkElement.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
2014-03-17 21:48:20 -07:00
|
|
|
class EventChainPostVisitor;
|
2014-03-17 21:48:19 -07:00
|
|
|
class EventChainPreVisitor;
|
2013-02-08 04:50:30 -08:00
|
|
|
namespace dom {
|
|
|
|
|
2013-07-11 14:26:54 -07:00
|
|
|
class HTMLLinkElement MOZ_FINAL : public nsGenericHTMLElement,
|
|
|
|
public nsIDOMHTMLLinkElement,
|
|
|
|
public nsStyleLinkElement,
|
|
|
|
public Link
|
2013-02-08 04:50:30 -08:00
|
|
|
{
|
|
|
|
public:
|
2014-09-01 17:49:25 -07:00
|
|
|
explicit HTMLLinkElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
2013-02-08 04:50:30 -08: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-07 22:26:32 -07:00
|
|
|
void LinkAdded();
|
|
|
|
void LinkRemoved();
|
2013-02-08 04:50:30 -08:00
|
|
|
|
2014-05-21 10:08:12 -07:00
|
|
|
void UpdateImport();
|
|
|
|
|
2013-02-08 04:50:30 -08:00
|
|
|
// nsIDOMEventTarget
|
2014-03-17 21:48:19 -07:00
|
|
|
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
|
2014-03-17 21:48:20 -07:00
|
|
|
virtual nsresult PostHandleEvent(
|
|
|
|
EventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
|
2013-02-08 04:50:30 -08:00
|
|
|
|
|
|
|
// nsINode
|
2014-06-19 19:01:40 -07:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult) const MOZ_OVERRIDE;
|
2014-04-08 15:27:17 -07:00
|
|
|
virtual JSObject* WrapNode(JSContext* aCx) MOZ_OVERRIDE;
|
2013-02-08 04:50:30 -08:00
|
|
|
|
|
|
|
// nsIContent
|
|
|
|
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
2013-05-29 13:43:41 -07:00
|
|
|
bool aCompileEventHandlers) MOZ_OVERRIDE;
|
2013-02-08 04:50:30 -08:00
|
|
|
virtual void UnbindFromTree(bool aDeep = true,
|
2013-05-29 13:43:41 -07:00
|
|
|
bool aNullParent = true) MOZ_OVERRIDE;
|
2013-02-08 04:50:30 -08: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,
|
2013-05-29 13:43:41 -07:00
|
|
|
bool aNotify) MOZ_OVERRIDE;
|
2013-02-08 04:50:30 -08:00
|
|
|
virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
|
2013-05-29 13:43:41 -07:00
|
|
|
bool aNotify) MOZ_OVERRIDE;
|
|
|
|
virtual bool IsLink(nsIURI** aURI) const MOZ_OVERRIDE;
|
|
|
|
virtual already_AddRefed<nsIURI> GetHrefURI() const MOZ_OVERRIDE;
|
2013-02-08 04:50:30 -08:00
|
|
|
|
|
|
|
// Element
|
|
|
|
virtual bool ParseAttribute(int32_t aNamespaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
2013-05-29 13:43:41 -07:00
|
|
|
nsAttrValue& aResult) MOZ_OVERRIDE;
|
|
|
|
virtual void GetLinkTarget(nsAString& aTarget) MOZ_OVERRIDE;
|
2014-04-02 21:18:36 -07:00
|
|
|
virtual EventStates IntrinsicState() const MOZ_OVERRIDE;
|
2013-02-08 04:50:30 -08:00
|
|
|
|
|
|
|
void CreateAndDispatchEvent(nsIDocument* aDoc, const nsAString& aEventName);
|
|
|
|
|
2013-02-08 04:50:30 -08:00
|
|
|
// WebIDL
|
2013-03-17 07:42:59 -07:00
|
|
|
bool Disabled();
|
|
|
|
void SetDisabled(bool aDisabled);
|
2013-02-08 04:50:30 -08:00
|
|
|
// XPCOM GetHref is fine.
|
|
|
|
void SetHref(const nsAString& aHref, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::href, aHref, aRv);
|
|
|
|
}
|
2014-09-05 19:42:33 -07:00
|
|
|
void GetCrossOrigin(nsAString& aResult)
|
2013-02-08 04:50:30 -08:00
|
|
|
{
|
2014-09-05 19:42:33 -07: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 04:50:30 -08:00
|
|
|
}
|
|
|
|
// XPCOM GetRel is fine.
|
|
|
|
void SetRel(const nsAString& aRel, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::rel, aRel, aRv);
|
|
|
|
}
|
2014-03-11 05:04:26 -07:00
|
|
|
nsDOMTokenList* RelList();
|
2013-02-08 04:50:30 -08: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);
|
|
|
|
}
|
2014-04-17 04:50:54 -07:00
|
|
|
nsDOMSettableTokenList* Sizes()
|
|
|
|
{
|
|
|
|
return GetTokenList(nsGkAtoms::sizes);
|
|
|
|
}
|
2013-02-08 04:50:30 -08: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);
|
|
|
|
}
|
|
|
|
|
2014-05-21 10:08:12 -07:00
|
|
|
already_AddRefed<nsIDocument> GetImport();
|
|
|
|
already_AddRefed<ImportLoader> GetImportLoader()
|
|
|
|
{
|
|
|
|
return nsRefPtr<ImportLoader>(mImportLoader).forget();
|
|
|
|
}
|
|
|
|
|
2013-02-08 04:50:30 -08:00
|
|
|
protected:
|
2014-07-08 14:23:16 -07:00
|
|
|
virtual ~HTMLLinkElement();
|
|
|
|
|
2013-02-08 04:50:30 -08:00
|
|
|
// nsStyleLinkElement
|
2013-05-29 13:43:41 -07:00
|
|
|
virtual already_AddRefed<nsIURI> GetStyleSheetURL(bool* aIsInline) MOZ_OVERRIDE;
|
2013-02-08 04:50:30 -08:00
|
|
|
virtual void GetStyleSheetInfo(nsAString& aTitle,
|
|
|
|
nsAString& aType,
|
|
|
|
nsAString& aMedia,
|
|
|
|
bool* aIsScoped,
|
2013-05-29 13:43:41 -07:00
|
|
|
bool* aIsAlternate) MOZ_OVERRIDE;
|
2013-02-08 04:50:30 -08:00
|
|
|
virtual CORSMode GetCORSMode() const;
|
|
|
|
protected:
|
|
|
|
// nsGenericHTMLElement
|
2013-05-29 13:43:41 -07:00
|
|
|
virtual void GetItemValueText(nsAString& text) MOZ_OVERRIDE;
|
|
|
|
virtual void SetItemValueText(const nsAString& text) MOZ_OVERRIDE;
|
2014-03-11 05:04:26 -07:00
|
|
|
nsRefPtr<nsDOMTokenList > mRelList;
|
2014-05-21 10:08:12 -07:00
|
|
|
private:
|
|
|
|
nsRefPtr<ImportLoader> mImportLoader;
|
2013-02-08 04:50:30 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_HTMLLinkElement_h
|