summaryrefslogtreecommitdiff
path: root/Source/WebCore/css/BasicShapeFunctions.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/css/BasicShapeFunctions.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/css/BasicShapeFunctions.cpp')
-rw-r--r--Source/WebCore/css/BasicShapeFunctions.cpp356
1 files changed, 110 insertions, 246 deletions
diff --git a/Source/WebCore/css/BasicShapeFunctions.cpp b/Source/WebCore/css/BasicShapeFunctions.cpp
index 5b4ba1282..5f225f74a 100644
--- a/Source/WebCore/css/BasicShapeFunctions.cpp
+++ b/Source/WebCore/css/BasicShapeFunctions.cpp
@@ -36,10 +36,11 @@
#include "CSSValuePool.h"
#include "Pair.h"
#include "RenderStyle.h"
+#include "SVGPathByteStream.h"
namespace WebCore {
-static PassRefPtr<CSSPrimitiveValue> valueForCenterCoordinate(CSSValuePool& pool, const RenderStyle* style, const BasicShapeCenterCoordinate& center, EBoxOrient orientation)
+static Ref<CSSPrimitiveValue> valueForCenterCoordinate(CSSValuePool& pool, const RenderStyle& style, const BasicShapeCenterCoordinate& center, EBoxOrient orientation)
{
if (center.direction() == BasicShapeCenterCoordinate::TopLeft)
return pool.createValue(center.length(), style);
@@ -49,7 +50,7 @@ static PassRefPtr<CSSPrimitiveValue> valueForCenterCoordinate(CSSValuePool& pool
return pool.createValue(Pair::create(pool.createIdentifierValue(keyword), pool.createValue(center.length(), style)));
}
-static PassRefPtr<CSSPrimitiveValue> basicShapeRadiusToCSSValue(const RenderStyle* style, CSSValuePool& pool, const BasicShapeRadius& radius)
+static Ref<CSSPrimitiveValue> basicShapeRadiusToCSSValue(const RenderStyle& style, CSSValuePool& pool, const BasicShapeRadius& radius)
{
switch (radius.type()) {
case BasicShapeRadius::Value:
@@ -61,147 +62,109 @@ static PassRefPtr<CSSPrimitiveValue> basicShapeRadiusToCSSValue(const RenderStyl
}
ASSERT_NOT_REACHED();
- return 0;
+ return pool.createIdentifierValue(CSSValueClosestSide);
}
-PassRefPtr<CSSValue> valueForBasicShape(const RenderStyle* style, const BasicShape* basicShape)
+Ref<CSSPrimitiveValue> valueForBasicShape(const RenderStyle& style, const BasicShape& basicShape)
{
- CSSValuePool& pool = cssValuePool();
+ auto& cssValuePool = CSSValuePool::singleton();
RefPtr<CSSBasicShape> basicShapeValue;
- switch (basicShape->type()) {
- case BasicShape::BasicShapeRectangleType: {
- const BasicShapeRectangle* rectangle = static_cast<const BasicShapeRectangle*>(basicShape);
- RefPtr<CSSBasicShapeRectangle> rectangleValue = CSSBasicShapeRectangle::create();
-
- rectangleValue->setX(pool.createValue(rectangle->x(), style));
- rectangleValue->setY(pool.createValue(rectangle->y(), style));
- rectangleValue->setWidth(pool.createValue(rectangle->width(), style));
- rectangleValue->setHeight(pool.createValue(rectangle->height(), style));
- rectangleValue->setRadiusX(pool.createValue(rectangle->cornerRadiusX(), style));
- rectangleValue->setRadiusY(pool.createValue(rectangle->cornerRadiusY(), style));
-
- basicShapeValue = rectangleValue.release();
- break;
- }
- case BasicShape::DeprecatedBasicShapeCircleType: {
- const DeprecatedBasicShapeCircle* circle = static_cast<const DeprecatedBasicShapeCircle*>(basicShape);
- RefPtr<CSSDeprecatedBasicShapeCircle> circleValue = CSSDeprecatedBasicShapeCircle::create();
-
- circleValue->setCenterX(pool.createValue(circle->centerX(), style));
- circleValue->setCenterY(pool.createValue(circle->centerY(), style));
- circleValue->setRadius(pool.createValue(circle->radius(), style));
-
- basicShapeValue = circleValue.release();
- break;
- }
+ switch (basicShape.type()) {
case BasicShape::BasicShapeCircleType: {
- const BasicShapeCircle* circle = static_cast<const BasicShapeCircle*>(basicShape);
- RefPtr<CSSBasicShapeCircle> circleValue = CSSBasicShapeCircle::create();
+ auto& circle = downcast<BasicShapeCircle>(basicShape);
+ auto circleValue = CSSBasicShapeCircle::create();
- circleValue->setCenterX(valueForCenterCoordinate(pool, style, circle->centerX(), HORIZONTAL));
- circleValue->setCenterY(valueForCenterCoordinate(pool, style, circle->centerY(), VERTICAL));
- circleValue->setRadius(basicShapeRadiusToCSSValue(style, pool, circle->radius()));
- basicShapeValue = circleValue.release();
- break;
- }
- 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));
- ellipseValue->setRadiusX(pool.createValue(ellipse->radiusX(), style));
- ellipseValue->setRadiusY(pool.createValue(ellipse->radiusY(), style));
+ circleValue->setCenterX(valueForCenterCoordinate(cssValuePool, style, circle.centerX(), HORIZONTAL));
+ circleValue->setCenterY(valueForCenterCoordinate(cssValuePool, style, circle.centerY(), VERTICAL));
+ circleValue->setRadius(basicShapeRadiusToCSSValue(style, cssValuePool, circle.radius()));
- basicShapeValue = ellipseValue.release();
+ basicShapeValue = WTFMove(circleValue);
break;
}
case BasicShape::BasicShapeEllipseType: {
- const BasicShapeEllipse* ellipse = static_cast<const BasicShapeEllipse*>(basicShape);
- RefPtr<CSSBasicShapeEllipse> ellipseValue = CSSBasicShapeEllipse::create();
-
- ellipseValue->setCenterX(valueForCenterCoordinate(pool, style, ellipse->centerX(), HORIZONTAL));
- ellipseValue->setCenterY(valueForCenterCoordinate(pool, style, ellipse->centerY(), VERTICAL));
- ellipseValue->setRadiusX(basicShapeRadiusToCSSValue(style, pool, ellipse->radiusX()));
- ellipseValue->setRadiusY(basicShapeRadiusToCSSValue(style, pool, ellipse->radiusY()));
- basicShapeValue = ellipseValue.release();
+ auto& ellipse = downcast<BasicShapeEllipse>(basicShape);
+ auto ellipseValue = CSSBasicShapeEllipse::create();
+
+ ellipseValue->setCenterX(valueForCenterCoordinate(cssValuePool, style, ellipse.centerX(), HORIZONTAL));
+ ellipseValue->setCenterY(valueForCenterCoordinate(cssValuePool, style, ellipse.centerY(), VERTICAL));
+ ellipseValue->setRadiusX(basicShapeRadiusToCSSValue(style, cssValuePool, ellipse.radiusX()));
+ ellipseValue->setRadiusY(basicShapeRadiusToCSSValue(style, cssValuePool, ellipse.radiusY()));
+
+ basicShapeValue = WTFMove(ellipseValue);
break;
}
case BasicShape::BasicShapePolygonType: {
- const BasicShapePolygon* polygon = static_cast<const BasicShapePolygon*>(basicShape);
- RefPtr<CSSBasicShapePolygon> polygonValue = CSSBasicShapePolygon::create();
+ auto& polygon = downcast<BasicShapePolygon>(basicShape);
+ auto polygonValue = CSSBasicShapePolygon::create();
- polygonValue->setWindRule(polygon->windRule());
- const Vector<Length>& values = polygon->values();
+ polygonValue->setWindRule(polygon.windRule());
+ const Vector<Length>& values = polygon.values();
for (unsigned i = 0; i < values.size(); i += 2)
- polygonValue->appendPoint(pool.createValue(values.at(i), style), pool.createValue(values.at(i + 1), style));
+ polygonValue->appendPoint(cssValuePool.createValue(values.at(i), style), cssValuePool.createValue(values.at(i + 1), style));
- basicShapeValue = polygonValue.release();
+ basicShapeValue = WTFMove(polygonValue);
break;
}
- case BasicShape::BasicShapeInsetRectangleType: {
- const BasicShapeInsetRectangle* rectangle = static_cast<const BasicShapeInsetRectangle*>(basicShape);
- RefPtr<CSSBasicShapeInsetRectangle> rectangleValue = CSSBasicShapeInsetRectangle::create();
-
- rectangleValue->setTop(pool.createValue(rectangle->top(), style));
- rectangleValue->setRight(pool.createValue(rectangle->right(), style));
- rectangleValue->setBottom(pool.createValue(rectangle->bottom(), style));
- rectangleValue->setLeft(pool.createValue(rectangle->left(), style));
- rectangleValue->setRadiusX(pool.createValue(rectangle->cornerRadiusX(), style));
- rectangleValue->setRadiusY(pool.createValue(rectangle->cornerRadiusY(), style));
-
- basicShapeValue = rectangleValue.release();
+ case BasicShape::BasicShapePathType: {
+ auto& pathShape = downcast<BasicShapePath>(basicShape);
+ auto pathShapeValue = CSSBasicShapePath::create(pathShape.pathData()->copy());
+ pathShapeValue->setWindRule(pathShape.windRule());
+
+ basicShapeValue = WTFMove(pathShapeValue);
break;
}
case BasicShape::BasicShapeInsetType: {
- const BasicShapeInset* inset = static_cast<const BasicShapeInset*>(basicShape);
- RefPtr<CSSBasicShapeInset> insetValue = CSSBasicShapeInset::create();
+ auto& inset = downcast<BasicShapeInset>(basicShape);
+ auto insetValue = CSSBasicShapeInset::create();
- insetValue->setTop(pool.createValue(inset->top()));
- insetValue->setRight(pool.createValue(inset->right()));
- insetValue->setBottom(pool.createValue(inset->bottom()));
- insetValue->setLeft(pool.createValue(inset->left()));
+ insetValue->setTop(cssValuePool.createValue(inset.top(), style));
+ insetValue->setRight(cssValuePool.createValue(inset.right(), style));
+ insetValue->setBottom(cssValuePool.createValue(inset.bottom(), style));
+ insetValue->setLeft(cssValuePool.createValue(inset.left(), style));
- insetValue->setTopLeftRadius(pool.createValue(inset->topLeftRadius()));
- insetValue->setTopRightRadius(pool.createValue(inset->topRightRadius()));
- insetValue->setBottomRightRadius(pool.createValue(inset->bottomRightRadius()));
- insetValue->setBottomLeftRadius(pool.createValue(inset->bottomLeftRadius()));
+ insetValue->setTopLeftRadius(cssValuePool.createValue(inset.topLeftRadius(), style));
+ insetValue->setTopRightRadius(cssValuePool.createValue(inset.topRightRadius(), style));
+ insetValue->setBottomRightRadius(cssValuePool.createValue(inset.bottomRightRadius(), style));
+ insetValue->setBottomLeftRadius(cssValuePool.createValue(inset.bottomLeftRadius(), style));
- basicShapeValue = insetValue.release();
+ basicShapeValue = WTFMove(insetValue);
break;
}
- default:
- break;
}
- if (basicShape->layoutBox() != BoxMissing)
- basicShapeValue->setLayoutBox(pool.createValue(basicShape->layoutBox()));
-
- return pool.createValue(basicShapeValue.release());
+ return cssValuePool.createValue(basicShapeValue.releaseNonNull());
}
-static Length convertToLength(const RenderStyle* style, const RenderStyle* rootStyle, CSSPrimitiveValue* value)
+static Length convertToLength(const CSSToLengthConversionData& conversionData, const CSSPrimitiveValue* value)
{
- return value->convertToLength<FixedIntegerConversion | FixedFloatConversion | PercentConversion | CalculatedConversion | ViewportPercentageConversion>(style, rootStyle, style->effectiveZoom());
+ return value->convertToLength<FixedIntegerConversion | FixedFloatConversion | PercentConversion | CalculatedConversion>(conversionData);
}
-static BasicShapeCenterCoordinate convertToCenterCoordinate(const RenderStyle* style, const RenderStyle* rootStyle, CSSPrimitiveValue* value)
+static LengthSize convertToLengthSize(const CSSToLengthConversionData& conversionData, const CSSPrimitiveValue* value)
{
- BasicShapeCenterCoordinate::Direction direction;
- Length offset = Length(0, Fixed);
+ if (!value)
+ return { { 0, Fixed }, { 0, Fixed } };
+ auto& pair = *value->pairValue();
+ return { convertToLength(conversionData, pair.first()), convertToLength(conversionData, pair.second()) };
+}
+
+static BasicShapeCenterCoordinate convertToCenterCoordinate(const CSSToLengthConversionData& conversionData, CSSPrimitiveValue* value)
+{
CSSValueID keyword = CSSValueTop;
+ Length offset { 0, Fixed };
if (!value)
keyword = CSSValueCenter;
else if (value->isValueID())
- keyword = value->getValueID();
- else if (Pair* pair = value->getPairValue()) {
- keyword = pair->first()->getValueID();
- offset = convertToLength(style, rootStyle, pair->second());
+ keyword = value->valueID();
+ else if (Pair* pair = value->pairValue()) {
+ keyword = pair->first()->valueID();
+ offset = convertToLength(conversionData, pair->second());
} else
- offset = convertToLength(style, rootStyle, value);
+ offset = convertToLength(conversionData, value);
+ BasicShapeCenterCoordinate::Direction direction;
switch (keyword) {
case CSSValueTop:
case CSSValueLeft:
@@ -224,13 +187,13 @@ static BasicShapeCenterCoordinate convertToCenterCoordinate(const RenderStyle* s
return BasicShapeCenterCoordinate(direction, offset);
}
-static BasicShapeRadius cssValueToBasicShapeRadius(const RenderStyle* style, const RenderStyle* rootStyle, PassRefPtr<CSSPrimitiveValue> radius)
+static BasicShapeRadius cssValueToBasicShapeRadius(const CSSToLengthConversionData& conversionData, CSSPrimitiveValue* radius)
{
if (!radius)
return BasicShapeRadius(BasicShapeRadius::ClosestSide);
if (radius->isValueID()) {
- switch (radius->getValueID()) {
+ switch (radius->valueID()) {
case CSSValueClosestSide:
return BasicShapeRadius(BasicShapeRadius::ClosestSide);
case CSSValueFarthestSide:
@@ -241,177 +204,78 @@ static BasicShapeRadius cssValueToBasicShapeRadius(const RenderStyle* style, con
}
}
- return BasicShapeRadius(convertToLength(style, rootStyle, radius.get()));
+ return BasicShapeRadius(convertToLength(conversionData, radius));
}
-PassRefPtr<BasicShape> basicShapeForValue(const RenderStyle* style, const RenderStyle* rootStyle, const CSSBasicShape* basicShapeValue)
+Ref<BasicShape> basicShapeForValue(const CSSToLengthConversionData& conversionData, const CSSBasicShape& basicShapeValue)
{
RefPtr<BasicShape> basicShape;
- switch (basicShapeValue->type()) {
- case CSSBasicShape::CSSBasicShapeRectangleType: {
- const CSSBasicShapeRectangle* rectValue = static_cast<const CSSBasicShapeRectangle *>(basicShapeValue);
- RefPtr<BasicShapeRectangle> rect = BasicShapeRectangle::create();
-
- rect->setX(convertToLength(style, rootStyle, rectValue->x()));
- rect->setY(convertToLength(style, rootStyle, rectValue->y()));
- rect->setWidth(convertToLength(style, rootStyle, rectValue->width()));
- rect->setHeight(convertToLength(style, rootStyle, rectValue->height()));
- if (rectValue->radiusX()) {
- Length radiusX = convertToLength(style, rootStyle, rectValue->radiusX());
- rect->setCornerRadiusX(radiusX);
- if (rectValue->radiusY())
- rect->setCornerRadiusY(convertToLength(style, rootStyle, rectValue->radiusY()));
- else
- rect->setCornerRadiusY(radiusX);
- } else {
- rect->setCornerRadiusX(Length(0, Fixed));
- rect->setCornerRadiusY(Length(0, Fixed));
- }
- basicShape = rect.release();
- break;
- }
- case CSSBasicShape::CSSDeprecatedBasicShapeCircleType: {
- const CSSDeprecatedBasicShapeCircle* circleValue = static_cast<const CSSDeprecatedBasicShapeCircle *>(basicShapeValue);
- RefPtr<DeprecatedBasicShapeCircle> circle = DeprecatedBasicShapeCircle::create();
-
- circle->setCenterX(convertToLength(style, rootStyle, circleValue->centerX()));
- circle->setCenterY(convertToLength(style, rootStyle, circleValue->centerY()));
- circle->setRadius(convertToLength(style, rootStyle, circleValue->radius()));
-
- basicShape = circle.release();
- break;
- }
+ switch (basicShapeValue.type()) {
case CSSBasicShape::CSSBasicShapeCircleType: {
- const CSSBasicShapeCircle* circleValue = static_cast<const CSSBasicShapeCircle *>(basicShapeValue);
- RefPtr<BasicShapeCircle> circle = BasicShapeCircle::create();
+ auto& circleValue = downcast<CSSBasicShapeCircle>(basicShapeValue);
+ auto circle = BasicShapeCircle::create();
- circle->setCenterX(convertToCenterCoordinate(style, rootStyle, circleValue->centerX()));
- circle->setCenterY(convertToCenterCoordinate(style, rootStyle, circleValue->centerY()));
- circle->setRadius(cssValueToBasicShapeRadius(style, rootStyle, circleValue->radius()));
+ circle->setCenterX(convertToCenterCoordinate(conversionData, circleValue.centerX()));
+ circle->setCenterY(convertToCenterCoordinate(conversionData, circleValue.centerY()));
+ circle->setRadius(cssValueToBasicShapeRadius(conversionData, circleValue.radius()));
- basicShape = circle.release();
- break;
- }
- case CSSBasicShape::CSSDeprecatedBasicShapeEllipseType: {
- const CSSDeprecatedBasicShapeEllipse* ellipseValue = static_cast<const CSSDeprecatedBasicShapeEllipse *>(basicShapeValue);
- RefPtr<DeprecatedBasicShapeEllipse> ellipse = DeprecatedBasicShapeEllipse::create();
-
- ellipse->setCenterX(convertToLength(style, rootStyle, ellipseValue->centerX()));
- ellipse->setCenterY(convertToLength(style, rootStyle, ellipseValue->centerY()));
- ellipse->setRadiusX(convertToLength(style, rootStyle, ellipseValue->radiusX()));
- ellipse->setRadiusY(convertToLength(style, rootStyle, ellipseValue->radiusY()));
-
- basicShape = ellipse.release();
+ basicShape = WTFMove(circle);
break;
}
case CSSBasicShape::CSSBasicShapeEllipseType: {
- const CSSBasicShapeEllipse* ellipseValue = static_cast<const CSSBasicShapeEllipse *>(basicShapeValue);
- RefPtr<BasicShapeEllipse> ellipse = BasicShapeEllipse::create();
+ auto& ellipseValue = downcast<CSSBasicShapeEllipse>(basicShapeValue);
+ auto ellipse = BasicShapeEllipse::create();
- ellipse->setCenterX(convertToCenterCoordinate(style, rootStyle, ellipseValue->centerX()));
- ellipse->setCenterY(convertToCenterCoordinate(style, rootStyle, ellipseValue->centerY()));
+ ellipse->setCenterX(convertToCenterCoordinate(conversionData, ellipseValue.centerX()));
+ ellipse->setCenterY(convertToCenterCoordinate(conversionData, ellipseValue.centerY()));
- ellipse->setRadiusX(cssValueToBasicShapeRadius(style, rootStyle, ellipseValue->radiusX()));
- ellipse->setRadiusY(cssValueToBasicShapeRadius(style, rootStyle, ellipseValue->radiusY()));
+ ellipse->setRadiusX(cssValueToBasicShapeRadius(conversionData, ellipseValue.radiusX()));
+ ellipse->setRadiusY(cssValueToBasicShapeRadius(conversionData, ellipseValue.radiusY()));
- basicShape = ellipse.release();
+ basicShape = WTFMove(ellipse);
break;
}
case CSSBasicShape::CSSBasicShapePolygonType: {
- const CSSBasicShapePolygon* polygonValue = static_cast<const CSSBasicShapePolygon *>(basicShapeValue);
- RefPtr<BasicShapePolygon> polygon = BasicShapePolygon::create();
+ auto& polygonValue = downcast<CSSBasicShapePolygon>(basicShapeValue);
+ auto polygon = BasicShapePolygon::create();
- polygon->setWindRule(polygonValue->windRule());
- const Vector<RefPtr<CSSPrimitiveValue>>& values = polygonValue->values();
+ polygon->setWindRule(polygonValue.windRule());
+ auto& values = polygonValue.values();
for (unsigned i = 0; i < values.size(); i += 2)
- polygon->appendPoint(convertToLength(style, rootStyle, values.at(i).get()), convertToLength(style, rootStyle, values.at(i + 1).get()));
+ polygon->appendPoint(convertToLength(conversionData, values[i].ptr()), convertToLength(conversionData, values[i + 1].ptr()));
- basicShape = polygon.release();
- break;
- }
- case CSSBasicShape::CSSBasicShapeInsetRectangleType: {
- const CSSBasicShapeInsetRectangle* rectValue = static_cast<const CSSBasicShapeInsetRectangle *>(basicShapeValue);
- RefPtr<BasicShapeInsetRectangle> rect = BasicShapeInsetRectangle::create();
-
- rect->setTop(convertToLength(style, rootStyle, rectValue->top()));
- rect->setRight(convertToLength(style, rootStyle, rectValue->right()));
- rect->setBottom(convertToLength(style, rootStyle, rectValue->bottom()));
- rect->setLeft(convertToLength(style, rootStyle, rectValue->left()));
- if (rectValue->radiusX()) {
- Length radiusX = convertToLength(style, rootStyle, rectValue->radiusX());
- rect->setCornerRadiusX(radiusX);
- if (rectValue->radiusY())
- rect->setCornerRadiusY(convertToLength(style, rootStyle, rectValue->radiusY()));
- else
- rect->setCornerRadiusY(radiusX);
- } else {
- rect->setCornerRadiusX(Length(0, Fixed));
- rect->setCornerRadiusY(Length(0, Fixed));
- }
- basicShape = rect.release();
+ basicShape = WTFMove(polygon);
break;
}
case CSSBasicShape::CSSBasicShapeInsetType: {
- const CSSBasicShapeInset* rectValue = static_cast<const CSSBasicShapeInset* >(basicShapeValue);
- RefPtr<BasicShapeInset> rect = BasicShapeInset::create();
-
- if (rectValue->top())
- rect->setTop(convertToLength(style, rootStyle, rectValue->top()));
- else {
- rect->setTop(Length(0, Fixed));
- return rect;
- }
- if (rectValue->right())
- rect->setRight(convertToLength(style, rootStyle, rectValue->right()));
- else
- rect->setRight(Length(0, Fixed));
-
- if (rectValue->bottom())
- rect->setBottom(convertToLength(style, rootStyle, rectValue->bottom()));
- else
- rect->setBottom(Length(0, Fixed));
-
- if (rectValue->left())
- rect->setLeft(convertToLength(style, rootStyle, rectValue->left()));
- else
- rect->setLeft(Length(0, Fixed));
-
- if (rectValue->topLeftRadius()) {
- Pair* topLeftRadius = rectValue->topLeftRadius()->getPairValue();
- rect->setTopLeftRadius(LengthSize(convertToLength(style, rootStyle, topLeftRadius->first()), convertToLength(style, rootStyle, topLeftRadius->second())));
- } else
- rect->setTopLeftRadius(LengthSize(Length(0, Fixed), Length(0, Fixed)));
-
- if (rectValue->topRightRadius()) {
- Pair* topRightRadius = rectValue->topRightRadius()->getPairValue();
- rect->setTopRightRadius(LengthSize(convertToLength(style, rootStyle, topRightRadius->first()), convertToLength(style, rootStyle, topRightRadius->second())));
- } else
- rect->setTopRightRadius(LengthSize(Length(0, Fixed), Length(0, Fixed)));
-
- if (rectValue->bottomRightRadius()) {
- Pair* bottomRightRadius = rectValue->bottomRightRadius()->getPairValue();
- rect->setBottomRightRadius(LengthSize(convertToLength(style, rootStyle, bottomRightRadius->first()), convertToLength(style, rootStyle, bottomRightRadius->second())));
- } else
- rect->setBottomRightRadius(LengthSize(Length(0, Fixed), Length(0, Fixed)));
-
- if (rectValue->topLeftRadius()) {
- Pair* bottomLeftRadius = rectValue->bottomLeftRadius()->getPairValue();
- rect->setBottomLeftRadius(LengthSize(convertToLength(style, rootStyle, bottomLeftRadius->first()), convertToLength(style, rootStyle, bottomLeftRadius->second())));
- } else
- rect->setBottomLeftRadius(LengthSize(Length(0, Fixed), Length(0, Fixed)));
-
- basicShape = rect.release();
+ auto& rectValue = downcast<CSSBasicShapeInset>(basicShapeValue);
+ auto rect = BasicShapeInset::create();
+
+ rect->setTop(convertToLength(conversionData, rectValue.top()));
+ rect->setRight(convertToLength(conversionData, rectValue.right()));
+ rect->setBottom(convertToLength(conversionData, rectValue.bottom()));
+ rect->setLeft(convertToLength(conversionData, rectValue.left()));
+
+ rect->setTopLeftRadius(convertToLengthSize(conversionData, rectValue.topLeftRadius()));
+ rect->setTopRightRadius(convertToLengthSize(conversionData, rectValue.topRightRadius()));
+ rect->setBottomRightRadius(convertToLengthSize(conversionData, rectValue.bottomRightRadius()));
+ rect->setBottomLeftRadius(convertToLengthSize(conversionData, rectValue.bottomLeftRadius()));
+
+ basicShape = WTFMove(rect);
break;
}
- default:
+ case CSSBasicShape::CSSBasicShapePathType: {
+ auto& pathValue = downcast<CSSBasicShapePath>(basicShapeValue);
+ auto path = BasicShapePath::create(pathValue.pathData().copy());
+ path->setWindRule(pathValue.windRule());
+
+ basicShape = WTFMove(path);
break;
}
+ }
- if (basicShapeValue->layoutBox())
- basicShape->setLayoutBox(LayoutBox(*basicShapeValue->layoutBox()));
-
- return basicShape.release();
+ return basicShape.releaseNonNull();
}
float floatValueForCenterCoordinate(const BasicShapeCenterCoordinate& center, float boxDimension)