dom/smil/nsSMILSetAnimationFunction.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/smil/nsSMILSetAnimationFunction.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,100 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "nsSMILSetAnimationFunction.h"
    1.10 +
    1.11 +inline bool
    1.12 +nsSMILSetAnimationFunction::IsDisallowedAttribute(
    1.13 +    const nsIAtom* aAttribute) const
    1.14 +{
    1.15 +  //
    1.16 +  // A <set> element is similar to <animate> but lacks:
    1.17 +  //   AnimationValue.attrib(calcMode, values, keyTimes, keySplines, from, to,
    1.18 +  //                         by) -- BUT has 'to'
    1.19 +  //   AnimationAddition.attrib(additive, accumulate)
    1.20 +  //
    1.21 +  if (aAttribute == nsGkAtoms::calcMode ||
    1.22 +      aAttribute == nsGkAtoms::values ||
    1.23 +      aAttribute == nsGkAtoms::keyTimes ||
    1.24 +      aAttribute == nsGkAtoms::keySplines ||
    1.25 +      aAttribute == nsGkAtoms::from ||
    1.26 +      aAttribute == nsGkAtoms::by ||
    1.27 +      aAttribute == nsGkAtoms::additive ||
    1.28 +      aAttribute == nsGkAtoms::accumulate) {
    1.29 +    return true;
    1.30 +  }
    1.31 +
    1.32 +  return false;
    1.33 +}
    1.34 +
    1.35 +bool
    1.36 +nsSMILSetAnimationFunction::SetAttr(nsIAtom* aAttribute,
    1.37 +                                    const nsAString& aValue,
    1.38 +                                    nsAttrValue& aResult,
    1.39 +                                    nsresult* aParseResult)
    1.40 +{
    1.41 +  if (IsDisallowedAttribute(aAttribute)) {
    1.42 +    aResult.SetTo(aValue);
    1.43 +    if (aParseResult) {
    1.44 +      // SMILANIM 4.2 says:
    1.45 +      //
    1.46 +      //   The additive and accumulate attributes are not allowed, and will be
    1.47 +      //   ignored if specified.
    1.48 +      //
    1.49 +      // So at least for those two attributes we shouldn't report an error even
    1.50 +      // if they're present. For now we'll also just silently ignore other
    1.51 +      // attribute types too.
    1.52 +      *aParseResult = NS_OK;
    1.53 +    }
    1.54 +    return true;
    1.55 +  }
    1.56 +
    1.57 +  return nsSMILAnimationFunction::SetAttr(aAttribute, aValue,
    1.58 +                                          aResult, aParseResult);
    1.59 +}
    1.60 +
    1.61 +bool
    1.62 +nsSMILSetAnimationFunction::UnsetAttr(nsIAtom* aAttribute)
    1.63 +{
    1.64 +  if (IsDisallowedAttribute(aAttribute)) {
    1.65 +    return true;
    1.66 +  }
    1.67 +
    1.68 +  return nsSMILAnimationFunction::UnsetAttr(aAttribute);
    1.69 +}
    1.70 +
    1.71 +bool
    1.72 +nsSMILSetAnimationFunction::HasAttr(nsIAtom* aAttName) const
    1.73 +{
    1.74 +  if (IsDisallowedAttribute(aAttName))
    1.75 +    return false;
    1.76 +
    1.77 +  return nsSMILAnimationFunction::HasAttr(aAttName);
    1.78 +}
    1.79 +
    1.80 +const nsAttrValue*
    1.81 +nsSMILSetAnimationFunction::GetAttr(nsIAtom* aAttName) const
    1.82 +{
    1.83 +  if (IsDisallowedAttribute(aAttName))
    1.84 +    return nullptr;
    1.85 +
    1.86 +  return nsSMILAnimationFunction::GetAttr(aAttName);
    1.87 +}
    1.88 +
    1.89 +bool
    1.90 +nsSMILSetAnimationFunction::GetAttr(nsIAtom* aAttName,
    1.91 +                                    nsAString& aResult) const
    1.92 +{
    1.93 +  if (IsDisallowedAttribute(aAttName))
    1.94 +    return false;
    1.95 +
    1.96 +  return nsSMILAnimationFunction::GetAttr(aAttName, aResult);
    1.97 +}
    1.98 +
    1.99 +bool
   1.100 +nsSMILSetAnimationFunction::WillReplace() const
   1.101 +{
   1.102 +  return true;
   1.103 +}

mercurial