SVG panning y-axis is flipped in WebKit2
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Aug 2011 22:02:52 +0000 (22:02 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Aug 2011 22:02:52 +0000 (22:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=65800
<rdar://problem/9908012>

Reviewed by Darin Adler.

We previously were not transforming the pointer coordinates passed
to SVGDocument's panning implementation into the coordinate space of
the contents, so on different platforms, the drag direction was different.

Test: svg/custom/pan-direction.svg

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

LayoutTests/ChangeLog
LayoutTests/platform/chromium-linux/svg/custom/pan-direction-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/custom/pan-direction-expected.png [new file with mode: 0644]
LayoutTests/svg/custom/pan-direction-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/pan-direction.svg [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/EventHandler.cpp
Source/WebCore/svg/SVGDocument.cpp

index 19bb267..ca7282f 100644 (file)
@@ -1,3 +1,18 @@
+2011-08-30  Tim Horton  <timothy_horton@apple.com>
+
+        SVG panning y-axis is flipped in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=65800
+        <rdar://problem/9908012>
+
+        Reviewed by Darin Adler.
+
+        Add a test which attempts to pan an SVG using eventSender.
+
+        * platform/chromium-linux/svg/custom/pan-direction-expected.png: Added.
+        * platform/mac/svg/custom/pan-direction-expected.png: Added.
+        * svg/custom/pan-direction-expected.txt: Added.
+        * svg/custom/pan-direction.svg: Added.
+
 2011-08-30  Cary Clark  <caryclark@google.com>
 
         LayoutTest expected results for Skia on Mac (animations and canvas directories only)
diff --git a/LayoutTests/platform/chromium-linux/svg/custom/pan-direction-expected.png b/LayoutTests/platform/chromium-linux/svg/custom/pan-direction-expected.png
new file mode 100644 (file)
index 0000000..b2902fd
Binary files /dev/null and b/LayoutTests/platform/chromium-linux/svg/custom/pan-direction-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/custom/pan-direction-expected.png b/LayoutTests/platform/mac/svg/custom/pan-direction-expected.png
new file mode 100644 (file)
index 0000000..f479c2c
Binary files /dev/null and b/LayoutTests/platform/mac/svg/custom/pan-direction-expected.png differ
diff --git a/LayoutTests/svg/custom/pan-direction-expected.txt b/LayoutTests/svg/custom/pan-direction-expected.txt
new file mode 100644 (file)
index 0000000..4342509
--- /dev/null
@@ -0,0 +1,6 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (0,0) size 800x600
+    RenderSVGPath {rect} at (0,0) size 800x600 [fill={[type=SOLID] [color=#FF0000]}] [x=-1000.00] [y=-1000.00] [width=5000.00] [height=5000.00]
+    RenderSVGPath {rect} at (50,20) size 20x20 [fill={[type=SOLID] [color=#008000]}] [x=50.00] [y=50.00] [width=20.00] [height=20.00]
diff --git a/LayoutTests/svg/custom/pan-direction.svg b/LayoutTests/svg/custom/pan-direction.svg
new file mode 100644 (file)
index 0000000..fc0bd48
--- /dev/null
@@ -0,0 +1,22 @@
+<?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">
+<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%" onload="runTest()">
+   <script type="text/ecmascript"><![CDATA[
+      function testPanUp(y) {
+         eventSender.mouseMoveTo(50, 50);
+         eventSender.mouseDown(0, ['shiftKey']);
+         eventSender.mouseMoveTo(50, 50 - y);
+         eventSender.mouseUp();
+      }
+      function runTest() {
+         if (window.eventSender) {
+            testPanUp(30);
+         } else {
+            // in manual mode
+            alert("Please use run-webkit-tests.");
+         }
+     }
+   ]]></script>
+   <rect x="-1000" y="-1000" width="5000" height="5000" fill="red" />
+   <rect x="50" y="50" width="20" height="20" fill="green" />
+</svg>
index 93d21df..b673349 100644 (file)
@@ -1,3 +1,25 @@
+2011-08-30  Tim Horton  <timothy_horton@apple.com>
+
+        SVG panning y-axis is flipped in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=65800
+        <rdar://problem/9908012>
+
+        Reviewed by Darin Adler.
+
+        We previously were not transforming the pointer coordinates passed
+        to SVGDocument's panning implementation into the coordinate space of
+        the contents, so on different platforms, the drag direction was different.
+
+        Test: svg/custom/pan-direction.svg
+
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::handleMousePressEvent):
+        (WebCore::EventHandler::handleMouseMoveEvent):
+        (WebCore::EventHandler::handleMouseReleaseEvent):
+        * svg/SVGDocument.cpp:
+        (WebCore::SVGDocument::startPan):
+        (WebCore::SVGDocument::updatePan):
+
 2011-08-30  Adam Barth  <abarth@webkit.org>
 
         Flaky crash with JavaScript URLs
index 08fd277..a1f1cfc 100644 (file)
@@ -473,7 +473,7 @@ bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& eve
         && static_cast<SVGDocument*>(m_frame->document())->zoomAndPanEnabled()) {
         if (event.event().shiftKey() && singleClick) {
             m_svgPan = true;
-            static_cast<SVGDocument*>(m_frame->document())->startPan(event.event().pos());
+            static_cast<SVGDocument*>(m_frame->document())->startPan(m_frame->view()->windowToContents(event.event().pos()));
             return true;
         }
     }
@@ -1561,7 +1561,7 @@ bool EventHandler::handleMouseMoveEvent(const PlatformMouseEvent& mouseEvent, Hi
 
 #if ENABLE(SVG)
     if (m_svgPan) {
-        static_cast<SVGDocument*>(m_frame->document())->updatePan(m_currentMousePosition);
+        static_cast<SVGDocument*>(m_frame->document())->updatePan(m_frame->view()->windowToContents(m_currentMousePosition));
         return true;
     }
 #endif
@@ -1682,7 +1682,7 @@ bool EventHandler::handleMouseReleaseEvent(const PlatformMouseEvent& mouseEvent)
 #if ENABLE(SVG)
     if (m_svgPan) {
         m_svgPan = false;
-        static_cast<SVGDocument*>(m_frame->document())->updatePan(m_currentMousePosition);
+        static_cast<SVGDocument*>(m_frame->document())->updatePan(m_frame->view()->windowToContents(m_currentMousePosition));
         return true;
     }
 #endif
index 9b200b7..f543948 100644 (file)
@@ -83,13 +83,13 @@ bool SVGDocument::zoomAndPanEnabled() const
 void SVGDocument::startPan(const FloatPoint& start)
 {
     if (rootElement())
-        m_translate = FloatPoint(start.x() - rootElement()->currentTranslate().x(), rootElement()->currentTranslate().y() + start.y());
+        m_translate = FloatPoint(start.x() - rootElement()->currentTranslate().x(), start.y() - rootElement()->currentTranslate().y());
 }
 
 void SVGDocument::updatePan(const FloatPoint& pos) const
 {
     if (rootElement()) {
-        rootElement()->setCurrentTranslate(FloatPoint(pos.x() - m_translate.x(), m_translate.y() - pos.y()));
+        rootElement()->setCurrentTranslate(FloatPoint(pos.x() - m_translate.x(), pos.y() - m_translate.y()));
         if (renderer())
             renderer()->repaint();
     }