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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 { | 42 { |
43 } | 43 } |
44 | 44 |
45 void RenderSVGRect::updateShapeFromElement() | 45 void RenderSVGRect::updateShapeFromElement() |
46 { | 46 { |
47 // Before creating a new object we need to clear the cached bounding box | 47 // Before creating a new object we need to clear the cached bounding box |
48 // to avoid using garbage. | 48 // to avoid using garbage. |
49 m_fillBoundingBox = FloatRect(); | 49 m_fillBoundingBox = FloatRect(); |
50 m_innerStrokeRect = FloatRect(); | 50 m_innerStrokeRect = FloatRect(); |
51 m_outerStrokeRect = FloatRect(); | 51 m_outerStrokeRect = FloatRect(); |
| 52 m_usePathFallback = false; |
52 SVGRectElement* rect = toSVGRectElement(element()); | 53 SVGRectElement* rect = toSVGRectElement(element()); |
53 ASSERT(rect); | 54 ASSERT(rect); |
54 | 55 |
55 SVGLengthContext lengthContext(rect); | 56 SVGLengthContext lengthContext(rect); |
56 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)); |
57 | 58 |
58 // Spec: "A negative value is an error." | 59 // Spec: "A negative value is an error." |
59 if (boundingBoxSize.width() < 0 || boundingBoxSize.height() < 0) | 60 if (boundingBoxSize.width() < 0 || boundingBoxSize.height() < 0) |
60 return; | 61 return; |
61 | 62 |
62 // Spec: "A value of zero disables rendering of the element." | 63 // Spec: "A value of zero disables rendering of the element." |
63 if (!boundingBoxSize.isEmpty()) { | 64 if (!boundingBoxSize.isEmpty()) { |
64 // Fallback to RenderSVGShape if rect has rounded corners or a non-scali
ng stroke. | 65 // Fallback to RenderSVGShape if rect has rounded corners or a non-scali
ng stroke. |
65 if (rect->rx()->currentValue()->value(lengthContext) > 0 || rect->ry()->
currentValue()->value(lengthContext) > 0 || hasNonScalingStroke()) { | 66 if (rect->rx()->currentValue()->value(lengthContext) > 0 || rect->ry()->
currentValue()->value(lengthContext) > 0 || hasNonScalingStroke()) { |
66 RenderSVGShape::updateShapeFromElement(); | 67 RenderSVGShape::updateShapeFromElement(); |
67 m_usePathFallback = true; | 68 m_usePathFallback = true; |
68 return; | 69 return; |
69 } | 70 } |
70 m_usePathFallback = false; | |
71 } | 71 } |
72 | 72 |
73 m_fillBoundingBox = FloatRect(FloatPoint(rect->x()->currentValue()->value(le
ngthContext), rect->y()->currentValue()->value(lengthContext)), boundingBoxSize)
; | 73 m_fillBoundingBox = FloatRect(FloatPoint(rect->x()->currentValue()->value(le
ngthContext), rect->y()->currentValue()->value(lengthContext)), boundingBoxSize)
; |
74 | 74 |
75 // To decide if the stroke contains a point we create two rects which repres
ent the inner and | 75 // To decide if the stroke contains a point we create two rects which repres
ent the inner and |
76 // the outer stroke borders. A stroke contains the point, if the point is be
tween them. | 76 // the outer stroke borders. A stroke contains the point, if the point is be
tween them. |
77 m_innerStrokeRect = m_fillBoundingBox; | 77 m_innerStrokeRect = m_fillBoundingBox; |
78 m_outerStrokeRect = m_fillBoundingBox; | 78 m_outerStrokeRect = m_fillBoundingBox; |
79 | 79 |
80 if (style()->svgStyle().hasStroke()) { | 80 if (style()->svgStyle().hasStroke()) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 } | 123 } |
124 | 124 |
125 bool RenderSVGRect::shapeDependentFillContains(const FloatPoint& point, const Wi
ndRule fillRule) const | 125 bool RenderSVGRect::shapeDependentFillContains(const FloatPoint& point, const Wi
ndRule fillRule) const |
126 { | 126 { |
127 if (m_usePathFallback) | 127 if (m_usePathFallback) |
128 return RenderSVGShape::shapeDependentFillContains(point, fillRule); | 128 return RenderSVGShape::shapeDependentFillContains(point, fillRule); |
129 return m_fillBoundingBox.contains(point.x(), point.y()); | 129 return m_fillBoundingBox.contains(point.x(), point.y()); |
130 } | 130 } |
131 | 131 |
132 } | 132 } |
OLD | NEW |