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();
|
2015-02-21 01:01:36 +03:00
|
|
|
void UpdatePreconnect();
|
2014-05-21 21:08:12 +04:00
|
|
|
|
2013-02-08 16:50:30 +04:00
|
|
|
// nsIDOMEventTarget
|
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;
|
2013-02-08 16:50:30 +04:00
|
|
|
|
|
|
|
// nsINode
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult) const override;
|
|
|
|
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;
|
2013-02-08 16:50:30 +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-02-08 16:50:30 +04:00
|
|
|
virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aNotify) override;
|
|
|
|
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);
|
|
|
|
|
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);
|
|
|
|
}
|
2014-04-17 15:50:54 +04:00
|
|
|
nsDOMSettableTokenList* Sizes()
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2014-05-21 21:08:12 +04:00
|
|
|
already_AddRefed<nsIDocument> GetImport();
|
|
|
|
already_AddRefed<ImportLoader> GetImportLoader()
|
|
|
|
{
|
|
|
|
return nsRefPtr<ImportLoader>(mImportLoader).forget();
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
virtual CORSMode GetCORSMode() const override;
|
2013-02-08 16:50:30 +04:00
|
|
|
protected:
|
|
|
|
// nsGenericHTMLElement
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void GetItemValueText(DOMString& text) override;
|
|
|
|
virtual void SetItemValueText(const nsAString& text) override;
|
2014-03-11 16:04:26 +04:00
|
|
|
nsRefPtr<nsDOMTokenList > mRelList;
|
2014-05-21 21:08:12 +04:00
|
|
|
private:
|
|
|
|
nsRefPtr<ImportLoader> mImportLoader;
|
2013-02-08 16:50:30 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_HTMLLinkElement_h
|