void InterpolableBool::interpolate(const InterpolableValue &to, const double progress, InterpolableValue& result) const { const InterpolableBool& toBool = toInterpolableBool(to); InterpolableBool& resultBool = toInterpolableBool(result); if (progress < 0.5) resultBool.m_value = m_value; else resultBool.m_value = toBool.m_value; }
void LengthBoxStyleInterpolation::apply(StyleResolverState& state) const { if (m_cachedValue.get()->isBool()) StyleBuilder::applyProperty(m_id, state, toInterpolableBool(m_cachedValue.get())->value() ? m_endCSSValue.get() : m_startCSSValue.get()); else StyleBuilder::applyProperty(m_id, state, interpolableValueToLengthBox(m_cachedValue.get(), *m_startCSSValue, *m_endCSSValue).get()); }
PathSegmentData consumeInterpolableArc(const InterpolableValue& value, SVGPathSegType segType, PathCoordinates& coordinates) { const InterpolableList& list = toInterpolableList(value); bool isAbsolute = isAbsolutePathSegType(segType); PathSegmentData segment; segment.command = segType; segment.targetPoint.setX(consumeInterpolableCoordinateAxis( list.get(0), isAbsolute, coordinates.currentX)); segment.targetPoint.setY(consumeInterpolableCoordinateAxis( list.get(1), isAbsolute, coordinates.currentY)); segment.arcRadii().setX(toInterpolableNumber(list.get(2))->value()); segment.arcRadii().setY(toInterpolableNumber(list.get(3))->value()); segment.setArcAngle(toInterpolableNumber(list.get(4))->value()); segment.arcLarge = toInterpolableBool(list.get(5))->value(); segment.arcSweep = toInterpolableBool(list.get(6))->value(); return segment; }
TEST_F(AnimationInterpolableValueTest, NestedList) { OwnPtrWillBeRawPtr<InterpolableList> listA = InterpolableList::create(3); listA->set(0, InterpolableNumber::create(0)); OwnPtrWillBeRawPtr<InterpolableList> subListA = InterpolableList::create(1); subListA->set(0, InterpolableNumber::create(100)); listA->set(1, subListA.release()); listA->set(2, InterpolableBool::create(false)); OwnPtrWillBeRawPtr<InterpolableList> listB = InterpolableList::create(3); listB->set(0, InterpolableNumber::create(100)); OwnPtrWillBeRawPtr<InterpolableList> subListB = InterpolableList::create(1); subListB->set(0, InterpolableNumber::create(50)); listB->set(1, subListB.release()); listB->set(2, InterpolableBool::create(true)); RefPtrWillBeRawPtr<Interpolation> i = interpolateLists(listA.release(), listB.release(), 0.5); InterpolableList* outList = toInterpolableList(interpolationValue(*i.get())); EXPECT_FLOAT_EQ(50, toInterpolableNumber(outList->get(0))->value()); EXPECT_FLOAT_EQ(75, toInterpolableNumber(toInterpolableList(outList->get(1))->get(0))->value()); EXPECT_TRUE(toInterpolableBool(outList->get(2))->value()); }
bool interpolateBools(bool a, bool b, double progress) { RefPtrWillBeRawPtr<Interpolation> i = SampleInterpolation::create(InterpolableBool::create(a), InterpolableBool::create(b)); i->interpolate(0, progress); return toInterpolableBool(interpolationValue(*i.get()))->value(); }