Commit 82b58a9e authored by Ella Ge's avatar Ella Ge Committed by Commit Bot

fix incorrect mac drop coordinate

The OnDragEnd coordinates was incorrect at mac,
because the api we are using:
draggedImage:endedAt:operation
(https://developer.apple.com/documentation/appkit/
nsdraggingsource/1806949-draggedimage?language=objc)
The endedAt location is the image’s origin in screen
coordinate, but we used it as dragend coordinate.

In this patch, I added a offset similar to startDrag
to correct the coordinates.

Bug: 762701
Change-Id: Ie92e84998d076c58f099215a548ab1934c973958
Reviewed-on: https://chromium-review.googlesource.com/655977Reviewed-by: default avatarNavid Zolghadr <nzolghadr@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Ella Ge <eirage@chromium.org>
Cr-Commit-Position: refs/heads/master@{#510234}
parent 960a9872
...@@ -244,6 +244,12 @@ void PromiseWriterHelper(const DropData& drop_data, ...@@ -244,6 +244,12 @@ void PromiseWriterHelper(const DropData& drop_data,
contents_->SystemDragEnded(dragStartRWH_.get()); contents_->SystemDragEnded(dragStartRWH_.get());
if (dragImage_) {
screenPoint.x += imageOffset_.x;
// Deal with Cocoa's flipped coordinate system.
screenPoint.y += [dragImage_.get() size].height - imageOffset_.y;
}
// Convert |screenPoint| to view coordinates and flip it. // Convert |screenPoint| to view coordinates and flip it.
NSPoint localPoint = NSZeroPoint; NSPoint localPoint = NSZeroPoint;
if ([contentsView_ window]) if ([contentsView_ window])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment