diff options
Diffstat (limited to 'chromium/third_party/WebKit/Source/core/rendering/svg/SVGPathData.cpp')
-rw-r--r-- | chromium/third_party/WebKit/Source/core/rendering/svg/SVGPathData.cpp | 93 |
1 files changed, 47 insertions, 46 deletions
diff --git a/chromium/third_party/WebKit/Source/core/rendering/svg/SVGPathData.cpp b/chromium/third_party/WebKit/Source/core/rendering/svg/SVGPathData.cpp index f42f6410e57..5a18ba50295 100644 --- a/chromium/third_party/WebKit/Source/core/rendering/svg/SVGPathData.cpp +++ b/chromium/third_party/WebKit/Source/core/rendering/svg/SVGPathData.cpp @@ -20,7 +20,7 @@ #include "config.h" #include "core/rendering/svg/SVGPathData.h" -#include "SVGNames.h" +#include "core/SVGNames.h" #include "core/svg/SVGCircleElement.h" #include "core/svg/SVGEllipseElement.h" #include "core/svg/SVGLineElement.h" @@ -34,14 +34,16 @@ namespace WebCore { +using namespace SVGNames; + static void updatePathFromCircleElement(SVGElement* element, Path& path) { SVGCircleElement* circle = toSVGCircleElement(element); SVGLengthContext lengthContext(element); - float r = circle->rCurrentValue().value(lengthContext); + float r = circle->r()->currentValue()->value(lengthContext); if (r > 0) - path.addEllipse(FloatRect(circle->cxCurrentValue().value(lengthContext) - r, circle->cyCurrentValue().value(lengthContext) - r, r * 2, r * 2)); + path.addEllipse(FloatRect(circle->cx()->currentValue()->value(lengthContext) - r, circle->cy()->currentValue()->value(lengthContext) - r, r * 2, r * 2)); } static void updatePathFromEllipseElement(SVGElement* element, Path& path) @@ -49,13 +51,16 @@ static void updatePathFromEllipseElement(SVGElement* element, Path& path) SVGEllipseElement* ellipse = toSVGEllipseElement(element); SVGLengthContext lengthContext(element); - float rx = ellipse->rxCurrentValue().value(lengthContext); - if (rx <= 0) + float rx = ellipse->rx()->currentValue()->value(lengthContext); + if (rx < 0) + return; + float ry = ellipse->ry()->currentValue()->value(lengthContext); + if (ry < 0) return; - float ry = ellipse->ryCurrentValue().value(lengthContext); - if (ry <= 0) + if (!rx && !ry) return; - path.addEllipse(FloatRect(ellipse->cxCurrentValue().value(lengthContext) - rx, ellipse->cyCurrentValue().value(lengthContext) - ry, rx * 2, ry * 2)); + + path.addEllipse(FloatRect(ellipse->cx()->currentValue()->value(lengthContext) - rx, ellipse->cy()->currentValue()->value(lengthContext) - ry, rx * 2, ry * 2)); } static void updatePathFromLineElement(SVGElement* element, Path& path) @@ -63,8 +68,8 @@ static void updatePathFromLineElement(SVGElement* element, Path& path) SVGLineElement* line = toSVGLineElement(element); SVGLengthContext lengthContext(element); - path.moveTo(FloatPoint(line->x1CurrentValue().value(lengthContext), line->y1CurrentValue().value(lengthContext))); - path.addLineTo(FloatPoint(line->x2CurrentValue().value(lengthContext), line->y2CurrentValue().value(lengthContext))); + path.moveTo(FloatPoint(line->x1()->currentValue()->value(lengthContext), line->y1()->currentValue()->value(lengthContext))); + path.addLineTo(FloatPoint(line->x2()->currentValue()->value(lengthContext), line->y2()->currentValue()->value(lengthContext))); } static void updatePathFromPathElement(SVGElement* element, Path& path) @@ -72,32 +77,26 @@ static void updatePathFromPathElement(SVGElement* element, Path& path) buildPathFromByteStream(toSVGPathElement(element)->pathByteStream(), path); } -static void updatePathFromPolygonElement(SVGElement* element, Path& path) +static void updatePathFromPolylineElement(SVGElement* element, Path& path) { - SVGPointList& points = toSVGPolygonElement(element)->pointsCurrentValue(); - if (points.isEmpty()) + RefPtr<SVGPointList> points = toSVGPolyElement(element)->points()->currentValue(); + if (points->isEmpty()) return; - path.moveTo(points.first()); - - unsigned size = points.size(); - for (unsigned i = 1; i < size; ++i) - path.addLineTo(points.at(i)); + SVGPointList::ConstIterator it = points->begin(); + SVGPointList::ConstIterator itEnd = points->end(); + ASSERT(it != itEnd); + path.moveTo(it->value()); + ++it; - path.closeSubpath(); + for (; it != itEnd; ++it) + path.addLineTo(it->value()); } -static void updatePathFromPolylineElement(SVGElement* element, Path& path) +static void updatePathFromPolygonElement(SVGElement* element, Path& path) { - SVGPointList& points = toSVGPolylineElement(element)->pointsCurrentValue(); - if (points.isEmpty()) - return; - - path.moveTo(points.first()); - - unsigned size = points.size(); - for (unsigned i = 1; i < size; ++i) - path.addLineTo(points.at(i)); + updatePathFromPolylineElement(element, path); + path.closeSubpath(); } static void updatePathFromRectElement(SVGElement* element, Path& path) @@ -105,19 +104,21 @@ static void updatePathFromRectElement(SVGElement* element, Path& path) SVGRectElement* rect = toSVGRectElement(element); SVGLengthContext lengthContext(element); - float width = rect->widthCurrentValue().value(lengthContext); - if (width <= 0) + float width = rect->width()->currentValue()->value(lengthContext); + if (width < 0) + return; + float height = rect->height()->currentValue()->value(lengthContext); + if (height < 0) return; - float height = rect->heightCurrentValue().value(lengthContext); - if (height <= 0) + if (!width && !height) return; - float x = rect->xCurrentValue().value(lengthContext); - float y = rect->yCurrentValue().value(lengthContext); - bool hasRx = rect->rxCurrentValue().value(lengthContext) > 0; - bool hasRy = rect->ryCurrentValue().value(lengthContext) > 0; + float x = rect->x()->currentValue()->value(lengthContext); + float y = rect->y()->currentValue()->value(lengthContext); + float rx = rect->rx()->currentValue()->value(lengthContext); + float ry = rect->ry()->currentValue()->value(lengthContext); + bool hasRx = rx > 0; + bool hasRy = ry > 0; if (hasRx || hasRy) { - float rx = rect->rxCurrentValue().value(lengthContext); - float ry = rect->ryCurrentValue().value(lengthContext); if (!hasRx) rx = ry; else if (!hasRy) @@ -139,13 +140,13 @@ void updatePathFromGraphicsElement(SVGElement* element, Path& path) static HashMap<StringImpl*, PathUpdateFunction>* map = 0; if (!map) { map = new HashMap<StringImpl*, PathUpdateFunction>; - map->set(SVGNames::circleTag.localName().impl(), updatePathFromCircleElement); - map->set(SVGNames::ellipseTag.localName().impl(), updatePathFromEllipseElement); - map->set(SVGNames::lineTag.localName().impl(), updatePathFromLineElement); - map->set(SVGNames::pathTag.localName().impl(), updatePathFromPathElement); - map->set(SVGNames::polygonTag.localName().impl(), updatePathFromPolygonElement); - map->set(SVGNames::polylineTag.localName().impl(), updatePathFromPolylineElement); - map->set(SVGNames::rectTag.localName().impl(), updatePathFromRectElement); + map->set(circleTag.localName().impl(), updatePathFromCircleElement); + map->set(ellipseTag.localName().impl(), updatePathFromEllipseElement); + map->set(lineTag.localName().impl(), updatePathFromLineElement); + map->set(pathTag.localName().impl(), updatePathFromPathElement); + map->set(polygonTag.localName().impl(), updatePathFromPolygonElement); + map->set(polylineTag.localName().impl(), updatePathFromPolylineElement); + map->set(rectTag.localName().impl(), updatePathFromRectElement); } if (PathUpdateFunction pathUpdateFunction = map->get(element->localName().impl())) |