| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 return NULL; | 111 return NULL; |
| 112 return rwhv->GetNativeView(); | 112 return rwhv->GetNativeView(); |
| 113 } | 113 } |
| 114 | 114 |
| 115 gfx::NativeWindow WebContentsViewMac::GetTopLevelNativeWindow() const { | 115 gfx::NativeWindow WebContentsViewMac::GetTopLevelNativeWindow() const { |
| 116 NSWindow* window = [cocoa_view_.get() window]; | 116 NSWindow* window = [cocoa_view_.get() window]; |
| 117 return window ? window : delegate_->GetNativeWindow(); | 117 return window ? window : delegate_->GetNativeWindow(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void WebContentsViewMac::GetContainerBounds(gfx::Rect* out) const { | 120 void WebContentsViewMac::GetContainerBounds(gfx::Rect* out) const { |
| 121 // Convert bounds to window coordinate space. | 121 NSWindow* window = [cocoa_view_.get() window]; |
| 122 NSRect bounds = | 122 NSRect bounds = [cocoa_view_.get() bounds]; |
| 123 [cocoa_view_.get() convertRect:[cocoa_view_.get() bounds] toView:nil]; | 123 if (window) { |
| 124 // Convert bounds to window coordinate space. |
| 125 bounds = [cocoa_view_.get() convertRect:bounds toView:nil]; |
| 124 | 126 |
| 125 // Convert bounds to screen coordinate space. | 127 // Convert bounds to screen coordinate space. |
| 126 NSWindow* window = [cocoa_view_.get() window]; | 128 bounds = [window convertRectToScreen:bounds]; |
| 127 bounds.origin = [window convertBaseToScreen:bounds.origin]; | 129 } |
| 128 | 130 |
| 129 // Flip y to account for screen flip. | 131 // Flip y to account for screen flip. |
| 130 NSScreen* screen = [[NSScreen screens] firstObject]; | 132 NSScreen* screen = [[NSScreen screens] firstObject]; |
| 131 bounds.origin.y = [screen frame].size.height - bounds.origin.y | 133 bounds.origin.y = [screen frame].size.height - bounds.origin.y |
| 132 - bounds.size.height; | 134 - bounds.size.height; |
| 133 *out = gfx::Rect(NSRectToCGRect(bounds)); | 135 *out = gfx::Rect(NSRectToCGRect(bounds)); |
| 134 } | 136 } |
| 135 | 137 |
| 136 void WebContentsViewMac::StartDragging( | 138 void WebContentsViewMac::StartDragging( |
| 137 const DropData& drop_data, | 139 const DropData& drop_data, |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 | 681 |
| 680 - (void)viewDidHide { | 682 - (void)viewDidHide { |
| 681 [self updateWebContentsVisibility]; | 683 [self updateWebContentsVisibility]; |
| 682 } | 684 } |
| 683 | 685 |
| 684 - (void)viewDidUnhide { | 686 - (void)viewDidUnhide { |
| 685 [self updateWebContentsVisibility]; | 687 [self updateWebContentsVisibility]; |
| 686 } | 688 } |
| 687 | 689 |
| 688 @end | 690 @end |
| OLD | NEW |