Esempio n. 1
0
PassRefPtr<AnimatableValue> AnimatableDouble::addWith(const AnimatableValue* value) const
{
    // Optimization for adding with 0.
    if (!m_number)
        return takeConstRef(value);
    const AnimatableDouble* other = toAnimatableDouble(value);
    if (!other->m_number)
        return takeConstRef(this);

    return AnimatableDouble::create(m_number + other->m_number);
}
Esempio n. 2
0
PassRefPtr<AnimatableValue> AnimatableVisibility::interpolateTo(
    const AnimatableValue* value,
    double fraction) const {
  EVisibility from = m_visibility;
  EVisibility to = toAnimatableVisibility(value)->m_visibility;
  if (from != EVisibility::Visible && to != EVisibility::Visible)
    return defaultInterpolateTo(this, value, fraction);
  if (fraction <= 0)
    return takeConstRef(this);
  if (fraction >= 1)
    return takeConstRef(value);
  return takeConstRef(from == EVisibility::Visible ? this : value);
}
PassRefPtrWillBeRawPtr<AnimatableValue> AnimatableStrokeDasharrayList::interpolateTo(const AnimatableValue* value, double fraction) const
{
    WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> > from = m_values;
    WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> > to = toAnimatableStrokeDasharrayList(value)->m_values;

    // The spec states that if the sum of all values is zero, this should be
    // treated like a value of 'none', which means that a solid line is drawn.
    // Since we animate to and from values of zero, treat a value of 'none' the
    // same. If both the two and from values are 'none', we return 'none'
    // rather than '0 0'.
    if (from.isEmpty() && to.isEmpty())
        return takeConstRef(this);
    if (from.isEmpty() || to.isEmpty()) {
        DEFINE_STATIC_REF_WILL_BE_PERSISTENT(AnimatableSVGLength, zeroPixels, (AnimatableSVGLength::create(SVGLength::create())));
        if (from.isEmpty()) {
            from.append(zeroPixels);
            from.append(zeroPixels);
        }
        if (to.isEmpty()) {
            to.append(zeroPixels);
            to.append(zeroPixels);
        }
    }

    WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> > interpolatedValues;
    bool success = interpolateLists(from, to, fraction, interpolatedValues);
    ASSERT_UNUSED(success, success);
    return adoptRefWillBeNoop(new AnimatableStrokeDasharrayList(interpolatedValues));
}
PassRefPtr<AnimatableValue> AnimatableStrokeDasharrayList::interpolateTo(
    const AnimatableValue* value,
    double fraction) const {
  if (usesDefaultInterpolationWith(value))
    return defaultInterpolateTo(this, value, fraction);

  Vector<RefPtr<AnimatableValue>> from = m_values;
  Vector<RefPtr<AnimatableValue>> to =
      toAnimatableStrokeDasharrayList(value)->m_values;

  // The spec states that if the sum of all values is zero, this should be
  // treated like a value of 'none', which means that a solid line is drawn.
  // Since we animate to and from values of zero, treat a value of 'none' the
  // same. If both the two and from values are 'none', we return 'none'
  // rather than '0 0'.
  if (from.isEmpty() && to.isEmpty())
    return takeConstRef(this);
  if (from.isEmpty() || to.isEmpty()) {
    DEFINE_STATIC_REF(AnimatableLength, zeroPixels,
                      (AnimatableLength::create(Length(Fixed), 1)));
    if (from.isEmpty()) {
      from.append(zeroPixels);
      from.append(zeroPixels);
    }
    if (to.isEmpty()) {
      to.append(zeroPixels);
      to.append(zeroPixels);
    }
  }

  Vector<RefPtr<AnimatableValue>> interpolatedValues;
  bool success = interpolateLists(from, to, fraction, interpolatedValues);
  ALLOW_UNUSED_LOCAL(success);
  return adoptRef(new AnimatableStrokeDasharrayList(interpolatedValues));
}