зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1451823 - support ping, rel, referrerPolicy, relList, hreflang, type and text on SVG a elements r=mystor
This commit is contained in:
Родитель
a0ee72689e
Коммит
a212766c28
|
@ -34,16 +34,26 @@ nsSVGElement::StringInfo SVGAElement::sStringInfo[3] =
|
|||
{ &nsGkAtoms::target, kNameSpaceID_None, true }
|
||||
};
|
||||
|
||||
// static
|
||||
const DOMTokenListSupportedToken SVGAElement::sSupportedRelValues[] = {
|
||||
"noreferrer",
|
||||
"noopener",
|
||||
nullptr
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsISupports methods
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(SVGAElement)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SVGAElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
|
||||
NS_INTERFACE_MAP_ENTRY(Link)
|
||||
NS_INTERFACE_MAP_END_INHERITING(SVGAElementBase)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(SVGAElement,
|
||||
SVGAElementBase,
|
||||
mRelList)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(SVGAElement, SVGAElementBase)
|
||||
NS_IMPL_RELEASE_INHERITED(SVGAElement, SVGAElementBase)
|
||||
|
||||
|
@ -118,6 +128,86 @@ SVGAElement::SetDownload(const nsAString& aDownload, ErrorResult& rv)
|
|||
SetAttr(nsGkAtoms::download, aDownload, rv);
|
||||
}
|
||||
|
||||
void
|
||||
SVGAElement::GetPing(nsAString& aPing)
|
||||
{
|
||||
GetAttr(nsGkAtoms::ping, aPing);
|
||||
}
|
||||
|
||||
void
|
||||
SVGAElement::SetPing(const nsAString& aPing, ErrorResult& rv)
|
||||
{
|
||||
SetAttr(nsGkAtoms::ping, aPing, rv);
|
||||
}
|
||||
|
||||
void
|
||||
SVGAElement::GetRel(nsAString& aRel)
|
||||
{
|
||||
GetAttr(nsGkAtoms::rel, aRel);
|
||||
}
|
||||
|
||||
void
|
||||
SVGAElement::SetRel(const nsAString& aRel, ErrorResult& rv)
|
||||
{
|
||||
SetAttr(nsGkAtoms::rel, aRel, rv);
|
||||
}
|
||||
|
||||
void
|
||||
SVGAElement::GetReferrerPolicy(nsAString& aPolicy)
|
||||
{
|
||||
GetEnumAttr(nsGkAtoms::referrerpolicy, EmptyCString().get(), aPolicy);
|
||||
}
|
||||
|
||||
void
|
||||
SVGAElement::SetReferrerPolicy(const nsAString& aPolicy,
|
||||
mozilla::ErrorResult& rv)
|
||||
{
|
||||
SetAttr(nsGkAtoms::referrerpolicy, aPolicy, rv);
|
||||
}
|
||||
|
||||
nsDOMTokenList*
|
||||
SVGAElement:: RelList()
|
||||
{
|
||||
if (!mRelList) {
|
||||
mRelList = new nsDOMTokenList(this, nsGkAtoms::rel, sSupportedRelValues);
|
||||
}
|
||||
return mRelList;
|
||||
}
|
||||
|
||||
void
|
||||
SVGAElement::GetHreflang(nsAString& aHreflang)
|
||||
{
|
||||
GetAttr(nsGkAtoms::hreflang, aHreflang);
|
||||
}
|
||||
|
||||
void
|
||||
SVGAElement::SetHreflang(const nsAString& aHreflang, mozilla::ErrorResult& rv)
|
||||
{
|
||||
SetAttr(nsGkAtoms::hreflang, aHreflang, rv);
|
||||
}
|
||||
|
||||
void SVGAElement::GetType(nsAString& aType)
|
||||
{
|
||||
GetAttr(nsGkAtoms::type, aType);
|
||||
}
|
||||
|
||||
void SVGAElement::SetType(const nsAString& aType, mozilla::ErrorResult& rv)
|
||||
{
|
||||
SetAttr(nsGkAtoms::type, aType, rv);
|
||||
}
|
||||
|
||||
void SVGAElement::GetText(nsAString& aText, mozilla::ErrorResult& rv)
|
||||
{
|
||||
if (NS_WARN_IF(!nsContentUtils::GetNodeTextContent(this, true, aText, fallible))) {
|
||||
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
}
|
||||
|
||||
void SVGAElement::SetText(const nsAString& aText, mozilla::ErrorResult& rv)
|
||||
{
|
||||
rv = nsContentUtils::SetNodeTextContent(this, aText, false);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIContent methods
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#define mozilla_dom_SVGAElement_h
|
||||
|
||||
#include "Link.h"
|
||||
#include "nsDOMTokenList.h"
|
||||
#include "nsSVGString.h"
|
||||
#include "mozilla/dom/SVGGraphicsElement.h"
|
||||
|
||||
|
@ -27,6 +28,8 @@ class SVGAElement final : public SVGAElementBase,
|
|||
public Link
|
||||
{
|
||||
protected:
|
||||
using Element::GetText;
|
||||
|
||||
explicit SVGAElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
||||
friend nsresult (::NS_NewSVGAElement(nsIContent **aResult,
|
||||
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
|
||||
|
@ -35,6 +38,8 @@ protected:
|
|||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGAElement, SVGAElementBase)
|
||||
|
||||
// nsINode interface methods
|
||||
void GetEventTargetParent(EventChainPreVisitor& aVisitor) override;
|
||||
virtual nsresult PostHandleEvent(
|
||||
|
@ -67,8 +72,21 @@ public:
|
|||
// WebIDL
|
||||
already_AddRefed<SVGAnimatedString> Href();
|
||||
already_AddRefed<SVGAnimatedString> Target();
|
||||
void GetDownload(nsAString & aDownload);
|
||||
void SetDownload(const nsAString & aDownload, ErrorResult& rv);
|
||||
void GetDownload(nsAString& aDownload);
|
||||
void SetDownload(const nsAString& aDownload, ErrorResult& rv);
|
||||
void GetPing(nsAString& aPing);
|
||||
void SetPing(const nsAString& aPing, mozilla::ErrorResult& rv);
|
||||
void GetRel(nsAString& aRel);
|
||||
void SetRel(const nsAString& aRel, mozilla::ErrorResult& rv);
|
||||
void SetReferrerPolicy(const nsAString& aReferrerPolicy, mozilla::ErrorResult& rv);
|
||||
void GetReferrerPolicy(nsAString& aReferrerPolicy);
|
||||
nsDOMTokenList* RelList();
|
||||
void GetHreflang(nsAString& aHreflang);
|
||||
void SetHreflang(const nsAString& aHreflang, mozilla::ErrorResult& rv);
|
||||
void GetType(nsAString& aType);
|
||||
void SetType(const nsAString& aType, mozilla::ErrorResult& rv);
|
||||
void GetText(nsAString& aText, mozilla::ErrorResult& rv);
|
||||
void SetText(const nsAString& aText, mozilla::ErrorResult& rv);
|
||||
|
||||
void NodeInfoChanged(nsIDocument* aOldDoc) final
|
||||
{
|
||||
|
@ -84,6 +102,9 @@ protected:
|
|||
enum { HREF, XLINK_HREF, TARGET };
|
||||
nsSVGString mStringAttributes[3];
|
||||
static StringInfo sStringInfo[3];
|
||||
|
||||
RefPtr<nsDOMTokenList> mRelList;
|
||||
static DOMTokenListSupportedToken sSupportedRelValues[];
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -626,6 +626,11 @@ nsSVGElement::ParseAttribute(int32_t aNamespaceID,
|
|||
aResult.ParseAtomArray(aValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (aAttribute == nsGkAtoms::rel) {
|
||||
aResult.ParseAtomArray(aValue);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundMatch) {
|
||||
|
|
|
@ -15,6 +15,21 @@ interface SVGAElement : SVGGraphicsElement {
|
|||
|
||||
[SetterThrows]
|
||||
attribute DOMString download;
|
||||
[SetterThrows]
|
||||
attribute DOMString ping;
|
||||
[SetterThrows]
|
||||
attribute DOMString rel;
|
||||
[SetterThrows]
|
||||
attribute DOMString referrerPolicy;
|
||||
[PutForwards=value]
|
||||
readonly attribute DOMTokenList relList;
|
||||
[SetterThrows]
|
||||
attribute DOMString hreflang;
|
||||
[SetterThrows]
|
||||
attribute DOMString type;
|
||||
|
||||
[Throws]
|
||||
attribute DOMString text;
|
||||
};
|
||||
|
||||
SVGAElement implements SVGURIReference;
|
||||
|
|
|
@ -10,9 +10,10 @@
|
|||
var pairs = [
|
||||
// Defined in DOM
|
||||
{attr: "classList", sup: ["anyElement"]},
|
||||
// Defined in HTML except for a which is also SVG
|
||||
{attr: "relList", sup: ["a", "area", "link"]},
|
||||
// Defined in HTML
|
||||
{attr: "htmlFor", sup: ["output"]},
|
||||
{attr: "relList", sup: ["a", "area", "link"]},
|
||||
{attr: "sandbox", sup: ["iframe"]},
|
||||
{attr: "sizes", sup: ["link"]}
|
||||
];
|
||||
|
@ -26,7 +27,11 @@ var namespaces = [
|
|||
|
||||
var elements = ["a", "area", "link", "iframe", "output", "td", "th"];
|
||||
function testAttr(pair, new_el){
|
||||
return (pair.attr === "classList" || (new_el.namespaceURI === "http://www.w3.org/1999/xhtml" && pair.sup.indexOf(new_el.localName) != -1));
|
||||
return (pair.attr === "classList" ||
|
||||
(pair.attr === "relList" && new_el.localName === "a" &&
|
||||
new_el.namespaceURI === "http://www.w3.org/2000/svg") ||
|
||||
(new_el.namespaceURI === "http://www.w3.org/1999/xhtml" &&
|
||||
pair.sup.indexOf(new_el.localName) != -1));
|
||||
}
|
||||
|
||||
pairs.forEach(function(pair) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче