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

Side by Side Diff: ui/views/cocoa/drag_drop_client_mac.mm

Issue 2307633002: [MacViews] Fix Drag and Drop bugs (Closed)
Patch Set: Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « ui/base/dragdrop/drag_drop_types_mac.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ui/views/cocoa/drag_drop_client_mac.h" 5 #import "ui/views/cocoa/drag_drop_client_mac.h"
6 6
7 #include "base/mac/mac_util.h" 7 #include "base/mac/mac_util.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #import "ui/base/dragdrop/os_exchange_data_provider_mac.h" 10 #import "ui/base/dragdrop/os_exchange_data_provider_mac.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 125 }
126 126
127 NSDragOperation DragDropClientMac::DragUpdate(id<NSDraggingInfo> sender) { 127 NSDragOperation DragDropClientMac::DragUpdate(id<NSDraggingInfo> sender) {
128 int drag_operation = ui::DragDropTypes::DRAG_NONE; 128 int drag_operation = ui::DragDropTypes::DRAG_NONE;
129 129
130 // Since dragging from non MacView sources does not generate OSExchangeData, 130 // Since dragging from non MacView sources does not generate OSExchangeData,
131 // we need to generate one based on the provided pasteboard. 131 // we need to generate one based on the provided pasteboard.
132 if (!data_source_.get()) { 132 if (!data_source_.get()) {
133 data_source_.reset([[CocoaDragDropDataProvider alloc] 133 data_source_.reset([[CocoaDragDropDataProvider alloc]
134 initWithPasteboard:[sender draggingPasteboard]]); 134 initWithPasteboard:[sender draggingPasteboard]]);
135 operation_ = ui::DragDropTypes::NSDragOperationToDragOperation(
136 [sender draggingSourceOperationMask]);
135 } 137 }
136 138
137 drag_operation = drop_helper_.OnDragOver( 139 drag_operation = drop_helper_.OnDragOver(
138 *[data_source_ data], LocationInView([sender draggingLocation]), 140 *[data_source_ data], LocationInView([sender draggingLocation]),
139 operation_); 141 operation_);
140 return ui::DragDropTypes::DragOperationToNSDragOperation(drag_operation); 142 return ui::DragDropTypes::DragOperationToNSDragOperation(drag_operation);
141 } 143 }
142 144
143 NSDragOperation DragDropClientMac::Drop(id<NSDraggingInfo> sender) { 145 NSDragOperation DragDropClientMac::Drop(id<NSDraggingInfo> sender) {
144 int drag_operation = drop_helper_.OnDrop( 146 int drag_operation = drop_helper_.OnDrop(
145 *[data_source_ data], LocationInView([sender draggingLocation]), 147 *[data_source_ data], LocationInView([sender draggingLocation]),
146 operation_); 148 operation_);
149 data_source_.reset();
147 return ui::DragDropTypes::DragOperationToNSDragOperation(drag_operation); 150 return ui::DragDropTypes::DragOperationToNSDragOperation(drag_operation);
148 } 151 }
149 152
150 void DragDropClientMac::EndDrag() { 153 void DragDropClientMac::EndDrag() {
151 data_source_.reset(); 154 data_source_.reset();
sky 2016/09/01 23:03:51 Is EndDrag() only called if Drop() isn't?
152 155
153 // Allow a test to invoke EndDrag() without spinning the nested run loop. 156 // Allow a test to invoke EndDrag() without spinning the nested run loop.
154 if (!quit_closure_.is_null()) { 157 if (!quit_closure_.is_null()) {
155 quit_closure_.Run(); 158 quit_closure_.Run();
156 quit_closure_.Reset(); 159 quit_closure_.Reset();
157 } 160 }
158 } 161 }
159 162
160 gfx::Point DragDropClientMac::LocationInView(NSPoint point) const { 163 gfx::Point DragDropClientMac::LocationInView(NSPoint point) const {
161 return gfx::Point(point.x, NSHeight([bridge_->ns_window() frame]) - point.y); 164 return gfx::Point(point.x, NSHeight([bridge_->ns_window() frame]) - point.y);
162 } 165 }
163 166
164 } // namespace views 167 } // namespace views
OLDNEW
« no previous file with comments | « ui/base/dragdrop/drag_drop_types_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698