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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 } | 45 } |
46 | 46 |
47 void RenderSVGEllipse::updateShapeFromElement() | 47 void RenderSVGEllipse::updateShapeFromElement() |
48 { | 48 { |
49 // Before creating a new object we need to clear the cached bounding box | 49 // Before creating a new object we need to clear the cached bounding box |
50 // to avoid using garbage. | 50 // to avoid using garbage. |
51 m_fillBoundingBox = FloatRect(); | 51 m_fillBoundingBox = FloatRect(); |
52 m_strokeBoundingBox = FloatRect(); | 52 m_strokeBoundingBox = FloatRect(); |
53 m_center = FloatPoint(); | 53 m_center = FloatPoint(); |
54 m_radii = FloatSize(); | 54 m_radii = FloatSize(); |
| 55 m_usePathFallback = false; |
55 | 56 |
56 calculateRadiiAndCenter(); | 57 calculateRadiiAndCenter(); |
57 | 58 |
58 // Spec: "A negative value is an error. A value of zero disables rendering o
f the element." | 59 // Spec: "A negative value is an error. A value of zero disables rendering o
f the element." |
59 if (m_radii.width() < 0 || m_radii.height() < 0) | 60 if (m_radii.width() < 0 || m_radii.height() < 0) |
60 return; | 61 return; |
61 | 62 |
62 if (!m_radii.isEmpty()) { | 63 if (!m_radii.isEmpty()) { |
63 // Fallback to RenderSVGShape if shape has a non-scaling stroke. | 64 // Fallback to RenderSVGShape if shape has a non-scaling stroke. |
64 if (hasNonScalingStroke()) { | 65 if (hasNonScalingStroke()) { |
65 RenderSVGShape::updateShapeFromElement(); | 66 RenderSVGShape::updateShapeFromElement(); |
66 m_usePathFallback = true; | 67 m_usePathFallback = true; |
67 return; | 68 return; |
68 } | 69 } |
69 m_usePathFallback = false; | |
70 } | 70 } |
71 | 71 |
72 m_fillBoundingBox = FloatRect(m_center.x() - m_radii.width(), m_center.y() -
m_radii.height(), 2 * m_radii.width(), 2 * m_radii.height()); | 72 m_fillBoundingBox = FloatRect(m_center.x() - m_radii.width(), m_center.y() -
m_radii.height(), 2 * m_radii.width(), 2 * m_radii.height()); |
73 m_strokeBoundingBox = m_fillBoundingBox; | 73 m_strokeBoundingBox = m_fillBoundingBox; |
74 if (style()->svgStyle().hasStroke()) | 74 if (style()->svgStyle().hasStroke()) |
75 m_strokeBoundingBox.inflate(strokeWidth() / 2); | 75 m_strokeBoundingBox.inflate(strokeWidth() / 2); |
76 } | 76 } |
77 | 77 |
78 void RenderSVGEllipse::calculateRadiiAndCenter() | 78 void RenderSVGEllipse::calculateRadiiAndCenter() |
79 { | 79 { |
(...skipping 68 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 |