PassOwnPtr<InterpolationValue> CSSImageListInterpolationType::maybeConvertNeutral(const UnderlyingValue& underlyingValue, ConversionCheckers& conversionCheckers) const
{
    if (!underlyingValue) {
        conversionCheckers.append(UnderlyingImageListChecker::create(*this, nullptr));
        return nullptr;
    }
    conversionCheckers.append(UnderlyingImageListChecker::create(*this, underlyingValue->clone()));
    return underlyingValue->clone();
}
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));
}
Esempio n. 3
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);
}
InterpolationValue CSSBasicShapeInterpolationType::maybeConvertNeutral(const InterpolationValue& underlying, ConversionCheckers& conversionCheckers) const
{
    // const_cast is for taking refs.
    NonInterpolableValue* nonInterpolableValue = const_cast<NonInterpolableValue*>(underlying.nonInterpolableValue.get());
    conversionCheckers.append(UnderlyingCompatibilityChecker::create(nonInterpolableValue));
    return InterpolationValue(BasicShapeInterpolationFunctions::createNeutralValue(*underlying.nonInterpolableValue), nonInterpolableValue);
}
InterpolationValue CSSScaleInterpolationType::maybeConvertInherit(
    const StyleResolverState& state,
    ConversionCheckers& conversionCheckers) const {
  Scale parentScale(state.parentStyle()->scale());
  conversionCheckers.append(ParentScaleChecker::create(parentScale));
  return InterpolationValue(parentScale.createInterpolableValue());
}
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());
}
InterpolationValue CSSTransformInterpolationType::maybeConvertValue(
    const CSSValue& value,
    const StyleResolverState& state,
    ConversionCheckers& conversionCheckers) const {
  if (value.isValueList()) {
    CSSLengthArray lengthArray;
    for (const CSSValue* item : toCSSValueList(value)) {
      const CSSFunctionValue& transformFunction = toCSSFunctionValue(*item);
      if (transformFunction.functionType() == CSSValueMatrix ||
          transformFunction.functionType() == CSSValueMatrix3d) {
        lengthArray.typeFlags.set(CSSPrimitiveValue::UnitTypePixels);
        continue;
      }
      for (const CSSValue* argument : transformFunction) {
        const CSSPrimitiveValue& primitiveValue =
            toCSSPrimitiveValue(*argument);
        if (!primitiveValue.isLength())
          continue;
        primitiveValue.accumulateLengthArray(lengthArray);
      }
    }
    std::unique_ptr<InterpolationType::ConversionChecker> lengthUnitsChecker =
        LengthUnitsChecker::maybeCreate(std::move(lengthArray), state);

    if (lengthUnitsChecker)
      conversionCheckers.append(std::move(lengthUnitsChecker));
  }

  TransformOperations transform;
  TransformBuilder::createTransformOperations(
      value, state.cssToLengthConversionData(), transform);
  return convertTransform(std::move(transform));
}
InterpolationValue CSSClipInterpolationType::maybeConvertInherit(const StyleResolverState& state, ConversionCheckers& conversionCheckers) const
{
    ClipAutos parentAutos = getClipAutos(*state.parentStyle());
    conversionCheckers.append(ParentAutosChecker::create(parentAutos));
    if (parentAutos.isAuto)
        return nullptr;
    return createClipValue(state.parentStyle()->clip(), 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());
}
void InvalidatableInterpolation::addConversionCheckers(
    const InterpolationType& type,
    ConversionCheckers& conversionCheckers) const {
  for (size_t i = 0; i < conversionCheckers.size(); i++) {
    conversionCheckers[i]->setType(type);
    m_conversionCheckers.append(std::move(conversionCheckers[i]));
  }
}
Esempio n. 11
0
InterpolationValue CSSRotateInterpolationType::maybeConvertInherit(
    const StyleResolverState& state,
    ConversionCheckers& conversionCheckers) const {
  Rotation inheritedRotation = getRotation(*state.parentStyle());
  conversionCheckers.push_back(
      InheritedRotationChecker::create(inheritedRotation));
  return convertRotation(inheritedRotation);
}
InterpolationValue CSSTransformInterpolationType::maybeConvertInherit(
    const StyleResolverState& state,
    ConversionCheckers& conversionCheckers) const {
  const TransformOperations& inheritedTransform =
      state.parentStyle()->transform();
  conversionCheckers.append(
      InheritedTransformChecker::create(inheritedTransform));
  return convertTransform(inheritedTransform);
}
PassOwnPtr<InterpolationValue> SVGPathInterpolationType::maybeConvertNeutral(const UnderlyingValue& underlyingValue, ConversionCheckers& conversionCheckers) const
{
    conversionCheckers.append(UnderlyingPathSegTypesChecker::create(*this, underlyingValue));
    OwnPtr<InterpolableList> result = InterpolableList::create(PathComponentIndexCount);
    result->set(PathArgsIndex, toInterpolableList(underlyingValue->interpolableValue()).get(PathArgsIndex)->cloneAndZero());
    result->set(PathNeutralIndex, InterpolableNumber::create(1));
    return InterpolationValue::create(*this, result.release(),
        const_cast<NonInterpolableValue*>(underlyingValue->nonInterpolableValue())); // Take ref.
}
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);
}
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());
}
Esempio n. 16
0
PassOwnPtr<InterpolationValue> SVGTransformListInterpolationType::maybeConvertNeutral(const UnderlyingValue& underlyingValue, ConversionCheckers& conversionCheckers) const
{
    Vector<SVGTransformType> underlyingTypes(toSVGTransformNonInterpolableValue(underlyingValue->nonInterpolableValue())->transformTypes());
    conversionCheckers.append(UnderlyingTypesChecker::create(*this, underlyingTypes));
    if (underlyingTypes.isEmpty())
        return nullptr;
    OwnPtr<InterpolationValue> result = underlyingValue->clone();
    result->mutableComponent().interpolableValue = result->interpolableValue().cloneAndZero();
    return result.release();
}
Esempio n. 17
0
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> 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);
}
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()));
}
InterpolationValue CSSImageSliceInterpolationType::maybeConvertNeutral(const InterpolationValue& underlying, ConversionCheckers& conversionCheckers) const
{
    SliceTypes underlyingTypes = UnderlyingSliceTypesChecker::getUnderlyingSliceTypes(underlying);
    conversionCheckers.append(UnderlyingSliceTypesChecker::create(underlyingTypes));
    LengthBox zeroBox(
        Length(0, underlyingTypes.isNumber[SideTop] ? Fixed : Percent),
        Length(0, underlyingTypes.isNumber[SideRight] ? Fixed : Percent),
        Length(0, underlyingTypes.isNumber[SideBottom] ? Fixed : Percent),
        Length(0, underlyingTypes.isNumber[SideLeft] ? Fixed : Percent));
    return convertImageSlice(ImageSlice(zeroBox, underlyingTypes.fill), 1);
}
Esempio n. 21
0
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());
}
Esempio n. 22
0
InterpolationValue CSSFilterListInterpolationType::maybeConvertNeutral(
    const InterpolationValue& underlying,
    ConversionCheckers& conversionCheckers) const {
  // const_cast for taking refs.
  NonInterpolableList& nonInterpolableList = const_cast<NonInterpolableList&>(
      toNonInterpolableList(*underlying.nonInterpolableValue));
  conversionCheckers.push_back(
      UnderlyingFilterListChecker::create(&nonInterpolableList));
  return InterpolationValue(underlying.interpolableValue->cloneAndZero(),
                            &nonInterpolableList);
}
Esempio n. 23
0
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
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 CSSLengthListInterpolationType::maybeConvertNeutral(const InterpolationValue& underlying, ConversionCheckers& conversionCheckers) const
{
    size_t underlyingLength = UnderlyingLengthChecker::getUnderlyingLength(underlying);
    conversionCheckers.append(UnderlyingLengthChecker::create(underlyingLength));

    if (underlyingLength == 0)
        return nullptr;

    return ListInterpolationFunctions::createList(underlyingLength, [](size_t) {
        return InterpolationValue(CSSLengthInterpolationType::createNeutralInterpolableValue());
    });
}
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 CSSClipInterpolationType::maybeConvertNeutral(const InterpolationValue& underlying, ConversionCheckers& conversionCheckers) const
{
    ClipAutos underlyingAutos = UnderlyingAutosChecker::getUnderlyingAutos(underlying);
    conversionCheckers.append(UnderlyingAutosChecker::create(underlyingAutos));
    if (underlyingAutos.isAuto)
        return nullptr;
    LengthBox neutralBox(
        underlyingAutos.isTopAuto ? Length(Auto) : Length(0, Fixed),
        underlyingAutos.isRightAuto ? Length(Auto) : Length(0, Fixed),
        underlyingAutos.isBottomAuto ? Length(Auto) : Length(0, Fixed),
        underlyingAutos.isLeftAuto ? Length(Auto) : Length(0, Fixed));
    return createClipValue(neutralBox, 1);
}
Esempio n. 28
0
PassOwnPtr<InterpolationValue> SVGNumberListInterpolationType::maybeConvertNeutral(const UnderlyingValue& underlyingValue, ConversionCheckers& conversionCheckers) const
{
    size_t underlyingLength = UnderlyingLengthChecker::getUnderlyingLength(underlyingValue);
    conversionCheckers.append(UnderlyingLengthChecker::create(*this, underlyingLength));

    if (underlyingLength == 0)
        return nullptr;

    OwnPtr<InterpolableList> result = InterpolableList::create(underlyingLength);
    for (size_t i = 0; i < underlyingLength; i++)
        result->set(i, InterpolableNumber::create(0));
    return InterpolationValue::create(*this, result.release());
}
InterpolationValue SVGPointListInterpolationType::maybeConvertNeutral(
    const InterpolationValue& underlying,
    ConversionCheckers& conversionCheckers) const {
  size_t underlyingLength =
      UnderlyingLengthChecker::getUnderlyingLength(underlying);
  conversionCheckers.append(UnderlyingLengthChecker::create(underlyingLength));

  if (underlyingLength == 0)
    return nullptr;

  std::unique_ptr<InterpolableList> result =
      InterpolableList::create(underlyingLength);
  for (size_t i = 0; i < underlyingLength; i++)
    result->set(i, InterpolableNumber::create(0));
  return InterpolationValue(std::move(result));
}
InterpolationValue
CSSBorderImageLengthBoxInterpolationType::maybeConvertNeutral(
    const InterpolationValue& underlying,
    ConversionCheckers& conversionCheckers) const {
  SideNumbers underlyingSideNumbers =
      UnderlyingSideNumbersChecker::getUnderlyingSideNumbers(underlying);
  conversionCheckers.append(
      UnderlyingSideNumbersChecker::create(underlyingSideNumbers));
  const auto& zero = [&underlyingSideNumbers](size_t index) {
    return underlyingSideNumbers.isNumber[index]
               ? BorderImageLength(0)
               : BorderImageLength(Length(0, Fixed));
  };
  BorderImageLengthBox zeroBox(zero(SideTop), zero(SideRight), zero(SideBottom),
                               zero(SideLeft));
  return convertBorderImageLengthBox(zeroBox, 1);
}