[BlackBerry] Set mouse document position for mouse event in DRT.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Feb 2013 18:11:32 +0000 (18:11 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Feb 2013 18:11:32 +0000 (18:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=109094.

Patch by Tiancheng Jiang <tijiang@rim.com> on 2013-02-11
Reviewed by Rob Buis.

RIM PR 246976.
Internally Reviewed by Nima Ghanavatian & Genevieve Mak.

Set mouse document position when we create mouse event in DRT.

* DumpRenderTree/blackberry/EventSender.cpp:
(setMouseEventDocumentPos):
(mouseDownCallback):
(mouseUpCallback):
(mouseMoveToCallback):

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

Tools/ChangeLog
Tools/DumpRenderTree/blackberry/EventSender.cpp

index 96fae34e546856f68bf02d8ee6672bf65ba1cb83..00a84a2a144ba6e355cb33be095252644e159993 100644 (file)
@@ -1,3 +1,21 @@
+2013-02-11  Tiancheng Jiang  <tijiang@rim.com>
+
+        [BlackBerry] Set mouse document position for mouse event in DRT.
+        https://bugs.webkit.org/show_bug.cgi?id=109094.
+
+        Reviewed by Rob Buis.
+
+        RIM PR 246976.
+        Internally Reviewed by Nima Ghanavatian & Genevieve Mak.
+
+        Set mouse document position when we create mouse event in DRT.
+
+        * DumpRenderTree/blackberry/EventSender.cpp:
+        (setMouseEventDocumentPos):
+        (mouseDownCallback):
+        (mouseUpCallback):
+        (mouseMoveToCallback):
+
 2013-02-11  Mike Lattanzio  <mlattanzio@rim.com>
 
         [BlackBerry] Add graphics subdirectory to include path.
index b2a8f2216c6a5bd2394888348a7e225f77cd39d0..941a2edfa238fa4f153cfa903aaa714a6be2789d 100644 (file)
@@ -26,6 +26,7 @@
 #include "DumpRenderTreeSupport.h"
 #include "IntPoint.h"
 #include "NotImplemented.h"
+#include "WebKitThreadViewportAccessor.h"
 #include "WebPage.h"
 
 #include <BlackBerryPlatformKeyboardEvent.h>
@@ -70,17 +71,34 @@ static JSValueRef contextClickCallback(JSContextRef context, JSObjectRef functio
     return JSValueMakeUndefined(context);
 }
 
+void setMouseEventDocumentPos(BlackBerry::Platform::MouseEvent &event, const BlackBerry::WebKit::WebPage* page)
+{
+    // We have added document viewport position and document content position as members of the mouse event, when we create the event, we should initialize them as well.
+    BlackBerry::Platform::ViewportAccessor* viewportAccessor = page->webkitThreadViewportAccessor();
+    IntPoint documentContentPos = viewportAccessor->roundToDocumentFromPixelContents(BlackBerry::Platform::FloatPoint(viewportAccessor->pixelContentsFromViewport(lastMousePosition)));
+    IntPoint documentViewportMousePos = viewportAccessor->roundToDocumentFromPixelContents(BlackBerry::Platform::FloatPoint(lastMousePosition));
+    event.populateDocumentPosition(documentViewportMousePos, documentContentPos);
+}
+
 static JSValueRef mouseDownCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     BlackBerry::WebKit::WebPage* page = BlackBerry::WebKit::DumpRenderTree::currentInstance()->page();
-    page->mouseEvent(BlackBerry::Platform::MouseEvent(BlackBerry::Platform::MouseEvent::ScreenLeftMouseButton, 0, lastMousePosition, IntPoint::zero(), 0, 0, 0));
+    BlackBerry::Platform::MouseEvent event(BlackBerry::Platform::MouseEvent::ScreenLeftMouseButton, 0, lastMousePosition, IntPoint::zero(), 0, 0, 0);
+
+    setMouseEventDocumentPos(event, page);
+
+    page->mouseEvent(event);
     return JSValueMakeUndefined(context);
 }
 
 static JSValueRef mouseUpCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     BlackBerry::WebKit::WebPage* page = BlackBerry::WebKit::DumpRenderTree::currentInstance()->page();
-    page->mouseEvent(BlackBerry::Platform::MouseEvent(0, BlackBerry::Platform::MouseEvent::ScreenLeftMouseButton, lastMousePosition, IntPoint::zero(), 0, 0, 0));
+    BlackBerry::Platform::MouseEvent event(0, BlackBerry::Platform::MouseEvent::ScreenLeftMouseButton, lastMousePosition, IntPoint::zero(), 0, 0, 0);
+
+    setMouseEventDocumentPos(event, page);
+
+    page->mouseEvent(event);
     return JSValueMakeUndefined(context);
 }
 
@@ -96,8 +114,11 @@ static JSValueRef mouseMoveToCallback(JSContextRef context, JSObjectRef function
 
     lastMousePosition = IntPoint(x, y);
     BlackBerry::WebKit::WebPage* page = BlackBerry::WebKit::DumpRenderTree::currentInstance()->page();
-    page->mouseEvent(BlackBerry::Platform::MouseEvent(BlackBerry::Platform::MouseEvent::ScreenLeftMouseButton, BlackBerry::Platform::MouseEvent::ScreenLeftMouseButton, lastMousePosition, IntPoint::zero(), 0, 0, 0));
+    BlackBerry::Platform::MouseEvent event(BlackBerry::Platform::MouseEvent::ScreenLeftMouseButton, BlackBerry::Platform::MouseEvent::ScreenLeftMouseButton, lastMousePosition, IntPoint::zero(), 0, 0, 0);
+
+    setMouseEventDocumentPos(event, page);
 
+    page->mouseEvent(event);
 
     return JSValueMakeUndefined(context);
 }