Fix SVG hit testing when padding is present
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Nov 2011 15:38:09 +0000 (15:38 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Nov 2011 15:38:09 +0000 (15:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=37325

Patch by Philip Rogers <pdr@google.com> on 2011-11-15
Reviewed by Nikolas Zimmermann.

Source/WebCore:

Test: svg/hittest/svg-padding.xhtml

* rendering/svg/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::nodeAtPoint):

LayoutTests:

* svg/hittest/svg-padding-expected.txt: Added.
* svg/hittest/svg-padding.xhtml: Added.

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

LayoutTests/ChangeLog
LayoutTests/svg/hittest/svg-padding-expected.txt [new file with mode: 0644]
LayoutTests/svg/hittest/svg-padding.xhtml [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/svg/RenderSVGRoot.cpp

index 2cc2b648c183e5540e2e8c6e9a1902d925f46eb2..1c800f166aead640e86b6aa1b1cc6a725dcdc7ad 100644 (file)
@@ -1,3 +1,13 @@
+2011-11-15  Philip Rogers  <pdr@google.com>
+
+        Fix SVG hit testing when padding is present
+        https://bugs.webkit.org/show_bug.cgi?id=37325
+
+        Reviewed by Nikolas Zimmermann.
+
+        * svg/hittest/svg-padding-expected.txt: Added.
+        * svg/hittest/svg-padding.xhtml: Added.
+
 2011-11-15  Philippe Normand  <pnormand@igalia.com>
 
         Unreviewed, marked
diff --git a/LayoutTests/svg/hittest/svg-padding-expected.txt b/LayoutTests/svg/hittest/svg-padding-expected.txt
new file mode 100644 (file)
index 0000000..53cdf1e
--- /dev/null
@@ -0,0 +1 @@
+PASSED
diff --git a/LayoutTests/svg/hittest/svg-padding.xhtml b/LayoutTests/svg/hittest/svg-padding.xhtml
new file mode 100644 (file)
index 0000000..451e311
--- /dev/null
@@ -0,0 +1,34 @@
+<html xmlns='http://www.w3.org/1999/xhtml'>
+  <head>
+    <style>
+      body {
+          margin: 0px;
+          padding: 0px;
+          border: 1px solid black;
+      }
+      #square {
+        fill: blue;
+      }
+      #square:hover {
+        fill: green;
+      }
+    </style>
+  </head>
+  <body>
+    <table><tr><td>
+      <svg width='100px' height='100px' style='padding: 50px' xmlns='http://www.w3.org/2000/svg'>
+        <svg>
+          <rect id='square' width='100' height='100' onclick='alert("You clicked the square! It worked!")'/>
+        </svg>
+      </svg>
+    </td></tr></table>
+    <script><![CDATA[
+    if (window.layoutTestController) {
+      layoutTestController.dumpAsText();
+    }
+    var hitElement = document.elementFromPoint(75, 75);
+    var hitSuccess = hitElement && hitElement == document.getElementById("square");
+    document.body.innerHTML = hitSuccess ? "PASSED" : "FAIL, hit " + hitElement + " @ 50, 50";
+    ]]></script>
+  </body>
+</html>
index 810b77bce455afd27f6aab4e06c4c4ac432238a6..7fd3ac750ee1a3c49381ff852cef2b7a8dd2f76d 100644 (file)
@@ -1,3 +1,15 @@
+2011-11-15  Philip Rogers  <pdr@google.com>
+
+        Fix SVG hit testing when padding is present
+        https://bugs.webkit.org/show_bug.cgi?id=37325
+
+        Reviewed by Nikolas Zimmermann.
+
+        Test: svg/hittest/svg-padding.xhtml
+
+        * rendering/svg/RenderSVGRoot.cpp:
+        (WebCore::RenderSVGRoot::nodeAtPoint):
+
 2011-11-15  Pavel Feldman  <pfeldman@google.com>
 
         Web Inspector: move generic code from DevTools.js into the WebCore.
index 21f69888358c7020dfd6ebdf877c0dfb09e71c88..5e0886882f1878d6c84b7bc799ff5d8ff7d02800 100644 (file)
@@ -434,8 +434,7 @@ bool RenderSVGRoot::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
     LayoutPoint pointInBorderBox = pointInParent - parentOriginToBorderBox();
 
     // Note: For now, we're ignoring hits to border and padding for <svg>
-    LayoutPoint pointInContentBox = pointInBorderBox - borderOriginToContentBox();
-    if (!contentBoxRect().contains(pointInContentBox))
+    if (!contentBoxRect().contains(pointInBorderBox))
         return false;
 
     LayoutPoint localPoint = localToParentTransform().inverse().mapPoint(pointInParent);