Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "base/mac/sdk_forward_declarations.h" | 10 #include "base/mac/sdk_forward_declarations.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 } | 95 } |
| 96 | 96 |
| 97 void WidgetOwnerNSWindowAdapter::OnWindowDidChangeOcclusionState() { | 97 void WidgetOwnerNSWindowAdapter::OnWindowDidChangeOcclusionState() { |
| 98 // The adapter only needs to handle a parent "show", since the only way it | 98 // The adapter only needs to handle a parent "show", since the only way it |
| 99 // should be hidden is via -[NSApp hide], and all BridgedNativeWidgets | 99 // should be hidden is via -[NSApp hide], and all BridgedNativeWidgets |
| 100 // subscribe to NSApplicationDidHideNotification already. | 100 // subscribe to NSApplicationDidHideNotification already. |
| 101 if (![anchor_window_ isVisible]) | 101 if (![anchor_window_ isVisible]) |
| 102 return; | 102 return; |
| 103 | 103 |
| 104 if (child_->window_visible()) { | 104 if (child_->window_visible()) { |
| 105 DCHECK([child_->ns_window() parentWindow]); | 105 // A sheet should never have a parentWindow, otherwise dismissing the sheet |
| 106 // causes graphical glitches (http://crbug.com/605098). Non-sheets should | |
| 107 // always have a parentWindow. | |
| 108 DCHECK([child_->ns_window() isSheet] != | |
|
karandeepb
2016/11/28 05:19:32
So this was/is slightly confusing. Is this correct
tapted
2016/11/28 06:15:41
yes. ([NSWindow parentWindow] should be nil -- but
karandeepb
2016/11/28 23:37:57
Acknowledged.
| |
| 109 !![child_->ns_window() parentWindow]); | |
| 106 DCHECK(child_->wants_to_be_visible()); | 110 DCHECK(child_->wants_to_be_visible()); |
| 107 return; | 111 return; |
| 108 } | 112 } |
| 109 | 113 |
| 110 // The parent relationship should have been removed when the child was hidden. | 114 // The parent relationship should have been removed when the child was hidden. |
| 111 DCHECK(![child_->ns_window() parentWindow]); | 115 DCHECK(![child_->ns_window() parentWindow]); |
| 112 if (!child_->wants_to_be_visible()) | 116 if (!child_->wants_to_be_visible()) |
| 113 return; | 117 return; |
| 114 | 118 |
| 115 [child_->ns_window() orderWindow:NSWindowAbove | 119 [child_->ns_window() orderWindow:NSWindowAbove |
| 116 relativeTo:[anchor_window_ windowNumber]]; | 120 relativeTo:[anchor_window_ windowNumber]]; |
| 117 | 121 |
| 118 // Ordering the window should add back the relationship. | 122 // Ordering the window should add back the relationship (unless it's a sheet). |
| 119 DCHECK([child_->ns_window() parentWindow]); | 123 DCHECK([child_->ns_window() isSheet] != !![child_->ns_window() parentWindow]); |
| 120 DCHECK(child_->window_visible()); | 124 DCHECK(child_->window_visible()); |
| 121 } | 125 } |
| 122 | 126 |
| 123 NSWindow* WidgetOwnerNSWindowAdapter::GetNSWindow() { | 127 NSWindow* WidgetOwnerNSWindowAdapter::GetNSWindow() { |
| 124 return anchor_window_; | 128 return anchor_window_; |
| 125 } | 129 } |
| 126 | 130 |
| 127 gfx::Vector2d WidgetOwnerNSWindowAdapter::GetChildWindowOffset() const { | 131 gfx::Vector2d WidgetOwnerNSWindowAdapter::GetChildWindowOffset() const { |
| 128 NSRect rect_in_window = | 132 NSRect rect_in_window = |
| 129 [anchor_view_ convertRect:[anchor_view_ bounds] toView:nil]; | 133 [anchor_view_ convertRect:[anchor_view_ bounds] toView:nil]; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 143 DCHECK_EQ(child, child_); | 147 DCHECK_EQ(child, child_); |
| 144 [GetNSWindow() removeChildWindow:child->ns_window()]; | 148 [GetNSWindow() removeChildWindow:child->ns_window()]; |
| 145 delete this; | 149 delete this; |
| 146 } | 150 } |
| 147 | 151 |
| 148 WidgetOwnerNSWindowAdapter::~WidgetOwnerNSWindowAdapter() { | 152 WidgetOwnerNSWindowAdapter::~WidgetOwnerNSWindowAdapter() { |
| 149 [[NSNotificationCenter defaultCenter] removeObserver:observer_bridge_]; | 153 [[NSNotificationCenter defaultCenter] removeObserver:observer_bridge_]; |
| 150 } | 154 } |
| 151 | 155 |
| 152 } // namespace views | 156 } // namespace views |
| OLD | NEW |