コード例 #1
0
ファイル: TimingParams.cpp プロジェクト: luke-chang/gecko-1
/* static */ TimingParams
TimingParams::FromOptionsType(const OptionsType& aOptions,
                              nsIDocument* aDocument,
                              ErrorResult& aRv)
{
  TimingParams result;
  if (aOptions.IsUnrestrictedDouble()) {
    double durationInMs = aOptions.GetAsUnrestrictedDouble();
    if (durationInMs >= 0) {
      result.mDuration.emplace(
        StickyTimeDuration::FromMilliseconds(durationInMs));
    } else {
      aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
      return result;
    }
  } else {
    const dom::AnimationEffectTimingProperties& timing =
      GetTimingProperties(aOptions);

    Maybe<StickyTimeDuration> duration =
      TimingParams::ParseDuration(timing.mDuration, aRv);
    if (aRv.Failed()) {
      return result;
    }
    TimingParams::ValidateIterationStart(timing.mIterationStart, aRv);
    if (aRv.Failed()) {
      return result;
    }
    TimingParams::ValidateIterations(timing.mIterations, aRv);
    if (aRv.Failed()) {
      return result;
    }
    Maybe<ComputedTimingFunction> easing =
      TimingParams::ParseEasing(timing.mEasing, aDocument, aRv);
    if (aRv.Failed()) {
      return result;
    }

    result.mDuration = duration;
    result.mDelay = TimeDuration::FromMilliseconds(timing.mDelay);
    result.mEndDelay = TimeDuration::FromMilliseconds(timing.mEndDelay);
    result.mIterations = timing.mIterations;
    result.mIterationStart = timing.mIterationStart;
    result.mDirection = timing.mDirection;
    result.mFill = timing.mFill;
    result.mFunction = easing;
  }
  result.Update();

  return result;
}
コード例 #2
0
static KeyframeEffectParams
KeyframeEffectParamsFromUnion(const OptionsType& aOptions,
                              nsAString& aInvalidPacedProperty,
                              ErrorResult& aRv)
{
  KeyframeEffectParams result;
  if (!aOptions.IsUnrestrictedDouble()) {
    const KeyframeEffectOptions& options =
      KeyframeEffectOptionsFromUnion(aOptions);
    KeyframeEffectParams::ParseSpacing(options.mSpacing,
                                       result.mSpacingMode,
                                       result.mPacedProperty,
                                       aInvalidPacedProperty,
                                       aRv);
  }
  return result;
}
コード例 #3
0
static KeyframeEffectParams
KeyframeEffectParamsFromUnion(const OptionsType& aOptions,
                              nsAString& aInvalidPacedProperty,
                              ErrorResult& aRv)
{
  KeyframeEffectParams result;
  if (!aOptions.IsUnrestrictedDouble()) {
    const KeyframeEffectOptions& options =
      KeyframeEffectOptionsFromUnion(aOptions);
    KeyframeEffectParams::ParseSpacing(options.mSpacing,
                                       result.mSpacingMode,
                                       result.mPacedProperty,
                                       aInvalidPacedProperty,
                                       aRv);
    // Ignore iterationComposite if the Web Animations API is not enabled,
    // then the default value 'Replace' will be used.
    if (AnimationUtils::IsCoreAPIEnabledForCaller()) {
      result.mIterationComposite = options.mIterationComposite;
    }
  }
  return result;
}