Reviewed by Oliver.
authoroliver <oliver@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Oct 2007 12:31:21 +0000 (12:31 +0000)
committeroliver <oliver@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Oct 2007 12:31:21 +0000 (12:31 +0000)
        http://bugs.webkit.org/show_bug.cgi?id=14144
        All tx/ty (parentX/parentY) usage should be removed from SVG renders
        http://bugs.webkit.org/show_bug.cgi?id=13981
        <br> prevents click handler from firing

        Fix the hit testing issues by making RenderSVGRoot take its m_x, m_y
        into account in the absolute transform.

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

LayoutTests/ChangeLog
LayoutTests/svg/custom/hit-test-with-br-expected.checksum [new file with mode: 0644]
LayoutTests/svg/custom/hit-test-with-br-expected.png [new file with mode: 0644]
LayoutTests/svg/custom/hit-test-with-br-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/hit-test-with-br.xhtml [new file with mode: 0644]
LayoutTests/svg/custom/image-parent-translation-expected.txt
WebCore/ChangeLog
WebCore/rendering/RenderPath.cpp
WebCore/rendering/RenderSVGImage.cpp
WebCore/rendering/RenderSVGRoot.cpp

index 395b437a1409500dd978152034a980be396bfc58..1df5efa53cebf5bb56d336c77e6858fb25288de0 100644 (file)
@@ -1,3 +1,24 @@
+2007-06-19  Rob Buis  <buis@kde.org>
+
+        Reviewed by Oliver.
+
+        Testcase for:
+        http://bugs.webkit.org/show_bug.cgi?id=14144
+        All tx/ty (parentX/parentY) usage should be removed from SVG renders
+        http://bugs.webkit.org/show_bug.cgi?id=13981
+        <br> prevents click handler from firing
+
+        The updated testcases are improvements.
+
+        * svg/custom/hit-test-with-br-expected.checksum: Added.
+        * svg/custom/hit-test-with-br-expected.png: Added.
+        * svg/custom/hit-test-with-br-expected.txt: Added.
+        * svg/custom/hit-test-with-br.xhtml: Added.
+        * svg/custom/image-parent-translation-expected.txt:
+        * svg/custom/invisible-text-after-scrolling-expected.txt:
+        * svg/custom/second-inline-text-expected.txt:
+        * svg/custom/svg-float-border-padding-expected.txt:
+
 2007-06-16  Nikolas Zimmermann  <zimmermann@kde.org>
 
         Reviewed by Eric.
diff --git a/LayoutTests/svg/custom/hit-test-with-br-expected.checksum b/LayoutTests/svg/custom/hit-test-with-br-expected.checksum
new file mode 100644 (file)
index 0000000..30065dc
--- /dev/null
@@ -0,0 +1 @@
+ee70b85e23c655a5c55a28d92c8e199f
\ No newline at end of file
diff --git a/LayoutTests/svg/custom/hit-test-with-br-expected.png b/LayoutTests/svg/custom/hit-test-with-br-expected.png
new file mode 100644 (file)
index 0000000..98f2a8b
Binary files /dev/null and b/LayoutTests/svg/custom/hit-test-with-br-expected.png differ
diff --git a/LayoutTests/svg/custom/hit-test-with-br-expected.txt b/LayoutTests/svg/custom/hit-test-with-br-expected.txt
new file mode 100644 (file)
index 0000000..529de5d
--- /dev/null
@@ -0,0 +1,15 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x95
+  RenderBlock {html} at (0,0) size 800x95
+    RenderBody {body} at (8,16) size 784x71
+      RenderBlock {p} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 658x18
+          text run at (0,0) width 435: "A test for hit testing when an svg container is relatively positioned in "
+          text run at (435,0) width 223: "a containing block. See bug 13981."
+      RenderBlock (anonymous) at (0,34) size 784x37
+        RenderBR {br} at (0,0) size 0x18
+        RenderSVGContainer {svg} at (8,68) size 720x15
+          RenderPath {rect} at (8,68) size 720x15 [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L720.00,0.00L720.00,15.00L0.00,15.00"]
+        RenderText {#text} at (0,0) size 0x0
+caret: position 0 of child 3 {br} of child 3 {body} of child 0 {html} of document
diff --git a/LayoutTests/svg/custom/hit-test-with-br.xhtml b/LayoutTests/svg/custom/hit-test-with-br.xhtml
new file mode 100644 (file)
index 0000000..90a21a2
--- /dev/null
@@ -0,0 +1,35 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+<title>&lt;br&gt; prevents click handler from firing</title>
+<script>
+function clickHandler(evt)
+{
+    evt.target.style.fill = "green";
+}
+
+if (window.layoutTestController)
+  layoutTestController.waitUntilDone();
+
+function doClick() {
+  if (window.eventSender) {
+      eventSender.mouseMoveTo(10, 70);
+      eventSender.mouseDown();
+      eventSender.mouseUp();
+      layoutTestController.notifyDone();
+  }
+}
+
+setTimeout("doClick()", 0);
+</script>
+  </head>
+  <body>
+    <p>
+    A test for hit testing when an svg container is relatively positioned in
+    a containing block. See bug 13981.
+    </p>
+    <br />
+    <svg xmlns="http://www.w3.org/2000/svg" width="720" height="15">
+      <rect width="720" height="15" onclick="clickHandler(evt)" />
+    </svg>
+  </body>
+</html>
index 93f5fd924d55d6a135d106ea82c6cf27e46e46e3..a226e44c2bfab977917d23845011986472e8429d 100644 (file)
@@ -21,8 +21,8 @@ layer at (0,0) size 800x218
         RenderText {#text} at (0,0) size 0x0
         RenderInline {div} at (0,0) size 75x18
           RenderText {#text} at (0,0) size 0x0
-          RenderSVGContainer {svg} at (5,128) size 81x81
+          RenderSVGContainer {svg} at (84,128) size 81x81
             RenderImage {image} at (0,0) size 75x75
-            RenderPath {rect} at (5,128) size 81x81 [stroke={[type=SOLID] [color=#FF0000] [stroke width=6.00]}] [data="M0.00,0.00L75.00,0.00L75.00,75.00L0.00,75.00"]
+            RenderPath {rect} at (84,128) size 81x81 [stroke={[type=SOLID] [color=#FF0000] [stroke width=6.00]}] [data="M0.00,0.00L75.00,0.00L75.00,75.00L0.00,75.00"]
           RenderText {#text} at (0,0) size 0x0
         RenderText {#text} at (0,0) size 0x0
index a6e19c7ce6388379ffc42ef1b0474857ec99deed..05d06490f1559a8871a0a2a7725b2db42f3c5da5 100644 (file)
@@ -1,3 +1,24 @@
+2007-06-19  Rob Buis  <buis@kde.org>
+
+        Reviewed by Oliver.
+
+        http://bugs.webkit.org/show_bug.cgi?id=14144
+        All tx/ty (parentX/parentY) usage should be removed from SVG renders
+        http://bugs.webkit.org/show_bug.cgi?id=13981
+        <br> prevents click handler from firing
+
+        Fix the hit testing issues by making RenderSVGRoot take its m_x, m_y
+        into account in the absolute transform.
+
+        * rendering/RenderPath.cpp:
+        (WebCore::RenderPath::absoluteRects):
+        (WebCore::RenderPath::nodeAtPoint):
+        * rendering/RenderSVGImage.cpp:
+        (WebCore::RenderSVGImage::nodeAtPoint):
+        * rendering/RenderSVGRoot.cpp:
+        (WebCore::RenderSVGRoot::absoluteTransform):
+        (WebCore::RenderSVGRoot::nodeAtPoint):
+
 2007-06-16  Nikolas Zimmermann  <zimmermann@kde.org>
 
         Reviewed by Eric.
index 368c9f10a068fd1524a6e1dbe4327dd9bfc6ed5f..a5b817ad237fa8d942bf8af2857aa72b38a577f1 100644 (file)
@@ -231,18 +231,18 @@ void RenderPath::addFocusRingRects(GraphicsContext* graphicsContext, int tx, int
     graphicsContext->addFocusRingRect(IntRect(boundingBox.x(), boundingBox.y(), boundingBox.width(), boundingBox.height()));
 }
 
-void RenderPath::absoluteRects(Vector<IntRect>& rects, int _tx, int _ty, bool)
+void RenderPath::absoluteRects(Vector<IntRect>& rects, int, int, bool)
 {
     rects.append(absoluteClippedOverflowRect());
 }
 
-bool RenderPath::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int _x, int _y, int _tx, int _ty, HitTestAction hitTestAction)
+bool RenderPath::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int _x, int _y, int, int, HitTestAction hitTestAction)
 {
     // We only draw in the forground phase, so we only hit-test then.
     if (hitTestAction != HitTestForeground)
         return false;
     
-    IntPoint absolutePoint(_x - _tx, _y - _ty);
+    IntPoint absolutePoint(_x, _y);
 
     PointerEventsHitRules hitRules(PointerEventsHitRules::SVG_PATH_HITTESTING, style()->svgStyle()->pointerEvents());
 
@@ -446,7 +446,7 @@ bool RenderPath::hasRelativeValues() const
 {
     return static_cast<SVGStyledElement*>(element())->hasRelativeValues();
 }
+
 }
 
 #endif // ENABLE(SVG)
index 04d820cab2c71160abbcf26a3b44fe09b3675a5b..3bba501d947dba91305b0536fbaabd1f59722ff9 100644 (file)
@@ -176,7 +176,7 @@ void RenderSVGImage::paint(PaintInfo& paintInfo, int, int)
     paintInfo.context->restore();
 }
 
-bool RenderSVGImage::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int _x, int _y, int _tx, int _ty, HitTestAction hitTestAction)
+bool RenderSVGImage::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int _x, int _y, int, int, HitTestAction hitTestAction)
 {
     // We only draw in the forground phase, so we only hit-test then.
     if (hitTestAction != HitTestForeground)
index e98bd8d36c221299855ae5910a6ab07e7de08e63..4d197f714c48f59e0917a75553f4fae9209dae9f 100644 (file)
@@ -299,6 +299,7 @@ void RenderSVGRoot::absoluteRects(Vector<IntRect>& rects, int, int)
 AffineTransform RenderSVGRoot::absoluteTransform() const
 {
     AffineTransform ctm = RenderContainer::absoluteTransform();
+    ctm.translate(m_x, m_y);
     SVGSVGElement* svg = static_cast<SVGSVGElement*>(element());
     ctm.scale(svg->currentScale());
     ctm.translate(svg->currentTranslate().x(), svg->currentTranslate().y());
@@ -401,6 +402,7 @@ AffineTransform RenderSVGRoot::getAspectRatio(const FloatRect& logical, const Fl
 
 bool RenderSVGRoot::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int _x, int _y, int _tx, int _ty, HitTestAction hitTestAction)
 {
+    AffineTransform ctm = RenderContainer::absoluteTransform();
     if (!viewport().isEmpty()
         && style()->overflowX() == OHIDDEN
         && style()->overflowY() == OHIDDEN) {
@@ -410,7 +412,6 @@ bool RenderSVGRoot::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
         // Check if we need to do anything at all.
         IntRect overflowBox = overflowRect(false);
         overflowBox.move(tx, ty);
-        AffineTransform ctm = RenderContainer::absoluteTransform();
         ctm.translate(viewport().x(), viewport().y());
         double localX, localY;
         ctm.inverse().map(_x - _tx, _y - _ty, &localX, &localY);
@@ -418,8 +419,10 @@ bool RenderSVGRoot::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
             return false;
     }
 
+    int sx = (_tx - ctm.e()); // scroll offset
+    int sy = (_ty - ctm.f()); // scroll offset
     for (RenderObject* child = lastChild(); child; child = child->previousSibling()) {
-        if (child->nodeAtPoint(request, result, _x, _y, _tx, _ty, hitTestAction)) {
+        if (child->nodeAtPoint(request, result, _x - sx, _y - sy, 0, 0, hitTestAction)) {
             updateHitTestResult(result, IntPoint(_x - _tx, _y - _ty));
             return true;
         }