https://bugs.webkit.org/show_bug.cgi?id=69305
Reviewed by Simon Fraser.
Source/WebCore:
Test: svg/custom/boundingBox.html
Rather than asserting and returning the zero rect, take the transform-aware code path for computing SVG
bounding rects.
* rendering/svg/RenderSVGForeignObject.cpp:
(WebCore::RenderSVGForeignObject::mapLocalToContainer): Updated for change to SVGRenderSupport::mapLocalToContainer().
* rendering/svg/RenderSVGInline.cpp:
(WebCore::RenderSVGInline::mapLocalToContainer): Ditto.
* rendering/svg/RenderSVGModelObject.cpp:
(WebCore::RenderSVGModelObject::mapLocalToContainer): Ditto.
(WebCore::RenderSVGModelObject::absoluteRects): Replaced an incorrect assertion with code to approximate the bounding
box.
* rendering/svg/RenderSVGText.cpp:
(WebCore::RenderSVGText::mapLocalToContainer): Updated for change to SVGRenderSupport::mapLocalToContainer().
* rendering/svg/SVGRenderSupport.cpp:
(WebCore::SVGRenderSupport::mapLocalToContainer): Removed the fixed and useTransform boolean parameters.
* rendering/svg/SVGRenderSupport.h:
LayoutTests:
* svg/custom/boundingBox-expected.txt: Added.
* svg/custom/boundingBox.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96558
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-10-03 Dan Bernstein <mitz@apple.com>
+
+ <rdar://problem/9973489> REGRESSION (r66599): -[DOMNode boundingBox] returns the zero rect for SVG elements
+ https://bugs.webkit.org/show_bug.cgi?id=69305
+
+ Reviewed by Simon Fraser.
+
+ * svg/custom/boundingBox-expected.txt: Added.
+ * svg/custom/boundingBox.html: Added.
+
2011-10-03 Ryosuke Niwa <rniwa@webkit.org>
REGRESSION(r94274): cloned text input loses value
--- /dev/null
+Test that -[DOMNode boundingBox] returns reasonable results for SVG elements.
+
+PASS
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.layoutTestController)
+ window.layoutTestController.dumpAsText()
+
+function runTest()
+{
+ var target = document.getElementById("target");
+ if (window.internals) {
+ var boundingBox = internals.boundingBox(target);
+ var boundingClientRect = target.getBoundingClientRect();
+ var rectsAreEqual = (boundingBox.width === boundingClientRect.width
+ && boundingBox.height === boundingClientRect.height
+ && boundingBox.left === boundingClientRect.left
+ && boundingBox.top === boundingClientRect.top);
+
+ document.getElementById("result").innerHTML = rectsAreEqual ? "PASS" : "FAIL: boundingBox: " + boundingBox.width + " x " + boundingBox.height + " @ (" + boundingBox.left + ", " + boundingBox.top + "), boundingClientRect: "
+ + boundingClientRect.width + " x " + boundingClientRect.height + " @ (" + boundingClientRect.left + ", " + boundingClientRect.top + ")";
+ }
+}
+</script>
+</head>
+<body onload="runTest()">
+<div style="height: 200px;"></div>
+<svg width=400 height=400>
+ <image width=200 height=200 x=50 y=50 id="target" />
+</svg>
+<p>
+ Test that -[DOMNode boundingBox] returns reasonable results for SVG elements.
+</p>
+<p id="result">This test can only be run in DumpRenderTree.</p>
+</body>
+</html>
+2011-10-03 Dan Bernstein <mitz@apple.com>
+
+ <rdar://problem/9973489> REGRESSION (r66599): -[DOMNode boundingBox] returns the zero rect for SVG elements
+ https://bugs.webkit.org/show_bug.cgi?id=69305
+
+ Reviewed by Simon Fraser.
+
+ Test: svg/custom/boundingBox.html
+
+ Rather than asserting and returning the zero rect, take the transform-aware code path for computing SVG
+ bounding rects.
+
+ * rendering/svg/RenderSVGForeignObject.cpp:
+ (WebCore::RenderSVGForeignObject::mapLocalToContainer): Updated for change to SVGRenderSupport::mapLocalToContainer().
+ * rendering/svg/RenderSVGInline.cpp:
+ (WebCore::RenderSVGInline::mapLocalToContainer): Ditto.
+ * rendering/svg/RenderSVGModelObject.cpp:
+ (WebCore::RenderSVGModelObject::mapLocalToContainer): Ditto.
+ (WebCore::RenderSVGModelObject::absoluteRects): Replaced an incorrect assertion with code to approximate the bounding
+ box.
+ * rendering/svg/RenderSVGText.cpp:
+ (WebCore::RenderSVGText::mapLocalToContainer): Updated for change to SVGRenderSupport::mapLocalToContainer().
+ * rendering/svg/SVGRenderSupport.cpp:
+ (WebCore::SVGRenderSupport::mapLocalToContainer): Removed the fixed and useTransform boolean parameters.
+ * rendering/svg/SVGRenderSupport.h:
+
2011-10-03 Michael Nordman <michaeln@google.com>
A little more WebSQLDatabase thread safety.
return false;
}
-void RenderSVGForeignObject::mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed, bool useTransforms, TransformState& transformState, bool* wasFixed) const
+void RenderSVGForeignObject::mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool /* fixed */, bool /* useTransforms */, TransformState& transformState, bool* wasFixed) const
{
- // When crawling up the hierachy starting from foreignObject child content, useTransforms may not be set to true.
- if (!useTransforms)
- useTransforms = true;
- SVGRenderSupport::mapLocalToContainer(this, repaintContainer, fixed, useTransforms, transformState, wasFixed);
+ SVGRenderSupport::mapLocalToContainer(this, repaintContainer, transformState, wasFixed);
}
}
SVGRenderSupport::computeRectForRepaint(this, repaintContainer, repaintRect, fixed);
}
-void RenderSVGInline::mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState& transformState, bool* wasFixed) const
+void RenderSVGInline::mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool /* useTransforms */, bool /* fixed */, TransformState& transformState, bool* wasFixed) const
{
- SVGRenderSupport::mapLocalToContainer(this, repaintContainer, useTransforms, fixed, transformState, wasFixed);
+ SVGRenderSupport::mapLocalToContainer(this, repaintContainer, transformState, wasFixed);
}
void RenderSVGInline::absoluteQuads(Vector<FloatQuad>& quads, bool* wasFixed)
SVGRenderSupport::computeRectForRepaint(this, repaintContainer, repaintRect, fixed);
}
-void RenderSVGModelObject::mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed, bool useTransforms, TransformState& transformState, bool* wasFixed) const
+void RenderSVGModelObject::mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool /* fixed */, bool /* useTransforms */, TransformState& transformState, bool* wasFixed) const
{
- SVGRenderSupport::mapLocalToContainer(this, repaintContainer, fixed, useTransforms, transformState, wasFixed);
+ SVGRenderSupport::mapLocalToContainer(this, repaintContainer, transformState, wasFixed);
}
// Copied from RenderBox, this method likely requires further refactoring to work easily for both SVG and CSS Box Model content.
return containerRelativeQuad.enclosingBoundingBox();
}
-void RenderSVGModelObject::absoluteRects(Vector<LayoutRect>&, const LayoutPoint&)
+void RenderSVGModelObject::absoluteRects(Vector<LayoutRect>& rects, const LayoutPoint& accumulatedOffset)
{
- // This code path should never be taken for SVG, as we're assuming useTransforms=true everywhere, absoluteQuads should be used.
- ASSERT_NOT_REACHED();
+ LayoutRect rect = enclosingLayoutRect(strokeBoundingBox());
+ rect.moveBy(accumulatedOffset);
+ rects.append(rect);
}
void RenderSVGModelObject::absoluteQuads(Vector<FloatQuad>& quads, bool* wasFixed)
SVGRenderSupport::computeRectForRepaint(this, repaintContainer, repaintRect, fixed);
}
-void RenderSVGText::mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed, bool useTransforms, TransformState& transformState, bool* wasFixed) const
+void RenderSVGText::mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool /* fixed */, bool /* useTransforms */, TransformState& transformState, bool* wasFixed) const
{
- SVGRenderSupport::mapLocalToContainer(this, repaintContainer, fixed, useTransforms, transformState, wasFixed);
+ SVGRenderSupport::mapLocalToContainer(this, repaintContainer, transformState, wasFixed);
}
static inline void recursiveUpdateScaledFont(RenderObject* start)
object->parent()->computeRectForRepaint(repaintContainer, repaintRect, fixed);
}
-void SVGRenderSupport::mapLocalToContainer(const RenderObject* object, RenderBoxModelObject* repaintContainer, bool fixed, bool useTransforms, TransformState& transformState, bool* wasFixed)
+void SVGRenderSupport::mapLocalToContainer(const RenderObject* object, RenderBoxModelObject* repaintContainer, TransformState& transformState, bool* wasFixed)
{
- ASSERT(!fixed); // We should have no fixed content in the SVG rendering tree.
- ASSERT(useTransforms); // Mapping a point through SVG w/o respecting transforms is useless.
transformState.applyTransform(object->localToParentTransform());
- object->parent()->mapLocalToContainer(repaintContainer, fixed, useTransforms, transformState, wasFixed);
+ object->parent()->mapLocalToContainer(repaintContainer, false, true, transformState, wasFixed);
}
bool SVGRenderSupport::prepareToRenderSVGContent(RenderObject* object, PaintInfo& paintInfo)
// Important functions used by nearly all SVG renderers centralizing coordinate transformations / repaint rect calculations
static LayoutRect clippedOverflowRectForRepaint(const RenderObject*, RenderBoxModelObject* repaintContainer);
static void computeRectForRepaint(const RenderObject*, RenderBoxModelObject* repaintContainer, LayoutRect&, bool fixed);
- static void mapLocalToContainer(const RenderObject*, RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState&, bool* wasFixed = 0);
+ static void mapLocalToContainer(const RenderObject*, RenderBoxModelObject* repaintContainer, TransformState&, bool* wasFixed = 0);
// Shared between SVG renderers and resources.
static void applyStrokeStyleToContext(GraphicsContext*, const RenderStyle*, const RenderObject*);