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

Unified Diff: ui/views/widget/native_widget_mac.mm

Issue 2061693003: MacViews: Suppress visibility changes during an asynchronous close. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Neater, but Linux, Windows disagree on WidgetTest.DesktopNativeWidgetVisibilityAfterCloseTest Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/widget/native_widget_mac.h ('k') | ui/views/widget/widget_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/native_widget_mac.mm
diff --git a/ui/views/widget/native_widget_mac.mm b/ui/views/widget/native_widget_mac.mm
index b1e67e8c5da32d7b029525e910ca24ec9524f40e..1adaec16d1d304ede65f860bf2f5f9c1519a8597 100644
--- a/ui/views/widget/native_widget_mac.mm
+++ b/ui/views/widget/native_widget_mac.mm
@@ -8,12 +8,9 @@
#include <utility>
-#import "base/mac/bind_objc_block.h"
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_nsobject.h"
#include "base/strings/sys_string_conversions.h"
-#include "base/threading/thread_task_runner_handle.h"
-#import "ui/base/cocoa/constrained_window/constrained_window_animation.h"
#import "ui/base/cocoa/window_size_constants.h"
#include "ui/gfx/font_list.h"
#import "ui/gfx/mac/coordinate_conversion.h"
@@ -30,18 +27,6 @@
#include "ui/views/widget/widget_delegate.h"
#include "ui/views/window/native_frame_view.h"
-// Self-owning animation delegate that starts a hide animation, then calls
-// -[NSWindow close] when the animation ends, releasing itself.
-@interface ViewsNSWindowCloseAnimator : NSObject<NSAnimationDelegate> {
- @private
- base::scoped_nsobject<NSWindow> window_;
- base::scoped_nsobject<NSAnimation> animation_;
-}
-
-+ (void)closeWindowWithAnimation:(NSWindow*)window;
-
-@end
-
namespace views {
namespace {
@@ -95,11 +80,6 @@ BridgedNativeWidget* NativeWidgetMac::GetBridgeForNativeWindow(
return nullptr; // Not created by NativeWidgetMac.
}
-bool NativeWidgetMac::IsWindowModalSheet() const {
- return GetWidget()->widget_delegate()->GetModalType() ==
- ui::MODAL_TYPE_WINDOW;
-}
-
void NativeWidgetMac::OnWindowWillClose() {
// Note: If closed via CloseNow(), |bridge_| will already be reset. If closed
// by the user, or via Close() and a RunLoop, notify observers while |bridge_|
@@ -344,38 +324,7 @@ void NativeWidgetMac::Close() {
if (!bridge_)
return;
- NSWindow* window = GetNativeWindow();
- if (IsWindowModalSheet()) {
- // Sheets can't be closed normally. This starts the sheet closing. Once the
- // sheet has finished animating, it will call sheetDidEnd: on the parent
- // window's delegate. Note it still needs to be asynchronous, since code
- // calling Widget::Close() doesn't expect things to be deleted upon return.
- [NSApp performSelector:@selector(endSheet:) withObject:window afterDelay:0];
- return;
- }
-
- // For other modal types, animate the close.
- if (delegate_->IsModal()) {
- [ViewsNSWindowCloseAnimator closeWindowWithAnimation:window];
- return;
- }
-
- // Clear the view early to suppress repaints.
- bridge_->SetRootView(NULL);
-
- // Widget::Close() ensures [Non]ClientView::CanClose() returns true, so there
- // is no need to call the NSWindow or its delegate's -windowShouldClose:
- // implementation in the manner of -[NSWindow performClose:]. But,
- // like -performClose:, first remove the window from AppKit's display
- // list to avoid crashes like http://crbug.com/156101.
- [window orderOut:nil];
-
- // Many tests assume that base::RunLoop().RunUntilIdle() is always sufficient
- // to execute a close. However, in rare cases, -performSelector:..afterDelay:0
- // does not do this. So post a regular task.
- base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, base::BindBlock(^{
- [window close];
- }));
+ bridge_->CloseAsynchronously();
}
void NativeWidgetMac::CloseNow() {
@@ -743,29 +692,3 @@ gfx::NativeView NativeWidgetPrivate::GetGlobalCapture(
} // namespace internal
} // namespace views
-
-@implementation ViewsNSWindowCloseAnimator
-
-- (id)initWithWindow:(NSWindow*)window {
- if ((self = [super init])) {
- window_.reset([window retain]);
- animation_.reset(
- [[ConstrainedWindowAnimationHide alloc] initWithWindow:window]);
- [animation_ setDelegate:self];
- [animation_ setAnimationBlockingMode:NSAnimationNonblocking];
- [animation_ startAnimation];
- }
- return self;
-}
-
-+ (void)closeWindowWithAnimation:(NSWindow*)window {
- [[ViewsNSWindowCloseAnimator alloc] initWithWindow:window];
-}
-
-- (void)animationDidEnd:(NSAnimation*)animation {
- [window_ close];
- [animation_ setDelegate:nil];
- [self release];
-}
-
-@end
« no previous file with comments | « ui/views/widget/native_widget_mac.h ('k') | ui/views/widget/widget_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698