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

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: Rebased 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..ab29c3fe39fbd29b12d9d7a83210b89cdc14d278 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,27 @@ PointerEvent* PointerEventFactory::create(
pointerEventInit.setScreenX(mouseEvent.globalPosition().x());
pointerEventInit.setScreenY(mouseEvent.globalPosition().y());
- pointerEventInit.setClientX(mouseEvent.position().x());
- pointerEventInit.setClientY(mouseEvent.position().y());
+
+ LayoutPoint scrollPosition;
+ LayoutPoint adjustedPageLocation;
+ if (view && view->frame()) {
+ LocalFrame* frame = view->frame();
+ if (FrameView* frameView = frame->view()) {
bokan 2016/05/10 22:24:09 Fold this check into the above one.
Navid Zolghadr 2016/05/11 18:09:43 Done.
+ scrollPosition = frameView->scrollPosition();
+ adjustedPageLocation = frameView->rootFrameToContents(mouseEvent.position());
bokan 2016/05/10 22:24:09 s/adjustedPageLocation/locationInContents
Navid Zolghadr 2016/05/11 18:09:43 Done.
+ float scaleFactor = 1 / frame->pageZoomFactor();
+ if (scaleFactor != 1.0f) {
bokan 2016/05/10 22:24:09 No need for the check here, just allow scaling by
Navid Zolghadr 2016/05/11 18:09:43 Done.
+ adjustedPageLocation.scale(scaleFactor, scaleFactor);
+ scrollPosition.scale(scaleFactor, scaleFactor);
+ }
+ }
+ }
+ LayoutPoint clientPoint = adjustedPageLocation - toLayoutSize(scrollPosition);
bokan 2016/05/10 22:24:09 I would do this like so: locationInContents = fra
Navid Zolghadr 2016/05/11 18:09:43 Done.
+
+ // Set up initial values for coordinates.
+ // Set up initial values for coordinates.
+ pointerEventInit.setClientX(clientPoint.x().toInt());
+ pointerEventInit.setClientY(clientPoint.y().toInt());
if (pointerEventName == EventTypeNames::pointerdown
|| pointerEventName == EventTypeNames::pointerup) {

Powered by Google App Engine
This is Rietveld 408576698