Title: [96558] trunk
Revision
96558
Author
m...@apple.com
Date
2011-10-03 17:10:38 -0700 (Mon, 03 Oct 2011)

Log Message

<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.

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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (96557 => 96558)


--- trunk/LayoutTests/ChangeLog	2011-10-03 23:54:26 UTC (rev 96557)
+++ trunk/LayoutTests/ChangeLog	2011-10-04 00:10:38 UTC (rev 96558)
@@ -1,3 +1,13 @@
+2011-10-03  Dan Bernstein  <m...@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  <rn...@webkit.org>
 
         REGRESSION(r94274): cloned text input loses value

Added: trunk/LayoutTests/svg/custom/boundingBox-expected.txt (0 => 96558)


--- trunk/LayoutTests/svg/custom/boundingBox-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/svg/custom/boundingBox-expected.txt	2011-10-04 00:10:38 UTC (rev 96558)
@@ -0,0 +1,3 @@
+Test that -[DOMNode boundingBox] returns reasonable results for SVG elements.
+
+PASS

Added: trunk/LayoutTests/svg/custom/boundingBox.html (0 => 96558)


--- trunk/LayoutTests/svg/custom/boundingBox.html	                        (rev 0)
+++ trunk/LayoutTests/svg/custom/boundingBox.html	2011-10-04 00:10:38 UTC (rev 96558)
@@ -0,0 +1,35 @@
+<!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>

Modified: trunk/Source/WebCore/ChangeLog (96557 => 96558)


--- trunk/Source/WebCore/ChangeLog	2011-10-03 23:54:26 UTC (rev 96557)
+++ trunk/Source/WebCore/ChangeLog	2011-10-04 00:10:38 UTC (rev 96558)
@@ -1,3 +1,29 @@
+2011-10-03  Dan Bernstein  <m...@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  <micha...@google.com>
 
         A little more WebSQLDatabase thread safety.

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGForeignObject.cpp (96557 => 96558)


--- trunk/Source/WebCore/rendering/svg/RenderSVGForeignObject.cpp	2011-10-03 23:54:26 UTC (rev 96557)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGForeignObject.cpp	2011-10-04 00:10:38 UTC (rev 96558)
@@ -160,12 +160,9 @@
     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);
 }
 
 }

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGInline.cpp (96557 => 96558)


--- trunk/Source/WebCore/rendering/svg/RenderSVGInline.cpp	2011-10-03 23:54:26 UTC (rev 96557)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGInline.cpp	2011-10-04 00:10:38 UTC (rev 96558)
@@ -77,9 +77,9 @@
     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)

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGModelObject.cpp (96557 => 96558)


--- trunk/Source/WebCore/rendering/svg/RenderSVGModelObject.cpp	2011-10-03 23:54:26 UTC (rev 96557)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGModelObject.cpp	2011-10-04 00:10:38 UTC (rev 96558)
@@ -53,9 +53,9 @@
     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.
@@ -70,10 +70,11 @@
     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)

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp (96557 => 96558)


--- trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp	2011-10-03 23:54:26 UTC (rev 96557)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp	2011-10-04 00:10:38 UTC (rev 96558)
@@ -93,9 +93,9 @@
     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)

Modified: trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp (96557 => 96558)


--- trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp	2011-10-03 23:54:26 UTC (rev 96557)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp	2011-10-04 00:10:38 UTC (rev 96558)
@@ -70,12 +70,10 @@
     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)

Modified: trunk/Source/WebCore/rendering/svg/SVGRenderSupport.h (96557 => 96558)


--- trunk/Source/WebCore/rendering/svg/SVGRenderSupport.h	2011-10-03 23:54:26 UTC (rev 96557)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderSupport.h	2011-10-04 00:10:38 UTC (rev 96558)
@@ -63,7 +63,7 @@
     // 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*);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to