1 /* 2 * Copyright (C) 2007 Ryan Leavengood <leavengood (at) gmail.com> 3 * 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 #include "config.h" 29 #include "Path.h" 30 31 #include "AffineTransform.h" 32 #include "FloatRect.h" 33 #include "NotImplemented.h" 34 #include "PlatformString.h" 35 #include <Region.h> 36 37 38 namespace WebCore { 39 40 Path::Path() 41 : m_path(new BRegion()) 42 { 43 } 44 45 Path::~Path() 46 { 47 delete m_path; 48 } 49 50 Path::Path(const Path& other) 51 : m_path(new BRegion(*other.platformPath())) 52 { 53 } 54 55 Path& Path::operator=(const Path& other) 56 { 57 if (&other != this) 58 m_path = other.platformPath(); 59 60 return *this; 61 } 62 63 bool Path::hasCurrentPoint() const 64 { 65 return !isEmpty(); 66 } 67 68 FloatPoint Path::currentPoint() const 69 { 70 // FIXME: implement safe way to return current point of subpath. 71 notImplemented(); 72 float quietNaN = std::numeric_limits<float>::quiet_NaN(); 73 return FloatPoint(quietNaN, quietNaN); 74 } 75 76 bool Path::contains(const FloatPoint& point, WindRule rule) const 77 { 78 return m_path->Contains(point); 79 } 80 81 void Path::translate(const FloatSize& size) 82 { 83 notImplemented(); 84 } 85 86 FloatRect Path::boundingRect() const 87 { 88 return m_path->Frame(); 89 } 90 91 void Path::moveTo(const FloatPoint& point) 92 { 93 // FIXME: Use OffsetBy? 94 notImplemented(); 95 } 96 97 void Path::addLineTo(const FloatPoint& p) 98 { 99 notImplemented(); 100 } 101 102 void Path::addQuadCurveTo(const FloatPoint& cp, const FloatPoint& p) 103 { 104 notImplemented(); 105 } 106 107 void Path::addBezierCurveTo(const FloatPoint& cp1, const FloatPoint& cp2, const FloatPoint& p) 108 { 109 notImplemented(); 110 } 111 112 void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius) 113 { 114 notImplemented(); 115 } 116 117 void Path::closeSubpath() 118 { 119 notImplemented(); 120 } 121 122 void Path::addArc(const FloatPoint& p, float r, float sar, float ear, bool anticlockwise) 123 { 124 notImplemented(); 125 } 126 127 void Path::addRect(const FloatRect& r) 128 { 129 m_path->Include(r); 130 } 131 132 void Path::addEllipse(const FloatRect& r) 133 { 134 notImplemented(); 135 } 136 137 void Path::clear() 138 { 139 m_path->MakeEmpty(); 140 } 141 142 bool Path::isEmpty() const 143 { 144 return !m_path->Frame().IsValid(); 145 } 146 147 void Path::apply(void* info, PathApplierFunction function) const 148 { 149 notImplemented(); 150 } 151 152 void Path::transform(const AffineTransform& transform) 153 { 154 notImplemented(); 155 } 156 157 FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) 158 { 159 notImplemented(); 160 return FloatRect(); 161 } 162 163 } // namespace WebCore 164 165