Exemplo n.º 1
0
void SVGPointList::calculateAnimatedValue(SVGAnimationElement* animationElement, float percentage, unsigned repeatCount, PassRefPtr<SVGPropertyBase> fromValue, PassRefPtr<SVGPropertyBase> toValue, PassRefPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextElement)
{
    RefPtr<SVGPointList> fromList = toSVGPointList(fromValue);
    RefPtr<SVGPointList> toList = toSVGPointList(toValue);
    RefPtr<SVGPointList> toAtEndOfDurationList = toSVGPointList(toAtEndOfDurationValue);

    size_t fromPointListSize = fromList->length();
    size_t toPointListSize = toList->length();
    size_t toAtEndOfDurationListSize = toAtEndOfDurationList->length();

    if (!adjustFromToListValues(fromList, toList, percentage, animationElement->animationMode() == ToAnimation, true))
        return;

    for (size_t i = 0; i < toPointListSize; ++i) {
        float animatedX = at(i)->x();
        float animatedY = at(i)->y();

        FloatPoint effectiveFrom;
        if (fromPointListSize)
            effectiveFrom = fromList->at(i)->value();
        FloatPoint effectiveTo = toList->at(i)->value();
        FloatPoint effectiveToAtEnd;
        if (i < toAtEndOfDurationListSize)
            effectiveToAtEnd = toAtEndOfDurationList->at(i)->value();

        animationElement->animateAdditiveNumber(percentage, repeatCount, effectiveFrom.x(), effectiveTo.x(), effectiveToAtEnd.x(), animatedX);
        animationElement->animateAdditiveNumber(percentage, repeatCount, effectiveFrom.y(), effectiveTo.y(), effectiveToAtEnd.y(), animatedY);
        at(i)->setValue(FloatPoint(animatedX, animatedY));
    }
}
Exemplo n.º 2
0
void SVGLengthList::calculateAnimatedValue(SVGAnimationElement* animationElement, float percentage, unsigned repeatCount, PassRefPtr<SVGPropertyBase> fromValue, PassRefPtr<SVGPropertyBase> toValue, PassRefPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextElement)
{
    RefPtr<SVGLengthList> fromList = toSVGLengthList(fromValue);
    RefPtr<SVGLengthList> toList = toSVGLengthList(toValue);
    RefPtr<SVGLengthList> toAtEndOfDurationList = toSVGLengthList(toAtEndOfDurationValue);

    SVGLengthContext lengthContext(contextElement);
    ASSERT(m_mode == SVGLength::lengthModeForAnimatedLengthAttribute(animationElement->attributeName()));

    size_t fromLengthListSize = fromList->length();
    size_t toLengthListSize = toList->length();
    size_t toAtEndOfDurationListSize = toAtEndOfDurationList->length();

    if (!adjustFromToListValues(fromList, toList, percentage, animationElement->animationMode()))
        return;

    for (size_t i = 0; i < toLengthListSize; ++i) {
        float animatedNumber = at(i)->value(lengthContext);
        SVGLengthType unitType = toList->at(i)->unitType();
        float effectiveFrom = 0;
        if (fromLengthListSize) {
            if (percentage < 0.5)
                unitType = fromList->at(i)->unitType();
            effectiveFrom = fromList->at(i)->value(lengthContext);
        }
        float effectiveTo = toList->at(i)->value(lengthContext);
        float effectiveToAtEnd = i < toAtEndOfDurationListSize ? toAtEndOfDurationList->at(i)->value(lengthContext) : 0;

        animationElement->animateAdditiveNumber(percentage, repeatCount, effectiveFrom, effectiveTo, effectiveToAtEnd, animatedNumber);
        at(i)->setUnitType(unitType);
        at(i)->setValue(animatedNumber, lengthContext, ASSERT_NO_EXCEPTION);
    }
}
Exemplo n.º 3
0
void SVGLengthList::calculateAnimatedValue(
    SVGAnimationElement* animationElement,
    float percentage,
    unsigned repeatCount,
    SVGPropertyBase* fromValue,
    SVGPropertyBase* toValue,
    SVGPropertyBase* toAtEndOfDurationValue,
    SVGElement* contextElement) {
  SVGLengthList* fromList = toSVGLengthList(fromValue);
  SVGLengthList* toList = toSVGLengthList(toValue);
  SVGLengthList* toAtEndOfDurationList =
      toSVGLengthList(toAtEndOfDurationValue);

  SVGLengthContext lengthContext(contextElement);
  ASSERT(m_mode == SVGLength::lengthModeForAnimatedLengthAttribute(
                       animationElement->attributeName()));

  size_t fromLengthListSize = fromList->length();
  size_t toLengthListSize = toList->length();
  size_t toAtEndOfDurationListSize = toAtEndOfDurationList->length();

  if (!adjustFromToListValues(fromList, toList, percentage,
                              animationElement->getAnimationMode()))
    return;

  for (size_t i = 0; i < toLengthListSize; ++i) {
    // TODO(shanmuga.m): Support calc for SVGLengthList animation
    float animatedNumber = at(i)->value(lengthContext);
    CSSPrimitiveValue::UnitType unitType =
        toList->at(i)->typeWithCalcResolved();
    float effectiveFrom = 0;
    if (fromLengthListSize) {
      if (percentage < 0.5)
        unitType = fromList->at(i)->typeWithCalcResolved();
      effectiveFrom = fromList->at(i)->value(lengthContext);
    }
    float effectiveTo = toList->at(i)->value(lengthContext);
    float effectiveToAtEnd =
        i < toAtEndOfDurationListSize
            ? toAtEndOfDurationList->at(i)->value(lengthContext)
            : 0;

    animationElement->animateAdditiveNumber(percentage, repeatCount,
                                            effectiveFrom, effectiveTo,
                                            effectiveToAtEnd, animatedNumber);
    at(i)->setUnitType(unitType);
    at(i)->setValue(animatedNumber, lengthContext);
  }
}
Exemplo n.º 4
0
void SVGNumberList::calculateAnimatedValue(SVGAnimationElement* animationElement, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> fromValue, PassRefPtrWillBeRawPtr<SVGPropertyBase> toValue, PassRefPtrWillBeRawPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextElement)
{
    RefPtrWillBeRawPtr<SVGNumberList> fromList = toSVGNumberList(fromValue);
    RefPtrWillBeRawPtr<SVGNumberList> toList = toSVGNumberList(toValue);
    RefPtrWillBeRawPtr<SVGNumberList> toAtEndOfDurationList = toSVGNumberList(toAtEndOfDurationValue);

    size_t fromListSize = fromList->length();
    size_t toListSize = toList->length();
    size_t toAtEndOfDurationListSize = toAtEndOfDurationList->length();

    if (!adjustFromToListValues(fromList, toList, percentage, animationElement->animationMode()))
        return;

    for (size_t i = 0; i < toListSize; ++i) {
        float effectiveFrom = fromListSize ? fromList->at(i)->value() : 0;
        float effectiveTo = toListSize ? toList->at(i)->value() : 0;
        float effectiveToAtEnd = i < toAtEndOfDurationListSize ? toAtEndOfDurationList->at(i)->value() : 0;

        float animated = at(i)->value();
        animationElement->animateAdditiveNumber(percentage, repeatCount, effectiveFrom, effectiveTo, effectiveToAtEnd, animated);
        at(i)->setValue(animated);
    }
}