nsresult SVGAnimationElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName, const nsAttrValue* aValue, bool aNotify) { nsresult rv = SVGAnimationElementBase::AfterSetAttr(aNamespaceID, aName, aValue, aNotify); if (SVGTests::IsConditionalProcessingAttribute(aName)) { bool isDisabled = !SVGTests::PassesConditionalProcessingTests(); if (mTimedElement.SetIsDisabled(isDisabled)) { AnimationNeedsResample(); } } if (aNamespaceID != kNameSpaceID_XLink || aName != nsGkAtoms::href) return rv; if (!aValue) { mHrefTarget.Unlink(); AnimationTargetChanged(); } else if (IsInDoc()) { MOZ_ASSERT(aValue->Type() == nsAttrValue::eString, "Expected href attribute to be string type"); UpdateHrefTarget(this, aValue->GetStringValue()); } // else: we're not yet in a document -- we'll update the target on // next BindToTree call. return rv; }
void SVGAnimationElement::UpdateHrefTarget(nsIContent* aNodeForContext, const nsAString& aHrefStr) { nsCOMPtr<nsIURI> targetURI; nsCOMPtr<nsIURI> baseURI = GetBaseURI(); nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(targetURI), aHrefStr, OwnerDoc(), baseURI); mHrefTarget.Reset(aNodeForContext, targetURI); AnimationTargetChanged(); }
nsresult SVGAnimationElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName, const nsAttrValue* aValue, bool aNotify) { nsresult rv = SVGAnimationElementBase::AfterSetAttr(aNamespaceID, aName, aValue, aNotify); if (aNamespaceID != kNameSpaceID_XLink || aName != nsGkAtoms::href) return rv; if (!aValue) { mHrefTarget.Unlink(); AnimationTargetChanged(); } else if (IsInDoc()) { NS_ABORT_IF_FALSE(aValue->Type() == nsAttrValue::eString, "Expected href attribute to be string type"); UpdateHrefTarget(this, aValue->GetStringValue()); } // else: we're not yet in a document -- we'll update the target on // next BindToTree call. return rv; }