コード例 #1
0
ファイル: SVGMPathElement.cpp プロジェクト: heiher/gecko-dev
nsresult
SVGMPathElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
                              const nsAttrValue* aValue,
                              const nsAttrValue* aOldValue,
                              nsIPrincipal* aMaybeScriptedPrincipal,
                              bool aNotify)
{
  if (!aValue && aName == nsGkAtoms::href) {
    // href attr being removed.
    if (aNamespaceID == kNameSpaceID_None) {
      UnlinkHrefTarget(true);

      // 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(GetParent(), xlinkHref->GetStringValue());
      }
    } else if (aNamespaceID == kNameSpaceID_XLink &&
               !HasAttr(kNameSpaceID_None, nsGkAtoms::href)) {
      UnlinkHrefTarget(true);
    } // else: we unset some random-namespace href attribute, or unset xlink:href
      // but still have href attribute, so keep the target linking to href.
  }

  return SVGMPathElementBase::AfterSetAttr(aNamespaceID, aName,
                                           aValue, aOldValue,
                                           aMaybeScriptedPrincipal, aNotify);
}
コード例 #2
0
nsresult
SVGMPathElement::UnsetAttr(int32_t aNamespaceID,
                           nsIAtom* aAttribute, bool aNotify)
{
  nsresult rv = SVGMPathElementBase::UnsetAttr(aNamespaceID, aAttribute,
                                               aNotify);
  NS_ENSURE_SUCCESS(rv, rv);

  if (aNamespaceID == kNameSpaceID_XLink &&
      aAttribute == nsGkAtoms::href) {
    UnlinkHrefTarget(true);
  }

  return NS_OK;
}