| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 gfx::NativeWindow WebContentsViewMac::GetTopLevelNativeWindow() const { | 147 gfx::NativeWindow WebContentsViewMac::GetTopLevelNativeWindow() const { |
| 148 NSWindow* window = [cocoa_view_.get() window]; | 148 NSWindow* window = [cocoa_view_.get() window]; |
| 149 return window ? window : delegate_->GetNativeWindow(); | 149 return window ? window : delegate_->GetNativeWindow(); |
| 150 } | 150 } |
| 151 | 151 |
| 152 void WebContentsViewMac::GetScreenInfo(ScreenInfo* results) const { | 152 void WebContentsViewMac::GetScreenInfo(ScreenInfo* results) const { |
| 153 *results = GetNSViewScreenInfo(GetNativeView()); | 153 *results = GetNSViewScreenInfo(GetNativeView()); |
| 154 } | 154 } |
| 155 | 155 |
| 156 void WebContentsViewMac::GetContainerBounds(gfx::Rect* out) const { | 156 void WebContentsViewMac::GetContainerBounds(gfx::Rect* out) const { |
| 157 NSWindow* window = [cocoa_view_.get() window]; | 157 // Note: This implementation should pretty much do the exact same thing that |
| 158 NSRect bounds = [cocoa_view_.get() bounds]; | 158 // is found in RenderWidgetHostViewMac::GetViewBounds(). |
| 159 if (window) { | |
| 160 // Convert bounds to window coordinate space. | |
| 161 bounds = [cocoa_view_.get() convertRect:bounds toView:nil]; | |
| 162 | 159 |
| 163 // Convert bounds to screen coordinate space. | 160 const NSRect bounds = [cocoa_view_.get() bounds]; |
| 164 bounds = [window convertRectToScreen:bounds]; | 161 const gfx::Size size(NSWidth(bounds), NSHeight(bounds)); |
| 162 NSWindow* const window = [cocoa_view_.get() window]; |
| 163 if (!window) { |
| 164 *out = gfx::Rect(size); |
| 165 return; |
| 165 } | 166 } |
| 166 | 167 |
| 167 *out = gfx::ScreenRectFromNSRect(bounds); | 168 NSRect boundsInScreen = [cocoa_view_.get() convertRect:bounds toView:nil]; |
| 169 boundsInScreen = [window convertRectToScreen:boundsInScreen]; |
| 170 const gfx::Point origin = gfx::ScreenRectFromNSRect(boundsInScreen).origin(); |
| 171 |
| 172 *out = gfx::Rect(origin, size); |
| 168 } | 173 } |
| 169 | 174 |
| 170 void WebContentsViewMac::StartDragging( | 175 void WebContentsViewMac::StartDragging( |
| 171 const DropData& drop_data, | 176 const DropData& drop_data, |
| 172 WebDragOperationsMask allowed_operations, | 177 WebDragOperationsMask allowed_operations, |
| 173 const gfx::ImageSkia& image, | 178 const gfx::ImageSkia& image, |
| 174 const gfx::Vector2d& image_offset, | 179 const gfx::Vector2d& image_offset, |
| 175 const DragEventSourceInfo& event_info, | 180 const DragEventSourceInfo& event_info, |
| 176 RenderWidgetHostImpl* source_rwh) { | 181 RenderWidgetHostImpl* source_rwh) { |
| 177 // By allowing nested tasks, the code below also allows Close(), | 182 // By allowing nested tasks, the code below also allows Close(), |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 | 726 |
| 722 - (void)viewDidHide { | 727 - (void)viewDidHide { |
| 723 [self updateWebContentsVisibility]; | 728 [self updateWebContentsVisibility]; |
| 724 } | 729 } |
| 725 | 730 |
| 726 - (void)viewDidUnhide { | 731 - (void)viewDidUnhide { |
| 727 [self updateWebContentsVisibility]; | 732 [self updateWebContentsVisibility]; |
| 728 } | 733 } |
| 729 | 734 |
| 730 @end | 735 @end |
| OLD | NEW |