michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsSMILSetAnimationFunction.h" michael@0: michael@0: inline bool michael@0: nsSMILSetAnimationFunction::IsDisallowedAttribute( michael@0: const nsIAtom* aAttribute) const michael@0: { michael@0: // michael@0: // A element is similar to but lacks: michael@0: // AnimationValue.attrib(calcMode, values, keyTimes, keySplines, from, to, michael@0: // by) -- BUT has 'to' michael@0: // AnimationAddition.attrib(additive, accumulate) michael@0: // michael@0: if (aAttribute == nsGkAtoms::calcMode || michael@0: aAttribute == nsGkAtoms::values || michael@0: aAttribute == nsGkAtoms::keyTimes || michael@0: aAttribute == nsGkAtoms::keySplines || michael@0: aAttribute == nsGkAtoms::from || michael@0: aAttribute == nsGkAtoms::by || michael@0: aAttribute == nsGkAtoms::additive || michael@0: aAttribute == nsGkAtoms::accumulate) { michael@0: return true; michael@0: } michael@0: michael@0: return false; michael@0: } michael@0: michael@0: bool michael@0: nsSMILSetAnimationFunction::SetAttr(nsIAtom* aAttribute, michael@0: const nsAString& aValue, michael@0: nsAttrValue& aResult, michael@0: nsresult* aParseResult) michael@0: { michael@0: if (IsDisallowedAttribute(aAttribute)) { michael@0: aResult.SetTo(aValue); michael@0: if (aParseResult) { michael@0: // SMILANIM 4.2 says: michael@0: // michael@0: // The additive and accumulate attributes are not allowed, and will be michael@0: // ignored if specified. michael@0: // michael@0: // So at least for those two attributes we shouldn't report an error even michael@0: // if they're present. For now we'll also just silently ignore other michael@0: // attribute types too. michael@0: *aParseResult = NS_OK; michael@0: } michael@0: return true; michael@0: } michael@0: michael@0: return nsSMILAnimationFunction::SetAttr(aAttribute, aValue, michael@0: aResult, aParseResult); michael@0: } michael@0: michael@0: bool michael@0: nsSMILSetAnimationFunction::UnsetAttr(nsIAtom* aAttribute) michael@0: { michael@0: if (IsDisallowedAttribute(aAttribute)) { michael@0: return true; michael@0: } michael@0: michael@0: return nsSMILAnimationFunction::UnsetAttr(aAttribute); michael@0: } michael@0: michael@0: bool michael@0: nsSMILSetAnimationFunction::HasAttr(nsIAtom* aAttName) const michael@0: { michael@0: if (IsDisallowedAttribute(aAttName)) michael@0: return false; michael@0: michael@0: return nsSMILAnimationFunction::HasAttr(aAttName); michael@0: } michael@0: michael@0: const nsAttrValue* michael@0: nsSMILSetAnimationFunction::GetAttr(nsIAtom* aAttName) const michael@0: { michael@0: if (IsDisallowedAttribute(aAttName)) michael@0: return nullptr; michael@0: michael@0: return nsSMILAnimationFunction::GetAttr(aAttName); michael@0: } michael@0: michael@0: bool michael@0: nsSMILSetAnimationFunction::GetAttr(nsIAtom* aAttName, michael@0: nsAString& aResult) const michael@0: { michael@0: if (IsDisallowedAttribute(aAttName)) michael@0: return false; michael@0: michael@0: return nsSMILAnimationFunction::GetAttr(aAttName, aResult); michael@0: } michael@0: michael@0: bool michael@0: nsSMILSetAnimationFunction::WillReplace() const michael@0: { michael@0: return true; michael@0: }