예제 #1
0
InterpolationValue CSSClipInterpolationType::maybeConvertUnderlyingValue(
    const InterpolationEnvironment& environment) const {
  if (environment.state().style()->hasAutoClip())
    return nullptr;
  return createClipValue(environment.state().style()->clip(),
                         environment.state().style()->effectiveZoom());
}
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 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());
}
예제 #4
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);
}
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);
}
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));
}
예제 #7
0
void CSSPaintInterpolationType::apply(
    const InterpolableValue& interpolableColor,
    const NonInterpolableValue*,
    InterpolationEnvironment& environment) const {
  PaintPropertyFunctions::setColor(
      cssProperty(), *environment.state().style(),
      CSSColorInterpolationType::resolveInterpolableColor(interpolableColor,
                                                          environment.state()));
}
예제 #8
0
void CSSImageInterpolationType::apply(
    const InterpolableValue& interpolableValue,
    const NonInterpolableValue* nonInterpolableValue,
    InterpolationEnvironment& environment) const {
  ImagePropertyFunctions::setStyleImage(
      cssProperty(), *environment.state().style(),
      resolveStyleImage(cssProperty(), interpolableValue, nonInterpolableValue,
                        environment.state()));
}
예제 #9
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();
    }
}
예제 #11
0
InterpolationValue CSSNumberInterpolationType::maybeConvertUnderlyingValue(const InterpolationEnvironment& environment) const
{
    double underlyingNumber;
    if (!NumberPropertyFunctions::getNumber(cssProperty(), *environment.state().style(), underlyingNumber))
        return nullptr;
    return createNumberValue(underlyingNumber);
}
예제 #12
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 UnderlyingValue&) const final
 {
     Length parentLength;
     if (!LengthPropertyFunctions::getLength(m_property, *environment.state().parentStyle(), parentLength))
         return false;
     return parentLength == m_length;
 }
예제 #14
0
void SVGInterpolationType::apply(
    const InterpolableValue& interpolableValue,
    const NonInterpolableValue* nonInterpolableValue,
    InterpolationEnvironment& environment) const {
  environment.svgElement().setWebAnimatedAttribute(
      attribute(), appliedSVGValue(interpolableValue, nonInterpolableValue));
}
예제 #15
0
InterpolationValue CSSImageSliceInterpolationType::maybeConvertUnderlyingValue(
    const InterpolationEnvironment& environment) const {
  const ComputedStyle& style = *environment.state().style();
  return convertImageSlice(
      ImageSlicePropertyFunctions::getImageSlice(cssProperty(), style),
      style.effectiveZoom());
}
 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;
 }
예제 #17
0
InterpolationValue CSSImageInterpolationType::maybeConvertUnderlyingValue(
    const InterpolationEnvironment& environment) const {
  return maybeConvertStyleImage(
      ImagePropertyFunctions::getStyleImage(cssProperty(),
                                            *environment.state().style()),
      true);
}
예제 #18
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));
}
InterpolationValue SVGInterpolationType::maybeConvertSingle(const PropertySpecificKeyframe& keyframe, const InterpolationEnvironment& environment, const InterpolationValue& underlying, ConversionCheckers& conversionCheckers) const
{
    if (keyframe.isNeutral())
        return maybeConvertNeutral(underlying, conversionCheckers);

    SVGPropertyBase* svgValue = environment.svgBaseValue().cloneForAnimation(toSVGPropertySpecificKeyframe(keyframe).value());
    return maybeConvertSVGValue(*svgValue);
}
InterpolationValue
CSSBorderImageLengthBoxInterpolationType::maybeConvertUnderlyingValue(
    const InterpolationEnvironment& environment) const {
  const ComputedStyle& style = *environment.state().style();
  return convertBorderImageLengthBox(
      BorderImageLengthBoxPropertyFunctions::getBorderImageLengthBox(
          cssProperty(), style),
      style.effectiveZoom());
}
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));
}
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));
}
예제 #25
0
 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;
 }
예제 #26
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)));
}
예제 #27
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));
}
예제 #28
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);
 }
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);
}
예제 #30
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));
}