Reviewed by Eric.
authorrwlbuis <rwlbuis@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Nov 2006 21:24:32 +0000 (21:24 +0000)
committerrwlbuis <rwlbuis@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Nov 2006 21:24:32 +0000 (21:24 +0000)
        http://bugs.webkit.org/show_bug.cgi?id=11661
        SVG: stroke not sensitive to mouse events (hit testing fails)

        Use mapAbsolutePointToLocal when hit-testing strokes.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@17876 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/svg/custom/hit-test-path-stroke-expected.checksum [new file with mode: 0644]
LayoutTests/svg/custom/hit-test-path-stroke-expected.png [new file with mode: 0644]
LayoutTests/svg/custom/hit-test-path-stroke-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/hit-test-path-stroke.svg [new file with mode: 0644]
WebCore/ChangeLog
WebCore/rendering/RenderPath.cpp

index eb0c271d91b3e53ce026b7d228cac2ff3434168d..45df4a52a2d9574c4e8cc22ce27e0bb081974bff 100644 (file)
@@ -1,3 +1,16 @@
+2006-11-22  Rob Buis  <buis@kde.org>
+
+        Reviewed by Eric.
+
+        Testcase for:
+        http://bugs.webkit.org/show_bug.cgi?id=11661
+        SVG: stroke not sensitive to mouse events (hit testing fails)
+
+        * svg/custom/hit-test-path-stroke-expected.checksum: Added.
+        * svg/custom/hit-test-path-stroke-expected.png: Added.
+        * svg/custom/hit-test-path-stroke-expected.txt: Added.
+        * svg/custom/hit-test-path-stroke.svg: Added.
+
 2006-11-21  Alex Taylor  <darwin@techvisual.co.nz>
 
         Reviewed by Mitz.
diff --git a/LayoutTests/svg/custom/hit-test-path-stroke-expected.checksum b/LayoutTests/svg/custom/hit-test-path-stroke-expected.checksum
new file mode 100644 (file)
index 0000000..452bd26
--- /dev/null
@@ -0,0 +1 @@
+e6be079518a7a35fb776b1e34f3e03c4
\ No newline at end of file
diff --git a/LayoutTests/svg/custom/hit-test-path-stroke-expected.png b/LayoutTests/svg/custom/hit-test-path-stroke-expected.png
new file mode 100644 (file)
index 0000000..9821de2
Binary files /dev/null and b/LayoutTests/svg/custom/hit-test-path-stroke-expected.png differ
diff --git a/LayoutTests/svg/custom/hit-test-path-stroke-expected.txt b/LayoutTests/svg/custom/hit-test-path-stroke-expected.txt
new file mode 100644 (file)
index 0000000..6c69a8a
--- /dev/null
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x576
+      RenderBlock {P} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 560x18
+          text run at (0,0) width 560: "If you see this, then SVG hit testing on paths works - the arrow was successfully clicked."
diff --git a/LayoutTests/svg/custom/hit-test-path-stroke.svg b/LayoutTests/svg/custom/hit-test-path-stroke.svg
new file mode 100644 (file)
index 0000000..ef45573
--- /dev/null
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Basic//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd">
+<!--======================================================================-->
+<!--=  Copyright 2000 World Wide Web Consortium, (Massachusetts          =-->
+<!--=  Institute of Technology, Institut National de Recherche en        =-->
+<!--=  Informatique et en Automatique, Keio University). All Rights      =-->
+<!--=  Reserved. See http://www.w3.org/Consortium/Legal/.                =-->
+<!--======================================================================-->
+<!-- ===================================================================== -->
+<!-- linking-a-01-b.svg                                             -->
+<!-- Notes.  This is based on sample files by Kelvin Lawrence et al, for   -->
+<!-- IBM's SVGview.  Requires supplemental file, linkingCircle-f.svg.        -->
+<!-- Author : Lofton Henderson  03-April-2000                              -->
+<!--======================================================================-->
+<svg version="1.1" baseProfile="basic" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="svg-root" width="100%" height="100%" viewBox="0 0 480 360" onload="clickLinkSoon()">
+
+<script>
+if (window.layoutTestController)
+    window.layoutTestController.waitUntilDone();
+
+function clickLinkSoon()
+{
+    window.setTimeout("clickLinkNow()", 0);
+}
+
+function clickLinkNow() {
+    if (window.eventSender) {
+        eventSender.mouseMoveTo(200, 170);
+        eventSender.mouseDown();
+        eventSender.mouseUp();
+    }
+}
+</script>
+
+       <title id="test-title">linking-a-01-b</title>
+       <desc id="test-desc">Basic in-bound link object addressing formats.</desc>
+       <g id="test-body-content" transform="scale(2)">
+               <a xlink:href="resources/link-target.html">
+                       <path fill="none" stroke-width="20" stroke="blue" d="M 185,40 h -100 v -12 l -45 36 l 45 36 v -12 h 100 z"/>
+               </a>
+       </g>
+       <text id="revision" x="10" y="340" font-size="20" stroke="none" fill="black">Clicking the arrow should load a new page.</text>
+       <rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000000"/>
+</svg>
index d78adae2c1be0cd1a8ea26e6fc41f0ca4930f269..78a203ac552cb60b2a0cfd20ffee3e02e2c03672 100644 (file)
@@ -1,3 +1,16 @@
+2006-11-22  Rob Buis  <buis@kde.org>
+
+        Reviewed by Eric.
+
+        http://bugs.webkit.org/show_bug.cgi?id=11661
+        SVG: stroke not sensitive to mouse events (hit testing fails)
+
+        Use mapAbsolutePointToLocal when hit-testing strokes.
+
+        * rendering/RenderPath.cpp:
+        (WebCore::RenderPath::fillContains):
+        (WebCore::RenderPath::nodeAtPoint):
+
 2006-11-21  Anders Carlsson  <acarlsson@apple.com>
 
         Reviewed by Mitz.
index d5fde1b23dd522ecb465b34cdd7bcb07fc779a52..5add510803df4de1fa2814f4debd6aaef12c826b 100644 (file)
@@ -81,7 +81,7 @@ bool RenderPath::fillContains(const FloatPoint& point, bool requiresFill) const
     if (requiresFill && !KSVGPainterFactory::fillPaintServer(style(), this))
         return false;
 
-    return path().contains(mapAbsolutePointToLocal(point), style()->svgStyle()->fillRule());
+    return path().contains(point, style()->svgStyle()->fillRule());
 }
 
 FloatRect RenderPath::relativeBBox(bool includeStroke) const
@@ -294,7 +294,7 @@ bool RenderPath::nodeAtPoint(const HitTestRequest& request, HitTestResult& resul
     
     bool isVisible = (style()->visibility() == VISIBLE);
     if (isVisible || !hitRules.requireVisible) {
-        FloatPoint hitPoint(_x,_y);
+        FloatPoint hitPoint = mapAbsolutePointToLocal(FloatPoint(_x, _y));
         if ((hitRules.canHitStroke && (style()->svgStyle()->hasStroke() || !hitRules.requireStroke) && strokeContains(hitPoint, hitRules.requireStroke))
             || (hitRules.canHitFill && (style()->svgStyle()->hasFill() || !hitRules.requireFill) && fillContains(hitPoint, hitRules.requireFill))) {
             setInnerNode(result);