Modified: trunk/LayoutTests/ChangeLog (112437 => 112438)
--- trunk/LayoutTests/ChangeLog 2012-03-28 20:59:06 UTC (rev 112437)
+++ trunk/LayoutTests/ChangeLog 2012-03-28 21:00:37 UTC (rev 112438)
@@ -1,3 +1,13 @@
+2012-03-28 Florin Malita <[email protected]>
+
+ Incorrect foreignObject hit test results when overlapping other SVG elements
+ https://bugs.webkit.org/show_bug.cgi?id=82059
+
+ Reviewed by Nikolas Zimmermann.
+
+ * svg/hittest/foreign-object-background-expected.txt: Added.
+ * svg/hittest/foreign-object-background.svg: Added.
+
2012-03-26 Shawn Singh <[email protected]>
[chromium] layer->clipRect() is not initialized for layers that create a renderSurface.
Added: trunk/LayoutTests/svg/hittest/foreign-object-background-expected.txt (0 => 112438)
--- trunk/LayoutTests/svg/hittest/foreign-object-background-expected.txt (rev 0)
+++ trunk/LayoutTests/svg/hittest/foreign-object-background-expected.txt 2012-03-28 21:00:37 UTC (rev 112438)
@@ -0,0 +1 @@
+PASS
Added: trunk/LayoutTests/svg/hittest/foreign-object-background.svg (0 => 112438)
--- trunk/LayoutTests/svg/hittest/foreign-object-background.svg (rev 0)
+++ trunk/LayoutTests/svg/hittest/foreign-object-background.svg 2012-03-28 21:00:37 UTC (rev 112438)
@@ -0,0 +1,23 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+ <rect width="100" height="100" fill="red" _onclick_="window.alert('FAIL: click not sent to FO content.');"/>
+ <foreignObject width="100" height="100">
+ <body xmlns="http://www.w3.org/1999/xhtml" style="margin: 0; padding: 0;">
+ <!-- Clicking on the green div (background) should be dispatched to the div element and not to the red SVG rect underneath. -->
+ <div id="target" style="width: 100px; height: 100px; background-color:green;" _onclick_="window.alert('PASS: click sent to FO content.');"></div>
+ </body>
+ </foreignObject>
+
+ <script><![CDATA[
+
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+
+ var hitElement = document.elementFromPoint(50, 50);
+ var hitSuccess = hitElement && hitElement == document.getElementById("target");
+ document.getElementById('target').innerHTML = hitSuccess ? 'PASS' : 'FAIL';
+ } else {
+ document.getElementById('target').innerHTML = 'Click me.';
+ }
+ ]]></script>
+</svg>
+
Modified: trunk/Source/WebCore/ChangeLog (112437 => 112438)
--- trunk/Source/WebCore/ChangeLog 2012-03-28 20:59:06 UTC (rev 112437)
+++ trunk/Source/WebCore/ChangeLog 2012-03-28 21:00:37 UTC (rev 112438)
@@ -1,3 +1,19 @@
+2012-03-28 Florin Malita <[email protected]>
+
+ Incorrect foreignObject hit test results when overlapping other SVG elements
+ https://bugs.webkit.org/show_bug.cgi?id=82059
+
+ Reviewed by Nikolas Zimmermann.
+
+ Test: svg/hittest/foreign-object-background.svg
+
+ Foreign content needs to be hit-tested atomically due to the (pseudo)
+ stacking context established by FOs.
+
+ * rendering/svg/RenderSVGForeignObject.cpp:
+ (WebCore::RenderSVGForeignObject::nodeAtFloatPoint):
+ Hit test all phases on FO HitTestForeground.
+
2012-03-26 Shawn Singh <[email protected]>
[chromium] layer->clipRect() is not initialized for layers that create a renderSurface.
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGForeignObject.cpp (112437 => 112438)
--- trunk/Source/WebCore/rendering/svg/RenderSVGForeignObject.cpp 2012-03-28 20:59:06 UTC (rev 112437)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGForeignObject.cpp 2012-03-28 21:00:37 UTC (rev 112438)
@@ -26,6 +26,7 @@
#include "GraphicsContext.h"
#include "LayoutRepainter.h"
+#include "RenderObject.h"
#include "RenderSVGResource.h"
#include "RenderView.h"
#include "SVGForeignObjectElement.h"
@@ -165,13 +166,20 @@
bool RenderSVGForeignObject::nodeAtFloatPoint(const HitTestRequest& request, HitTestResult& result, const FloatPoint& pointInParent, HitTestAction hitTestAction)
{
+ // Embedded content is drawn in the foreground phase.
+ if (hitTestAction != HitTestForeground)
+ return false;
+
FloatPoint localPoint = localTransform().inverse().mapPoint(pointInParent);
// Early exit if local point is not contained in clipped viewport area
if (SVGRenderSupport::isOverflowHidden(this) && !m_viewport.contains(localPoint))
return false;
- return RenderBlock::nodeAtPoint(request, result, roundedLayoutPoint(localPoint), LayoutPoint(), hitTestAction);
+ // FOs establish a stacking context, so we need to hit-test all layers.
+ return RenderBlock::nodeAtPoint(request, result, roundedLayoutPoint(localPoint), LayoutPoint(), HitTestForeground)
+ || RenderBlock::nodeAtPoint(request, result, roundedLayoutPoint(localPoint), LayoutPoint(), HitTestFloat)
+ || RenderBlock::nodeAtPoint(request, result, roundedLayoutPoint(localPoint), LayoutPoint(), HitTestChildBlockBackgrounds);
}
bool RenderSVGForeignObject::nodeAtPoint(const HitTestRequest&, HitTestResult&, const LayoutPoint&, const LayoutPoint&, HitTestAction)