Bug 1245751 - Part 8: Allow href without xlink on SVG <textPath> elements. r=jwatt

MozReview-Commit-ID: KObkvkctP4L

--HG--
extra : rebase_source : 0a91f7826814e944c9ab440ff80d2d4fdc35dd10
This commit is contained in:
Boris Chiou 2016-07-07 11:44:25 +08:00
parent 5555a786b4
commit e7eb14fbe6
3 changed files with 18 additions and 7 deletions

View File

@ -61,8 +61,9 @@ nsSVGElement::EnumInfo SVGTextPathElement::sEnumInfo[3] =
}
};
nsSVGElement::StringInfo SVGTextPathElement::sStringInfo[1] =
nsSVGElement::StringInfo SVGTextPathElement::sStringInfo[2] =
{
{ &nsGkAtoms::href, kNameSpaceID_None, true },
{ &nsGkAtoms::href, kNameSpaceID_XLink, true }
};
@ -82,7 +83,9 @@ 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);
}
//----------------------------------------------------------------------

View File

@ -74,9 +74,9 @@ public:
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

View File

@ -3385,7 +3385,8 @@ SVGTextFrame::HandleAttributeChangeInDescendant(Element* aElement,
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();
@ -4822,7 +4823,14 @@ SVGTextFrame::GetTextPathPathElement(nsIFrame* aTextPathFrame)
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
}