Пример #1
0
BorderImageLengthBox CSSToStyleMap::mapNinePieceImageQuad(StyleResolverState& state, CSSValue* value)
{
    if (!value || !value->isPrimitiveValue())
        return BorderImageLengthBox(Length(Auto));

    Quad* slices = toCSSPrimitiveValue(value)->getQuadValue();

    // Set up a border image length box to represent our image slices.
    return BorderImageLengthBox(
        toBorderImageLength(*slices->top(), state.cssToLengthConversionData()),
        toBorderImageLength(*slices->right(), state.cssToLengthConversionData()),
        toBorderImageLength(*slices->bottom(), state.cssToLengthConversionData()),
        toBorderImageLength(*slices->left(), state.cssToLengthConversionData()));
}
Пример #2
0
BorderImageLengthBox CSSToStyleMap::mapNinePieceImageQuad(StyleResolverState& state, const CSSValue& value)
{
    if (!value.isQuadValue())
        return BorderImageLengthBox(Length(Auto));

    const CSSQuadValue& slices = toCSSQuadValue(value);

    // Set up a border image length box to represent our image slices.
    return BorderImageLengthBox(
        toBorderImageLength(*slices.top(), state.cssToLengthConversionData()),
        toBorderImageLength(*slices.right(), state.cssToLengthConversionData()),
        toBorderImageLength(*slices.bottom(), state.cssToLengthConversionData()),
        toBorderImageLength(*slices.left(), state.cssToLengthConversionData()));
}
Пример #3
0
BorderImageLengthBox CSSToStyleMap::mapNinePieceImageQuad(CSSValue* value) const
{
    if (!value || !value->isPrimitiveValue())
        return BorderImageLengthBox(Length(Auto));

    float zoom = useSVGZoomRules() ? 1.0f : cssToLengthConversionData().zoom();
    Quad* slices = toCSSPrimitiveValue(value)->getQuadValue();

    // Set up a border image length box to represent our image slices.
    const CSSToLengthConversionData& conversionData = cssToLengthConversionData().copyWithAdjustedZoom(zoom);
    return BorderImageLengthBox(
        toBorderImageLength(*slices->top(), conversionData),
        toBorderImageLength(*slices->right(), conversionData),
        toBorderImageLength(*slices->bottom(), conversionData),
        toBorderImageLength(*slices->left(), conversionData));
}
BorderImageLengthBox CSSToStyleMap::mapNinePieceImageQuad(CSSValue* value) const
{
    if (!value || !value->isPrimitiveValue())
        return BorderImageLengthBox();

    // Get our zoom value.
    float zoom = useSVGZoomRules() ? 1.0f : style()->effectiveZoom();

    // Retrieve the primitive value.
    CSSPrimitiveValue* borderWidths = toCSSPrimitiveValue(value);

    // Set up a length box to represent our image slices.
    BorderImageLengthBox box; // Defaults to 'auto' so we don't have to handle that explicitly below.
    Quad* slices = borderWidths->getQuadValue();
    if (slices->top()->isNumber())
        box.setTop(slices->top()->getIntValue());
    else if (slices->top()->isPercentage())
        box.setTop(Length(slices->top()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent));
    else if (slices->top()->getValueID() != CSSValueAuto)
        box.setTop(slices->top()->computeLength<Length>(style(), rootElementStyle(), zoom));

    if (slices->right()->isNumber())
        box.setRight(slices->right()->getIntValue());
    else if (slices->right()->isPercentage())
        box.setRight(Length(slices->right()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent));
    else if (slices->right()->getValueID() != CSSValueAuto)
        box.setRight(slices->right()->computeLength<Length>(style(), rootElementStyle(), zoom));

    if (slices->bottom()->isNumber())
        box.setBottom(slices->bottom()->getIntValue());
    else if (slices->bottom()->isPercentage())
        box.setBottom(Length(slices->bottom()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent));
    else if (slices->bottom()->getValueID() != CSSValueAuto)
        box.setBottom(slices->bottom()->computeLength<Length>(style(), rootElementStyle(), zoom));

    if (slices->left()->isNumber())
        box.setLeft(slices->left()->getIntValue());
    else if (slices->left()->isPercentage())
        box.setLeft(Length(slices->left()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent));
    else if (slices->left()->getValueID() != CSSValueAuto)
        box.setLeft(slices->left()->computeLength<Length>(style(), rootElementStyle(), zoom));

    return box;
}