Chromium Code Reviews| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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. | 57 // Fallback to RenderSVGShape if rect has rounded corners or a non-scaling s troke. |
| 58 m_usePathFallback = false; | |
| 58 if (rect->rx()->currentValue()->value(lengthContext) > 0 || rect->ry()->curr entValue()->value(lengthContext) > 0 || hasNonScalingStroke()) { | 59 if (rect->rx()->currentValue()->value(lengthContext) > 0 || rect->ry()->curr entValue()->value(lengthContext) > 0 || hasNonScalingStroke()) { |
| 59 RenderSVGShape::updateShapeFromElement(); | 60 RenderSVGShape::updateShapeFromElement(); |
| 60 m_usePathFallback = true; | 61 m_usePathFallback = true; |
| 61 return; | |
| 62 } | 62 } |
| 63 | 63 |
| 64 m_usePathFallback = false; | |
| 65 FloatSize boundingBoxSize(rect->width()->currentValue()->value(lengthContext ), rect->height()->currentValue()->value(lengthContext)); | 64 FloatSize boundingBoxSize(rect->width()->currentValue()->value(lengthContext ), rect->height()->currentValue()->value(lengthContext)); |
| 66 if (boundingBoxSize.isEmpty()) | 65 |
| 66 // Spec: "A negative value is an error. A value of zero disables rendering o f the element." | |
| 67 if (boundingBoxSize.isZero() || boundingBoxSize.width() < 0 || boundingBoxSi ze.height() < 0) | |
| 67 return; | 68 return; |
| 68 | 69 |
| 69 m_fillBoundingBox = FloatRect(FloatPoint(rect->x()->currentValue()->value(le ngthContext), rect->y()->currentValue()->value(lengthContext)), boundingBoxSize) ; | 70 m_fillBoundingBox = FloatRect(FloatPoint(rect->x()->currentValue()->value(le ngthContext), rect->y()->currentValue()->value(lengthContext)), boundingBoxSize) ; |
| 70 | 71 |
| 72 if (m_usePathFallback) | |
| 73 return; | |
| 74 | |
| 71 // 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 |
| 72 // 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. |
| 73 m_innerStrokeRect = m_fillBoundingBox; | 77 m_innerStrokeRect = m_fillBoundingBox; |
| 74 m_outerStrokeRect = m_fillBoundingBox; | 78 m_outerStrokeRect = m_fillBoundingBox; |
| 75 | 79 |
| 76 if (style()->svgStyle()->hasStroke()) { | 80 if (style()->svgStyle()->hasStroke() && boundingBoxSize.width() && boundingB oxSize.height()) { |
|
Stephen Chennney
2014/03/24 15:49:16
Same here.
| |
| 77 float strokeWidth = this->strokeWidth(); | 81 float strokeWidth = this->strokeWidth(); |
| 78 m_innerStrokeRect.inflate(-strokeWidth / 2); | 82 m_innerStrokeRect.inflate(-strokeWidth / 2); |
| 79 m_outerStrokeRect.inflate(strokeWidth / 2); | 83 m_outerStrokeRect.inflate(strokeWidth / 2); |
| 80 } | 84 } |
| 81 | 85 |
| 82 m_strokeBoundingBox = m_outerStrokeRect; | 86 m_strokeBoundingBox = m_outerStrokeRect; |
| 83 } | 87 } |
| 84 | 88 |
| 85 void RenderSVGRect::fillShape(GraphicsContext* context) const | 89 void RenderSVGRect::fillShape(GraphicsContext* context) const |
| 86 { | 90 { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 } | 123 } |
| 120 | 124 |
| 121 bool RenderSVGRect::shapeDependentFillContains(const FloatPoint& point, const Wi ndRule fillRule) const | 125 bool RenderSVGRect::shapeDependentFillContains(const FloatPoint& point, const Wi ndRule fillRule) const |
| 122 { | 126 { |
| 123 if (m_usePathFallback) | 127 if (m_usePathFallback) |
| 124 return RenderSVGShape::shapeDependentFillContains(point, fillRule); | 128 return RenderSVGShape::shapeDependentFillContains(point, fillRule); |
| 125 return m_fillBoundingBox.contains(point.x(), point.y()); | 129 return m_fillBoundingBox.contains(point.x(), point.y()); |
| 126 } | 130 } |
| 127 | 131 |
| 128 } | 132 } |
| OLD | NEW |