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

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

Issue 1777653002: Prepare ui/ module for compilation with OS X 10.7 deployment target. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compile errors. Created 4 years, 9 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/views/cocoa/tooltip_manager_mac.mm ('k') | ui/views/controls/menu/menu_runner_impl_cocoa.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/widget_owner_nswindow_adapter.h" 5 #import "ui/views/cocoa/widget_owner_nswindow_adapter.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/base/cocoa/cocoa_base_utils.h"
10 #include "ui/gfx/geometry/rect.h" 11 #include "ui/gfx/geometry/rect.h"
11 #include "ui/gfx/geometry/vector2d.h" 12 #include "ui/gfx/geometry/vector2d.h"
12 #import "ui/gfx/mac/coordinate_conversion.h" 13 #import "ui/gfx/mac/coordinate_conversion.h"
13 #import "ui/views/cocoa/bridged_native_widget.h" 14 #import "ui/views/cocoa/bridged_native_widget.h"
14 15
15 // Bridges an AppKit observer to observe when the (non-views) NSWindow owning a 16 // Bridges an AppKit observer to observe when the (non-views) NSWindow owning a
16 // views::Widget will close. 17 // views::Widget will close.
17 @interface WidgetOwnerNSWindowAdapterBridge : NSObject { 18 @interface WidgetOwnerNSWindowAdapterBridge : NSObject {
18 @private 19 @private
19 views::WidgetOwnerNSWindowAdapter* adapter_; // Weak. Owns us. 20 views::WidgetOwnerNSWindowAdapter* adapter_; // Weak. Owns us.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // Note: |this| will be deleted here. 66 // Note: |this| will be deleted here.
66 } 67 }
67 68
68 NSWindow* WidgetOwnerNSWindowAdapter::GetNSWindow() { 69 NSWindow* WidgetOwnerNSWindowAdapter::GetNSWindow() {
69 return anchor_window_; 70 return anchor_window_;
70 } 71 }
71 72
72 gfx::Vector2d WidgetOwnerNSWindowAdapter::GetChildWindowOffset() const { 73 gfx::Vector2d WidgetOwnerNSWindowAdapter::GetChildWindowOffset() const {
73 NSRect rect_in_window = 74 NSRect rect_in_window =
74 [anchor_view_ convertRect:[anchor_view_ bounds] toView:nil]; 75 [anchor_view_ convertRect:[anchor_view_ bounds] toView:nil];
76 NSRect rect_in_screen = [anchor_window_ convertRectToScreen:rect_in_window];
75 // Ensure we anchor off the top-left of |anchor_view_| (rect_in_window.origin 77 // Ensure we anchor off the top-left of |anchor_view_| (rect_in_window.origin
Avi (use Gerrit) 2016/03/08 21:37:40 ... (rect_in_screen.origin
erikchen 2016/03/08 21:42:10 Done.
76 // is the bottom-left of the view). 78 // is the bottom-left of the view).
77 // TODO(tapted): Use -[NSWindow convertRectToScreen:] when we ditch 10.6. 79 NSPoint anchor_in_screen =
78 NSRect rect_in_screen = NSZeroRect; 80 NSMakePoint(NSMinX(rect_in_screen), NSMaxY(rect_in_screen));
79 rect_in_screen.origin = 81 return gfx::ScreenPointFromNSPoint(anchor_in_screen).OffsetFromOrigin();
80 [anchor_window_ convertBaseToScreen:NSMakePoint(NSMinX(rect_in_window),
81 NSMaxY(rect_in_window))];
82 return gfx::ScreenRectFromNSRect(rect_in_screen).OffsetFromOrigin();
83 } 82 }
84 83
85 bool WidgetOwnerNSWindowAdapter::IsVisibleParent() const { 84 bool WidgetOwnerNSWindowAdapter::IsVisibleParent() const {
86 return [anchor_window_ isVisible]; 85 return [anchor_window_ isVisible];
87 } 86 }
88 87
89 void WidgetOwnerNSWindowAdapter::RemoveChildWindow(BridgedNativeWidget* child) { 88 void WidgetOwnerNSWindowAdapter::RemoveChildWindow(BridgedNativeWidget* child) {
90 DCHECK_EQ(child, child_); 89 DCHECK_EQ(child, child_);
91 [GetNSWindow() removeChildWindow:child->ns_window()]; 90 [GetNSWindow() removeChildWindow:child->ns_window()];
92 delete this; 91 delete this;
93 } 92 }
94 93
95 WidgetOwnerNSWindowAdapter::~WidgetOwnerNSWindowAdapter() { 94 WidgetOwnerNSWindowAdapter::~WidgetOwnerNSWindowAdapter() {
96 [[NSNotificationCenter defaultCenter] removeObserver:observer_bridge_]; 95 [[NSNotificationCenter defaultCenter] removeObserver:observer_bridge_];
97 } 96 }
98 97
99 } // namespace views 98 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/cocoa/tooltip_manager_mac.mm ('k') | ui/views/controls/menu/menu_runner_impl_cocoa.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698