summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-15 20:37:30 +0000
committerjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-15 20:37:30 +0000
commit84981baa4338eec37363ad541054df96b3ad456a (patch)
tree4d64991f115150e5b61a70474b426da841377556
parent9197dbcbb276b2e8bf39789b34e9a0a569b31495 (diff)
downloadchromium_src-84981baa4338eec37363ad541054df96b3ad456a.zip
chromium_src-84981baa4338eec37363ad541054df96b3ad456a.tar.gz
chromium_src-84981baa4338eec37363ad541054df96b3ad456a.tar.bz2
Fix the problem that closing one panel in a stack causes other panels in the stack to disappear on Mac
There're 2 problems that have been fixed here: 1) Hiding a window that still has its parentWindow could cause all other child windows of this parent window to disappear. The fix is to detach the child window from its parent window before hiding and closing it in PanelCocoa::ClosePanel. 2) We should not remove the child window in PanelStackWindowCocoa::RemoveWindow since the native window might be gone already. BUG=240952 TEST=existing tests R=dimich@chromium.org Review URL: https://codereview.chromium.org/14995020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200340 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/cocoa/panels/panel_cocoa.h3
-rw-r--r--chrome/browser/ui/cocoa/panels/panel_cocoa.mm17
-rw-r--r--chrome/browser/ui/cocoa/panels/panel_stack_window_cocoa.mm4
3 files changed, 17 insertions, 7 deletions
diff --git a/chrome/browser/ui/cocoa/panels/panel_cocoa.h b/chrome/browser/ui/cocoa/panels/panel_cocoa.h
index f35d5fc..29648c8 100644
--- a/chrome/browser/ui/cocoa/panels/panel_cocoa.h
+++ b/chrome/browser/ui/cocoa/panels/panel_cocoa.h
@@ -70,6 +70,8 @@ class PanelCocoa : public NativePanel {
Panel* panel() const;
void DidCloseNativeWindow();
+ bool IsClosed() const;
+
// PanelStackWindowCocoa might want to update the stored bounds directly since
// it has already taken care of updating the window bounds directly.
void set_cached_bounds_directly(const gfx::Rect& bounds) { bounds_ = bounds; }
@@ -88,7 +90,6 @@ class PanelCocoa : public NativePanel {
FRIEND_TEST_ALL_PREFIXES(PanelCocoaTest, SetTitle);
FRIEND_TEST_ALL_PREFIXES(PanelCocoaTest, ActivatePanel);
- bool isClosed();
void setBoundsInternal(const gfx::Rect& bounds, bool animate);
scoped_ptr<Panel> panel_;
diff --git a/chrome/browser/ui/cocoa/panels/panel_cocoa.mm b/chrome/browser/ui/cocoa/panels/panel_cocoa.mm
index aef2521..357f07e 100644
--- a/chrome/browser/ui/cocoa/panels/panel_cocoa.mm
+++ b/chrome/browser/ui/cocoa/panels/panel_cocoa.mm
@@ -47,7 +47,7 @@ PanelCocoa::PanelCocoa(Panel* panel, const gfx::Rect& bounds)
PanelCocoa::~PanelCocoa() {
}
-bool PanelCocoa::isClosed() {
+bool PanelCocoa::IsClosed() const {
return !controller_;
}
@@ -63,7 +63,7 @@ void PanelCocoa::ShowPanel() {
}
void PanelCocoa::ShowPanelInactive() {
- if (isClosed())
+ if (IsClosed())
return;
// This method may be called several times, meaning 'ensure it's shown'.
@@ -112,7 +112,7 @@ void PanelCocoa::setBoundsInternal(const gfx::Rect& bounds, bool animate) {
}
void PanelCocoa::ClosePanel() {
- if (isClosed())
+ if (IsClosed())
return;
NSWindow* window = [controller_ window];
@@ -122,6 +122,13 @@ void PanelCocoa::ClosePanel() {
// spin a nested loop.
// TODO(dimich): refactor similar method from BWC and reuse here.
if ([controller_ windowShouldClose:window]) {
+ // Make sure that the panel window is not associated with the underlying
+ // stack window because otherwise hiding the panel window could cause all
+ // other panel windows in the same stack to disappear.
+ NSWindow* stackWindow = [window parentWindow];
+ if (stackWindow)
+ [stackWindow removeChildWindow:window];
+
[window orderOut:nil];
[window close];
}
@@ -313,9 +320,9 @@ Panel* PanelCocoa::panel() const {
}
void PanelCocoa::DidCloseNativeWindow() {
- DCHECK(!isClosed());
- panel_->OnNativePanelClosed();
+ DCHECK(!IsClosed());
controller_ = NULL;
+ panel_->OnNativePanelClosed();
}
// NativePanelTesting implementation.
diff --git a/chrome/browser/ui/cocoa/panels/panel_stack_window_cocoa.mm b/chrome/browser/ui/cocoa/panels/panel_stack_window_cocoa.mm
index 4219aca..ee2045d 100644
--- a/chrome/browser/ui/cocoa/panels/panel_stack_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/panels/panel_stack_window_cocoa.mm
@@ -84,7 +84,9 @@ void PanelStackWindowCocoa::AddPanel(Panel* panel) {
void PanelStackWindowCocoa::RemovePanel(Panel* panel) {
panels_.remove(panel);
- [window_ removeChildWindow:panel->GetNativeWindow()];
+ // If the native panel is closed, the native window should already be gone.
+ if (!static_cast<PanelCocoa*>(panel->native_panel())->IsClosed())
+ [window_ removeChildWindow:panel->GetNativeWindow()];
UpdateStackWindowBounds();
}