mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Bug 1245751 - Part 11: Allow href without xlink on SVG Animation elements. r=dholbert,jwatt
MozReview-Commit-ID: LJnJgHipDMP --HG-- extra : rebase_source : 627198828d137c7ed97d4745c6f5ce0e930c9442
This commit is contained in:
parent
443fceb6e7
commit
a96f44bfd1
@ -81,14 +81,15 @@ SVGAnimationElement::HasAnimAttr(nsIAtom* aAttName) const
|
||||
Element*
|
||||
SVGAnimationElement::GetTargetElementContent()
|
||||
{
|
||||
if (HasAttr(kNameSpaceID_XLink, nsGkAtoms::href)) {
|
||||
if (HasAttr(kNameSpaceID_XLink, nsGkAtoms::href) ||
|
||||
HasAttr(kNameSpaceID_None, nsGkAtoms::href)) {
|
||||
return mHrefTarget.get();
|
||||
}
|
||||
MOZ_ASSERT(!mHrefTarget.get(),
|
||||
"We shouldn't have an xlink:href target "
|
||||
"if we don't have an xlink:href attribute");
|
||||
"We shouldn't have a href target "
|
||||
"if we don't have an xlink:href or href attribute");
|
||||
|
||||
// No "xlink:href" attribute --> I should target my parent.
|
||||
// No "href" or "xlink:href" attribute --> I should target my parent.
|
||||
nsIContent* parent = GetFlattenedTreeParent();
|
||||
return parent && parent->IsElement() ? parent->AsElement() : nullptr;
|
||||
}
|
||||
@ -216,8 +217,10 @@ SVGAnimationElement::BindToTree(nsIDocument* aDocument,
|
||||
if (controller) {
|
||||
controller->RegisterAnimationElement(this);
|
||||
}
|
||||
const nsAttrValue* href = mAttrsAndChildren.GetAttr(nsGkAtoms::href,
|
||||
kNameSpaceID_XLink);
|
||||
const nsAttrValue* href =
|
||||
HasAttr(kNameSpaceID_None, nsGkAtoms::href)
|
||||
? mAttrsAndChildren.GetAttr(nsGkAtoms::href, kNameSpaceID_None)
|
||||
: mAttrsAndChildren.GetAttr(nsGkAtoms::href, kNameSpaceID_XLink);
|
||||
if (href) {
|
||||
nsAutoString hrefStr;
|
||||
href->ToString(hrefStr);
|
||||
@ -309,13 +312,34 @@ SVGAnimationElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
||||
}
|
||||
}
|
||||
|
||||
if (aNamespaceID != kNameSpaceID_XLink || aName != nsGkAtoms::href)
|
||||
if (!((aNamespaceID == kNameSpaceID_None ||
|
||||
aNamespaceID == kNameSpaceID_XLink) &&
|
||||
aName == nsGkAtoms::href)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (!aValue) {
|
||||
mHrefTarget.Unlink();
|
||||
AnimationTargetChanged();
|
||||
} else if (IsInUncomposedDoc()) {
|
||||
if (aNamespaceID == kNameSpaceID_None) {
|
||||
mHrefTarget.Unlink();
|
||||
AnimationTargetChanged();
|
||||
|
||||
// After unsetting href, we may still have xlink:href, so we
|
||||
// should try to add it back.
|
||||
const nsAttrValue* xlinkHref =
|
||||
mAttrsAndChildren.GetAttr(nsGkAtoms::href, kNameSpaceID_XLink);
|
||||
if (xlinkHref) {
|
||||
UpdateHrefTarget(this, xlinkHref->GetStringValue());
|
||||
}
|
||||
} else if (!HasAttr(kNameSpaceID_None, nsGkAtoms::href)) {
|
||||
mHrefTarget.Unlink();
|
||||
AnimationTargetChanged();
|
||||
} // else: we unset xlink:href, but we still have href attribute, so keep
|
||||
// mHrefTarget linking to href.
|
||||
} else if (IsInUncomposedDoc() &&
|
||||
!(aNamespaceID == kNameSpaceID_XLink &&
|
||||
HasAttr(kNameSpaceID_None, nsGkAtoms::href))) {
|
||||
// Note: "href" takes priority over xlink:href. So if "xlink:href" is being
|
||||
// set here, we only let that update our target if "href" is *unset*.
|
||||
MOZ_ASSERT(aValue->Type() == nsAttrValue::eString,
|
||||
"Expected href attribute to be string type");
|
||||
UpdateHrefTarget(this, aValue->GetStringValue());
|
||||
|
Loading…
Reference in New Issue
Block a user