OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <Carbon/Carbon.h> | 5 #import <Carbon/Carbon.h> |
6 | 6 |
7 #import "content/browser/web_contents/web_contents_view_mac.h" | 7 #import "content/browser/web_contents/web_contents_view_mac.h" |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; | 167 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; |
168 bounds.origin.y = [screen frame].size.height - bounds.origin.y | 168 bounds.origin.y = [screen frame].size.height - bounds.origin.y |
169 - bounds.size.height; | 169 - bounds.size.height; |
170 *out = gfx::Rect(NSRectToCGRect(bounds)); | 170 *out = gfx::Rect(NSRectToCGRect(bounds)); |
171 } | 171 } |
172 | 172 |
173 void WebContentsViewMac::StartDragging( | 173 void WebContentsViewMac::StartDragging( |
174 const WebDropData& drop_data, | 174 const WebDropData& drop_data, |
175 WebDragOperationsMask allowed_operations, | 175 WebDragOperationsMask allowed_operations, |
176 const gfx::ImageSkia& image, | 176 const gfx::ImageSkia& image, |
177 const gfx::Point& image_offset) { | 177 const gfx::Vector2d& image_offset) { |
178 // By allowing nested tasks, the code below also allows Close(), | 178 // By allowing nested tasks, the code below also allows Close(), |
179 // which would deallocate |this|. The same problem can occur while | 179 // which would deallocate |this|. The same problem can occur while |
180 // processing -sendEvent:, so Close() is deferred in that case. | 180 // processing -sendEvent:, so Close() is deferred in that case. |
181 // Drags from web content do not come via -sendEvent:, this sets the | 181 // Drags from web content do not come via -sendEvent:, this sets the |
182 // same flag -sendEvent: would. | 182 // same flag -sendEvent: would. |
183 base::mac::ScopedSendingEvent sending_event_scoper; | 183 base::mac::ScopedSendingEvent sending_event_scoper; |
184 | 184 |
185 // The drag invokes a nested event loop, arrange to continue | 185 // The drag invokes a nested event loop, arrange to continue |
186 // processing events. | 186 // processing events. |
187 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); | 187 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); |
188 NSDragOperation mask = static_cast<NSDragOperation>(allowed_operations); | 188 NSDragOperation mask = static_cast<NSDragOperation>(allowed_operations); |
189 NSPoint offset = NSPointFromCGPoint(image_offset.ToCGPoint()); | 189 gfx::Point image_point = gfx::PointAtOffsetFromOrigin(image_offset); |
Peter Kasting
2012/10/30 01:14:14
Nit: Inline
| |
190 NSPoint offset = NSPointFromCGPoint(image_point.ToCGPoint()); | |
190 [cocoa_view_ startDragWithDropData:drop_data | 191 [cocoa_view_ startDragWithDropData:drop_data |
191 dragOperationMask:mask | 192 dragOperationMask:mask |
192 image:gfx::NSImageFromImageSkia(image) | 193 image:gfx::NSImageFromImageSkia(image) |
193 offset:offset]; | 194 offset:offset]; |
194 } | 195 } |
195 | 196 |
196 void WebContentsViewMac::RenderViewCreated(content::RenderViewHost* host) { | 197 void WebContentsViewMac::RenderViewCreated(content::RenderViewHost* host) { |
197 // We want updates whenever the intrinsic width of the webpage changes. | 198 // We want updates whenever the intrinsic width of the webpage changes. |
198 // Put the RenderView into that mode. The preferred width is used for example | 199 // Put the RenderView into that mode. The preferred width is used for example |
199 // when the "zoom" button in the browser window is clicked. | 200 // when the "zoom" button in the browser window is clicked. |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
530 [[[notification userInfo] objectForKey:kSelectionDirection] | 531 [[[notification userInfo] objectForKey:kSelectionDirection] |
531 unsignedIntegerValue]; | 532 unsignedIntegerValue]; |
532 if (direction == NSDirectSelection) | 533 if (direction == NSDirectSelection) |
533 return; | 534 return; |
534 | 535 |
535 [self webContents]-> | 536 [self webContents]-> |
536 FocusThroughTabTraversal(direction == NSSelectingPrevious); | 537 FocusThroughTabTraversal(direction == NSSelectingPrevious); |
537 } | 538 } |
538 | 539 |
539 @end | 540 @end |
OLD | NEW |