diff options
author | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-16 18:15:01 +0000 |
---|---|---|
committer | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-16 18:15:01 +0000 |
commit | df556e8a19da3fa32bee81ef5db6f100cf5e4238 (patch) | |
tree | cb437520b5d7ce760624af9cae9789dfe9200910 /chrome | |
parent | cf430e2ea4fb5a3e65cb4ca16061ac6663d0ab1c (diff) | |
download | chromium_src-df556e8a19da3fa32bee81ef5db6f100cf5e4238.zip chromium_src-df556e8a19da3fa32bee81ef5db6f100cf5e4238.tar.gz chromium_src-df556e8a19da3fa32bee81ef5db6f100cf5e4238.tar.bz2 |
Call the DragSource* API on the RenderViewHost during a drag.
BUG=16909
TEST=Dragging thumbs on the NTP
Review URL: http://codereview.chromium.org/155640
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20881 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/tab_contents/tab_contents_view_mac.mm | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/chrome/browser/tab_contents/tab_contents_view_mac.mm b/chrome/browser/tab_contents/tab_contents_view_mac.mm index ae464d0..192a082 100644 --- a/chrome/browser/tab_contents/tab_contents_view_mac.mm +++ b/chrome/browser/tab_contents/tab_contents_view_mac.mm @@ -435,11 +435,45 @@ void TabContentsViewMac::Observe(NotificationType type, // Called when a drag initiated in our view ends. We need to make sure that // we tell WebCore so that it can go about processing things as normal. - (void)draggedImage:(NSImage*)anImage - endedAt:(NSPoint)aPoint + endedAt:(NSPoint)screenPoint operation:(NSDragOperation)operation { RenderViewHost* rvh = [self tabContents]->render_view_host(); - if (rvh) + if (rvh) { rvh->DragSourceSystemDragEnded(); + + // Convert |screenPoint| to view coordinates and flip it. + NSPoint localPoint = [self convertPointFromBase:screenPoint]; + NSRect viewFrame = [self frame]; + localPoint.y = viewFrame.size.height - localPoint.y; + // Flip |screenPoint|. + NSRect screenFrame = [[[self window] screen] frame]; + screenPoint.y = screenFrame.size.height - screenPoint.y; + + if (operation != NSDragOperationNone) + rvh->DragSourceEndedAt(localPoint.x, localPoint.y, + screenPoint.x, screenPoint.y); + else + rvh->DragSourceCancelledAt(localPoint.x, localPoint.y, + screenPoint.x, screenPoint.y); + } +} + +// Called when a drag initiated in our view moves. We need to tell WebCore +// so it can update anything watching for drag events. +- (void)draggedImage:(NSImage*)draggedImage movedTo:(NSPoint)screenPoint { + RenderViewHost* rvh = [self tabContents]->render_view_host(); + if (rvh) { + // Convert |screenPoint| to view coordinates and flip it. + NSPoint localPoint = [self convertPointFromBase:screenPoint]; + NSRect viewFrame = [self frame]; + localPoint.y = viewFrame.size.height - localPoint.y; + // Flip |screenPoint|. + NSRect screenFrame = [[[self window] screen] frame]; + screenPoint.y = screenFrame.size.height - screenPoint.y; + + rvh->DragSourceMovedTo(localPoint.x, localPoint.y, + screenPoint.x, screenPoint.y); + } } // NSDraggingDestination methods |