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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 | 55 |
56 m_usePathFallback = false; | |
56 // Fallback to RenderSVGShape if shape has a non-scaling stroke. | 57 // Fallback to RenderSVGShape if shape has a non-scaling stroke. |
57 if (hasNonScalingStroke()) { | 58 if (hasNonScalingStroke()) { |
58 RenderSVGShape::updateShapeFromElement(); | 59 RenderSVGShape::updateShapeFromElement(); |
59 m_usePathFallback = true; | 60 m_usePathFallback = true; |
pdr.
2014/03/24 17:39:32
I'm afraid this part isn't right.
Some background
jmunhoz
2014/03/24 18:51:24
On 2014/03/24 17:39:32, pdr wrote:
[...]
| |
60 return; | 61 } |
61 } else | |
62 m_usePathFallback = false; | |
63 | 62 |
64 calculateRadiiAndCenter(); | 63 calculateRadiiAndCenter(); |
65 | 64 |
66 // Spec: "A value of zero disables rendering of the element." | 65 // Spec: "A negative value is an error. A value of zero disables rendering o f the element." |
67 if (m_radii.width() <= 0 || m_radii.height() <= 0) | 66 if (m_radii.isZero() || m_radii.width() < 0 || m_radii.height() < 0) |
68 return; | 67 return; |
69 | 68 |
70 m_fillBoundingBox = FloatRect(m_center.x() - m_radii.width(), m_center.y() - m_radii.height(), 2 * m_radii.width(), 2 * m_radii.height()); | 69 m_fillBoundingBox = FloatRect(m_center.x() - m_radii.width(), m_center.y() - m_radii.height(), 2 * m_radii.width(), 2 * m_radii.height()); |
70 | |
71 if (m_usePathFallback) | |
72 return; | |
73 | |
71 m_strokeBoundingBox = m_fillBoundingBox; | 74 m_strokeBoundingBox = m_fillBoundingBox; |
72 if (style()->svgStyle()->hasStroke()) | 75 if (style()->svgStyle()->hasStroke() && m_radii.width() && m_radii.height()) ; |
Stephen Chennney
2014/03/24 15:49:16
Typo? Does strokeWidth() depend on having non-zero
| |
73 m_strokeBoundingBox.inflate(strokeWidth() / 2); | 76 m_strokeBoundingBox.inflate(strokeWidth() / 2); |
74 } | 77 } |
75 | 78 |
76 void RenderSVGEllipse::calculateRadiiAndCenter() | 79 void RenderSVGEllipse::calculateRadiiAndCenter() |
77 { | 80 { |
78 ASSERT(element()); | 81 ASSERT(element()); |
79 if (isSVGCircleElement(*element())) { | 82 if (isSVGCircleElement(*element())) { |
80 SVGCircleElement& circle = toSVGCircleElement(*element()); | 83 SVGCircleElement& circle = toSVGCircleElement(*element()); |
81 | 84 |
82 SVGLengthContext lengthContext(&circle); | 85 SVGLengthContext lengthContext(&circle); |
(...skipping 63 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()); | 149 FloatPoint center = FloatPoint(m_center.x() - point.x(), m_center.y() - poin t.y()); |
147 | 150 |
148 // This works by checking if the point satisfies the ellipse equation. | 151 // This works by checking if the point satisfies the ellipse equation. |
149 // (x/rX)^2 + (y/rY)^2 <= 1 | 152 // (x/rX)^2 + (y/rY)^2 <= 1 |
150 float xrX = center.x() / m_radii.width(); | 153 float xrX = center.x() / m_radii.width(); |
151 float yrY = center.y() / m_radii.height(); | 154 float yrY = center.y() / m_radii.height(); |
152 return xrX * xrX + yrY * yrY <= 1.0; | 155 return xrX * xrX + yrY * yrY <= 1.0; |
153 } | 156 } |
154 | 157 |
155 } | 158 } |
OLD | NEW |