2007-01-17 Eric Seidel <eric@webkit.org>
authoreseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Jan 2007 14:59:18 +0000 (14:59 +0000)
committereseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Jan 2007 14:59:18 +0000 (14:59 +0000)
        Reviewed by rwlbuis.

        Test: svg/custom/inner-svg-hit-test.svg

        * rendering/RenderSVGContainer.cpp:
        (WebCore::RenderSVGContainer::nodeAtPoint): never allow containers to be hit.

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

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

index 7664c95..c50177c 100644 (file)
@@ -1,5 +1,14 @@
 2007-01-17  Eric Seidel  <eric@webkit.org>
 
+        Reviewed by rwlbuis.
+
+        * svg/custom/inner-svg-hit-test-expected.checksum: Added.
+        * svg/custom/inner-svg-hit-test-expected.png: Added.
+        * svg/custom/inner-svg-hit-test-expected.txt: Added.
+        * svg/custom/inner-svg-hit-test.svg: Added.
+
+2007-01-17  Eric Seidel  <eric@webkit.org>
+
         Reviewed by mitz and rwlbuis.
         
         SVGs don't work as background images.
diff --git a/LayoutTests/svg/custom/inner-svg-hit-test-expected.checksum b/LayoutTests/svg/custom/inner-svg-hit-test-expected.checksum
new file mode 100644 (file)
index 0000000..3a4f1f7
--- /dev/null
@@ -0,0 +1 @@
+16310588467cfc20d551635abc59b784
\ No newline at end of file
diff --git a/LayoutTests/svg/custom/inner-svg-hit-test-expected.png b/LayoutTests/svg/custom/inner-svg-hit-test-expected.png
new file mode 100644 (file)
index 0000000..3db2634
Binary files /dev/null and b/LayoutTests/svg/custom/inner-svg-hit-test-expected.png differ
diff --git a/LayoutTests/svg/custom/inner-svg-hit-test-expected.txt b/LayoutTests/svg/custom/inner-svg-hit-test-expected.txt
new file mode 100644 (file)
index 0000000..209a1ad
--- /dev/null
@@ -0,0 +1,5 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+    RenderSVGContainer {svg} at (0,0) size 100x100
+      RenderPath {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,100.00L0.00,100.00"]
+      RenderSVGContainer {svg} at (0,0) size 0x0
diff --git a/LayoutTests/svg/custom/inner-svg-hit-test.svg b/LayoutTests/svg/custom/inner-svg-hit-test.svg
new file mode 100644 (file)
index 0000000..f6f16ea
--- /dev/null
@@ -0,0 +1,23 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+    <rect id="rect" width="100" height="100" fill="red" />
+    <svg onclick="hit()">
+    </svg>
+    <script>
+      <![CDATA[
+        var hitDetected = 0;
+        function hit() {
+          hitDetected = 1;
+        }
+        
+        if (window.eventSender) {
+          eventSender.mouseMoveTo(200, 200);
+          eventSender.mouseDown();
+          eventSender.mouseUp();
+          
+          if (hitDetected == 0) {
+            document.getElementById('rect').style.fill = 'green';
+          }
+        }
+      ]]>
+    </script>
+</svg>
index d005900..80d6169 100644 (file)
@@ -1,3 +1,12 @@
+2007-01-17  Eric Seidel  <eric@webkit.org>
+
+        Reviewed by rwlbuis.
+
+        Test: svg/custom/inner-svg-hit-test.svg
+
+        * rendering/RenderSVGContainer.cpp:
+        (WebCore::RenderSVGContainer::nodeAtPoint): never allow containers to be hit.
+
 2007-01-17  Lars Knoll <lars@trolltech.com>
 
         Reviewed by Zack
index b96c194..e8c171d 100644 (file)
@@ -418,7 +418,16 @@ bool RenderSVGContainer::nodeAtPoint(const HitTestRequest& request, HitTestResul
             return false;
     }
 
-    return RenderContainer::nodeAtPoint(request, result, _x, _y, _tx, _ty, hitTestAction);
+    for (RenderObject* child = lastChild(); child; child = child->previousSibling()) {
+        if (child->nodeAtPoint(request, result, _x, _y, _tx, _ty, hitTestAction)) {
+            updateHitTestResult(result, IntPoint(_x - _tx, _y - _ty));
+            return true;
+        }
+    }
+    
+    // Spec: Only graphical elements can be targeted by the mouse, period.
+    // 16.4: "If there are no graphics elements whose relevant graphics content is under the pointer (i.e., there is no target element), the event is not dispatched."
+    return false;
 }
 
 }