Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(304)

Unified Diff: third_party/WebKit/Source/core/events/PointerEventFactory.cpp

Issue 1960233002: Fix mouse pointer event clientX/Y (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix a typo Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/events/PointerEventFactory.cpp
diff --git a/third_party/WebKit/Source/core/events/PointerEventFactory.cpp b/third_party/WebKit/Source/core/events/PointerEventFactory.cpp
index 0d88fc6d8148197b56ceeb685b710c4e2bfd354d..9eed8a9e3ae87d8169da4ce58f9b71870e456669 100644
--- a/third_party/WebKit/Source/core/events/PointerEventFactory.cpp
+++ b/third_party/WebKit/Source/core/events/PointerEventFactory.cpp
@@ -4,6 +4,7 @@
#include "core/events/PointerEventFactory.h"
+#include "core/frame/FrameView.h"
#include "platform/geometry/FloatSize.h"
namespace blink {
@@ -89,7 +90,7 @@ void PointerEventFactory::setBubblesAndCancelable(PointerEventInit& pointerEvent
PointerEvent* PointerEventFactory::create(
const AtomicString& mouseEventName, const PlatformMouseEvent& mouseEvent,
EventTarget* relatedTarget,
- AbstractView* view)
+ LocalDOMWindow* view)
{
AtomicString pointerEventName = pointerEventNameForMouseEventName(mouseEventName);
unsigned buttons = MouseEvent::platformModifiersToButtons(mouseEvent.getModifiers());
@@ -100,8 +101,20 @@ PointerEvent* PointerEventFactory::create(
pointerEventInit.setScreenX(mouseEvent.globalPosition().x());
pointerEventInit.setScreenY(mouseEvent.globalPosition().y());
- pointerEventInit.setClientX(mouseEvent.position().x());
- pointerEventInit.setClientY(mouseEvent.position().y());
+
+ IntPoint locationInFrameZoomed;
+ if (view && view->frame() && view->frame()->view()) {
+ LocalFrame* frame = view->frame();
+ FrameView* frameView = frame->view();
+ IntPoint locationInContents = frameView->rootFrameToContents(mouseEvent.position());
+ locationInFrameZoomed = frameView->contentsToFrame(locationInContents);
+ float scaleFactor = 1 / frame->pageZoomFactor();
+ locationInFrameZoomed.scale(scaleFactor, scaleFactor);
+ }
+
+ // Set up initial values for coordinates.
+ pointerEventInit.setClientX(locationInFrameZoomed.x());
+ pointerEventInit.setClientY(locationInFrameZoomed.y());
if (pointerEventName == EventTypeNames::pointerdown
|| pointerEventName == EventTypeNames::pointerup) {
« no previous file with comments | « third_party/WebKit/Source/core/events/PointerEventFactory.h ('k') | third_party/WebKit/Source/core/input/EventHandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698