commit 289df582d2ad3a27a1576087f7f1e27889dde5ea
parent 3c1b634086934ed630c7e4058a7559681010148e
Author: longsonr <longsonr@gmail.com>
Date: Sun, 14 Dec 2025 23:52:57 +0000
Bug 2005594 - ensure href is prioritised over xlink:href when neither are set r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D276376
Diffstat:
10 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/dom/svg/SVGAElement.cpp b/dom/svg/SVGAElement.cpp
@@ -49,7 +49,8 @@ SVGAElement::SVGAElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
: SVGAElementBase(std::move(aNodeInfo)), Link(this) {}
already_AddRefed<DOMSVGAnimatedString> SVGAElement::Href() {
- return mStringAttributes[HREF].IsExplicitlySet()
+ return mStringAttributes[HREF].IsExplicitlySet() ||
+ !mStringAttributes[XLINK_HREF].IsExplicitlySet()
? mStringAttributes[HREF].ToDOMAnimatedString(this)
: mStringAttributes[XLINK_HREF].ToDOMAnimatedString(this);
}
diff --git a/dom/svg/SVGFEImageElement.cpp b/dom/svg/SVGFEImageElement.cpp
@@ -327,7 +327,8 @@ bool SVGFEImageElement::OutputIsTainted(const nsTArray<bool>& aInputsAreTainted,
// SVGElement methods
already_AddRefed<DOMSVGAnimatedString> SVGFEImageElement::Href() {
- return mStringAttributes[HREF].IsExplicitlySet()
+ return mStringAttributes[HREF].IsExplicitlySet() ||
+ !mStringAttributes[XLINK_HREF].IsExplicitlySet()
? mStringAttributes[HREF].ToDOMAnimatedString(this)
: mStringAttributes[XLINK_HREF].ToDOMAnimatedString(this);
}
diff --git a/dom/svg/SVGFilterElement.cpp b/dom/svg/SVGFilterElement.cpp
@@ -83,7 +83,8 @@ already_AddRefed<DOMSVGAnimatedEnumeration> SVGFilterElement::PrimitiveUnits() {
}
already_AddRefed<DOMSVGAnimatedString> SVGFilterElement::Href() {
- return mStringAttributes[HREF].IsExplicitlySet()
+ return mStringAttributes[HREF].IsExplicitlySet() ||
+ !mStringAttributes[XLINK_HREF].IsExplicitlySet()
? mStringAttributes[HREF].ToDOMAnimatedString(this)
: mStringAttributes[XLINK_HREF].ToDOMAnimatedString(this);
}
diff --git a/dom/svg/SVGGradientElement.cpp b/dom/svg/SVGGradientElement.cpp
@@ -78,7 +78,8 @@ already_AddRefed<DOMSVGAnimatedEnumeration> SVGGradientElement::SpreadMethod() {
}
already_AddRefed<DOMSVGAnimatedString> SVGGradientElement::Href() {
- return mStringAttributes[HREF].IsExplicitlySet()
+ return mStringAttributes[HREF].IsExplicitlySet() ||
+ !mStringAttributes[XLINK_HREF].IsExplicitlySet()
? mStringAttributes[HREF].ToDOMAnimatedString(this)
: mStringAttributes[XLINK_HREF].ToDOMAnimatedString(this);
}
diff --git a/dom/svg/SVGImageElement.cpp b/dom/svg/SVGImageElement.cpp
@@ -120,7 +120,8 @@ SVGImageElement::PreserveAspectRatio() {
}
already_AddRefed<DOMSVGAnimatedString> SVGImageElement::Href() {
- return mStringAttributes[HREF].IsExplicitlySet()
+ return mStringAttributes[HREF].IsExplicitlySet() ||
+ !mStringAttributes[XLINK_HREF].IsExplicitlySet()
? mStringAttributes[HREF].ToDOMAnimatedString(this)
: mStringAttributes[XLINK_HREF].ToDOMAnimatedString(this);
}
diff --git a/dom/svg/SVGMPathElement.cpp b/dom/svg/SVGMPathElement.cpp
@@ -59,7 +59,8 @@ SVGMPathElement::SVGMPathElement(
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGMPathElement)
already_AddRefed<DOMSVGAnimatedString> SVGMPathElement::Href() {
- return mStringAttributes[HREF].IsExplicitlySet()
+ return mStringAttributes[HREF].IsExplicitlySet() ||
+ !mStringAttributes[XLINK_HREF].IsExplicitlySet()
? mStringAttributes[HREF].ToDOMAnimatedString(this)
: mStringAttributes[XLINK_HREF].ToDOMAnimatedString(this);
}
diff --git a/dom/svg/SVGPatternElement.cpp b/dom/svg/SVGPatternElement.cpp
@@ -111,7 +111,8 @@ already_AddRefed<DOMSVGAnimatedLength> SVGPatternElement::Height() {
}
already_AddRefed<DOMSVGAnimatedString> SVGPatternElement::Href() {
- return mStringAttributes[HREF].IsExplicitlySet()
+ return mStringAttributes[HREF].IsExplicitlySet() ||
+ !mStringAttributes[XLINK_HREF].IsExplicitlySet()
? mStringAttributes[HREF].ToDOMAnimatedString(this)
: mStringAttributes[XLINK_HREF].ToDOMAnimatedString(this);
}
diff --git a/dom/svg/SVGScriptElement.cpp b/dom/svg/SVGScriptElement.cpp
@@ -94,7 +94,8 @@ void SVGScriptElement::SetCrossOrigin(const nsAString& aCrossOrigin,
}
already_AddRefed<DOMSVGAnimatedString> SVGScriptElement::Href() {
- return mStringAttributes[HREF].IsExplicitlySet()
+ return mStringAttributes[HREF].IsExplicitlySet() ||
+ !mStringAttributes[XLINK_HREF].IsExplicitlySet()
? mStringAttributes[HREF].ToDOMAnimatedString(this)
: mStringAttributes[XLINK_HREF].ToDOMAnimatedString(this);
}
diff --git a/dom/svg/SVGTextPathElement.cpp b/dom/svg/SVGTextPathElement.cpp
@@ -83,7 +83,8 @@ void SVGTextPathElement::HrefAsString(nsAString& aHref) {
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGTextPathElement)
already_AddRefed<DOMSVGAnimatedString> SVGTextPathElement::Href() {
- return mStringAttributes[HREF].IsExplicitlySet()
+ return mStringAttributes[HREF].IsExplicitlySet() ||
+ !mStringAttributes[XLINK_HREF].IsExplicitlySet()
? mStringAttributes[HREF].ToDOMAnimatedString(this)
: mStringAttributes[XLINK_HREF].ToDOMAnimatedString(this);
}
diff --git a/dom/svg/SVGUseElement.cpp b/dom/svg/SVGUseElement.cpp
@@ -177,7 +177,8 @@ void SVGUseElement::UnbindFromTree(UnbindContext& aContext) {
}
already_AddRefed<DOMSVGAnimatedString> SVGUseElement::Href() {
- return mStringAttributes[HREF].IsExplicitlySet()
+ return mStringAttributes[HREF].IsExplicitlySet() ||
+ !mStringAttributes[XLINK_HREF].IsExplicitlySet()
? mStringAttributes[HREF].ToDOMAnimatedString(this)
: mStringAttributes[XLINK_HREF].ToDOMAnimatedString(this);
}