Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(823)

Unified Diff: Source/core/rendering/svg/RenderSVGRect.cpp

Issue 208323007: Fix getBBox() returning (0,0) bug when width or height is zero (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@myzbackup
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/rendering/svg/RenderSVGRect.cpp
diff --git a/Source/core/rendering/svg/RenderSVGRect.cpp b/Source/core/rendering/svg/RenderSVGRect.cpp
index ce796422d932e7259436a049259b59167932f405..7f04bf93de62c87412baa56c9dca2702e14e2283 100644
--- a/Source/core/rendering/svg/RenderSVGRect.cpp
+++ b/Source/core/rendering/svg/RenderSVGRect.cpp
@@ -55,25 +55,29 @@ void RenderSVGRect::updateShapeFromElement()
SVGLengthContext lengthContext(rect);
// Fallback to RenderSVGShape if rect has rounded corners or a non-scaling stroke.
+ m_usePathFallback = false;
if (rect->rx()->currentValue()->value(lengthContext) > 0 || rect->ry()->currentValue()->value(lengthContext) > 0 || hasNonScalingStroke()) {
RenderSVGShape::updateShapeFromElement();
m_usePathFallback = true;
- return;
}
- m_usePathFallback = false;
FloatSize boundingBoxSize(rect->width()->currentValue()->value(lengthContext), rect->height()->currentValue()->value(lengthContext));
- if (boundingBoxSize.isEmpty())
+
+ // Spec: "A negative value is an error. A value of zero disables rendering of the element."
+ if (boundingBoxSize.isZero() || boundingBoxSize.width() < 0 || boundingBoxSize.height() < 0)
return;
m_fillBoundingBox = FloatRect(FloatPoint(rect->x()->currentValue()->value(lengthContext), rect->y()->currentValue()->value(lengthContext)), boundingBoxSize);
+ if (m_usePathFallback)
+ return;
+
// To decide if the stroke contains a point we create two rects which represent the inner and
// the outer stroke borders. A stroke contains the point, if the point is between them.
m_innerStrokeRect = m_fillBoundingBox;
m_outerStrokeRect = m_fillBoundingBox;
- if (style()->svgStyle()->hasStroke()) {
+ if (style()->svgStyle()->hasStroke() && boundingBoxSize.width() && boundingBoxSize.height()) {
Stephen Chennney 2014/03/24 15:49:16 Same here.
float strokeWidth = this->strokeWidth();
m_innerStrokeRect.inflate(-strokeWidth / 2);
m_outerStrokeRect.inflate(strokeWidth / 2);

Powered by Google App Engine
This is Rietveld 408576698