コード例 #1
0
PassRefPtr<AnimatableValue> AnimatableImage::interpolateTo(const AnimatableValue* value, double fraction) const
{
    if (fraction <= 0 || fraction >= 1)
        return defaultInterpolateTo(this, value, fraction);
    RefPtr<CSSValue> fromValue = toCSSValue();
    // FIXME: Once cross-fade works on generated image types, remove this check.
    if (fromValue->isImageGeneratorValue())
        return defaultInterpolateTo(this, value, fraction);
    if (!fromValue->isImageValue() && !fromValue->isImageGeneratorValue()) {
        if (!m_image->isImageResource())
            return defaultInterpolateTo(this, value, fraction);
        ImageResource* resource = static_cast<ImageResource*>(m_image->data());
        fromValue = CSSImageValue::create(resource->url(), m_image.get());
    }
    const AnimatableImage* image = toAnimatableImage(value);
    RefPtr<CSSValue> toValue = image->toCSSValue();
    // FIXME: Once cross-fade works on generated image types, remove this check.
    if (toValue->isImageGeneratorValue())
        return defaultInterpolateTo(this, value, fraction);
    if (!toValue->isImageValue() && !toValue->isImageGeneratorValue()) {
        if (!image->m_image->isImageResource())
            return defaultInterpolateTo(this, value, fraction);
        ImageResource* resource = static_cast<ImageResource*>(image->m_image->data());
        toValue = CSSImageValue::create(resource->url(), image->m_image.get());
    }
    RefPtr<CSSCrossfadeValue> crossfadeValue = CSSCrossfadeValue::create(fromValue, toValue);
    crossfadeValue->setPercentage(CSSPrimitiveValue::create(fraction, CSSPrimitiveValue::CSS_NUMBER));
    return create(StyleGeneratedImage::create(crossfadeValue.get()).get());
}
コード例 #2
0
PassRefPtr<AnimatableValue> AnimatableFilterOperations::interpolateTo(const AnimatableValue* value, double fraction) const
{
    if (usesDefaultInterpolationWith(value))
        return defaultInterpolateTo(this, value, fraction);

    const AnimatableFilterOperations* target = toAnimatableFilterOperations(value);
    FilterOperations result;
    size_t fromSize = operations().size();
    size_t toSize = target->operations().size();
    size_t size = std::max(fromSize, toSize);
    for (size_t i = 0; i < size; i++) {
#if ENABLE(OILPAN)
        FilterOperation* from = (i < fromSize) ? m_operationWrapper->operations().operations()[i].get() : 0;
        FilterOperation* to = (i < toSize) ? target->m_operationWrapper->operations().operations()[i].get() : 0;
#else
        FilterOperation* from = (i < fromSize) ? m_operations.operations()[i].get() : 0;
        FilterOperation* to = (i < toSize) ? target->m_operations.operations()[i].get() : 0;
#endif
        RefPtrWillBeRawPtr<FilterOperation> blendedOp = FilterOperation::blend(from, to, fraction);
        if (blendedOp)
            result.operations().append(blendedOp);
        else
            ASSERT_NOT_REACHED();
    }
    return AnimatableFilterOperations::create(result);
}
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);
    ASSERT_UNUSED(success, success);
    return adoptRef(new AnimatableStrokeDasharrayList(interpolatedValues));
}
コード例 #4
0
ファイル: AnimatableDouble.cpp プロジェクト: Igalia/blink
PassRefPtr<AnimatableValue> AnimatableDouble::interpolateTo(const AnimatableValue* value, double fraction) const
{
    const AnimatableDouble* other = toAnimatableDouble(value);
    ASSERT(m_constraint == other->m_constraint);
    if ((m_constraint == InterpolationIsNonContinuousWithZero) && (!m_number || !other->m_number))
        return defaultInterpolateTo(this, value, fraction);
    return AnimatableDouble::create(blend(m_number, other->m_number, fraction));
}
コード例 #5
0
PassRefPtrWillBeRawPtr<AnimatableValue> AnimatableRepeatable::interpolateTo(const AnimatableValue* value, double fraction) const
{
    WillBeHeapVector<RefPtrWillBeMember<AnimatableValue>> interpolatedValues;
    bool success = interpolateLists(m_values, toAnimatableRepeatable(value)->m_values, fraction, interpolatedValues);
    if (success)
        return create(interpolatedValues);
    return defaultInterpolateTo(this, value, fraction);
}
PassRefPtr<AnimatableValue> AnimatableLengthBoxAndBool::interpolateTo(const AnimatableValue* value, double fraction) const
{
    const AnimatableLengthBoxAndBool* lengthBoxAndBool = toAnimatableLengthBoxAndBool(value);
    if (usesDefaultInterpolationWith(lengthBoxAndBool))
        return defaultInterpolateTo(this, value, fraction);
    return AnimatableLengthBoxAndBool::create(
        AnimatableValue::interpolate(box(), lengthBoxAndBool->box(), fraction),
        flag());
}
コード例 #7
0
PassRefPtrWillBeRawPtr<AnimatableValue> AnimatableSVGPaint::interpolateTo(const AnimatableValue* value, double fraction) const
{
    const AnimatableSVGPaint* svgPaint = toAnimatableSVGPaint(value);
    if (paintType() == SVGPaint::SVG_PAINTTYPE_RGBCOLOR && svgPaint->paintType() == SVGPaint::SVG_PAINTTYPE_RGBCOLOR) {
        ASSERT(uri().isNull());
        return AnimatableSVGPaint::create(SVGPaint::SVG_PAINTTYPE_RGBCOLOR, m_color.interpolateTo(svgPaint->m_color, fraction), String());
    }
    return defaultInterpolateTo(this, value, fraction);
}
コード例 #8
0
PassRefPtrWillBeRawPtr<AnimatableValue> AnimatableShapeValue::interpolateTo(const AnimatableValue* value, double fraction) const
{
    if (usesDefaultInterpolationWith(value))
        return defaultInterpolateTo(this, value, fraction);

    const AnimatableShapeValue* shapeValue = toAnimatableShapeValue(value);
    const BasicShape* fromShape = this->m_shape->shape();
    const BasicShape* toShape = shapeValue->m_shape->shape();
    return AnimatableShapeValue::create(ShapeValue::createShapeValue(toShape->blend(fromShape, fraction), shapeValue->m_shape->cssBox()).get());
}
コード例 #9
0
PassRefPtrWillBeRawPtr<AnimatableValue> AnimatableLengthBoxAndBool::interpolateTo(const AnimatableValue* value, double fraction) const
{
    const AnimatableLengthBoxAndBool* lengthBox = toAnimatableLengthBoxAndBool(value);
    if (lengthBox->flag() == flag()) {
        return AnimatableLengthBoxAndBool::create(
            AnimatableValue::interpolate(box(), lengthBox->box(), fraction),
            flag());
    }
    return defaultInterpolateTo(this, value, fraction);
}
コード例 #10
0
PassRefPtr<AnimatableValue> AnimatableImage::interpolateTo(const AnimatableValue* value, double fraction) const
{
    if (fraction <= 0 || fraction >= 1 || usesDefaultInterpolationWith(value))
        return defaultInterpolateTo(this, value, fraction);

    CSSValue* fromValue = toCSSValue();
    CSSValue* toValue = toAnimatableImage(value)->toCSSValue();

    return create(CSSCrossfadeValue::create(fromValue, toValue, CSSPrimitiveValue::create(fraction, CSSPrimitiveValue::UnitType::Number)));
}
コード例 #11
0
PassRefPtr<AnimatableValue> AnimatableSVGPaint::interpolateTo(const AnimatableValue* value, double fraction) const
{
    if (usesDefaultInterpolationWith(value))
        return defaultInterpolateTo(this, value, fraction);

    const AnimatableSVGPaint* svgPaint = toAnimatableSVGPaint(value);
    RefPtr<AnimatableColor> color = toAnimatableColor(AnimatableValue::interpolate(m_color.get(), svgPaint->m_color.get(), fraction).get());
    if (fraction < 0.5)
        return create(paintType(), visitedLinkPaintType(), color, uri(), visitedLinkURI());
    return create(svgPaint->paintType(), svgPaint->visitedLinkPaintType(), color, svgPaint->uri(), svgPaint->visitedLinkURI());
}
コード例 #12
0
ファイル: AnimatableValue.cpp プロジェクト: Miaque/mojo
PassRefPtr<AnimatableValue> AnimatableValue::interpolate(const AnimatableValue* left, const AnimatableValue* right, double fraction)
{
    ASSERT(left);
    ASSERT(right);
    ASSERT(!left->isNeutral());
    ASSERT(!right->isNeutral());

    if (fraction && fraction != 1 && left->isSameType(right))
        return left->interpolateTo(right, fraction);

    return defaultInterpolateTo(left, right, fraction);
}
コード例 #13
0
PassRefPtrWillBeRawPtr<AnimatableValue> AnimatableImage::interpolateTo(const AnimatableValue* value, double fraction) const
{
    if (fraction <= 0 || fraction >= 1 || usesDefaultInterpolationWith(value))
        return defaultInterpolateTo(this, value, fraction);

    CSSValue* fromValue = toCSSValue();
    CSSValue* toValue = toAnimatableImage(value)->toCSSValue();

    RefPtrWillBeRawPtr<CSSCrossfadeValue> crossfadeValue = CSSCrossfadeValue::create(fromValue, toValue);
    crossfadeValue->setPercentage(CSSPrimitiveValue::create(fraction, CSSPrimitiveValue::CSS_NUMBER));
    return create(crossfadeValue);
}
コード例 #14
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);
}
コード例 #15
0
PassRefPtrWillBeRawPtr<AnimatableValue> AnimatableLength::interpolateTo(const AnimatableValue* value, double fraction) const
{
    const AnimatableLength* length = toAnimatableLength(value);
    CSSPrimitiveValue::LengthUnitType type = commonUnitType(length);
    if (!isCalc(type))
        return AnimatableLength::create(blend(m_lengthValue, length->m_lengthValue, fraction), type);

    // FIXME(crbug.com/168840): Support for viewport units in calc needs to be added before we can blend them with other units.
    if (isViewportUnit() || length->isViewportUnit())
        return defaultInterpolateTo(this, value, fraction);

    return AnimatableLength::create(scale(1 - fraction).get(), length->scale(fraction).get());
}
コード例 #16
0
PassRefPtr<AnimatableValue> AnimatablePath::interpolateTo(const AnimatableValue* value, double fraction) const
{
    if (usesDefaultInterpolationWith(value))
        return defaultInterpolateTo(this, value, fraction);

    std::unique_ptr<SVGPathByteStream> byteStream = SVGPathByteStream::create();
    SVGPathByteStreamBuilder builder(*byteStream);

    SVGPathByteStreamSource fromSource(path()->byteStream());
    SVGPathByteStreamSource toSource(toAnimatablePath(value)->path()->byteStream());

    SVGPathBlender blender(&fromSource, &toSource, &builder);
    bool ok = blender.blendAnimatedPath(fraction);
    ASSERT_UNUSED(ok, ok);
    return AnimatablePath::create(StylePath::create(std::move(byteStream)));
}