summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/qt/PathQt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/graphics/qt/PathQt.cpp')
-rw-r--r--WebCore/platform/graphics/qt/PathQt.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/WebCore/platform/graphics/qt/PathQt.cpp b/WebCore/platform/graphics/qt/PathQt.cpp
index de9de07..ce5da2e 100644
--- a/WebCore/platform/graphics/qt/PathQt.cpp
+++ b/WebCore/platform/graphics/qt/PathQt.cpp
@@ -51,6 +51,7 @@
namespace WebCore {
Path::Path()
+ : m_lastMoveToIndex(0)
{
}
@@ -60,12 +61,14 @@ Path::~Path()
Path::Path(const Path& other)
: m_path(other.m_path)
+ , m_lastMoveToIndex(other.m_lastMoveToIndex)
{
}
Path& Path::operator=(const Path& other)
{
m_path = other.m_path;
+ m_lastMoveToIndex = other.m_lastMoveToIndex;
return *this;
}
@@ -180,6 +183,7 @@ FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier)
void Path::moveTo(const FloatPoint& point)
{
+ m_lastMoveToIndex = m_path.elementCount();
m_path.moveTo(point);
}
@@ -260,7 +264,26 @@ void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius)
void Path::closeSubpath()
{
- m_path.closeSubpath();
+ const int elementCount = m_path.elementCount();
+
+ if (!elementCount)
+ return;
+
+ QPointF lastMoveToPoint = m_path.elementAt(m_lastMoveToIndex);
+ int elementsInLastSubpath = 0;
+
+ for (int i = m_lastMoveToIndex; i < elementCount; ++i) {
+ QPainterPath::Element element = m_path.elementAt(i);
+ if (element.isLineTo() || element.isCurveTo()) {
+ // All we need to know is if there are 1 or more elements in the last subpath.
+ if (++elementsInLastSubpath == 2) {
+ m_path.lineTo(lastMoveToPoint);
+ return;
+ }
+ }
+ }
+
+ moveTo(lastMoveToPoint);
}
#define DEGREES(t) ((t) * 180.0 / M_PI)
@@ -440,7 +463,7 @@ void Path::transform(const AffineTransform& transform)
// QTransform.map doesn't handle the MoveTo element because of the isEmpty issue
if (m_path.isEmpty() && m_path.elementCount()) {
QPointF point = qTransform.map(m_path.currentPosition());
- m_path.moveTo(point);
+ moveTo(point);
} else
#endif
m_path = qTransform.map(m_path);