| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 University of Szeged | 2 * Copyright (C) 2011 University of Szeged |
| 3 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org> | 3 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org> |
| 4 * All rights reserved. | 4 * All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #include "config.h" | 28 #include "config.h" |
| 29 | 29 |
| 30 #include "core/rendering/svg/RenderSVGRect.h" | 30 #include "core/rendering/svg/RenderSVGRect.h" |
| 31 #include "platform/graphics/GraphicsContext.h" | 31 #include "core/svg/SVGRectElement.h" |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 RenderSVGRect::RenderSVGRect(SVGRectElement* node) | 35 RenderSVGRect::RenderSVGRect(SVGRectElement* node) |
| 36 : RenderSVGShape(node) | 36 : RenderSVGShape(node) |
| 37 , m_usePathFallback(false) | 37 , m_usePathFallback(false) |
| 38 { | 38 { |
| 39 } | 39 } |
| 40 | 40 |
| 41 RenderSVGRect::~RenderSVGRect() | 41 RenderSVGRect::~RenderSVGRect() |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 79 |
| 80 if (style()->svgStyle().hasStroke()) { | 80 if (style()->svgStyle().hasStroke()) { |
| 81 float strokeWidth = this->strokeWidth(); | 81 float strokeWidth = this->strokeWidth(); |
| 82 m_innerStrokeRect.inflate(-strokeWidth / 2); | 82 m_innerStrokeRect.inflate(-strokeWidth / 2); |
| 83 m_outerStrokeRect.inflate(strokeWidth / 2); | 83 m_outerStrokeRect.inflate(strokeWidth / 2); |
| 84 } | 84 } |
| 85 | 85 |
| 86 m_strokeBoundingBox = m_outerStrokeRect; | 86 m_strokeBoundingBox = m_outerStrokeRect; |
| 87 } | 87 } |
| 88 | 88 |
| 89 void RenderSVGRect::fillShape(GraphicsContext* context) const | |
| 90 { | |
| 91 if (m_usePathFallback) { | |
| 92 RenderSVGShape::fillShape(context); | |
| 93 return; | |
| 94 } | |
| 95 | |
| 96 context->fillRect(m_fillBoundingBox); | |
| 97 } | |
| 98 | |
| 99 void RenderSVGRect::strokeShape(GraphicsContext* context) const | |
| 100 { | |
| 101 if (!style()->svgStyle().hasVisibleStroke()) | |
| 102 return; | |
| 103 | |
| 104 if (m_usePathFallback) { | |
| 105 RenderSVGShape::strokeShape(context); | |
| 106 return; | |
| 107 } | |
| 108 | |
| 109 context->strokeRect(m_fillBoundingBox, strokeWidth()); | |
| 110 } | |
| 111 | |
| 112 bool RenderSVGRect::shapeDependentStrokeContains(const FloatPoint& point) | 89 bool RenderSVGRect::shapeDependentStrokeContains(const FloatPoint& point) |
| 113 { | 90 { |
| 114 // The optimized contains code below does not support non-smooth strokes so
we need | 91 // The optimized contains code below does not support non-smooth strokes so
we need |
| 115 // to fall back to RenderSVGShape::shapeDependentStrokeContains in these cas
es. | 92 // to fall back to RenderSVGShape::shapeDependentStrokeContains in these cas
es. |
| 116 if (m_usePathFallback || !hasSmoothStroke()) { | 93 if (m_usePathFallback || !hasSmoothStroke()) { |
| 117 if (!hasPath()) | 94 if (!hasPath()) |
| 118 RenderSVGShape::updateShapeFromElement(); | 95 RenderSVGShape::updateShapeFromElement(); |
| 119 return RenderSVGShape::shapeDependentStrokeContains(point); | 96 return RenderSVGShape::shapeDependentStrokeContains(point); |
| 120 } | 97 } |
| 121 | 98 |
| 122 return m_outerStrokeRect.contains(point, FloatRect::InsideOrOnStroke) && !m_
innerStrokeRect.contains(point, FloatRect::InsideButNotOnStroke); | 99 return m_outerStrokeRect.contains(point, FloatRect::InsideOrOnStroke) && !m_
innerStrokeRect.contains(point, FloatRect::InsideButNotOnStroke); |
| 123 } | 100 } |
| 124 | 101 |
| 125 bool RenderSVGRect::shapeDependentFillContains(const FloatPoint& point, const Wi
ndRule fillRule) const | 102 bool RenderSVGRect::shapeDependentFillContains(const FloatPoint& point, const Wi
ndRule fillRule) const |
| 126 { | 103 { |
| 127 if (m_usePathFallback) | 104 if (m_usePathFallback) |
| 128 return RenderSVGShape::shapeDependentFillContains(point, fillRule); | 105 return RenderSVGShape::shapeDependentFillContains(point, fillRule); |
| 129 return m_fillBoundingBox.contains(point.x(), point.y()); | 106 return m_fillBoundingBox.contains(point.x(), point.y()); |
| 130 } | 107 } |
| 131 | 108 |
| 132 } | 109 } |
| OLD | NEW |