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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 m_fillBoundingBox = FloatRect(m_center.x() - m_radii.width(), m_center.y() -
m_radii.height(), 2 * m_radii.width(), 2 * m_radii.height()); | 76 m_fillBoundingBox = FloatRect(m_center.x() - m_radii.width(), m_center.y() -
m_radii.height(), 2 * m_radii.width(), 2 * m_radii.height()); |
77 m_strokeBoundingBox = m_fillBoundingBox; | 77 m_strokeBoundingBox = m_fillBoundingBox; |
78 if (style()->svgStyle().hasStroke()) | 78 if (style()->svgStyle().hasStroke()) |
79 m_strokeBoundingBox.inflate(strokeWidth() / 2); | 79 m_strokeBoundingBox.inflate(strokeWidth() / 2); |
80 } | 80 } |
81 | 81 |
82 void LayoutSVGEllipse::calculateRadiiAndCenter() | 82 void LayoutSVGEllipse::calculateRadiiAndCenter() |
83 { | 83 { |
84 ASSERT(element()); | 84 ASSERT(element()); |
| 85 SVGLengthContext lengthContext(element()); |
| 86 m_center = FloatPoint( |
| 87 lengthContext.valueForLength(style()->svgStyle().cx(), styleRef(), SVGLe
ngthMode::Width), |
| 88 lengthContext.valueForLength(style()->svgStyle().cy(), styleRef(), SVGLe
ngthMode::Height)); |
| 89 |
85 if (isSVGCircleElement(*element())) { | 90 if (isSVGCircleElement(*element())) { |
86 SVGCircleElement& circle = toSVGCircleElement(*element()); | 91 float radius = lengthContext.valueForLength(style()->svgStyle().r(), sty
leRef(), SVGLengthMode::Other); |
87 | |
88 SVGLengthContext lengthContext(&circle); | |
89 float radius = circle.r()->currentValue()->value(lengthContext); | |
90 m_radii = FloatSize(radius, radius); | 92 m_radii = FloatSize(radius, radius); |
91 m_center = FloatPoint(circle.cx()->currentValue()->value(lengthContext),
circle.cy()->currentValue()->value(lengthContext)); | 93 } else { |
92 return; | 94 m_radii = FloatSize( |
| 95 lengthContext.valueForLength(style()->svgStyle().rx(), styleRef(), S
VGLengthMode::Width), |
| 96 lengthContext.valueForLength(style()->svgStyle().ry(), styleRef(), S
VGLengthMode::Height)); |
93 } | 97 } |
94 | |
95 SVGEllipseElement& ellipse = toSVGEllipseElement(*element()); | |
96 | |
97 SVGLengthContext lengthContext(&ellipse); | |
98 m_radii = FloatSize(ellipse.rx()->currentValue()->value(lengthContext), elli
pse.ry()->currentValue()->value(lengthContext)); | |
99 m_center = FloatPoint(ellipse.cx()->currentValue()->value(lengthContext), el
lipse.cy()->currentValue()->value(lengthContext)); | |
100 } | 98 } |
101 | 99 |
102 bool LayoutSVGEllipse::shapeDependentStrokeContains(const FloatPoint& point) | 100 bool LayoutSVGEllipse::shapeDependentStrokeContains(const FloatPoint& point) |
103 { | 101 { |
104 // The optimized check below for circles does not support non-scaling or | 102 // The optimized check below for circles does not support non-scaling or |
105 // discontinuous strokes. | 103 // discontinuous strokes. |
106 if (m_usePathFallback | 104 if (m_usePathFallback |
107 || !hasContinuousStroke() | 105 || !hasContinuousStroke() |
108 || m_radii.width() != m_radii.height()) { | 106 || m_radii.width() != m_radii.height()) { |
109 if (!hasPath()) | 107 if (!hasPath()) |
(...skipping 18 matching lines...) Expand all Loading... |
128 return xrX * xrX + yrY * yrY <= 1.0; | 126 return xrX * xrX + yrY * yrY <= 1.0; |
129 } | 127 } |
130 | 128 |
131 bool LayoutSVGEllipse::hasContinuousStroke() const | 129 bool LayoutSVGEllipse::hasContinuousStroke() const |
132 { | 130 { |
133 const SVGLayoutStyle& svgStyle = style()->svgStyle(); | 131 const SVGLayoutStyle& svgStyle = style()->svgStyle(); |
134 return svgStyle.strokeDashArray()->isEmpty(); | 132 return svgStyle.strokeDashArray()->isEmpty(); |
135 } | 133 } |
136 | 134 |
137 } | 135 } |
OLD | NEW |