| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_innerStrokeRect = FloatRect(); | 51 m_innerStrokeRect = FloatRect(); |
| 52 m_outerStrokeRect = FloatRect(); | 52 m_outerStrokeRect = FloatRect(); |
| 53 SVGRectElement* rect = toSVGRectElement(element()); | 53 SVGRectElement* rect = toSVGRectElement(element()); |
| 54 ASSERT(rect); | 54 ASSERT(rect); |
| 55 | 55 |
| 56 SVGLengthContext lengthContext(rect); | 56 SVGLengthContext lengthContext(rect); |
| 57 // Fallback to RenderSVGShape if rect has rounded corners or a non-scaling s
troke. | |
| 58 if (rect->rx()->currentValue()->value(lengthContext) > 0 || rect->ry()->curr
entValue()->value(lengthContext) > 0 || hasNonScalingStroke()) { | |
| 59 RenderSVGShape::updateShapeFromElement(); | |
| 60 m_usePathFallback = true; | |
| 61 return; | |
| 62 } | |
| 63 | |
| 64 m_usePathFallback = false; | |
| 65 FloatSize boundingBoxSize(rect->width()->currentValue()->value(lengthContext
), rect->height()->currentValue()->value(lengthContext)); | 57 FloatSize boundingBoxSize(rect->width()->currentValue()->value(lengthContext
), rect->height()->currentValue()->value(lengthContext)); |
| 66 | 58 |
| 67 // 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." |
| 68 if (boundingBoxSize.isZero() || boundingBoxSize.width() < 0 || boundingBoxSi
ze.height() < 0) | 60 if (boundingBoxSize.width() < 0 || boundingBoxSize.height() < 0) |
| 69 return; | 61 return; |
| 70 | 62 |
| 63 // Spec: "A value of zero disables rendering of the element." |
| 64 if (boundingBoxSize.width() > 0 && boundingBoxSize.height() > 0) { |
| 65 // Fallback to RenderSVGShape if rect has rounded corners or a non-scali
ng stroke. |
| 66 if (rect->rx()->currentValue()->value(lengthContext) > 0 || rect->ry()->
currentValue()->value(lengthContext) > 0 || hasNonScalingStroke()) { |
| 67 RenderSVGShape::updateShapeFromElement(); |
| 68 m_usePathFallback = true; |
| 69 return; |
| 70 } |
| 71 m_usePathFallback = false; |
| 72 } |
| 73 |
| 71 m_fillBoundingBox = FloatRect(FloatPoint(rect->x()->currentValue()->value(le
ngthContext), rect->y()->currentValue()->value(lengthContext)), boundingBoxSize)
; | 74 m_fillBoundingBox = FloatRect(FloatPoint(rect->x()->currentValue()->value(le
ngthContext), rect->y()->currentValue()->value(lengthContext)), boundingBoxSize)
; |
| 72 | 75 |
| 73 // To decide if the stroke contains a point we create two rects which repres
ent the inner and | 76 // To decide if the stroke contains a point we create two rects which repres
ent the inner and |
| 74 // the outer stroke borders. A stroke contains the point, if the point is be
tween them. | 77 // the outer stroke borders. A stroke contains the point, if the point is be
tween them. |
| 75 m_innerStrokeRect = m_fillBoundingBox; | 78 m_innerStrokeRect = m_fillBoundingBox; |
| 76 m_outerStrokeRect = m_fillBoundingBox; | 79 m_outerStrokeRect = m_fillBoundingBox; |
| 77 | 80 |
| 78 if (style()->svgStyle()->hasStroke()) { | 81 if (style()->svgStyle()->hasStroke()) { |
| 79 float strokeWidth = this->strokeWidth(); | 82 float strokeWidth = this->strokeWidth(); |
| 80 m_innerStrokeRect.inflate(-strokeWidth / 2); | 83 m_innerStrokeRect.inflate(-strokeWidth / 2); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 } | 124 } |
| 122 | 125 |
| 123 bool RenderSVGRect::shapeDependentFillContains(const FloatPoint& point, const Wi
ndRule fillRule) const | 126 bool RenderSVGRect::shapeDependentFillContains(const FloatPoint& point, const Wi
ndRule fillRule) const |
| 124 { | 127 { |
| 125 if (m_usePathFallback) | 128 if (m_usePathFallback) |
| 126 return RenderSVGShape::shapeDependentFillContains(point, fillRule); | 129 return RenderSVGShape::shapeDependentFillContains(point, fillRule); |
| 127 return m_fillBoundingBox.contains(point.x(), point.y()); | 130 return m_fillBoundingBox.contains(point.x(), point.y()); |
| 128 } | 131 } |
| 129 | 132 |
| 130 } | 133 } |
| OLD | NEW |