std::unique_ptr<InterpolableValue> CSSColorInterpolationType::maybeCreateInterpolableColor(const CSSValue& value)
{
    if (value.isColorValue())
        return createInterpolableColor(toCSSColorValue(value).value());
    if (!value.isPrimitiveValue())
        return nullptr;
    const CSSPrimitiveValue& primitive = toCSSPrimitiveValue(value);
    if (!primitive.isValueID())
        return nullptr;
    if (!StyleColor::isColorKeyword(primitive.getValueID()))
        return nullptr;
    return createInterpolableColor(primitive.getValueID());
}
void CSSToStyleMap::mapFillRepeatX(StyleResolverState&, FillLayer* layer, const CSSValue& value)
{
    if (value.isInitialValue()) {
        layer->setRepeatX(FillLayer::initialFillRepeatX(layer->type()));
        return;
    }

    if (!value.isPrimitiveValue())
        return;

    const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
    layer->setRepeatX(primitiveValue.convertTo<EFillRepeat>());
}
Example #3
0
bool LengthStyleInterpolation::canCreateFrom(const CSSValue& value)
{
    if (value.isPrimitiveValue()) {
        const CSSPrimitiveValue& primitiveValue = blink::toCSSPrimitiveValue(value);
        if (primitiveValue.cssCalcValue())
            return true;

        CSSPrimitiveValue::LengthUnitType type;
        // Only returns true if the type is a primitive length unit.
        return CSSPrimitiveValue::unitTypeToLengthUnitType(primitiveValue.primitiveType(), type);
    }
    return value.isCalcValue();
}
bool ShadowStyleInterpolation::usesDefaultStyleInterpolation(const CSSValue& start, const CSSValue& end)
{
    if (start.isValueList() && end.isValueList() && toCSSValueList(start).length() == toCSSValueList(end).length()) {
        const CSSValueList* startList = toCSSValueList(&start);
        const CSSValueList* endList = toCSSValueList(&end);
        for (size_t i = 0; i < toCSSValueList(start).length(); i++) {
            if (startList->item(i)->isShadowValue() && endList->item(i)->isShadowValue()
                && toCSSShadowValue(startList->item(i))->style != toCSSShadowValue(endList->item(i))->style)
                return true;
        }
    }
    return false;
}
InterpolationValue CSSShadowListInterpolationType::maybeConvertValue(const CSSValue& value, const StyleResolverState&, ConversionCheckers&) const
{
    if (value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID() == CSSValueNone)
        return createNeutralValue();

    if (!value.isBaseValueList())
        return nullptr;

    const CSSValueList& valueList = toCSSValueList(value);
    return ListInterpolationFunctions::createList(valueList.length(), [&valueList](size_t index) {
        return ShadowInterpolationFunctions::maybeConvertCSSValue(valueList.item(index));
    });
}
static PassRefPtr<CustomFilterParameter> parseCustomFilterArrayParameter(const String& name, CSSValueList* values)
{
    RefPtr<CustomFilterArrayParameter> arrayParameter = CustomFilterArrayParameter::create(name);
    for (unsigned i = 0, length = values->length(); i < length; ++i) {
        CSSValue* value = values->itemWithoutBoundsCheck(i);
        if (!value->isPrimitiveValue())
            return 0;
        CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
        if (primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
            return 0;
        arrayParameter->addValue(primitiveValue->getDoubleValue());
    }
    return arrayParameter.release();
}
    static void compareLengthLists(PassRefPtrWillBeRawPtr<CSSValueList> expectedList, PassRefPtrWillBeRawPtr<CSSValue> actualList)
    {
        ASSERT(actualList->isValueList());

        for (size_t i = 0; i < 10; i++) {
            CSSValue* currentExpectedValue = expectedList->item(i);
            CSSValue* currentActualValue = toCSSValueList(*actualList).item(i);
            ASSERT(currentExpectedValue->isPrimitiveValue());
            ASSERT(currentActualValue->isPrimitiveValue());

            EXPECT_EQ(toCSSPrimitiveValue(currentExpectedValue)->getDoubleValue(), toCSSPrimitiveValue(currentActualValue)->getDoubleValue());
            EXPECT_EQ(toCSSPrimitiveValue(currentExpectedValue)->getDoubleValue(), toCSSPrimitiveValue(currentActualValue)->getDoubleValue());
        }
    }
Example #8
0
void CSSToStyleMap::mapAnimationDirection(Animation& layer, const CSSValue& value)
{
    if (value.isInitialValue()) {
        layer.setDirection(Animation::initialDirection());
        return;
    }

    if (!is<CSSPrimitiveValue>(value))
        return;

    switch (downcast<CSSPrimitiveValue>(value).getValueID()) {
    case CSSValueNormal:
        layer.setDirection(Animation::AnimationDirectionNormal);
        break;
    case CSSValueAlternate:
        layer.setDirection(Animation::AnimationDirectionAlternate);
        break;
    case CSSValueReverse:
        layer.setDirection(Animation::AnimationDirectionReverse);
        break;
    case CSSValueAlternateReverse:
        layer.setDirection(Animation::AnimationDirectionAlternateReverse);
        break;
    default:
        break;
    }
}
Example #9
0
void CSSToStyleMap::mapFillMaskSourceType(CSSPropertyID, FillLayer& layer, const CSSValue& value)
{
    EMaskSourceType type = FillLayer::initialFillMaskSourceType(layer.type());
    if (value.isInitialValue()) {
        layer.setMaskSourceType(type);
        return;
    }

    if (!is<CSSPrimitiveValue>(value))
        return;

    switch (downcast<CSSPrimitiveValue>(value).getValueID()) {
    case CSSValueAlpha:
        type = EMaskSourceType::MaskAlpha;
        break;
    case CSSValueLuminance:
        type = EMaskSourceType::MaskLuminance;
        break;
    case CSSValueAuto:
        break;
    default:
        ASSERT_NOT_REACHED();
    }

    layer.setMaskSourceType(type);
}
Example #10
0
void CSSToStyleMap::mapFillYPosition(CSSPropertyID propertyID, FillLayer& layer, const CSSValue& value)
{
    if (value.isInitialValue()) {
        layer.setYPosition(FillLayer::initialFillYPosition(layer.type()));
        return;
    }

    if (!is<CSSPrimitiveValue>(value))
        return;

    auto* primitiveValue = &downcast<CSSPrimitiveValue>(value);
    Pair* pair = primitiveValue->getPairValue();
    if (pair) {
        ASSERT_UNUSED(propertyID, propertyID == CSSPropertyBackgroundPositionY || propertyID == CSSPropertyWebkitMaskPositionY);
        primitiveValue = pair->second();
    }

    Length length;
    if (primitiveValue->isLength())
        length = primitiveValue->computeLength<Length>(m_resolver->state().cssToLengthConversionData());
    else if (primitiveValue->isPercentage())
        length = Length(primitiveValue->getDoubleValue(), Percent);
    else if (primitiveValue->isCalculatedPercentageWithLength())
        length = Length(primitiveValue->cssCalcValue()->createCalculationValue(m_resolver->state().cssToLengthConversionData()));
    else
        return;

    layer.setYPosition(length);
    if (pair)
        layer.setBackgroundYOrigin(*pair->first());
}
Example #11
0
void CSSToStyleMap::mapFillSize(CSSPropertyID, FillLayer& layer, const CSSValue& value)
{
    if (value.isInitialValue()) {
        layer.setSize(FillLayer::initialFillSize(layer.type()));
        return;
    }

    if (!is<CSSPrimitiveValue>(value))
        return;

    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
    FillSize fillSize;
    switch (primitiveValue.getValueID()) {
    case CSSValueContain:
        fillSize.type = Contain;
        break;
    case CSSValueCover:
        fillSize.type = Cover;
        break;
    default:
        ASSERT(fillSize.type == SizeLength);
        if (!convertToLengthSize(primitiveValue, m_resolver->state().cssToLengthConversionData(), fillSize.size))
            return;
        break;
    }
    layer.setSize(fillSize);
}
PassRefPtrWillBeRawPtr<StyleImage> ElementStyleResources::styleImage(CSSPropertyID property, const CSSValue& value)
{
    if (value.isImageValue())
        return cachedOrPendingFromValue(property, toCSSImageValue(value));

    if (value.isImageGeneratorValue())
        return generatedOrPendingFromValue(property, toCSSImageGeneratorValue(value));

    if (value.isImageSetValue())
        return setOrPendingFromValue(property, toCSSImageSetValue(value));

    if (value.isCursorImageValue())
        return cursorOrPendingFromValue(property, toCSSCursorImageValue(value));

    return nullptr;
}
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));
}
InterpolationComponent CSSLengthInterpolationType::maybeConvertCSSValue(const CSSValue& value)
{
    if (!value.isPrimitiveValue())
        return nullptr;

    const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);

    CSSLengthArray valueArray;
    for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++)
        valueArray.append(0);
    bool hasPercentage = false;

    if (!primitiveValue.isLength() && !primitiveValue.isPercentage() && !primitiveValue.isCalculatedPercentageWithLength())
        return nullptr;
    CSSLengthTypeArray hasType;
    hasType.ensureSize(CSSPrimitiveValue::LengthUnitTypeCount);
    primitiveValue.accumulateLengthArray(valueArray, hasType);
    hasPercentage = hasType.get(CSSPrimitiveValue::UnitTypePercentage);

    OwnPtr<InterpolableList> values = InterpolableList::create(CSSPrimitiveValue::LengthUnitTypeCount);
    for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++)
        values->set(i, InterpolableNumber::create(valueArray.at(i)));

    return InterpolationComponent(values.release(), CSSLengthNonInterpolableValue::create(hasPercentage));
}
Example #15
0
void CSSToStyleMap::mapAnimationFillMode(Animation& layer, const CSSValue& value)
{
    if (value.isInitialValue()) {
        layer.setFillMode(Animation::initialFillMode());
        return;
    }

    if (!is<CSSPrimitiveValue>(value))
        return;

    switch (downcast<CSSPrimitiveValue>(value).getValueID()) {
    case CSSValueNone:
        layer.setFillMode(AnimationFillModeNone);
        break;
    case CSSValueForwards:
        layer.setFillMode(AnimationFillModeForwards);
        break;
    case CSSValueBackwards:
        layer.setFillMode(AnimationFillModeBackwards);
        break;
    case CSSValueBoth:
        layer.setFillMode(AnimationFillModeBoth);
        break;
    default:
        break;
    }
}
Example #16
0
void FontBuilder::setFeatureSettingsValue(CSSValue* value)
{
    FontDescriptionChangeScope scope(this);

    CSSValueList* list = toCSSValueList(value);
    RefPtr<FontFeatureSettings> settings = FontFeatureSettings::create();
    int len = list->length();
    for (int i = 0; i < len; ++i) {
        CSSValue* item = list->itemWithoutBoundsCheck(i);
        if (!item->isFontFeatureValue())
            continue;
        CSSFontFeatureValue* feature = toCSSFontFeatureValue(item);
        settings->append(FontFeature(feature->tag(), feature->value()));
    }
    scope.fontDescription().setFeatureSettings(settings.release());
}
bool LengthBoxStyleInterpolation::usesDefaultInterpolation(const CSSValue& start, const CSSValue& end)
{
    if (start.isPrimitiveValue() && end.isPrimitiveValue()) {
        const CSSPrimitiveValue& startValue = toCSSPrimitiveValue(start);
        const CSSPrimitiveValue& endValue = toCSSPrimitiveValue(end);
        return (startValue.isValueID() && startValue.getValueID() == CSSValueAuto)
            || (endValue.isValueID() && endValue.getValueID() == CSSValueAuto);
    }

    if (!start.isQuadValue() || !end.isQuadValue())
        return false;

    const CSSQuadValue& startValue = toCSSQuadValue(start);
    const CSSQuadValue& endValue = toCSSQuadValue(end);
    return onlyInterpolateBetweenLengthAndCSSValueAuto(startValue, endValue);
}
Example #18
0
InterpolationValue CSSImageSliceInterpolationType::maybeConvertValue(
    const CSSValue& value,
    const StyleResolverState&,
    ConversionCheckers&) const {
  if (!value.isBorderImageSliceValue())
    return nullptr;

  const CSSBorderImageSliceValue& slice = toCSSBorderImageSliceValue(value);
  std::unique_ptr<InterpolableList> list =
      InterpolableList::create(SideIndexCount);
  const CSSValue* sides[SideIndexCount];
  sides[SideTop] = slice.slices().top();
  sides[SideRight] = slice.slices().right();
  sides[SideBottom] = slice.slices().bottom();
  sides[SideLeft] = slice.slices().left();

  for (size_t i = 0; i < SideIndexCount; i++) {
    const CSSPrimitiveValue& side = *toCSSPrimitiveValue(sides[i]);
    DCHECK(side.isNumber() || side.isPercentage());
    list->set(i, InterpolableNumber::create(side.getDoubleValue()));
  }

  return InterpolationValue(
      std::move(list),
      CSSImageSliceNonInterpolableValue::create(SliceTypes(slice)));
}
Example #19
0
bool FontFace::setFamilyValue(const CSSValue& familyValue)
{
    AtomicString family;
    if (familyValue.isCustomIdentValue()) {
        family = AtomicString(toCSSCustomIdentValue(familyValue).value());
    } else if (toCSSPrimitiveValue(familyValue).isValueID()) {
        // We need to use the raw text for all the generic family types, since @font-face is a way of actually
        // defining what font to use for those types.
        switch (toCSSPrimitiveValue(familyValue).getValueID()) {
        case CSSValueSerif:
            family =  FontFamilyNames::webkit_serif;
            break;
        case CSSValueSansSerif:
            family =  FontFamilyNames::webkit_sans_serif;
            break;
        case CSSValueCursive:
            family =  FontFamilyNames::webkit_cursive;
            break;
        case CSSValueFantasy:
            family =  FontFamilyNames::webkit_fantasy;
            break;
        case CSSValueMonospace:
            family =  FontFamilyNames::webkit_monospace;
            break;
        case CSSValueWebkitPictograph:
            family =  FontFamilyNames::webkit_pictograph;
            break;
        default:
            return false;
        }
    }
    m_family = family;
    return true;
}
PassOwnPtrWillBeRawPtr<InterpolableValue> ColorStyleInterpolation::colorToInterpolableValue(const CSSValue& value)
{
    ASSERT(value.isPrimitiveValue());
    const CSSPrimitiveValue& primitive = toCSSPrimitiveValue(value);
    RGBA32 color;
    if (primitive.isValueID()) {
        if (CSSPropertyParser::isSystemColor(primitive.getValueID())) {
            color = LayoutTheme::theme().systemColor(primitive.getValueID()).rgb();
        } else {
            Color colorFromID;
            colorFromID.setNamedColor(getValueName(primitive.getValueID()));
            color = colorFromID.rgb();
        }
    } else {
        color = primitive.getRGBA32Value();
    }

    int alpha = alphaChannel(color);

    OwnPtrWillBeRawPtr<InterpolableList> list = InterpolableList::create(4);
    list->set(0, InterpolableNumber::create(redChannel(color) * alpha));
    list->set(1, InterpolableNumber::create(greenChannel(color) * alpha));
    list->set(2, InterpolableNumber::create(blueChannel(color) * alpha));
    list->set(3, InterpolableNumber::create(alpha));

    return list->clone();
}
Example #21
0
void CSSToStyleMap::mapNinePieceImageSlice(StyleResolverState&, const CSSValue& value, NinePieceImage& image)
{
    if (!value.isBorderImageSliceValue())
        return;

    // Retrieve the border image value.
    const CSSBorderImageSliceValue& borderImageSlice = toCSSBorderImageSliceValue(value);

    // Set up a length box to represent our image slices.
    LengthBox box;
    CSSQuadValue* slices = borderImageSlice.slices();
    if (slices->top()->isPercentage())
        box.m_top = Length(slices->top()->getDoubleValue(), Percent);
    else
        box.m_top = Length(slices->top()->getIntValue(), Fixed);
    if (slices->bottom()->isPercentage())
        box.m_bottom = Length(slices->bottom()->getDoubleValue(), Percent);
    else
        box.m_bottom = Length(slices->bottom()->getIntValue(), Fixed);
    if (slices->left()->isPercentage())
        box.m_left = Length(slices->left()->getDoubleValue(), Percent);
    else
        box.m_left = Length(slices->left()->getIntValue(), Fixed);
    if (slices->right()->isPercentage())
        box.m_right = Length(slices->right()->getDoubleValue(), Percent);
    else
        box.m_right = Length(slices->right()->getIntValue(), Fixed);
    image.setImageSlices(box);

    // Set our fill mode.
    image.setFill(borderImageSlice.m_fill);
}
Example #22
0
PassRefPtr<TimingFunction> CSSToStyleMap::mapAnimationTimingFunction(const CSSValue& value, bool allowStepMiddle)
{
    // FIXME: We should probably only call into this function with a valid
    // single timing function value which isn't initial or inherit. We can
    // currently get into here with initial since the parser expands unset
    // properties in shorthands to initial.

    if (value.isPrimitiveValue()) {
        const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
        switch (primitiveValue.getValueID()) {
        case CSSValueLinear:
            return LinearTimingFunction::shared();
        case CSSValueEase:
            return CubicBezierTimingFunction::preset(CubicBezierTimingFunction::Ease);
        case CSSValueEaseIn:
            return CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseIn);
        case CSSValueEaseOut:
            return CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseOut);
        case CSSValueEaseInOut:
            return CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseInOut);
        case CSSValueStepStart:
            return StepsTimingFunction::preset(StepsTimingFunction::Start);
        case CSSValueStepMiddle:
            if (allowStepMiddle)
                return StepsTimingFunction::preset(StepsTimingFunction::Middle);
            return CSSTimingData::initialTimingFunction();
        case CSSValueStepEnd:
            return StepsTimingFunction::preset(StepsTimingFunction::End);
        default:
            ASSERT_NOT_REACHED();
            return CSSTimingData::initialTimingFunction();
        }
    }

    if (value.isCubicBezierTimingFunctionValue()) {
        const CSSCubicBezierTimingFunctionValue& cubicTimingFunction = toCSSCubicBezierTimingFunctionValue(value);
        return CubicBezierTimingFunction::create(cubicTimingFunction.x1(), cubicTimingFunction.y1(), cubicTimingFunction.x2(), cubicTimingFunction.y2());
    }

    if (value.isInitialValue())
        return CSSTimingData::initialTimingFunction();

    const CSSStepsTimingFunctionValue& stepsTimingFunction = toCSSStepsTimingFunctionValue(value);
    if (stepsTimingFunction.stepAtPosition() == StepsTimingFunction::Middle && !allowStepMiddle)
        return CSSTimingData::initialTimingFunction();
    return StepsTimingFunction::create(stepsTimingFunction.numberOfSteps(), stepsTimingFunction.stepAtPosition());
}
Example #23
0
void CSSToStyleMap::mapNinePieceImage(StyleResolverState& state, CSSPropertyID property, const CSSValue& value, NinePieceImage& image)
{
    // If we're not a value list, then we are "none" and don't need to alter the empty image at all.
    if (!value.isValueList())
        return;

    // Retrieve the border image value.
    const CSSValueList& borderImage = toCSSValueList(value);

    // Set the image (this kicks off the load).
    CSSPropertyID imageProperty;
    if (property == CSSPropertyWebkitBorderImage)
        imageProperty = CSSPropertyBorderImageSource;
    else if (property == CSSPropertyWebkitMaskBoxImage)
        imageProperty = CSSPropertyWebkitMaskBoxImageSource;
    else
        imageProperty = property;

    for (unsigned i = 0 ; i < borderImage.length() ; ++i) {
        const CSSValue& current = *borderImage.item(i);

        if (current.isImageValue() || current.isImageGeneratorValue() || current.isImageSetValue()) {
            image.setImage(state.styleImage(imageProperty, current));
        } else if (current.isBorderImageSliceValue()) {
            mapNinePieceImageSlice(state, current, image);
        } else if (current.isValueList()) {
            const CSSValueList& slashList = toCSSValueList(current);
            size_t length = slashList.length();
            // Map in the image slices.
            if (length && slashList.item(0)->isBorderImageSliceValue())
                mapNinePieceImageSlice(state, *slashList.item(0), image);

            // Map in the border slices.
            if (length > 1)
                image.setBorderSlices(mapNinePieceImageQuad(state, *slashList.item(1)));

            // Map in the outset.
            if (length > 2)
                image.setOutset(mapNinePieceImageQuad(state, *slashList.item(2)));
        } else if (current.isPrimitiveValue() || current.isValuePair()) {
            // Set the appropriate rules for stretch/round/repeat of the slices.
            mapNinePieceImageRepeat(state, current, image);
        }
    }

    if (property == CSSPropertyWebkitBorderImage) {
        // We have to preserve the legacy behavior of -webkit-border-image and make the border slices
        // also set the border widths. We don't need to worry about percentages, since we don't even support
        // those on real borders yet.
        if (image.borderSlices().top().isLength() && image.borderSlices().top().length().isFixed())
            state.style()->setBorderTopWidth(image.borderSlices().top().length().value());
        if (image.borderSlices().right().isLength() && image.borderSlices().right().length().isFixed())
            state.style()->setBorderRightWidth(image.borderSlices().right().length().value());
        if (image.borderSlices().bottom().isLength() && image.borderSlices().bottom().length().isFixed())
            state.style()->setBorderBottomWidth(image.borderSlices().bottom().length().value());
        if (image.borderSlices().left().isLength() && image.borderSlices().left().length().isFixed())
            state.style()->setBorderLeftWidth(image.borderSlices().left().length().value());
    }
}
Example #24
0
EAnimPlayState CSSToStyleMap::mapAnimationPlayState(const CSSValue& value)
{
    if (value.isInitialValue())
        return CSSAnimationData::initialPlayState();
    if (toCSSPrimitiveValue(value).getValueID() == CSSValuePaused)
        return AnimPlayStatePaused;
    ASSERT(toCSSPrimitiveValue(value).getValueID() == CSSValueRunning);
    return AnimPlayStatePlaying;
}
Example #25
0
double CSSToStyleMap::mapAnimationIterationCount(const CSSValue& value)
{
    if (value.isInitialValue())
        return CSSAnimationData::initialIterationCount();
    const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
    if (primitiveValue.getValueID() == CSSValueInfinite)
        return std::numeric_limits<double>::infinity();
    return primitiveValue.getFloatValue();
}
Example #26
0
void CSSToStyleMap::mapFillImage(CSSPropertyID property, FillLayer& layer, CSSValue& value)
{
    if (value.isInitialValue()) {
        layer.setImage(FillLayer::initialFillImage(layer.type()));
        return;
    }

    layer.setImage(styleImage(property, value));
}
InterpolationValue CSSLengthListInterpolationType::maybeConvertValue(const CSSValue& value, const StyleResolverState&, ConversionCheckers&) const
{
    if (!value.isBaseValueList())
        return nullptr;

    const CSSValueList& list = toCSSValueList(value);
    return ListInterpolationFunctions::createList(list.length(), [&list](size_t index) {
        return CSSLengthInterpolationType::maybeConvertCSSValue(*list.item(index));
    });
}
InterpolationValue CSSBasicShapeInterpolationType::maybeConvertValue(const CSSValue& value, const StyleResolverState&, ConversionCheckers&) const
{
    if (!value.isBaseValueList())
        return BasicShapeInterpolationFunctions::maybeConvertCSSValue(value);

    const CSSValueList& list = toCSSValueList(value);
    if (list.length() != 1)
        return nullptr;
    return BasicShapeInterpolationFunctions::maybeConvertCSSValue(*list.item(0));
}
Example #29
0
void CSSToStyleMap::mapFillImage(StyleResolverState& state, FillLayer* layer, const CSSValue& value)
{
    if (value.isInitialValue()) {
        layer->setImage(FillLayer::initialFillImage(layer->type()));
        return;
    }

    CSSPropertyID property = layer->type() == BackgroundFillLayer ? CSSPropertyBackgroundImage : CSSPropertyWebkitMaskImage;
    layer->setImage(state.styleImage(property, value));
}
void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextEmphasisStyle(StyleResolverState& state, CSSValue* value)
{
    if (value->isValueList()) {
        CSSValueList* list = toCSSValueList(value);
        ASSERT(list->length() == 2);
        if (list->length() != 2)
            return;
        for (unsigned i = 0; i < 2; ++i) {
            CSSValue* item = list->item(i);
            if (!item->isPrimitiveValue())
                continue;

            CSSPrimitiveValue* value = toCSSPrimitiveValue(item);
            if (value->getValueID() == CSSValueFilled || value->getValueID() == CSSValueOpen)
                state.style()->setTextEmphasisFill(*value);
            else
                state.style()->setTextEmphasisMark(*value);
        }
        state.style()->setTextEmphasisCustomMark(nullAtom);
        return;
    }

    if (!value->isPrimitiveValue())
        return;
    CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);

    if (primitiveValue->isString()) {
        state.style()->setTextEmphasisFill(TextEmphasisFillFilled);
        state.style()->setTextEmphasisMark(TextEmphasisMarkCustom);
        state.style()->setTextEmphasisCustomMark(AtomicString(primitiveValue->getStringValue()));
        return;
    }

    state.style()->setTextEmphasisCustomMark(nullAtom);

    if (primitiveValue->getValueID() == CSSValueFilled || primitiveValue->getValueID() == CSSValueOpen) {
        state.style()->setTextEmphasisFill(*primitiveValue);
        state.style()->setTextEmphasisMark(TextEmphasisMarkAuto);
    } else {
        state.style()->setTextEmphasisFill(TextEmphasisFillFilled);
        state.style()->setTextEmphasisMark(*primitiveValue);
    }
}