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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 69 |
70 m_fillBoundingBox = FloatRect(m_center.x() - m_radii.width(), m_center.y() -
m_radii.height(), 2 * m_radii.width(), 2 * m_radii.height()); | 70 m_fillBoundingBox = FloatRect(m_center.x() - m_radii.width(), m_center.y() -
m_radii.height(), 2 * m_radii.width(), 2 * m_radii.height()); |
71 m_strokeBoundingBox = m_fillBoundingBox; | 71 m_strokeBoundingBox = m_fillBoundingBox; |
72 if (style()->svgStyle()->hasStroke()) | 72 if (style()->svgStyle()->hasStroke()) |
73 m_strokeBoundingBox.inflate(strokeWidth() / 2); | 73 m_strokeBoundingBox.inflate(strokeWidth() / 2); |
74 } | 74 } |
75 | 75 |
76 void RenderSVGEllipse::calculateRadiiAndCenter() | 76 void RenderSVGEllipse::calculateRadiiAndCenter() |
77 { | 77 { |
78 ASSERT(element()); | 78 ASSERT(element()); |
79 if (element()->hasTagName(SVGNames::circleTag)) { | 79 if (isSVGCircleElement(*element())) { |
80 SVGCircleElement* circle = toSVGCircleElement(element()); | 80 SVGCircleElement& circle = toSVGCircleElement(*element()); |
81 | 81 |
82 SVGLengthContext lengthContext(circle); | 82 SVGLengthContext lengthContext(&circle); |
83 float radius = circle->r()->currentValue()->value(lengthContext); | 83 float radius = circle.r()->currentValue()->value(lengthContext); |
84 m_radii = FloatSize(radius, radius); | 84 m_radii = FloatSize(radius, radius); |
85 m_center = FloatPoint(circle->cx()->currentValue()->value(lengthContext)
, circle->cy()->currentValue()->value(lengthContext)); | 85 m_center = FloatPoint(circle.cx()->currentValue()->value(lengthContext),
circle.cy()->currentValue()->value(lengthContext)); |
86 return; | 86 return; |
87 } | 87 } |
88 | 88 |
89 SVGEllipseElement* ellipse = toSVGEllipseElement(element()); | 89 SVGEllipseElement& ellipse = toSVGEllipseElement(*element()); |
90 | 90 |
91 SVGLengthContext lengthContext(ellipse); | 91 SVGLengthContext lengthContext(&ellipse); |
92 m_radii = FloatSize(ellipse->rx()->currentValue()->value(lengthContext), ell
ipse->ry()->currentValue()->value(lengthContext)); | 92 m_radii = FloatSize(ellipse.rx()->currentValue()->value(lengthContext), elli
pse.ry()->currentValue()->value(lengthContext)); |
93 m_center = FloatPoint(ellipse->cx()->currentValue()->value(lengthContext), e
llipse->cy()->currentValue()->value(lengthContext)); | 93 m_center = FloatPoint(ellipse.cx()->currentValue()->value(lengthContext), el
lipse.cy()->currentValue()->value(lengthContext)); |
94 } | 94 } |
95 | 95 |
96 void RenderSVGEllipse::fillShape(GraphicsContext* context) const | 96 void RenderSVGEllipse::fillShape(GraphicsContext* context) const |
97 { | 97 { |
98 if (m_usePathFallback) { | 98 if (m_usePathFallback) { |
99 RenderSVGShape::fillShape(context); | 99 RenderSVGShape::fillShape(context); |
100 return; | 100 return; |
101 } | 101 } |
102 context->fillEllipse(m_fillBoundingBox); | 102 context->fillEllipse(m_fillBoundingBox); |
103 } | 103 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 FloatPoint center = FloatPoint(m_center.x() - point.x(), m_center.y() - poin
t.y()); | 146 FloatPoint center = FloatPoint(m_center.x() - point.x(), m_center.y() - poin
t.y()); |
147 | 147 |
148 // This works by checking if the point satisfies the ellipse equation. | 148 // This works by checking if the point satisfies the ellipse equation. |
149 // (x/rX)^2 + (y/rY)^2 <= 1 | 149 // (x/rX)^2 + (y/rY)^2 <= 1 |
150 float xrX = center.x() / m_radii.width(); | 150 float xrX = center.x() / m_radii.width(); |
151 float yrY = center.y() / m_radii.height(); | 151 float yrY = center.y() / m_radii.height(); |
152 return xrX * xrX + yrY * yrY <= 1.0; | 152 return xrX * xrX + yrY * yrY <= 1.0; |
153 } | 153 } |
154 | 154 |
155 } | 155 } |
OLD | NEW |