| OLD | NEW | 
|    1 /* |    1 /* | 
|    2  * Copyright (C) Research In Motion Limited 2011. All rights reserved. |    2  * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 
|    3  * |    3  * | 
|    4  * This library is free software; you can redistribute it and/or |    4  * This library is free software; you can redistribute it and/or | 
|    5  * modify it under the terms of the GNU Library General Public |    5  * modify it under the terms of the GNU Library General Public | 
|    6  * License as published by the Free Software Foundation; either |    6  * License as published by the Free Software Foundation; either | 
|    7  * version 2 of the License, or (at your option) any later version. |    7  * version 2 of the License, or (at your option) any later version. | 
|    8  * |    8  * | 
|    9  * This library is distributed in the hope that it will be useful, |    9  * This library is distributed in the hope that it will be useful, | 
|   10  * but WITHOUT ANY WARRANTY; without even the implied warranty of |   10  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
|   33 #include <wtf/HashMap.h> |   33 #include <wtf/HashMap.h> | 
|   34  |   34  | 
|   35 namespace WebCore { |   35 namespace WebCore { | 
|   36  |   36  | 
|   37 static void updatePathFromCircleElement(SVGElement* element, Path& path) |   37 static void updatePathFromCircleElement(SVGElement* element, Path& path) | 
|   38 { |   38 { | 
|   39     ASSERT(element->hasTagName(SVGNames::circleTag)); |   39     ASSERT(element->hasTagName(SVGNames::circleTag)); | 
|   40     SVGCircleElement* circle = static_cast<SVGCircleElement*>(element); |   40     SVGCircleElement* circle = static_cast<SVGCircleElement*>(element); | 
|   41  |   41  | 
|   42     SVGLengthContext lengthContext(element); |   42     SVGLengthContext lengthContext(element); | 
|   43     float r = circle->r().value(lengthContext); |   43     float r = circle->rCurrentValue().value(lengthContext); | 
|   44     if (r > 0) |   44     if (r > 0) | 
|   45         path.addEllipse(FloatRect(circle->cx().value(lengthContext) - r, circle-
     >cy().value(lengthContext) - r, r * 2, r * 2)); |   45         path.addEllipse(FloatRect(circle->cxCurrentValue().value(lengthContext) 
     - r, circle->cyCurrentValue().value(lengthContext) - r, r * 2, r * 2)); | 
|   46 } |   46 } | 
|   47  |   47  | 
|   48 static void updatePathFromEllipseElement(SVGElement* element, Path& path) |   48 static void updatePathFromEllipseElement(SVGElement* element, Path& path) | 
|   49 { |   49 { | 
|   50     ASSERT(element->hasTagName(SVGNames::ellipseTag)); |   50     ASSERT(element->hasTagName(SVGNames::ellipseTag)); | 
|   51     SVGEllipseElement* ellipse = static_cast<SVGEllipseElement*>(element); |   51     SVGEllipseElement* ellipse = static_cast<SVGEllipseElement*>(element); | 
|   52  |   52  | 
|   53     SVGLengthContext lengthContext(element); |   53     SVGLengthContext lengthContext(element); | 
|   54     float rx = ellipse->rx().value(lengthContext); |   54     float rx = ellipse->rxCurrentValue().value(lengthContext); | 
|   55     if (rx <= 0) |   55     if (rx <= 0) | 
|   56         return; |   56         return; | 
|   57     float ry = ellipse->ry().value(lengthContext); |   57     float ry = ellipse->ryCurrentValue().value(lengthContext); | 
|   58     if (ry <= 0) |   58     if (ry <= 0) | 
|   59         return; |   59         return; | 
|   60     path.addEllipse(FloatRect(ellipse->cx().value(lengthContext) - rx, ellipse->
     cy().value(lengthContext) - ry, rx * 2, ry * 2)); |   60     path.addEllipse(FloatRect(ellipse->cxCurrentValue().value(lengthContext) - r
     x, ellipse->cyCurrentValue().value(lengthContext) - ry, rx * 2, ry * 2)); | 
|   61 } |   61 } | 
|   62  |   62  | 
|   63 static void updatePathFromLineElement(SVGElement* element, Path& path) |   63 static void updatePathFromLineElement(SVGElement* element, Path& path) | 
|   64 { |   64 { | 
|   65     ASSERT(element->hasTagName(SVGNames::lineTag)); |   65     ASSERT(element->hasTagName(SVGNames::lineTag)); | 
|   66     SVGLineElement* line = static_cast<SVGLineElement*>(element); |   66     SVGLineElement* line = static_cast<SVGLineElement*>(element); | 
|   67  |   67  | 
|   68     SVGLengthContext lengthContext(element); |   68     SVGLengthContext lengthContext(element); | 
|   69     path.moveTo(FloatPoint(line->x1().value(lengthContext), line->y1().value(len
     gthContext))); |   69     path.moveTo(FloatPoint(line->x1CurrentValue().value(lengthContext), line->y1
     CurrentValue().value(lengthContext))); | 
|   70     path.addLineTo(FloatPoint(line->x2().value(lengthContext), line->y2().value(
     lengthContext))); |   70     path.addLineTo(FloatPoint(line->x2CurrentValue().value(lengthContext), line-
     >y2CurrentValue().value(lengthContext))); | 
|   71 } |   71 } | 
|   72  |   72  | 
|   73 static void updatePathFromPathElement(SVGElement* element, Path& path) |   73 static void updatePathFromPathElement(SVGElement* element, Path& path) | 
|   74 { |   74 { | 
|   75     ASSERT(element->hasTagName(SVGNames::pathTag)); |   75     ASSERT(element->hasTagName(SVGNames::pathTag)); | 
|   76     buildPathFromByteStream(static_cast<SVGPathElement*>(element)->pathByteStrea
     m(), path); |   76     buildPathFromByteStream(static_cast<SVGPathElement*>(element)->pathByteStrea
     m(), path); | 
|   77 } |   77 } | 
|   78  |   78  | 
|   79 static void updatePathFromPolygonElement(SVGElement* element, Path& path) |   79 static void updatePathFromPolygonElement(SVGElement* element, Path& path) | 
|   80 { |   80 { | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
|  109     for (unsigned i = 1; i < size; ++i) |  109     for (unsigned i = 1; i < size; ++i) | 
|  110         path.addLineTo(points.at(i)); |  110         path.addLineTo(points.at(i)); | 
|  111 } |  111 } | 
|  112  |  112  | 
|  113 static void updatePathFromRectElement(SVGElement* element, Path& path) |  113 static void updatePathFromRectElement(SVGElement* element, Path& path) | 
|  114 { |  114 { | 
|  115     ASSERT(element->hasTagName(SVGNames::rectTag)); |  115     ASSERT(element->hasTagName(SVGNames::rectTag)); | 
|  116     SVGRectElement* rect = static_cast<SVGRectElement*>(element); |  116     SVGRectElement* rect = static_cast<SVGRectElement*>(element); | 
|  117  |  117  | 
|  118     SVGLengthContext lengthContext(element); |  118     SVGLengthContext lengthContext(element); | 
|  119     float width = rect->width().value(lengthContext); |  119     float width = rect->widthCurrentValue().value(lengthContext); | 
|  120     if (width <= 0) |  120     if (width <= 0) | 
|  121         return; |  121         return; | 
|  122     float height = rect->height().value(lengthContext); |  122     float height = rect->heightCurrentValue().value(lengthContext); | 
|  123     if (height <= 0) |  123     if (height <= 0) | 
|  124         return; |  124         return; | 
|  125     float x = rect->x().value(lengthContext); |  125     float x = rect->xCurrentValue().value(lengthContext); | 
|  126     float y = rect->y().value(lengthContext); |  126     float y = rect->yCurrentValue().value(lengthContext); | 
|  127     bool hasRx = rect->rx().value(lengthContext) > 0; |  127     bool hasRx = rect->rxCurrentValue().value(lengthContext) > 0; | 
|  128     bool hasRy = rect->ry().value(lengthContext) > 0; |  128     bool hasRy = rect->ryCurrentValue().value(lengthContext) > 0; | 
|  129     if (hasRx || hasRy) { |  129     if (hasRx || hasRy) { | 
|  130         float rx = rect->rx().value(lengthContext); |  130         float rx = rect->rxCurrentValue().value(lengthContext); | 
|  131         float ry = rect->ry().value(lengthContext); |  131         float ry = rect->ryCurrentValue().value(lengthContext); | 
|  132         if (!hasRx) |  132         if (!hasRx) | 
|  133             rx = ry; |  133             rx = ry; | 
|  134         else if (!hasRy) |  134         else if (!hasRy) | 
|  135             ry = rx; |  135             ry = rx; | 
|  136         // FIXME: We currently enforce using beziers here, as at least on CoreGr
     aphics/Lion, as |  136         // FIXME: We currently enforce using beziers here, as at least on CoreGr
     aphics/Lion, as | 
|  137         // the native method uses a different line dash origin, causing svg/cust
     om/dashOrigin.svg to fail. |  137         // the native method uses a different line dash origin, causing svg/cust
     om/dashOrigin.svg to fail. | 
|  138         // See bug https://bugs.webkit.org/show_bug.cgi?id=79932 which tracks th
     is issue. |  138         // See bug https://bugs.webkit.org/show_bug.cgi?id=79932 which tracks th
     is issue. | 
|  139         path.addRoundedRect(FloatRect(x, y, width, height), FloatSize(rx, ry), P
     ath::PreferBezierRoundedRect); |  139         path.addRoundedRect(FloatRect(x, y, width, height), FloatSize(rx, ry), P
     ath::PreferBezierRoundedRect); | 
|  140         return; |  140         return; | 
|  141     } |  141     } | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
|  159         map->set(SVGNames::polygonTag.localName().impl(), updatePathFromPolygonE
     lement); |  159         map->set(SVGNames::polygonTag.localName().impl(), updatePathFromPolygonE
     lement); | 
|  160         map->set(SVGNames::polylineTag.localName().impl(), updatePathFromPolylin
     eElement); |  160         map->set(SVGNames::polylineTag.localName().impl(), updatePathFromPolylin
     eElement); | 
|  161         map->set(SVGNames::rectTag.localName().impl(), updatePathFromRectElement
     ); |  161         map->set(SVGNames::rectTag.localName().impl(), updatePathFromRectElement
     ); | 
|  162     } |  162     } | 
|  163  |  163  | 
|  164     if (PathUpdateFunction pathUpdateFunction = map->get(element->localName().im
     pl())) |  164     if (PathUpdateFunction pathUpdateFunction = map->get(element->localName().im
     pl())) | 
|  165         (*pathUpdateFunction)(element, path); |  165         (*pathUpdateFunction)(element, path); | 
|  166 } |  166 } | 
|  167  |  167  | 
|  168 } // namespace WebCore |  168 } // namespace WebCore | 
| OLD | NEW |