1/*
2 *  Copyright (C) 2007-2009 Torch Mobile, Inc.
3 *
4 *  This library is free software; you can redistribute it and/or
5 *  modify it under the terms of the GNU Library General Public
6 *  License as published by the Free Software Foundation; either
7 *  version 2 of the License, or (at your option) any later version.
8 *
9 *  This library is distributed in the hope that it will be useful,
10 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 *  Library General Public License for more details.
13 *
14 *  You should have received a copy of the GNU Library General Public License
15 *  along with this library; see the file COPYING.LIB.  If not, write to
16 *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 *  Boston, MA 02110-1301, USA.
18 */
19
20#include "config.h"
21#include "Path.h"
22
23#include "AffineTransform.h"
24#include "FloatRect.h"
25#include "NotImplemented.h"
26#include "PlatformPathWinCE.h"
27#include <wtf/OwnPtr.h>
28#include <wtf/text/WTFString.h>
29
30namespace WebCore {
31
32Path::Path()
33    : m_path(new PlatformPath())
34{
35}
36
37Path::Path(const Path& other)
38    : m_path(new PlatformPath(*other.m_path))
39{
40}
41
42Path::~Path()
43{
44    delete m_path;
45}
46
47Path& Path::operator=(const Path& other)
48{
49    if (&other != this) {
50        delete m_path;
51        m_path = new PlatformPath(*other.m_path);
52    }
53    return *this;
54}
55
56bool Path::contains(const FloatPoint& point, WindRule rule) const
57{
58    return m_path->contains(point, rule);
59}
60
61void Path::translate(const FloatSize& size)
62{
63    m_path->translate(size);
64}
65
66FloatRect Path::boundingRect() const
67{
68    return m_path->boundingRect();
69}
70
71void Path::moveTo(const FloatPoint& point)
72{
73    m_path->moveTo(point);
74}
75
76void Path::addLineTo(const FloatPoint& point)
77{
78    m_path->addLineTo(point);
79}
80
81void Path::addQuadCurveTo(const FloatPoint& cp, const FloatPoint& p)
82{
83    m_path->addQuadCurveTo(cp, p);
84}
85
86void Path::addBezierCurveTo(const FloatPoint& cp1, const FloatPoint& cp2, const FloatPoint& p)
87{
88    m_path->addBezierCurveTo(cp1, cp2, p);
89}
90
91void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius)
92{
93    m_path->addArcTo(p1, p2, radius);
94}
95
96void Path::closeSubpath()
97{
98    m_path->closeSubpath();
99}
100
101void Path::addArc(const FloatPoint& p, float r, float sar, float ear, bool anticlockwise)
102{
103    m_path->addEllipse(p, r, r, sar, ear, anticlockwise);
104}
105
106void Path::addRect(const FloatRect& r)
107{
108    m_path->addRect(r);
109}
110
111void Path::addEllipse(const FloatRect& r)
112{
113    m_path->addEllipse(r);
114}
115
116void Path::addPath(const Path&, const AffineTransform&)
117{
118    notImplemented();
119}
120
121void Path::clear()
122{
123    m_path->clear();
124}
125
126bool Path::isEmpty() const
127{
128    return m_path->isEmpty();
129}
130
131void Path::apply(void* info, PathApplierFunction function) const
132{
133    m_path->apply(info, function);
134}
135
136void Path::transform(const AffineTransform& t)
137{
138    m_path->transform(t);
139}
140
141FloatRect Path::strokeBoundingRect(StrokeStyleApplier*) const
142{
143    notImplemented();
144    return FloatRect();
145}
146
147bool Path::strokeContains(StrokeStyleApplier*, const FloatPoint&) const
148{
149    notImplemented();
150    return false;
151}
152
153bool Path::hasCurrentPoint() const
154{
155    // Not sure if this is correct. At the meantime, we do what other ports
156    // do.
157    // See https://bugs.webkit.org/show_bug.cgi?id=27266,
158    // https://bugs.webkit.org/show_bug.cgi?id=27187, and
159    // http://trac.webkit.org/changeset/45873
160    return !isEmpty();
161}
162
163FloatPoint Path::currentPoint() const
164{
165    return m_path->lastPoint();
166}
167
168} // namespace WebCore
169