FloatPoint floatPointForCenterCoordinate(const BasicShapeCenterCoordinate& centerX, const BasicShapeCenterCoordinate& centerY, FloatSize boxSize) { FloatPoint p; float offset = floatValueForLength(centerX.length(), boxSize.width()); switch (centerX.keyword()) { case BasicShapeCenterCoordinate::None: case BasicShapeCenterCoordinate::Left: p.setX(offset); break; case BasicShapeCenterCoordinate::Right: p.setX(boxSize.width() - offset); break; default: ASSERT_NOT_REACHED(); } offset = floatValueForLength(centerY.length(), boxSize.height()); switch (centerY.keyword()) { case BasicShapeCenterCoordinate::None: case BasicShapeCenterCoordinate::Top: p.setY(offset); break; case BasicShapeCenterCoordinate::Bottom: p.setY(boxSize.height() - offset); break; default: ASSERT_NOT_REACHED(); } return p; }
float floatValueForCenterCoordinate(const BasicShapeCenterCoordinate& center, float boxDimension) { float offset = floatValueForLength(center.length(), boxDimension); if (center.direction() == BasicShapeCenterCoordinate::TopLeft) return offset; return boxDimension - offset; }
FloatPoint floatPointForCenterCoordinate( const BasicShapeCenterCoordinate& centerX, const BasicShapeCenterCoordinate& centerY, FloatSize boxSize) { float x = floatValueForLength(centerX.computedLength(), boxSize.width()); float y = floatValueForLength(centerY.computedLength(), boxSize.height()); return FloatPoint(x, y); }
static PassRefPtr<CSSPrimitiveValue> valueForCenterCoordinate(CSSValuePool& pool, const RenderStyle* style, const BasicShapeCenterCoordinate& center, EBoxOrient orientation) { if (center.direction() == BasicShapeCenterCoordinate::TopLeft) return pool.createValue(center.length(), style); CSSValueID keyword = orientation == HORIZONTAL ? CSSValueRight : CSSValueBottom; return pool.createValue(Pair::create(pool.createIdentifierValue(keyword), pool.createValue(center.length(), style))); }
static PassRefPtr<CSSPrimitiveValue> valueForCenterCoordinate(CSSValuePool& pool, const RenderStyle& style, const BasicShapeCenterCoordinate& center) { CSSValueID keyword = CSSValueInvalid; switch (center.keyword()) { case BasicShapeCenterCoordinate::None: return pool.createValue(center.length(), style); case BasicShapeCenterCoordinate::Top: keyword = CSSValueTop; break; case BasicShapeCenterCoordinate::Right: keyword = CSSValueRight; break; case BasicShapeCenterCoordinate::Bottom: keyword = CSSValueBottom; break; case BasicShapeCenterCoordinate::Left: keyword = CSSValueLeft; break; } return pool.createValue(Pair::create(pool.createIdentifierValue(keyword), pool.createValue(center.length(), style), Pair::DropIdenticalValues)); }