diff --git a/dom/svg/SVGUseElement.cpp b/dom/svg/SVGUseElement.cpp index a61e63609cb3..c7b334800c96 100644 --- a/dom/svg/SVGUseElement.cpp +++ b/dom/svg/SVGUseElement.cpp @@ -38,8 +38,9 @@ nsSVGElement::LengthInfo SVGUseElement::sLengthInfo[4] = { &nsGkAtoms::height, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }, }; -nsSVGElement::StringInfo SVGUseElement::sStringInfo[1] = +nsSVGElement::StringInfo SVGUseElement::sStringInfo[2] = { + { &nsGkAtoms::href, kNameSpaceID_None, true }, { &nsGkAtoms::href, kNameSpaceID_XLink, true } }; @@ -109,7 +110,9 @@ SVGUseElement::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const already_AddRefed SVGUseElement::Href() { - return mStringAttributes[HREF].ToDOMAnimatedString(this); + return mStringAttributes[HREF].IsExplicitlySet() + ? mStringAttributes[HREF].ToDOMAnimatedString(this) + : mStringAttributes[XLINK_HREF].ToDOMAnimatedString(this); } //---------------------------------------------------------------------- @@ -395,9 +398,15 @@ void SVGUseElement::LookupHref() { nsAutoString href; - mStringAttributes[HREF].GetAnimValue(href, this); - if (href.IsEmpty()) + if (mStringAttributes[HREF].IsExplicitlySet()) { + mStringAttributes[HREF].GetAnimValue(href, this); + } else { + mStringAttributes[XLINK_HREF].GetAnimValue(href, this); + } + + if (href.IsEmpty()) { return; + } nsCOMPtr targetURI; nsCOMPtr baseURI = mOriginal ? mOriginal->GetBaseURI() : GetBaseURI(); diff --git a/dom/svg/SVGUseElement.h b/dom/svg/SVGUseElement.h index 36f2be50eb5f..98778052daa5 100644 --- a/dom/svg/SVGUseElement.h +++ b/dom/svg/SVGUseElement.h @@ -110,9 +110,9 @@ protected: nsSVGLength2 mLengthAttributes[4]; static LengthInfo sLengthInfo[4]; - enum { HREF }; - nsSVGString mStringAttributes[1]; - static StringInfo sStringInfo[1]; + enum { HREF, XLINK_HREF }; + nsSVGString mStringAttributes[2]; + static StringInfo sStringInfo[2]; nsCOMPtr mOriginal; // if we've been cloned, our "real" copy nsCOMPtr mClone; // cloned tree diff --git a/layout/svg/nsSVGUseFrame.cpp b/layout/svg/nsSVGUseFrame.cpp index 5c15ade4230f..118d24f69110 100644 --- a/layout/svg/nsSVGUseFrame.cpp +++ b/layout/svg/nsSVGUseFrame.cpp @@ -117,8 +117,7 @@ nsSVGUseFrame::AttributeChanged(int32_t aNameSpaceID, SVGUseElement *useElement = static_cast(mContent); if (aNameSpaceID == kNameSpaceID_None) { - if (aAttribute == nsGkAtoms::x || - aAttribute == nsGkAtoms::y) { + if (aAttribute == nsGkAtoms::x || aAttribute == nsGkAtoms::y) { // make sure our cached transform matrix gets (lazily) updated mCanvasTM = nullptr; nsLayoutUtils::PostRestyleEvent( @@ -144,8 +143,11 @@ nsSVGUseFrame::AttributeChanged(int32_t aNameSpaceID, nsSVGUtils::ScheduleReflowSVG(this); } } - } else if (aNameSpaceID == kNameSpaceID_XLink && - aAttribute == nsGkAtoms::href) { + } + + if ((aNameSpaceID == kNameSpaceID_XLink || + aNameSpaceID == kNameSpaceID_None) && + aAttribute == nsGkAtoms::href) { // we're changing our nature, clear out the clone information nsLayoutUtils::PostRestyleEvent( useElement, nsRestyleHint(0),