Exemple #1
0
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);
}
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()));
}
void CSSImageInterpolationType::apply(
    const InterpolableValue& interpolableValue,
    const NonInterpolableValue* nonInterpolableValue,
    InterpolationEnvironment& environment) const {
  ImagePropertyFunctions::setStyleImage(
      cssProperty(), *environment.state().style(),
      resolveStyleImage(cssProperty(), interpolableValue, nonInterpolableValue,
                        environment.state()));
}
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 CSSPaintInterpolationType::apply(
    const InterpolableValue& interpolableColor,
    const NonInterpolableValue*,
    InterpolationEnvironment& environment) const {
  PaintPropertyFunctions::setColor(
      cssProperty(), *environment.state().style(),
      CSSColorInterpolationType::resolveInterpolableColor(interpolableColor,
                                                          environment.state()));
}
Exemple #6
0
void CSSBasicShapeInterpolationType::apply(
    const InterpolableValue& interpolableValue,
    const NonInterpolableValue* nonInterpolableValue,
    InterpolationEnvironment& environment) const {
  BasicShapePropertyFunctions::setBasicShape(
      cssProperty(), *environment.state().style(),
      BasicShapeInterpolationFunctions::createBasicShape(
          interpolableValue, *nonInterpolableValue,
          environment.state().cssToLengthConversionData()));
}
void InvalidatableInterpolation::setFlagIfInheritUsed(InterpolationEnvironment& environment) const
{
    if (!m_property.isCSSProperty() && !m_property.isPresentationAttribute())
        return;
    if (!environment.state().parentStyle())
        return;
    const CSSValue* startValue = toCSSPropertySpecificKeyframe(m_startKeyframe)->value();
    const CSSValue* endValue = toCSSPropertySpecificKeyframe(m_endKeyframe)->value();
    if ((startValue && startValue->isInheritedValue())
        || (endValue && endValue->isInheritedValue())) {
        environment.state().parentStyle()->setHasExplicitlyInheritedProperties();
    }
}
Exemple #8
0
InterpolationValue CSSImageSliceInterpolationType::maybeConvertUnderlyingValue(
    const InterpolationEnvironment& environment) const {
  const ComputedStyle& style = *environment.state().style();
  return convertImageSlice(
      ImageSlicePropertyFunctions::getImageSlice(cssProperty(), style),
      style.effectiveZoom());
}
Exemple #9
0
InterpolationValue CSSNumberInterpolationType::maybeConvertUnderlyingValue(const InterpolationEnvironment& environment) const
{
    double underlyingNumber;
    if (!NumberPropertyFunctions::getNumber(cssProperty(), *environment.state().style(), underlyingNumber))
        return nullptr;
    return createNumberValue(underlyingNumber);
}
Exemple #10
0
 bool isValid(const InterpolationEnvironment& environment, const InterpolationValue& underlying) const final
 {
     double parentNumber;
     if (!NumberPropertyFunctions::getNumber(m_property, *environment.state().parentStyle(), parentNumber))
         return false;
     return parentNumber == m_number;
 }
 bool isValid(const InterpolationEnvironment& environment, const InterpolationValue& underlying) const final
 {
     StyleColor parentColor;
     if (!PaintPropertyFunctions::getColor(m_property, *environment.state().parentStyle(), parentColor))
         return !m_validColor;
     return m_validColor && parentColor == m_color;
 }
 bool isValid(const InterpolationEnvironment& environment, const UnderlyingValue&) const final
 {
     Length parentLength;
     if (!LengthPropertyFunctions::getLength(m_property, *environment.state().parentStyle(), parentLength))
         return false;
     return parentLength == m_length;
 }
InterpolationValue CSSImageInterpolationType::maybeConvertUnderlyingValue(
    const InterpolationEnvironment& environment) const {
  return maybeConvertStyleImage(
      ImagePropertyFunctions::getStyleImage(cssProperty(),
                                            *environment.state().style()),
      true);
}
Exemple #14
0
InterpolationValue CSSBasicShapeInterpolationType::maybeConvertUnderlyingValue(
    const InterpolationEnvironment& environment) const {
  const ComputedStyle& style = *environment.state().style();
  return BasicShapeInterpolationFunctions::maybeConvertBasicShape(
      BasicShapePropertyFunctions::getBasicShape(cssProperty(), style),
      style.effectiveZoom());
}
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));
}
void CSSLengthListInterpolationType::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);
    Vector<Length> result(length);
    for (size_t i = 0; i < length; i++) {
        result[i] = CSSLengthInterpolationType::resolveInterpolableLength(
            *interpolableList.get(i),
            nonInterpolableList.get(i),
            environment.state().cssToLengthConversionData(),
            m_valueRange);
    }
    LengthListPropertyFunctions::setLengthList(cssProperty(), *environment.state().style(), std::move(result));
}
void CSSScaleInterpolationType::apply(
    const InterpolableValue& interpolableValue,
    const NonInterpolableValue*,
    InterpolationEnvironment& environment) const {
  Scale scale(interpolableValue);
  environment.state().style()->setScale(ScaleTransformOperation::create(
      scale.array[0], scale.array[1], scale.array[2],
      TransformOperation::Scale3D));
}
InterpolationValue
CSSBorderImageLengthBoxInterpolationType::maybeConvertUnderlyingValue(
    const InterpolationEnvironment& environment) const {
  const ComputedStyle& style = *environment.state().style();
  return convertBorderImageLengthBox(
      BorderImageLengthBoxPropertyFunctions::getBorderImageLengthBox(
          cssProperty(), style),
      style.effectiveZoom());
}
void CSSTransformInterpolationType::apply(
    const InterpolableValue& interpolableValue,
    const NonInterpolableValue* untypedNonInterpolableValue,
    InterpolationEnvironment& environment) const {
  double progress = toInterpolableNumber(interpolableValue).value();
  const CSSTransformNonInterpolableValue& nonInterpolableValue =
      toCSSTransformNonInterpolableValue(*untypedNonInterpolableValue);
  environment.state().style()->setTransform(
      nonInterpolableValue.getInterpolatedTransform(progress));
}
 bool isValid(const InterpolationEnvironment& environment,
              const InterpolationValue& underlying) const final {
   const StyleImage* inheritedImage = ImagePropertyFunctions::getStyleImage(
       m_property, *environment.state().parentStyle());
   if (!m_inheritedImage && !inheritedImage)
     return true;
   if (!m_inheritedImage || !inheritedImage)
     return false;
   return *m_inheritedImage == *inheritedImage;
 }
Exemple #21
0
 bool isValid(const InterpolationEnvironment& environment,
              const InterpolationValue& underlying) const final {
   // TODO(alancutter): Just check the variables referenced instead of doing a
   // full CSSValue resolve.
   bool omitAnimationTainted = false;
   const CSSValue* resolvedValue =
       CSSVariableResolver::resolveVariableReferences(
           environment.state(), m_property, *m_variableReference,
           omitAnimationTainted);
   return m_resolvedValue->equals(*resolvedValue);
 }
Exemple #22
0
void CSSClipInterpolationType::apply(
    const InterpolableValue& interpolableValue,
    const NonInterpolableValue* nonInterpolableValue,
    InterpolationEnvironment& environment) const {
  const ClipAutos& autos =
      toCSSClipNonInterpolableValue(nonInterpolableValue)->clipAutos();
  const InterpolableList& list = toInterpolableList(interpolableValue);
  const auto& convertIndex = [&list, &environment](bool isAuto, size_t index) {
    if (isAuto)
      return Length(Auto);
    return LengthInterpolationFunctions::createLength(
        *list.get(index), nullptr,
        environment.state().cssToLengthConversionData(), ValueRangeAll);
  };
  environment.state().style()->setClip(
      LengthBox(convertIndex(autos.isTopAuto, ClipTop),
                convertIndex(autos.isRightAuto, ClipRight),
                convertIndex(autos.isBottomAuto, ClipBottom),
                convertIndex(autos.isLeftAuto, ClipLeft)));
}
Exemple #23
0
void CSSRotateInterpolationType::apply(
    const InterpolableValue& interpolableValue,
    const NonInterpolableValue* untypedNonInterpolableValue,
    InterpolationEnvironment& environment) const {
  double progress = toInterpolableNumber(interpolableValue).value();
  const CSSRotateNonInterpolableValue& nonInterpolableValue =
      toCSSRotateNonInterpolableValue(*untypedNonInterpolableValue);
  Rotation rotation = nonInterpolableValue.slerpedRotation(progress);
  environment.state().style()->setRotate(
      RotateTransformOperation::create(rotation, TransformOperation::Rotate3D));
}
Exemple #24
0
void CSSFilterListInterpolationType::apply(
    const InterpolableValue& interpolableValue,
    const NonInterpolableValue* nonInterpolableValue,
    InterpolationEnvironment& environment) const {
  const InterpolableList& interpolableList =
      toInterpolableList(interpolableValue);
  const NonInterpolableList& nonInterpolableList =
      toNonInterpolableList(*nonInterpolableValue);
  size_t length = interpolableList.length();
  DCHECK_EQ(length, nonInterpolableList.length());

  FilterOperations filterOperations;
  filterOperations.operations().reserveCapacity(length);
  for (size_t i = 0; i < length; i++)
    filterOperations.operations().push_back(
        FilterInterpolationFunctions::createFilter(*interpolableList.get(i),
                                                   *nonInterpolableList.get(i),
                                                   environment.state()));
  FilterListPropertyFunctions::setFilterList(
      cssProperty(), *environment.state().style(), std::move(filterOperations));
}
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);
}
void CSSImageSliceInterpolationType::apply(const InterpolableValue& interpolableValue, const NonInterpolableValue* nonInterpolableValue, InterpolationEnvironment& environment) const
{
    ComputedStyle& style = *environment.state().style();
    const InterpolableList& list = toInterpolableList(interpolableValue);
    const SliceTypes& types = toCSSImageSliceNonInterpolableValue(nonInterpolableValue)->types();
    const auto& convertSide = [&types, &list, &style](size_t index)
    {
        float value = clampTo<float>(toInterpolableNumber(list.get(index))->value(), 0);
        return types.isNumber[index] ? Length(value * style.effectiveZoom(), Fixed) : Length(value, Percent);
    };
    LengthBox box(
        convertSide(SideTop),
        convertSide(SideRight),
        convertSide(SideBottom),
        convertSide(SideLeft));
    ImageSlicePropertyFunctions::setImageSlice(cssProperty(), style, ImageSlice(box, types.fill));
}
void CSSLengthInterpolationType::apply(const InterpolableValue& interpolableValue, const NonInterpolableValue* nonInterpolableValue, InterpolationEnvironment& environment) const
{
    StyleResolverState& state = environment.state();
    const InterpolableList& values = toInterpolableList(interpolableValue);
    bool hasPercentage = CSSLengthNonInterpolableValue::hasPercentage(nonInterpolableValue);
    if (isPixelsOrPercentOnly(values)) {
        Length length = resolveInterpolablePixelsOrPercentageLength(values, hasPercentage, m_valueRange, effectiveZoom(*state.style()));
        if (LengthPropertyFunctions::setLength(cssProperty(), *state.style(), length)) {
#if ENABLE(ASSERT)
            // Assert that setting the length on ComputedStyle directly is identical to the AnimatableValue code path.
            RefPtr<AnimatableValue> before = CSSAnimatableValueFactory::create(cssProperty(), *state.style());
            StyleBuilder::applyProperty(cssProperty(), state, createCSSValue(values, hasPercentage, m_valueRange).get());
            RefPtr<AnimatableValue> after = CSSAnimatableValueFactory::create(cssProperty(), *state.style());
            ASSERT(before->equals(*after));
#endif
            return;
        }
    }
    StyleBuilder::applyProperty(cssProperty(), state, createCSSValue(values, hasPercentage, m_valueRange).get());
}
void CSSMotionRotationInterpolationType::apply(const InterpolableValue& interpolableValue, const NonInterpolableValue* nonInterpolableValue, InterpolationEnvironment& environment) const
{
    environment.state().style()->setMotionRotation(StyleMotionRotation(
        toInterpolableNumber(interpolableValue).value(),
        toCSSMotionRotationNonInterpolableValue(*nonInterpolableValue).rotationType()));
}
InterpolationValue CSSMotionRotationInterpolationType::maybeConvertUnderlyingValue(const InterpolationEnvironment& environment) const
{
    return convertMotionRotation(environment.state().style()->motionRotation());
}
Exemple #30
0
 bool isValid(const InterpolationEnvironment& environment,
              const InterpolationValue& underlying) const final {
   return m_inheritedAutos == getClipAutos(*environment.state().parentStyle());
 }