OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google, Inc. | 2 * Copyright (C) 2012 Google, Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 } | 74 } |
75 | 75 |
76 void RenderSVGEllipse::calculateRadiiAndCenter() | 76 void RenderSVGEllipse::calculateRadiiAndCenter() |
77 { | 77 { |
78 ASSERT(node()); | 78 ASSERT(node()); |
79 if (node()->hasTagName(SVGNames::circleTag)) { | 79 if (node()->hasTagName(SVGNames::circleTag)) { |
80 | 80 |
81 SVGCircleElement* circle = static_cast<SVGCircleElement*>(node()); | 81 SVGCircleElement* circle = static_cast<SVGCircleElement*>(node()); |
82 | 82 |
83 SVGLengthContext lengthContext(circle); | 83 SVGLengthContext lengthContext(circle); |
84 float radius = circle->r().value(lengthContext); | 84 float radius = circle->rCurrentValue().value(lengthContext); |
85 m_radii = FloatSize(radius, radius); | 85 m_radii = FloatSize(radius, radius); |
86 m_center = FloatPoint(circle->cx().value(lengthContext), circle->cy().va
lue(lengthContext)); | 86 m_center = FloatPoint(circle->cxCurrentValue().value(lengthContext), cir
cle->cyCurrentValue().value(lengthContext)); |
87 return; | 87 return; |
88 } | 88 } |
89 | 89 |
90 ASSERT(node()->hasTagName(SVGNames::ellipseTag)); | 90 ASSERT(node()->hasTagName(SVGNames::ellipseTag)); |
91 SVGEllipseElement* ellipse = static_cast<SVGEllipseElement*>(node()); | 91 SVGEllipseElement* ellipse = static_cast<SVGEllipseElement*>(node()); |
92 | 92 |
93 SVGLengthContext lengthContext(ellipse); | 93 SVGLengthContext lengthContext(ellipse); |
94 m_radii = FloatSize(ellipse->rx().value(lengthContext), ellipse->ry().value(
lengthContext)); | 94 m_radii = FloatSize(ellipse->rxCurrentValue().value(lengthContext), ellipse-
>ryCurrentValue().value(lengthContext)); |
95 m_center = FloatPoint(ellipse->cx().value(lengthContext), ellipse->cy().valu
e(lengthContext)); | 95 m_center = FloatPoint(ellipse->cxCurrentValue().value(lengthContext), ellips
e->cyCurrentValue().value(lengthContext)); |
96 } | 96 } |
97 | 97 |
98 void RenderSVGEllipse::fillShape(GraphicsContext* context) const | 98 void RenderSVGEllipse::fillShape(GraphicsContext* context) const |
99 { | 99 { |
100 if (m_usePathFallback) { | 100 if (m_usePathFallback) { |
101 RenderSVGShape::fillShape(context); | 101 RenderSVGShape::fillShape(context); |
102 return; | 102 return; |
103 } | 103 } |
104 context->fillEllipse(m_fillBoundingBox); | 104 context->fillEllipse(m_fillBoundingBox); |
105 } | 105 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 FloatPoint center = FloatPoint(m_center.x() - point.x(), m_center.y() - poin
t.y()); | 148 FloatPoint center = FloatPoint(m_center.x() - point.x(), m_center.y() - poin
t.y()); |
149 | 149 |
150 // This works by checking if the point satisfies the ellipse equation. | 150 // This works by checking if the point satisfies the ellipse equation. |
151 // (x/rX)^2 + (y/rY)^2 <= 1 | 151 // (x/rX)^2 + (y/rY)^2 <= 1 |
152 float xrX = center.x() / m_radii.width(); | 152 float xrX = center.x() / m_radii.width(); |
153 float yrY = center.y() / m_radii.height(); | 153 float yrY = center.y() / m_radii.height(); |
154 return xrX * xrX + yrY * yrY <= 1.0; | 154 return xrX * xrX + yrY * yrY <= 1.0; |
155 } | 155 } |
156 | 156 |
157 } | 157 } |
OLD | NEW |