summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/ExclusionShape.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/rendering/ExclusionShape.cpp')
-rw-r--r--Source/WebCore/rendering/ExclusionShape.cpp36
1 files changed, 27 insertions, 9 deletions
diff --git a/Source/WebCore/rendering/ExclusionShape.cpp b/Source/WebCore/rendering/ExclusionShape.cpp
index 0f430ef04..c3ec8acaa 100644
--- a/Source/WebCore/rendering/ExclusionShape.cpp
+++ b/Source/WebCore/rendering/ExclusionShape.cpp
@@ -31,10 +31,10 @@
#include "ExclusionShape.h"
#include "BasicShapeFunctions.h"
+#include "ExclusionPolygon.h"
#include "ExclusionRectangle.h"
#include "FloatSize.h"
#include "LengthFunctions.h"
-#include "NotImplemented.h"
#include "WindRule.h"
#include <wtf/MathExtras.h>
#include <wtf/OwnPtr.h>
@@ -60,6 +60,11 @@ static PassOwnPtr<ExclusionShape> createExclusionEllipse(const FloatPoint& cente
return adoptPtr(new ExclusionRectangle(FloatRect(center.x() - radii.width(), center.y() - radii.height(), radii.width()*2, radii.height()*2), radii));
}
+static PassOwnPtr<ExclusionShape> createExclusionPolygon(PassOwnPtr<Vector<FloatPoint> > vertices, WindRule fillRule)
+{
+ return adoptPtr(new ExclusionPolygon(vertices, fillRule));
+}
+
// If the writingMode is vertical, then the BasicShape's (physical) x and y coordinates are swapped, so that
// line segments are parallel to the internal coordinate system's X axis.
@@ -87,8 +92,8 @@ PassOwnPtr<ExclusionShape> ExclusionShape::createExclusionShape(const BasicShape
float radiusY = radiusYLength.isUndefined() ? 0 : floatValueForLength(radiusYLength, boxHeight);
exclusionShape = horizontalWritingMode
- ? createExclusionRectangle(FloatRect(x, y, width, height), FloatSize(radiusX, radiusY))
- : createExclusionRectangle(FloatRect(y, x, height, width), FloatSize(radiusY, radiusX));
+ ? createExclusionRectangle(FloatRect(x, y, width, height), FloatSize(radiusX, radiusY))
+ : createExclusionRectangle(FloatRect(y, x, height, width), FloatSize(radiusY, radiusX));
break;
}
@@ -99,8 +104,8 @@ PassOwnPtr<ExclusionShape> ExclusionShape::createExclusionShape(const BasicShape
float radius = floatValueForLength(circle->radius(), std::max(boxHeight, boxWidth));
exclusionShape = horizontalWritingMode
- ? createExclusionCircle(FloatPoint(centerX, centerY), radius)
- : createExclusionCircle(FloatPoint(centerY, centerX), radius);
+ ? createExclusionCircle(FloatPoint(centerX, centerY), radius)
+ : createExclusionCircle(FloatPoint(centerY, centerX), radius);
break;
}
@@ -112,13 +117,26 @@ PassOwnPtr<ExclusionShape> ExclusionShape::createExclusionShape(const BasicShape
float radiusY = floatValueForLength(ellipse->radiusY(), boxHeight);
exclusionShape = horizontalWritingMode
- ? createExclusionEllipse(FloatPoint(centerX, centerY), FloatSize(radiusX, radiusY))
- : createExclusionEllipse(FloatPoint(centerY, centerX), FloatSize(radiusY, radiusX));
+ ? createExclusionEllipse(FloatPoint(centerX, centerY), FloatSize(radiusX, radiusY))
+ : createExclusionEllipse(FloatPoint(centerY, centerX), FloatSize(radiusY, radiusX));
break;
}
- case BasicShape::BASIC_SHAPE_POLYGON:
- notImplemented();
+ case BasicShape::BASIC_SHAPE_POLYGON: {
+ const BasicShapePolygon* polygon = static_cast<const BasicShapePolygon*>(basicShape);
+ const Vector<Length>& values = polygon->values();
+ size_t valuesSize = values.size();
+ ASSERT(!(valuesSize % 2));
+ Vector<FloatPoint>* vertices = new Vector<FloatPoint>(valuesSize / 2);
+ for (unsigned i = 0; i < valuesSize; i += 2) {
+ FloatPoint vertex(
+ floatValueForLength(values.at(i), boxWidth),
+ floatValueForLength(values.at(i + 1), boxHeight));
+ (*vertices)[i / 2] = horizontalWritingMode ? vertex : vertex.transposedPoint();
+ }
+ exclusionShape = createExclusionPolygon(adoptPtr(vertices), polygon->windRule());
+ break;
+ }
default:
ASSERT_NOT_REACHED();