InterpolationValue CSSInterpolationType::maybeConvertSingle( const PropertySpecificKeyframe& keyframe, const InterpolationEnvironment& environment, const InterpolationValue& underlying, ConversionCheckers& conversionCheckers) const { const CSSValue* value = toCSSPropertySpecificKeyframe(keyframe).value(); if (!value) return maybeConvertNeutral(underlying, conversionCheckers); if (value->isVariableReferenceValue() || value->isPendingSubstitutionValue()) { bool omitAnimationTainted = false; const CSSValue* resolvedValue = CSSVariableResolver::resolveVariableReferences( environment.state(), cssProperty(), *value, omitAnimationTainted); conversionCheckers.push_back( ResolvedVariableChecker::create(cssProperty(), value, resolvedValue)); value = resolvedValue; } if (value->isInitialValue() || (value->isUnsetValue() && !CSSPropertyMetadata::isInheritedProperty(cssProperty()))) return maybeConvertInitial(environment.state(), conversionCheckers); if (value->isInheritedValue() || (value->isUnsetValue() && CSSPropertyMetadata::isInheritedProperty(cssProperty()))) return maybeConvertInherit(environment.state(), conversionCheckers); return maybeConvertValue(*value, environment.state(), conversionCheckers); }
InterpolationValue CSSBasicShapeInterpolationType::maybeConvertInherit(const StyleResolverState& state, ConversionCheckers& conversionCheckers) const { const BasicShape* shape = BasicShapePropertyFunctions::getBasicShape(cssProperty(), *state.parentStyle()); // const_cast to take a ref. conversionCheckers.append(InheritedShapeChecker::create(cssProperty(), const_cast<BasicShape*>(shape))); return BasicShapeInterpolationFunctions::maybeConvertBasicShape(shape, state.parentStyle()->effectiveZoom()); }
PassOwnPtr<InterpolationValue> CSSShadowListInterpolationType::maybeConvertInherit(const StyleResolverState& state, ConversionCheckers& conversionCheckers) const { if (!state.parentStyle()) return nullptr; const ShadowList* parentShadowList = ShadowListPropertyFunctions::getShadowList(cssProperty(), *state.parentStyle()); conversionCheckers.append(ParentShadowListChecker::create(*this, cssProperty(), const_cast<ShadowList*>(parentShadowList))); // Take ref. return convertShadowList(parentShadowList, state.parentStyle()->effectiveZoom()); }
InterpolationValue CSSColorInterpolationType::maybeConvertInherit(const StyleResolverState& state, ConversionCheckers& conversionCheckers) const { if (!state.parentStyle()) return nullptr; // Visited color can never explicitly inherit from parent visited color so only use the unvisited color. const StyleColor inheritedColor = ColorPropertyFunctions::getUnvisitedColor(cssProperty(), *state.parentStyle()); conversionCheckers.append(ParentColorChecker::create(cssProperty(), inheritedColor)); return convertStyleColorPair(inheritedColor, inheritedColor); }
void CSSColorInterpolationType::apply(const InterpolableValue& interpolableValue, const NonInterpolableValue*, InterpolationEnvironment& environment) const { const InterpolableList& colorPair = toInterpolableList(interpolableValue); ASSERT(colorPair.length() == InterpolableColorPairIndexCount); ColorPropertyFunctions::setUnvisitedColor(cssProperty(), *environment.state().style(), resolveInterpolableColor(*colorPair.get(Unvisited), environment.state(), false, cssProperty() == CSSPropertyTextDecorationColor)); ColorPropertyFunctions::setVisitedColor(cssProperty(), *environment.state().style(), resolveInterpolableColor(*colorPair.get(Visited), environment.state(), true, cssProperty() == CSSPropertyTextDecorationColor)); }
void CSSImageInterpolationType::apply( const InterpolableValue& interpolableValue, const NonInterpolableValue* nonInterpolableValue, InterpolationEnvironment& environment) const { ImagePropertyFunctions::setStyleImage( cssProperty(), *environment.state().style(), resolveStyleImage(cssProperty(), interpolableValue, nonInterpolableValue, environment.state())); }
InterpolationValue CSSLengthListInterpolationType::maybeConvertInherit(const StyleResolverState& state, ConversionCheckers& conversionCheckers) const { Vector<Length> inheritedLengthList; bool success = LengthListPropertyFunctions::getLengthList(cssProperty(), *state.parentStyle(), inheritedLengthList); conversionCheckers.append(ParentLengthListChecker::create(cssProperty(), inheritedLengthList)); if (!success) return nullptr; return maybeConvertLengthList(inheritedLengthList, state.parentStyle()->effectiveZoom()); }
InterpolationValue CSSNumberInterpolationType::maybeConvertInherit(const StyleResolverState& state, ConversionCheckers& conversionCheckers) const { if (!state.parentStyle()) return nullptr; double inheritedNumber; if (!NumberPropertyFunctions::getNumber(cssProperty(), *state.parentStyle(), inheritedNumber)) return nullptr; conversionCheckers.append(ParentNumberChecker::create(cssProperty(), inheritedNumber)); return createNumberValue(inheritedNumber); }
PassOwnPtr<InterpolationValue> CSSLengthInterpolationType::maybeConvertInherit(const StyleResolverState& state, ConversionCheckers& conversionCheckers) const { if (!state.parentStyle()) return nullptr; Length inheritedLength; if (!LengthPropertyFunctions::getLength(cssProperty(), *state.parentStyle(), inheritedLength)) return nullptr; conversionCheckers.append(ParentLengthChecker::create(*this, cssProperty(), inheritedLength)); return maybeConvertLength(inheritedLength, effectiveZoom(*state.parentStyle())); }
PassOwnPtr<InterpolationValue> CSSImageListInterpolationType::maybeConvertInherit(const StyleResolverState& state, ConversionCheckers& conversionCheckers) const { if (!state.parentStyle()) return nullptr; StyleImageList inheritedImageList; ImageListPropertyFunctions::getImageList(cssProperty(), *state.parentStyle(), inheritedImageList); conversionCheckers.append(ParentImageListChecker::create(*this, cssProperty(), inheritedImageList)); return maybeConvertStyleImageList(inheritedImageList); }
InterpolationValue CSSFilterListInterpolationType::maybeConvertInherit( const StyleResolverState& state, ConversionCheckers& conversionCheckers) const { const FilterOperations& inheritedFilterOperations = FilterListPropertyFunctions::getFilterList(cssProperty(), *state.parentStyle()); conversionCheckers.push_back(InheritedFilterListChecker::create( cssProperty(), inheritedFilterOperations)); return convertFilterList(inheritedFilterOperations, state.style()->effectiveZoom()); }
InterpolationValue CSSImageSliceInterpolationType::maybeConvertInherit( const StyleResolverState& state, ConversionCheckers& conversionCheckers) const { const ImageSlice& inheritedImageSlice = ImageSlicePropertyFunctions::getImageSlice(cssProperty(), *state.parentStyle()); conversionCheckers.push_back(InheritedSliceTypesChecker::create( cssProperty(), SliceTypes(inheritedImageSlice))); return convertImageSlice(inheritedImageSlice, state.parentStyle()->effectiveZoom()); }
InterpolationValue CSSPaintInterpolationType::maybeConvertInherit(const StyleResolverState& state, ConversionCheckers& conversionCheckers) const { if (!state.parentStyle()) return nullptr; StyleColor parentColor; if (!PaintPropertyFunctions::getColor(cssProperty(), *state.parentStyle(), parentColor)) { conversionCheckers.append(ParentPaintChecker::create(cssProperty())); return nullptr; } conversionCheckers.append(ParentPaintChecker::create(cssProperty(), parentColor)); return InterpolationValue(CSSColorInterpolationType::createInterpolableColor(parentColor)); }
void CSSImageListInterpolationType::apply(const InterpolableValue& interpolableValue, const NonInterpolableValue* nonInterpolableValue, InterpolationEnvironment& environment) const { const InterpolableList& interpolableList = toInterpolableList(interpolableValue); const size_t length = interpolableList.length(); ASSERT(length > 0); const NonInterpolableList& nonInterpolableList = toNonInterpolableList(*nonInterpolableValue); ASSERT(nonInterpolableList.length() == length); StyleImageList imageList(length); for (size_t i = 0; i < length; i++) imageList[i] = CSSImageInterpolationType::resolveStyleImage(cssProperty(), *interpolableList.get(i), nonInterpolableList.get(i), environment.state()); ImageListPropertyFunctions::setImageList(cssProperty(), *environment.state().style(), imageList); }
InterpolationValue CSSBorderImageLengthBoxInterpolationType::maybeConvertInherit( const StyleResolverState& state, ConversionCheckers& conversionCheckers) const { const BorderImageLengthBox& inherited = BorderImageLengthBoxPropertyFunctions::getBorderImageLengthBox( cssProperty(), *state.parentStyle()); conversionCheckers.append(InheritedSideNumbersChecker::create( cssProperty(), SideNumbers(inherited))); return convertBorderImageLengthBox(inherited, state.parentStyle()->effectiveZoom()); }
InterpolationValue CSSImageInterpolationType::maybeConvertInherit( const StyleResolverState& state, ConversionCheckers& conversionCheckers) const { if (!state.parentStyle()) return nullptr; const StyleImage* inheritedImage = ImagePropertyFunctions::getStyleImage( cssProperty(), *state.parentStyle()); StyleImage* refableImage = const_cast<StyleImage*>(inheritedImage); conversionCheckers.append( InheritedImageChecker::create(cssProperty(), refableImage)); return maybeConvertStyleImage(inheritedImage, true); }
InterpolationValue CSSPaintInterpolationType::maybeConvertInitial(const StyleResolverState&, ConversionCheckers& conversionCheckers) const { StyleColor initialColor; if (!PaintPropertyFunctions::getInitialColor(cssProperty(), initialColor)) return nullptr; return InterpolationValue(CSSColorInterpolationType::createInterpolableColor(initialColor)); }
PassOwnPtr<InterpolationValue> CSSLengthInterpolationType::maybeConvertUnderlyingValue(const InterpolationEnvironment& environment) const { Length underlyingLength; if (!LengthPropertyFunctions::getLength(cssProperty(), *environment.state().style(), underlyingLength)) return nullptr; return maybeConvertLength(underlyingLength, effectiveZoom(*environment.state().style())); }
InterpolationValue CSSImageInterpolationType::maybeConvertUnderlyingValue( const InterpolationEnvironment& environment) const { return maybeConvertStyleImage( ImagePropertyFunctions::getStyleImage(cssProperty(), *environment.state().style()), true); }
InterpolationValue CSSLengthListInterpolationType::maybeConvertUnderlyingValue(const InterpolationEnvironment& environment) const { Vector<Length> underlyingLengthList; if (!LengthListPropertyFunctions::getLengthList(cssProperty(), *environment.state().style(), underlyingLengthList)) return nullptr; return maybeConvertLengthList(underlyingLengthList, environment.state().style()->effectiveZoom()); }
InterpolationValue CSSImageSliceInterpolationType::maybeConvertUnderlyingValue( const InterpolationEnvironment& environment) const { const ComputedStyle& style = *environment.state().style(); return convertImageSlice( ImageSlicePropertyFunctions::getImageSlice(cssProperty(), style), style.effectiveZoom()); }
InterpolationValue CSSNumberInterpolationType::maybeConvertUnderlyingValue(const InterpolationEnvironment& environment) const { double underlyingNumber; if (!NumberPropertyFunctions::getNumber(cssProperty(), *environment.state().style(), underlyingNumber)) return nullptr; return createNumberValue(underlyingNumber); }
InterpolationValue CSSBasicShapeInterpolationType::maybeConvertUnderlyingValue( const InterpolationEnvironment& environment) const { const ComputedStyle& style = *environment.state().style(); return BasicShapeInterpolationFunctions::maybeConvertBasicShape( BasicShapePropertyFunctions::getBasicShape(cssProperty(), style), style.effectiveZoom()); }
PassOwnPtr<InterpolationValue> CSSLengthInterpolationType::maybeConvertInitial() const { Length initialLength; if (!LengthPropertyFunctions::getInitialLength(cssProperty(), initialLength)) return nullptr; return maybeConvertLength(initialLength, 1); }
PassOwnPtr<InterpolationValue> CSSPaintInterpolationType::maybeConvertInitial() const { StyleColor initialColor; if (!PaintPropertyFunctions::getInitialColor(cssProperty(), initialColor)) return nullptr; return InterpolationValue::create(*this, CSSColorInterpolationType::createInterpolableColor(initialColor)); }
InterpolationValue CSSNumberInterpolationType::maybeConvertInitial(const StyleResolverState&) const { double initialNumber; if (!NumberPropertyFunctions::getInitialNumber(cssProperty(), initialNumber)) return nullptr; return createNumberValue(initialNumber); }
void CSSBorderImageLengthBoxInterpolationType::apply( const InterpolableValue& interpolableValue, const NonInterpolableValue* nonInterpolableValue, InterpolationEnvironment& environment) const { const SideNumbers& sideNumbers = toCSSBorderImageLengthBoxNonInterpolableValue(nonInterpolableValue) ->sideNumbers(); const Vector<RefPtr<NonInterpolableValue>>& nonInterpolableValues = toCSSBorderImageLengthBoxNonInterpolableValue(nonInterpolableValue) ->sideNonInterpolableValues(); const InterpolableList& list = toInterpolableList(interpolableValue); const auto& convertSide = [&sideNumbers, &list, &environment, &nonInterpolableValues](size_t index) -> BorderImageLength { if (sideNumbers.isNumber[index]) return clampTo<double>(toInterpolableNumber(list.get(index))->value(), 0); return LengthInterpolationFunctions::createLength( *list.get(index), nonInterpolableValues[index].get(), environment.state().cssToLengthConversionData(), ValueRangeNonNegative); }; BorderImageLengthBox box(convertSide(SideTop), convertSide(SideRight), convertSide(SideBottom), convertSide(SideLeft)); BorderImageLengthBoxPropertyFunctions::setBorderImageLengthBox( cssProperty(), *environment.state().style(), box); }
InterpolationValue CSSLengthListInterpolationType::maybeConvertInitial(const StyleResolverState&) const { Vector<Length> initialLengthList; if (!LengthListPropertyFunctions::getInitialLengthList(cssProperty(), initialLengthList)) return nullptr; return maybeConvertLengthList(initialLengthList, 1); }
InterpolationValue CSSPaintInterpolationType::maybeConvertUnderlyingValue(const InterpolationEnvironment& environment) const { // TODO(alancutter): Support capturing and animating with the visited paint color. StyleColor underlyingColor; if (!PaintPropertyFunctions::getColor(cssProperty(), *environment.state().style(), underlyingColor)) return nullptr; return InterpolationValue(CSSColorInterpolationType::createInterpolableColor(underlyingColor)); }
InterpolationValue CSSBorderImageLengthBoxInterpolationType::maybeConvertUnderlyingValue( const InterpolationEnvironment& environment) const { const ComputedStyle& style = *environment.state().style(); return convertBorderImageLengthBox( BorderImageLengthBoxPropertyFunctions::getBorderImageLengthBox( cssProperty(), style), style.effectiveZoom()); }