Bug 1245751 - Part 8: Allow href without xlink on SVG <textPath> elements.
MozReview-Commit-ID: KObkvkctP4L
--- a/dom/svg/SVGTextPathElement.cpp
+++ b/dom/svg/SVGTextPathElement.cpp
@@ -56,18 +56,19 @@ nsSVGElement::EnumInfo SVGTextPathElemen
TEXTPATH_METHODTYPE_ALIGN
},
{ &nsGkAtoms::spacing,
sSpacingMap,
TEXTPATH_SPACINGTYPE_EXACT
}
};
-nsSVGElement::StringInfo SVGTextPathElement::sStringInfo[1] =
+nsSVGElement::StringInfo SVGTextPathElement::sStringInfo[2] =
{
+ { &nsGkAtoms::href, kNameSpaceID_None, true },
{ &nsGkAtoms::href, kNameSpaceID_XLink, true }
};
//----------------------------------------------------------------------
// Implementation
SVGTextPathElement::SVGTextPathElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
: SVGTextPathElementBase(aNodeInfo)
@@ -77,17 +78,19 @@ SVGTextPathElement::SVGTextPathElement(a
//----------------------------------------------------------------------
// nsIDOMNode methods
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGTextPathElement)
already_AddRefed<SVGAnimatedString>
SVGTextPathElement::Href()
{
- return mStringAttributes[HREF].ToDOMAnimatedString(this);
+ return mStringAttributes[HREF].IsExplicitlySet()
+ ? mStringAttributes[HREF].ToDOMAnimatedString(this)
+ : mStringAttributes[XLINK_HREF].ToDOMAnimatedString(this);
}
//----------------------------------------------------------------------
already_AddRefed<SVGAnimatedLength>
SVGTextPathElement::StartOffset()
{
return mLengthAttributes[STARTOFFSET].ToDOMAnimatedLength(this);
--- a/dom/svg/SVGTextPathElement.h
+++ b/dom/svg/SVGTextPathElement.h
@@ -69,17 +69,17 @@ public:
enum { /* LENGTHADJUST, */ METHOD = 1, SPACING };
nsSVGEnum mEnumAttributes[3];
virtual nsSVGEnum* EnumAttributes() override
{ return mEnumAttributes; }
static nsSVGEnumMapping sMethodMap[];
static nsSVGEnumMapping sSpacingMap[];
static EnumInfo sEnumInfo[3];
- enum { HREF };
- nsSVGString mStringAttributes[1];
- static StringInfo sStringInfo[1];
+ enum { HREF, XLINK_HREF };
+ nsSVGString mStringAttributes[2];
+ static StringInfo sStringInfo[2];
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_SVGTextPathElement_h
--- a/layout/svg/SVGTextFrame.cpp
+++ b/layout/svg/SVGTextFrame.cpp
@@ -3380,17 +3380,18 @@ void
SVGTextFrame::HandleAttributeChangeInDescendant(Element* aElement,
int32_t aNameSpaceID,
nsIAtom* aAttribute)
{
if (aElement->IsSVGElement(nsGkAtoms::textPath)) {
if (aNameSpaceID == kNameSpaceID_None &&
aAttribute == nsGkAtoms::startOffset) {
NotifyGlyphMetricsChange();
- } else if (aNameSpaceID == kNameSpaceID_XLink &&
+ } else if ((aNameSpaceID == kNameSpaceID_XLink ||
+ aNameSpaceID == kNameSpaceID_None) &&
aAttribute == nsGkAtoms::href) {
// Blow away our reference, if any
nsIFrame* childElementFrame = aElement->GetPrimaryFrame();
if (childElementFrame) {
childElementFrame->Properties().Delete(
nsSVGEffects::HrefAsTextPathProperty());
NotifyGlyphMetricsChange();
}
@@ -4817,17 +4818,24 @@ SVGTextFrame::GetTextPathPathElement(nsI
{
nsSVGTextPathProperty *property =
aTextPathFrame->Properties().Get(nsSVGEffects::HrefAsTextPathProperty());
if (!property) {
nsIContent* content = aTextPathFrame->GetContent();
dom::SVGTextPathElement* tp = static_cast<dom::SVGTextPathElement*>(content);
nsAutoString href;
- tp->mStringAttributes[dom::SVGTextPathElement::HREF].GetAnimValue(href, tp);
+ if (tp->mStringAttributes[dom::SVGTextPathElement::HREF].IsExplicitlySet()) {
+ tp->mStringAttributes[dom::SVGTextPathElement::HREF]
+ .GetAnimValue(href, tp);
+ } else {
+ tp->mStringAttributes[dom::SVGTextPathElement::XLINK_HREF]
+ .GetAnimValue(href, tp);
+ }
+
if (href.IsEmpty()) {
return nullptr; // no URL
}
nsCOMPtr<nsIURI> targetURI;
nsCOMPtr<nsIURI> base = content->GetBaseURI();
nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(targetURI), href,
content->GetUncomposedDoc(), base);