void
nsSMILAnimationFunction::UnsetKeyTimes()
{
  mKeyTimes.Clear();
  SetKeyTimesErrorFlag(PR_FALSE);
  mHasChanged = PR_TRUE;
}
void
nsSMILAnimationFunction::UnsetKeyTimes()
{
    mKeyTimes.Clear();
    SetKeyTimesErrorFlag(false);
    mHasChanged = true;
}
/**
 * Performs checks for the keyTimes attribute required by the SMIL spec but
 * which depend on other attributes and therefore needs to be updated as
 * dependent attributes are set.
 */
void
nsSMILAnimationFunction::CheckKeyTimes(PRUint32 aNumValues)
{
  if (!HasAttr(nsGkAtoms::keyTimes))
    return;

  // attribute is ignored for calcMode = paced
  if (GetCalcMode() == CALC_PACED) {
    SetKeyTimesErrorFlag(PR_FALSE);
    return;
  }

  if (mKeyTimes.Length() < 1) {
    // keyTimes isn't set or failed preliminary checks
    SetKeyTimesErrorFlag(PR_TRUE);
    return;
  }

  // no. keyTimes == no. values
  if ((mKeyTimes.Length() != aNumValues && !IsToAnimation()) ||
      (IsToAnimation() && mKeyTimes.Length() != 2)) {
    SetKeyTimesErrorFlag(PR_TRUE);
    return;
  }

  // special handling if there is only one keyTime. The spec doesn't say what to
  // do in this case so we allow the keyTime to be either 0 or 1.
  if (mKeyTimes.Length() == 1) {
    double time = mKeyTimes[0];
    SetKeyTimesErrorFlag(!(time == 0.0 || time == 1.0));
    return;
  }

  // According to the spec, the first value should be 0 and for linear or spline
  // calcMode's the last value should be 1, but then an example is give with
  // a spline calcMode and keyTimes "0.0; 0.7". So we don't bother checking
  // the end-values here but just allow bad specs.

  SetKeyTimesErrorFlag(PR_FALSE);
}
/**
 * Performs checks for the keyTimes attribute required by the SMIL spec but
 * which depend on other attributes and therefore needs to be updated as
 * dependent attributes are set.
 */
void
nsSMILAnimationFunction::CheckKeyTimes(uint32_t aNumValues)
{
    if (!HasAttr(nsGkAtoms::keyTimes))
        return;

    nsSMILCalcMode calcMode = GetCalcMode();

    // attribute is ignored for calcMode = paced
    if (calcMode == CALC_PACED) {
        SetKeyTimesErrorFlag(false);
        return;
    }

    uint32_t numKeyTimes = mKeyTimes.Length();
    if (numKeyTimes < 1) {
        // keyTimes isn't set or failed preliminary checks
        SetKeyTimesErrorFlag(true);
        return;
    }

    // no. keyTimes == no. values
    // For to-animation the number of values is considered to be 2.
    bool matchingNumOfValues =
        numKeyTimes == (IsToAnimation() ? 2 : aNumValues);
    if (!matchingNumOfValues) {
        SetKeyTimesErrorFlag(true);
        return;
    }

    // first value must be 0
    if (mKeyTimes[0] != 0.0) {
        SetKeyTimesErrorFlag(true);
        return;
    }

    // last value must be 1 for linear or spline calcModes
    if (calcMode != CALC_DISCRETE && numKeyTimes > 1 &&
            mKeyTimes[numKeyTimes - 1] != 1.0) {
        SetKeyTimesErrorFlag(true);
        return;
    }

    SetKeyTimesErrorFlag(false);
}