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

Side by Side 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 unified diff | Download patch
OLDNEW
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (rect->rx()->currentValue()->value(lengthContext) > 0 || rect->ry()->curr entValue()->value(lengthContext) > 0 || hasNonScalingStroke()) { 58 if (rect->rx()->currentValue()->value(lengthContext) > 0 || rect->ry()->curr entValue()->value(lengthContext) > 0 || hasNonScalingStroke()) {
59 RenderSVGShape::updateShapeFromElement(); 59 RenderSVGShape::updateShapeFromElement();
60 m_usePathFallback = true; 60 m_usePathFallback = true;
61 return; 61 return;
62 } 62 }
63 63
64 m_usePathFallback = false; 64 m_usePathFallback = false;
65 FloatSize boundingBoxSize(rect->width()->currentValue()->value(lengthContext ), rect->height()->currentValue()->value(lengthContext)); 65 FloatSize boundingBoxSize(rect->width()->currentValue()->value(lengthContext ), rect->height()->currentValue()->value(lengthContext));
66 if (boundingBoxSize.isEmpty()) 66
67 // Spec: "A negative value is an error. A value of zero disables rendering o f the element."
68 if (boundingBoxSize.isZero() || boundingBoxSize.width() < 0 || boundingBoxSi ze.height() < 0)
67 return; 69 return;
68 70
69 m_fillBoundingBox = FloatRect(FloatPoint(rect->x()->currentValue()->value(le ngthContext), rect->y()->currentValue()->value(lengthContext)), boundingBoxSize) ; 71 m_fillBoundingBox = FloatRect(FloatPoint(rect->x()->currentValue()->value(le ngthContext), rect->y()->currentValue()->value(lengthContext)), boundingBoxSize) ;
70 72
71 // To decide if the stroke contains a point we create two rects which repres ent the inner and 73 // 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. 74 // the outer stroke borders. A stroke contains the point, if the point is be tween them.
73 m_innerStrokeRect = m_fillBoundingBox; 75 m_innerStrokeRect = m_fillBoundingBox;
74 m_outerStrokeRect = m_fillBoundingBox; 76 m_outerStrokeRect = m_fillBoundingBox;
75 77
76 if (style()->svgStyle()->hasStroke()) { 78 if (style()->svgStyle()->hasStroke()) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 121 }
120 122
121 bool RenderSVGRect::shapeDependentFillContains(const FloatPoint& point, const Wi ndRule fillRule) const 123 bool RenderSVGRect::shapeDependentFillContains(const FloatPoint& point, const Wi ndRule fillRule) const
122 { 124 {
123 if (m_usePathFallback) 125 if (m_usePathFallback)
124 return RenderSVGShape::shapeDependentFillContains(point, fillRule); 126 return RenderSVGShape::shapeDependentFillContains(point, fillRule);
125 return m_fillBoundingBox.contains(point.x(), point.y()); 127 return m_fillBoundingBox.contains(point.x(), point.y());
126 } 128 }
127 129
128 } 130 }
OLDNEW
« no previous file with comments | « Source/core/rendering/svg/RenderSVGEllipse.cpp ('k') | Source/core/rendering/svg/SVGPathData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698