示例#1
0
float SVGLength::value(const SVGLengthContext& context) const {
  if (isCalculated())
    return context.resolveValue(asCSSPrimitiveValue(), unitMode());

  return context.convertValueToUserUnits(m_value->getFloatValue(), unitMode(),
                                         m_value->typeWithCalcResolved());
}
示例#2
0
SVGLength::SVGLength(SVGLengthMode mode)
    : SVGPropertyBase(classType())
    , m_value(cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::UserUnits))
    , m_unitMode(static_cast<unsigned>(mode))
{
    ASSERT(unitMode() == mode);
}
示例#3
0
void SVGLength::convertToSpecifiedUnits(CSSPrimitiveValue::UnitType type, const SVGLengthContext& context)
{
    ASSERT(isSupportedCSSUnitType(type));

    float valueInUserUnits = value(context);
    m_value = CSSPrimitiveValue::create(
        context.convertValueFromUserUnits(valueInUserUnits, unitMode(), type),
        type);
}
示例#4
0
void SVGLength::setValue(float value, const SVGLengthContext& context)
{
    m_value = CSSPrimitiveValue::create(
        context.convertValueFromUserUnits(value, unitMode(), m_value->typeWithCalcResolved()),
        m_value->typeWithCalcResolved());
}
示例#5
0
float SVGLength::value(const SVGLengthContext& context) const
{
    return context.convertValueToUserUnits(
        m_value->getFloatValue(), unitMode(), m_value->typeWithCalcResolved());
}
示例#6
0
SVGLength::SVGLength(SVGLengthMode mode)
    : m_value(CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::UserUnits))
    , m_unitMode(static_cast<unsigned>(mode))
{
    ASSERT(unitMode() == mode);
}