| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 RenderSVGEllipse::~RenderSVGEllipse() | 42 RenderSVGEllipse::~RenderSVGEllipse() |
| 43 { | 43 { |
| 44 } | 44 } |
| 45 | 45 |
| 46 void RenderSVGEllipse::updateShapeFromElement() | 46 void RenderSVGEllipse::updateShapeFromElement() |
| 47 { | 47 { |
| 48 // Before creating a new object we need to clear the cached bounding box | 48 // Before creating a new object we need to clear the cached bounding box |
| 49 // to avoid using garbage. | 49 // to avoid using garbage. |
| 50 m_fillBoundingBox = FloatRect(); | 50 m_fillBoundingBox = FloatRect(); |
| 51 m_strokeBoundingBox = FloatRect(); | 51 m_strokeBoundingBox = FloatRect(); |
| 52 m_hitTestStrokeBoundingBox = FloatRect(); | |
| 53 m_center = FloatPoint(); | 52 m_center = FloatPoint(); |
| 54 m_radii = FloatSize(); | 53 m_radii = FloatSize(); |
| 55 m_usePathFallback = false; | 54 m_usePathFallback = false; |
| 56 | 55 |
| 57 calculateRadiiAndCenter(); | 56 calculateRadiiAndCenter(); |
| 58 | 57 |
| 59 // Spec: "A negative value is an error. A value of zero disables rendering o
f the element." | 58 // Spec: "A negative value is an error. A value of zero disables rendering o
f the element." |
| 60 if (m_radii.width() < 0 || m_radii.height() < 0) | 59 if (m_radii.width() < 0 || m_radii.height() < 0) |
| 61 return; | 60 return; |
| 62 | 61 |
| 63 if (!m_radii.isEmpty()) { | 62 if (!m_radii.isEmpty()) { |
| 64 // Fallback to RenderSVGShape and path-based hit detection if the ellips
e | 63 // Fallback to RenderSVGShape and path-based hit detection if the ellips
e |
| 65 // has a non-scaling or discontinuous stroke. | 64 // has a non-scaling or discontinuous stroke. |
| 66 if (hasNonScalingStroke() || !hasContinuousStroke()) { | 65 if (hasNonScalingStroke() || !hasContinuousStroke()) { |
| 67 RenderSVGShape::updateShapeFromElement(); | 66 RenderSVGShape::updateShapeFromElement(); |
| 68 m_usePathFallback = true; | 67 m_usePathFallback = true; |
| 69 return; | 68 return; |
| 70 } | 69 } |
| 71 } | 70 } |
| 72 | 71 |
| 73 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()); |
| 74 m_hitTestStrokeBoundingBox = m_fillBoundingBox; | 73 m_strokeBoundingBox = m_fillBoundingBox; |
| 75 m_hitTestStrokeBoundingBox.inflate(strokeWidth() / 2); | 74 if (style()->svgStyle().hasStroke()) |
| 76 m_strokeBoundingBox = style()->svgStyle().hasStroke() ? m_hitTestStrokeBound
ingBox : m_fillBoundingBox; | 75 m_strokeBoundingBox.inflate(strokeWidth() / 2); |
| 77 } | 76 } |
| 78 | 77 |
| 79 void RenderSVGEllipse::calculateRadiiAndCenter() | 78 void RenderSVGEllipse::calculateRadiiAndCenter() |
| 80 { | 79 { |
| 81 ASSERT(element()); | 80 ASSERT(element()); |
| 82 if (isSVGCircleElement(*element())) { | 81 if (isSVGCircleElement(*element())) { |
| 83 SVGCircleElement& circle = toSVGCircleElement(*element()); | 82 SVGCircleElement& circle = toSVGCircleElement(*element()); |
| 84 | 83 |
| 85 SVGLengthContext lengthContext(&circle); | 84 SVGLengthContext lengthContext(&circle); |
| 86 float radius = circle.r()->currentValue()->value(lengthContext); | 85 float radius = circle.r()->currentValue()->value(lengthContext); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 return xrX * xrX + yrY * yrY <= 1.0; | 134 return xrX * xrX + yrY * yrY <= 1.0; |
| 136 } | 135 } |
| 137 | 136 |
| 138 bool RenderSVGEllipse::hasContinuousStroke() const | 137 bool RenderSVGEllipse::hasContinuousStroke() const |
| 139 { | 138 { |
| 140 const SVGRenderStyle& svgStyle = style()->svgStyle(); | 139 const SVGRenderStyle& svgStyle = style()->svgStyle(); |
| 141 return svgStyle.strokeDashArray()->isEmpty(); | 140 return svgStyle.strokeDashArray()->isEmpty(); |
| 142 } | 141 } |
| 143 | 142 |
| 144 } | 143 } |
| OLD | NEW |