| Index: Source/core/css/BasicShapeFunctions.cpp
|
| diff --git a/Source/core/css/BasicShapeFunctions.cpp b/Source/core/css/BasicShapeFunctions.cpp
|
| index 8f948ae8eeb4d49654c17aadd78c4d88f106699e..e6bdc103bc85e17a16d0acd89ec8e120f1bb5d2a 100644
|
| --- a/Source/core/css/BasicShapeFunctions.cpp
|
| +++ b/Source/core/css/BasicShapeFunctions.cpp
|
| @@ -63,6 +63,21 @@ static PassRefPtr<CSSPrimitiveValue> valueForCenterCoordinate(CSSValuePool& pool
|
| return pool.createValue(Pair::create(pool.createIdentifierValue(keyword), pool.createValue(center.length(), style), Pair::DropIdenticalValues));
|
| }
|
|
|
| +static PassRefPtr<CSSPrimitiveValue> basicShapeRadiusToCSSValue(CSSValuePool& pool, const RenderStyle& style, const BasicShapeRadius& radius)
|
| +{
|
| + switch (radius.type()) {
|
| + case BasicShapeRadius::Value:
|
| + return pool.createValue(radius.value(), style);
|
| + case BasicShapeRadius::ClosestSide:
|
| + return pool.createIdentifierValue(CSSValueClosestSide);
|
| + case BasicShapeRadius::FarthestSide:
|
| + return pool.createIdentifierValue(CSSValueFarthestSide);
|
| + }
|
| +
|
| + ASSERT_NOT_REACHED();
|
| + return 0;
|
| +}
|
| +
|
| PassRefPtr<CSSValue> valueForBasicShape(const RenderStyle& style, const BasicShape* basicShape)
|
| {
|
| CSSValuePool& pool = cssValuePool();
|
| @@ -100,23 +115,13 @@ PassRefPtr<CSSValue> valueForBasicShape(const RenderStyle& style, const BasicSha
|
|
|
| circleValue->setCenterX(valueForCenterCoordinate(pool, style, circle->centerX()));
|
| circleValue->setCenterY(valueForCenterCoordinate(pool, style, circle->centerY()));
|
| - switch (circle->radius().type()) {
|
| - case BasicShapeRadius::Value:
|
| - circleValue->setRadius(pool.createValue(circle->radius().value(), style));
|
| - break;
|
| - case BasicShapeRadius::ClosestSide:
|
| - circleValue->setRadius(pool.createIdentifierValue(CSSValueClosestSide));
|
| - break;
|
| - case BasicShapeRadius::FarthestSide:
|
| - circleValue->setRadius(pool.createIdentifierValue(CSSValueFarthestSide));
|
| - break;
|
| - }
|
| + circleValue->setRadius(basicShapeRadiusToCSSValue(pool, style, circle->radius()));
|
| basicShapeValue = circleValue.release();
|
| break;
|
| }
|
| - case BasicShape::BasicShapeEllipseType: {
|
| - const BasicShapeEllipse* ellipse = static_cast<const BasicShapeEllipse*>(basicShape);
|
| - RefPtr<CSSBasicShapeEllipse> ellipseValue = CSSBasicShapeEllipse::create();
|
| + case BasicShape::DeprecatedBasicShapeEllipseType: {
|
| + const DeprecatedBasicShapeEllipse* ellipse = static_cast<const DeprecatedBasicShapeEllipse*>(basicShape);
|
| + RefPtr<CSSDeprecatedBasicShapeEllipse> ellipseValue = CSSDeprecatedBasicShapeEllipse::create();
|
|
|
| ellipseValue->setCenterX(pool.createValue(ellipse->centerX(), style));
|
| ellipseValue->setCenterY(pool.createValue(ellipse->centerY(), style));
|
| @@ -126,6 +131,17 @@ PassRefPtr<CSSValue> valueForBasicShape(const RenderStyle& style, const BasicSha
|
| basicShapeValue = ellipseValue.release();
|
| break;
|
| }
|
| + case BasicShape::BasicShapeEllipseType: {
|
| + const BasicShapeEllipse* ellipse = static_cast<const BasicShapeEllipse*>(basicShape);
|
| + RefPtr<CSSBasicShapeEllipse> ellipseValue = CSSBasicShapeEllipse::create();
|
| +
|
| + ellipseValue->setCenterX(valueForCenterCoordinate(pool, style, ellipse->centerX()));
|
| + ellipseValue->setCenterY(valueForCenterCoordinate(pool, style, ellipse->centerY()));
|
| + ellipseValue->setRadiusX(basicShapeRadiusToCSSValue(pool, style, ellipse->radiusX()));
|
| + ellipseValue->setRadiusY(basicShapeRadiusToCSSValue(pool, style, ellipse->radiusY()));
|
| + basicShapeValue = ellipseValue.release();
|
| + break;
|
| + }
|
| case BasicShape::BasicShapePolygonType: {
|
| const BasicShapePolygon* polygon = static_cast<const BasicShapePolygon*>(basicShape);
|
| RefPtr<CSSBasicShapePolygon> polygonValue = CSSBasicShapePolygon::create();
|
| @@ -194,6 +210,26 @@ static BasicShapeCenterCoordinate convertToCenterCoordinate(const StyleResolverS
|
| return BasicShapeCenterCoordinate(convertToLength(state, value));
|
| }
|
|
|
| +static BasicShapeRadius cssValueToBasicShapeRadius(const StyleResolverState& state, PassRefPtr<CSSPrimitiveValue> radius)
|
| +{
|
| + if (!radius)
|
| + return BasicShapeRadius(BasicShapeRadius::ClosestSide);
|
| +
|
| + if (radius->isValueID()) {
|
| + switch (radius->getValueID()) {
|
| + case CSSValueClosestSide:
|
| + return BasicShapeRadius(BasicShapeRadius::ClosestSide);
|
| + case CSSValueFarthestSide:
|
| + return BasicShapeRadius(BasicShapeRadius::FarthestSide);
|
| + default:
|
| + ASSERT_NOT_REACHED();
|
| + break;
|
| + }
|
| + }
|
| +
|
| + return BasicShapeRadius(convertToLength(state, radius.get()));
|
| +}
|
| +
|
| PassRefPtr<BasicShape> basicShapeForValue(const StyleResolverState& state, const CSSBasicShape* basicShapeValue)
|
| {
|
| RefPtr<BasicShape> basicShape;
|
| @@ -243,32 +279,14 @@ PassRefPtr<BasicShape> basicShapeForValue(const StyleResolverState& state, const
|
| circle->setCenterX(BasicShapeCenterCoordinate(Length(50, Percent)));
|
| circle->setCenterY(BasicShapeCenterCoordinate(Length(50, Percent)));
|
| }
|
| - if (RefPtr<CSSPrimitiveValue> radius = circleValue->radius()) {
|
| - if (radius->isValueID()) {
|
| - switch (radius->getValueID()) {
|
| - case CSSValueClosestSide:
|
| - circle->setRadius(BasicShapeRadius(BasicShapeRadius::ClosestSide));
|
| - break;
|
| - case CSSValueFarthestSide:
|
| - circle->setRadius(BasicShapeRadius(BasicShapeRadius::FarthestSide));
|
| - break;
|
| - default:
|
| - ASSERT_NOT_REACHED();
|
| - break;
|
| - }
|
| - } else {
|
| - circle->setRadius(BasicShapeRadius(convertToLength(state, radius.get())));
|
| - }
|
| - } else {
|
| - circle->setRadius(BasicShapeRadius(BasicShapeRadius::ClosestSide));
|
| - }
|
| + circle->setRadius(cssValueToBasicShapeRadius(state, circleValue->radius()));
|
|
|
| basicShape = circle.release();
|
| break;
|
| }
|
| - case CSSBasicShape::CSSBasicShapeEllipseType: {
|
| - const CSSBasicShapeEllipse* ellipseValue = static_cast<const CSSBasicShapeEllipse *>(basicShapeValue);
|
| - RefPtr<BasicShapeEllipse> ellipse = BasicShapeEllipse::create();
|
| + case CSSBasicShape::CSSDeprecatedBasicShapeEllipseType: {
|
| + const CSSDeprecatedBasicShapeEllipse* ellipseValue = static_cast<const CSSDeprecatedBasicShapeEllipse *>(basicShapeValue);
|
| + RefPtr<DeprecatedBasicShapeEllipse> ellipse = DeprecatedBasicShapeEllipse::create();
|
|
|
| ellipse->setCenterX(convertToLength(state, ellipseValue->centerX()));
|
| ellipse->setCenterY(convertToLength(state, ellipseValue->centerY()));
|
| @@ -278,6 +296,23 @@ PassRefPtr<BasicShape> basicShapeForValue(const StyleResolverState& state, const
|
| basicShape = ellipse.release();
|
| break;
|
| }
|
| + case CSSBasicShape::CSSBasicShapeEllipseType: {
|
| + const CSSBasicShapeEllipse* ellipseValue = static_cast<const CSSBasicShapeEllipse *>(basicShapeValue);
|
| + RefPtr<BasicShapeEllipse> ellipse = BasicShapeEllipse::create();
|
| +
|
| + if (ellipseValue->centerX() && ellipseValue->centerY()) {
|
| + ellipse->setCenterX(convertToCenterCoordinate(state, ellipseValue->centerX()));
|
| + ellipse->setCenterY(convertToCenterCoordinate(state, ellipseValue->centerY()));
|
| + } else {
|
| + ellipse->setCenterX(BasicShapeCenterCoordinate(Length(50, Percent)));
|
| + ellipse->setCenterY(BasicShapeCenterCoordinate(Length(50, Percent)));
|
| + }
|
| + ellipse->setRadiusX(cssValueToBasicShapeRadius(state, ellipseValue->radiusX()));
|
| + ellipse->setRadiusY(cssValueToBasicShapeRadius(state, ellipseValue->radiusY()));
|
| +
|
| + basicShape = ellipse.release();
|
| + break;
|
| + }
|
| case CSSBasicShape::CSSBasicShapePolygonType: {
|
| const CSSBasicShapePolygon* polygonValue = static_cast<const CSSBasicShapePolygon *>(basicShapeValue);
|
| RefPtr<BasicShapePolygon> polygon = BasicShapePolygon::create();
|
|
|