https://bugs.webkit.org/show_bug.cgi?id=76177
Patch by Philip Rogers <pdr@google.com> on 2012-01-17
Reviewed by Darin Adler.
Source/WebCore:
Test: svg/custom/getBBox-perpendicular-path.svg
* platform/graphics/FloatRect.cpp:
(WebCore::FloatRect::unite):
(WebCore::FloatRect::uniteEvenIfEmpty):
(WebCore::FloatRect::uniteIfNonZero):
* platform/graphics/FloatRect.h:
* rendering/svg/SVGRenderSupport.cpp:
(WebCore::SVGRenderSupport::computeContainerBoundingBoxes):
LayoutTests:
* svg/custom/getBBox-perpendicular-path-expected.txt: Added.
* svg/custom/getBBox-perpendicular-path.svg: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105231
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-01-17 Philip Rogers <pdr@google.com>
+
+ Fix getBBox for perpendicular paths
+ https://bugs.webkit.org/show_bug.cgi?id=76177
+
+ Reviewed by Darin Adler.
+
+ * svg/custom/getBBox-perpendicular-path-expected.txt: Added.
+ * svg/custom/getBBox-perpendicular-path.svg: Added.
+
2012-01-17 James Robinson <jamesr@chromium.org>
[chromium] Mark some compositing tests as failing with an IMAGE diff due to video playback problem
--- /dev/null
+100 100 PASS
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Test the bounding box calculated for two perpendicular lines of length 100px -->
+<!-- If the bounding box is 100x100, we consider this test passing. -->
+<svg xmlns="http://www.w3.org/2000/svg" onload="init()">
+ <script type="text/javascript">
+ <![CDATA[
+ function init()
+ {
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+ var txt = document.getElementById("text");
+ size = document.getElementById("shape").getBBox();
+ var passState = "FAIL";
+ if(size.width == 100 && size.height == 100)
+ passState = "PASS";
+ var textNode = document.createTextNode(size.width + " " + size.height + " " + passState);
+ txt.appendChild(textNode);
+ }
+ ]]>
+ </script>
+ <g id="shape">
+ <path stroke="#666666" stroke-width="2.0" stroke-linejoin="round" stroke-linecap="butt" d="M5 5L5 105" fill-rule="nonzero"></path>
+ <path stroke="#666666" stroke-width="2.0" stroke-linejoin="round" stroke-linecap="butt" d="M5 5L105 5" fill-rule="nonzero"></path>
+ </g>
+ <text id="text" x="50" y="50" />
+</svg>
+2012-01-17 Philip Rogers <pdr@google.com>
+
+ Fix getBBox for perpendicular paths
+ https://bugs.webkit.org/show_bug.cgi?id=76177
+
+ Reviewed by Darin Adler.
+
+ Test: svg/custom/getBBox-perpendicular-path.svg
+
+ * platform/graphics/FloatRect.cpp:
+ (WebCore::FloatRect::unite):
+ (WebCore::FloatRect::uniteEvenIfEmpty):
+ (WebCore::FloatRect::uniteIfNonZero):
+ * platform/graphics/FloatRect.h:
+ * rendering/svg/SVGRenderSupport.cpp:
+ (WebCore::SVGRenderSupport::computeContainerBoundingBoxes):
+
2012-01-17 Kenneth Russell <kbr@google.com>
[chromium] Apply color profiles in more cases
return;
}
- float l = min(x(), other.x());
- float t = min(y(), other.y());
- float r = max(maxX(), other.maxX());
- float b = max(maxY(), other.maxY());
+ uniteEvenIfEmpty(other);
+}
- setLocationAndSizeFromEdges(l, t, r, b);
+void FloatRect::uniteEvenIfEmpty(const FloatRect& other)
+{
+ float minX = min(x(), other.x());
+ float minY = min(y(), other.y());
+ float maxX = max(this->maxX(), other.maxX());
+ float maxY = max(this->maxY(), other.maxY());
+
+ setLocationAndSizeFromEdges(minX, minY, maxX, maxY);
}
void FloatRect::uniteIfNonZero(const FloatRect& other)
return;
}
- float left = min(x(), other.x());
- float top = min(y(), other.y());
- float right = max(maxX(), other.maxX());
- float bottom = max(maxY(), other.maxY());
-
- setLocationAndSizeFromEdges(left, top, right, bottom);
+ uniteEvenIfEmpty(other);
}
void FloatRect::scale(float sx, float sy)
void intersect(const FloatRect&);
void unite(const FloatRect&);
+ void uniteEvenIfEmpty(const FloatRect&);
void uniteIfNonZero(const FloatRect&);
// Note, this doesn't match what IntRect::contains(IntPoint&) does; the int version
void SVGRenderSupport::computeContainerBoundingBoxes(const RenderObject* container, FloatRect& objectBoundingBox, FloatRect& strokeBoundingBox, FloatRect& repaintBoundingBox)
{
+ bool isFirstChild = true;
+
for (RenderObject* current = container->firstChild(); current; current = current->nextSibling()) {
if (current->isSVGHiddenContainer())
continue;
const AffineTransform& transform = current->localToParentTransform();
if (transform.isIdentity()) {
- objectBoundingBox.unite(current->objectBoundingBox());
+ if (isFirstChild)
+ objectBoundingBox = current->objectBoundingBox();
+ else
+ objectBoundingBox.uniteEvenIfEmpty(current->objectBoundingBox());
strokeBoundingBox.unite(current->strokeBoundingBox());
repaintBoundingBox.unite(current->repaintRectInLocalCoordinates());
} else {
- objectBoundingBox.unite(transform.mapRect(current->objectBoundingBox()));
+ if (isFirstChild)
+ objectBoundingBox = transform.mapRect(current->objectBoundingBox());
+ else
+ objectBoundingBox.uniteEvenIfEmpty(transform.mapRect(current->objectBoundingBox()));
strokeBoundingBox.unite(transform.mapRect(current->strokeBoundingBox()));
repaintBoundingBox.unite(transform.mapRect(current->repaintRectInLocalCoordinates()));
}
+
+ if (isFirstChild)
+ isFirstChild = false;
}
}