diff options
author | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-12 03:11:12 +0000 |
---|---|---|
committer | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-12 03:11:12 +0000 |
commit | 84c626f55742b9bf8672809bc5936cf197af9317 (patch) | |
tree | 04471b48561518ce15754fafdb88e7f01236b67c /chrome/browser/ui/panels | |
parent | 1d769a58a80fd2474f24ae613288a83f8a2e42f7 (diff) | |
download | chromium_src-84c626f55742b9bf8672809bc5936cf197af9317.zip chromium_src-84c626f55742b9bf8672809bc5936cf197af9317.tar.gz chromium_src-84c626f55742b9bf8672809bc5936cf197af9317.tar.bz2 |
Minimized panel that overflows should stay minimized when returning from overflow
BUG=109690
TEST=new test
Review URL: http://codereview.chromium.org/9114049
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117379 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/panels')
-rw-r--r-- | chrome/browser/ui/panels/panel.cc | 5 | ||||
-rw-r--r-- | chrome/browser/ui/panels/panel.h | 4 | ||||
-rw-r--r-- | chrome/browser/ui/panels/panel_manager.cc | 7 | ||||
-rw-r--r-- | chrome/browser/ui/panels/panel_manager.h | 3 | ||||
-rw-r--r-- | chrome/browser/ui/panels/panel_overflow_browsertest.cc | 211 | ||||
-rw-r--r-- | chrome/browser/ui/panels/panel_overflow_strip.cc | 3 | ||||
-rw-r--r-- | chrome/browser/ui/panels/panel_overflow_strip.h | 3 | ||||
-rw-r--r-- | chrome/browser/ui/panels/panel_strip.cc | 34 | ||||
-rw-r--r-- | chrome/browser/ui/panels/panel_strip.h | 3 |
9 files changed, 241 insertions, 32 deletions
diff --git a/chrome/browser/ui/panels/panel.cc b/chrome/browser/ui/panels/panel.cc index 1980bd3..eacf7b2 100644 --- a/chrome/browser/ui/panels/panel.cc +++ b/chrome/browser/ui/panels/panel.cc @@ -49,6 +49,7 @@ Panel::Panel(Browser* browser, const gfx::Size& requested_size) auto_resizable_(false), draggable_(true), expansion_state_(EXPANDED), + old_expansion_state_(EXPANDED), app_icon_visible_(true) { } @@ -139,10 +140,10 @@ void Panel::SetAppIconVisibility(bool visible) { void Panel::SetExpansionState(ExpansionState new_state) { if (expansion_state_ == new_state) return; - ExpansionState old_state = expansion_state_; + old_expansion_state_ = expansion_state_; expansion_state_ = new_state; - manager()->OnPanelExpansionStateChanged(this, old_state); + manager()->OnPanelExpansionStateChanged(this); // The minimized panel should not get the focus. if (expansion_state_ == MINIMIZED) diff --git a/chrome/browser/ui/panels/panel.h b/chrome/browser/ui/panels/panel.h index 6645ad4..aefb8fd 100644 --- a/chrome/browser/ui/panels/panel.h +++ b/chrome/browser/ui/panels/panel.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -219,6 +219,7 @@ class Panel : public BrowserWindow, NativePanel* native_panel() { return native_panel_; } Browser* browser() const { return browser_; } ExpansionState expansion_state() const { return expansion_state_; } + ExpansionState old_expansion_state() const { return old_expansion_state_; } const gfx::Size& min_size() const { return min_size_; } const gfx::Size& max_size() const { return max_size_; } bool auto_resizable() const { return auto_resizable_; } @@ -310,6 +311,7 @@ class Panel : public BrowserWindow, NativePanel* native_panel_; // Weak, owns us. ExpansionState expansion_state_; + ExpansionState old_expansion_state_; // Indicates whether the panel app icon is visible in the taskbar. bool app_icon_visible_; diff --git a/chrome/browser/ui/panels/panel_manager.cc b/chrome/browser/ui/panels/panel_manager.cc index 291d0c7..25ca6e0 100644 --- a/chrome/browser/ui/panels/panel_manager.cc +++ b/chrome/browser/ui/panels/panel_manager.cc @@ -178,10 +178,9 @@ void PanelManager::EndDragging(bool cancelled) { panel_strip_->EndDragging(cancelled); } -void PanelManager::OnPanelExpansionStateChanged( - Panel* panel, Panel::ExpansionState old_state) { - panel_strip_->OnPanelExpansionStateChanged(panel, old_state); - panel_overflow_strip_->OnPanelExpansionStateChanged(panel, old_state); +void PanelManager::OnPanelExpansionStateChanged(Panel* panel) { + panel_strip_->OnPanelExpansionStateChanged(panel); + panel_overflow_strip_->OnPanelExpansionStateChanged(panel); } void PanelManager::OnPanelAttentionStateChanged(Panel* panel) { diff --git a/chrome/browser/ui/panels/panel_manager.h b/chrome/browser/ui/panels/panel_manager.h index 424ed96..3815813 100644 --- a/chrome/browser/ui/panels/panel_manager.h +++ b/chrome/browser/ui/panels/panel_manager.h @@ -48,8 +48,7 @@ class PanelManager : public AutoHidingDesktopBar::Observer { void EndDragging(bool cancelled); // Invoked when a panel's expansion state changes. - void OnPanelExpansionStateChanged(Panel* panel, - Panel::ExpansionState old_state); + void OnPanelExpansionStateChanged(Panel* panel); // Invoked when a panel is starting/stopping drawing an attention. void OnPanelAttentionStateChanged(Panel* panel); diff --git a/chrome/browser/ui/panels/panel_overflow_browsertest.cc b/chrome/browser/ui/panels/panel_overflow_browsertest.cc index b7b1f0f..3d8894e 100644 --- a/chrome/browser/ui/panels/panel_overflow_browsertest.cc +++ b/chrome/browser/ui/panels/panel_overflow_browsertest.cc @@ -198,7 +198,10 @@ class PanelOverflowBrowserTest : public BasePanelBrowserTest { #define MAYBE_CloseNormalPanels CloseNormalPanels #define MAYBE_CloseWithDelayedOverflow CloseWithDelayedOverflow #define MAYBE_ActivateOverflowPanels ActivateOverflowPanels -#define MAYBE_MoveMinimizedPanelToOverflow MoveMinimizedPanelToOverflow +#define MAYBE_MoveMinimizedPanelToOverflowAndBringBackByActivate \ + MoveMinimizedPanelToOverflowAndBringBackByActivate +#define MAYBE_MoveMinimizedPanelToOverflowAndBringBackByCloseOrResize \ + MoveMinimizedPanelToOverflowAndBringBackByCloseOrResize #define MAYBE_HoverOverOverflowAreaWithoutOverflowOfOverflow \ HoverOverOverflowAreaWithoutOverflowOfOverflow #define MAYBE_HoverOverOverflowAreaWithOverflowOfOverflow \ @@ -216,7 +219,10 @@ class PanelOverflowBrowserTest : public BasePanelBrowserTest { #define MAYBE_CloseNormalPanels DISABLED_CloseNormalPanels #define MAYBE_CloseWithDelayedOverflow DISABLED_CloseWithDelayedOverflow #define MAYBE_ActivateOverflowPanels DISABLED_ActivateOverflowPanels -#define MAYBE_MoveMinimizedPanelToOverflow DISABLED_MoveMinimizedPanelToOverflo +#define MAYBE_MoveMinimizedPanelToOverflowAndBringBackByActivate \ + DISABLED_MoveMinimizedPanelToOverflowAndBringBackByActivate +#define MAYBE_MoveMinimizedPanelToOverflowAndBringBackByCloseOrResize \ + DISABLED_MoveMinimizedPanelToOverflowAndBringBackByCloseOrResize #define MAYBE_HoverOverOverflowAreaWithoutOverflowOfOverflow \ DISABLED_HoverOverOverflowAreaWithoutOverflowOfOverflow #define MAYBE_HoverOverOverflowAreaWithOverflowOfOverflow \ @@ -782,8 +788,9 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_ActivateOverflowPanels) { PanelManager::GetInstance()->RemoveAll(); } -IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, - MAYBE_MoveMinimizedPanelToOverflow) { +IN_PROC_BROWSER_TEST_F( + PanelOverflowBrowserTest, + MAYBE_MoveMinimizedPanelToOverflowAndBringBackByActivate) { // Create normal and overflow panels. // normal: P0, P1, P2 // overflow: P3, P4 @@ -883,6 +890,202 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, PanelManager::GetInstance()->RemoveAll(); } +IN_PROC_BROWSER_TEST_F( + PanelOverflowBrowserTest, + MAYBE_MoveMinimizedPanelToOverflowAndBringBackByCloseOrResizeOrResize) { + PanelManager* panel_manager = PanelManager::GetInstance(); + + // Create normal and overflow panels. + // normal: P0, P1, P2 + // overflow: P3, P4, P5 + const int panel_widths[] = { + 240, 240, 120, // normal + 240, 240, 240 // overflow + }; + std::vector<Panel*> panels = CreateOverflowPanels(3, 3, panel_widths); + + PanelDataList expected_normal_list; + expected_normal_list.Add(panels[0], Panel::EXPANDED, true, false); + expected_normal_list.Add(panels[1], Panel::EXPANDED, true, false); + expected_normal_list.Add(panels[2], Panel::EXPANDED, true, false); + EXPECT_EQ(expected_normal_list, GetAllNormalPanelData()); + + PanelDataList expected_overflow_list; + expected_overflow_list.Add(panels[3], Panel::IN_OVERFLOW, true, false); + expected_overflow_list.Add(panels[4], Panel::IN_OVERFLOW, true, false); + expected_overflow_list.Add(panels[5], Panel::IN_OVERFLOW, true, false); + + // Test case 1: restoring minimized to minimized. + { + // Minimize a normal panel and then bump it to overflow by activating an + // overflow panel. + // normal: P0, P1, P3 + // overflow: P2, P4, P5 + panels[2]->SetExpansionState(Panel::MINIMIZED); + panels[3]->Activate(); + WaitForPanelActiveState(panels[3], SHOW_AS_ACTIVE); + WaitForExpansionStateChanged(panels[3], Panel::EXPANDED); + + expected_normal_list.clear(); + expected_normal_list.Add(panels[0], Panel::EXPANDED, true, false); + expected_normal_list.Add(panels[1], Panel::EXPANDED, true, false); + expected_normal_list.Add(panels[3], Panel::EXPANDED, true, true); + EXPECT_EQ(expected_normal_list, GetAllNormalPanelData()); + + expected_overflow_list.clear(); + expected_overflow_list.Add(panels[2], Panel::IN_OVERFLOW, true, false); + expected_overflow_list.Add(panels[4], Panel::IN_OVERFLOW, true, false); + expected_overflow_list.Add(panels[5], Panel::IN_OVERFLOW, true, false); + EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData()); + + // Bring back the formerly minimized panel by closing a panel. It will + // return to the panel strip in the minimized state. + // normal: P0, P1, P2 + // overflow: P4, P5 + CloseWindowAndWait(panels[3]->browser()); + WaitForExpansionStateChanged(panels[2], Panel::MINIMIZED); + + expected_normal_list.clear(); + expected_normal_list.Add(panels[0], Panel::EXPANDED, true, false); + expected_normal_list.Add(panels[1], Panel::EXPANDED, true, false); + expected_normal_list.Add(panels[2], Panel::MINIMIZED, true, false); + EXPECT_EQ(expected_normal_list, GetAllNormalPanelData()); + + expected_overflow_list.clear(); + expected_overflow_list.Add(panels[4], Panel::IN_OVERFLOW, true, false); + expected_overflow_list.Add(panels[5], Panel::IN_OVERFLOW, true, false); + EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData()); + } + + // Test case 2: restoring minimized to title-only. + { + // Bump the minimized panel to overflow by activating an overflow panel. + // normal: P0, P1, P4 + // overflow: P2, P5 + panels[4]->Activate(); + WaitForPanelActiveState(panels[4], SHOW_AS_ACTIVE); + WaitForExpansionStateChanged(panels[4], Panel::EXPANDED); + + expected_normal_list.clear(); + expected_normal_list.Add(panels[0], Panel::EXPANDED, true, false); + expected_normal_list.Add(panels[1], Panel::EXPANDED, true, false); + expected_normal_list.Add(panels[4], Panel::EXPANDED, true, true); + EXPECT_EQ(expected_normal_list, GetAllNormalPanelData()); + + expected_overflow_list.clear(); + expected_overflow_list.Add(panels[2], Panel::IN_OVERFLOW, true, false); + expected_overflow_list.Add(panels[5], Panel::IN_OVERFLOW, true, false); + EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData()); + + // Minimize another panel and hover the mouse over it. This should bring up + // all currently minimized panels. When a formerly minimized or title-only + // panel is restored from the overflow area, it should also be title-only. + panels[0]->SetExpansionState(Panel::MINIMIZED); + MoveMouse(gfx::Point(panels[0]->GetBounds().x(), + panels[0]->GetBounds().y())); + WaitForExpansionStateChanged(panels[0], Panel::TITLE_ONLY); + + // Bring back the formerly minimized panel by closing a panel. It will + // return to the panel strip in the title-only state. + // normal: P0, P1, P2 + // overflow: P5 + CloseWindowAndWait(panels[4]->browser()); + WaitForExpansionStateChanged(panels[2], Panel::TITLE_ONLY); + + expected_normal_list.clear(); + expected_normal_list.Add(panels[0], Panel::TITLE_ONLY, true, false); + expected_normal_list.Add(panels[1], Panel::EXPANDED, true, false); + expected_normal_list.Add(panels[2], Panel::TITLE_ONLY, true, false); + EXPECT_EQ(expected_normal_list, GetAllNormalPanelData()); + + expected_overflow_list.clear(); + expected_overflow_list.Add(panels[5], Panel::IN_OVERFLOW, true, false); + EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData()); + } + + // Test case 3: restoring title-only to title-only. + { + // Bump the title-only panel to overflow by activating an overflow panel. + // normal: P0, P1, P5 + // overflow: P2 + panels[5]->Activate(); + WaitForPanelActiveState(panels[5], SHOW_AS_ACTIVE); + WaitForExpansionStateChanged(panels[5], Panel::EXPANDED); + + expected_normal_list.clear(); + expected_normal_list.Add(panels[0], Panel::TITLE_ONLY, true, false); + expected_normal_list.Add(panels[1], Panel::EXPANDED, true, false); + expected_normal_list.Add(panels[5], Panel::EXPANDED, true, true); + EXPECT_EQ(expected_normal_list, GetAllNormalPanelData()); + + expected_overflow_list.clear(); + expected_overflow_list.Add(panels[2], Panel::IN_OVERFLOW, true, false); + EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData()); + + // Bring back the formerly title-only panel by shrinking a panel. It will + // return to the panel strip in the title-only state. + // normal: P0, P1, P5, P2 + panel_manager->ResizePanel(panels[5], gfx::Size( + panels[5]->GetBounds().width() / 2, + panels[5]->GetBounds().height() / 2)); + + expected_normal_list.clear(); + expected_normal_list.Add(panels[0], Panel::TITLE_ONLY, true, false); + expected_normal_list.Add(panels[1], Panel::EXPANDED, true, false); + expected_normal_list.Add(panels[5], Panel::EXPANDED, true, true); + expected_normal_list.Add(panels[2], Panel::TITLE_ONLY, true, false); + EXPECT_EQ(expected_normal_list, GetAllNormalPanelData()); + + expected_overflow_list.clear(); + EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData()); + } + + // Test case 4: restoring title-only to minimized. + { + // Bump the minimized panel to overflow by enlarging a panel. + // normal: P0, P1, P5 + // overflow: P2 + panel_manager->ResizePanel(panels[5], gfx::Size( + panels[5]->GetBounds().width() * 2, + panels[5]->GetBounds().height() * 2)); + + expected_normal_list.clear(); + expected_normal_list.Add(panels[0], Panel::TITLE_ONLY, true, false); + expected_normal_list.Add(panels[1], Panel::EXPANDED, true, false); + expected_normal_list.Add(panels[5], Panel::EXPANDED, true, true); + EXPECT_EQ(expected_normal_list, GetAllNormalPanelData()); + + expected_overflow_list.clear(); + expected_overflow_list.Add(panels[2], Panel::IN_OVERFLOW, true, false); + EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData()); + + // Move the mouse away. This should bring down all currently title-only + // panels. When a formerly minimized or title-only panel is restored from + // the overflow area, it should be minimized. + MoveMouse(gfx::Point(0, 0)); + WaitForExpansionStateChanged(panels[0], Panel::MINIMIZED); + + // Bring back the formerly title-only panel by shrinking a panel. It will + // return to the panel strip in the minimized state. + // normal: P0, P1, P5, P2 + panel_manager->ResizePanel(panels[5], gfx::Size( + panels[5]->GetBounds().width() / 2, + panels[5]->GetBounds().height() / 2)); + + expected_normal_list.clear(); + expected_normal_list.Add(panels[0], Panel::MINIMIZED, true, false); + expected_normal_list.Add(panels[1], Panel::EXPANDED, true, false); + expected_normal_list.Add(panels[5], Panel::EXPANDED, true, true); + expected_normal_list.Add(panels[2], Panel::MINIMIZED, true, false); + EXPECT_EQ(expected_normal_list, GetAllNormalPanelData()); + + expected_overflow_list.clear(); + EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData()); + } + + PanelManager::GetInstance()->RemoveAll(); +} + IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_HoverOverOverflowAreaWithoutOverflowOfOverflow) { PanelManager* panel_manager = PanelManager::GetInstance(); diff --git a/chrome/browser/ui/panels/panel_overflow_strip.cc b/chrome/browser/ui/panels/panel_overflow_strip.cc index d85ebcf..d56bcd4 100644 --- a/chrome/browser/ui/panels/panel_overflow_strip.cc +++ b/chrome/browser/ui/panels/panel_overflow_strip.cc @@ -146,8 +146,7 @@ void PanelOverflowStrip::RemoveAll() { (*iter)->Close(); } -void PanelOverflowStrip::OnPanelExpansionStateChanged( - Panel* panel, Panel::ExpansionState old_state) { +void PanelOverflowStrip::OnPanelExpansionStateChanged(Panel* panel) { // Only care about new state being overflow. if (panel->expansion_state() != Panel::IN_OVERFLOW) return; diff --git a/chrome/browser/ui/panels/panel_overflow_strip.h b/chrome/browser/ui/panels/panel_overflow_strip.h index b65656a..7231fda 100644 --- a/chrome/browser/ui/panels/panel_overflow_strip.h +++ b/chrome/browser/ui/panels/panel_overflow_strip.h @@ -39,8 +39,7 @@ class PanelOverflowStrip : public PanelMouseWatcherObserver, void RemoveAll(); // Called when a panel's expansion state changes. - void OnPanelExpansionStateChanged( - Panel* panel, Panel::ExpansionState old_state); + void OnPanelExpansionStateChanged(Panel* panel); // Called when a panel is starting/stopping drawing an attention. void OnPanelAttentionStateChanged(Panel* panel); diff --git a/chrome/browser/ui/panels/panel_strip.cc b/chrome/browser/ui/panels/panel_strip.cc index 6bb2d03..d2cc30f 100644 --- a/chrome/browser/ui/panels/panel_strip.cc +++ b/chrome/browser/ui/panels/panel_strip.cc @@ -81,7 +81,7 @@ void PanelStrip::SetDisplayArea(const gfx::Rect& new_area) { } void PanelStrip::AddPanel(Panel* panel) { - DCHECK_EQ(Panel::EXPANDED, panel->expansion_state()); + DCHECK_NE(Panel::IN_OVERFLOW, panel->expansion_state()); // Always update limits, even for exiting panels, in case the maximums changed // while panel was out of the strip. @@ -351,29 +351,29 @@ void PanelStrip::EndDragging(bool cancelled) { DelayedRemove(); } -void PanelStrip::OnPanelExpansionStateChanged( - Panel* panel, Panel::ExpansionState old_state) { +void PanelStrip::OnPanelExpansionStateChanged(Panel* panel) { gfx::Size size = panel->restored_size(); Panel::ExpansionState expansion_state = panel->expansion_state(); + Panel::ExpansionState old_state = panel->old_expansion_state(); + if (old_state == Panel::IN_OVERFLOW) { + panel_manager_->panel_overflow_strip()->Remove(panel); + AddPanel(panel); + panel->SetAppIconVisibility(true); + panel->set_draggable(true); + } switch (expansion_state) { case Panel::EXPANDED: - if (old_state == Panel::TITLE_ONLY || old_state == Panel::MINIMIZED) { + if (old_state == Panel::TITLE_ONLY || old_state == Panel::MINIMIZED) DecrementMinimizedPanels(); - } else if (old_state == Panel::IN_OVERFLOW) { - panel_manager_->panel_overflow_strip()->Remove(panel); - AddPanel(panel); - panel->SetAppIconVisibility(true); - panel->set_draggable(true); - } break; case Panel::TITLE_ONLY: size.set_height(panel->TitleOnlyHeight()); - if (old_state == Panel::EXPANDED) + if (old_state == Panel::EXPANDED || old_state == Panel::IN_OVERFLOW) IncrementMinimizedPanels(); break; case Panel::MINIMIZED: size.set_height(Panel::kMinimizedPanelHeight); - if (old_state == Panel::EXPANDED) + if (old_state == Panel::EXPANDED || old_state == Panel::IN_OVERFLOW) IncrementMinimizedPanels(); break; case Panel::IN_OVERFLOW: @@ -665,7 +665,15 @@ void PanelStrip::Rearrange() { while ((overflow_panel = overflow_strip->first_panel()) && GetRightMostAvailablePosition() >= display_area_.x() + overflow_panel->restored_size().width()) { - overflow_panel->SetExpansionState(Panel::EXPANDED); + // We need to get back to the previous expansion state. + Panel::ExpansionState expansion_state_to_restore = + overflow_panel->old_expansion_state(); + if (expansion_state_to_restore == Panel::MINIMIZED || + expansion_state_to_restore == Panel::TITLE_ONLY) { + expansion_state_to_restore = are_titlebars_up_ ? Panel::TITLE_ONLY + : Panel::MINIMIZED; + } + overflow_panel->SetExpansionState(expansion_state_to_restore); } } #endif diff --git a/chrome/browser/ui/panels/panel_strip.h b/chrome/browser/ui/panels/panel_strip.h index 30e4115..ef732df 100644 --- a/chrome/browser/ui/panels/panel_strip.h +++ b/chrome/browser/ui/panels/panel_strip.h @@ -47,8 +47,7 @@ class PanelStrip : public PanelMouseWatcherObserver { void EndDragging(bool cancelled); // Invoked when a panel's expansion state changes. - void OnPanelExpansionStateChanged(Panel* panel, - Panel::ExpansionState old_state); + void OnPanelExpansionStateChanged(Panel* panel); // Invoked when the window size of the given panel is changed. void OnWindowSizeChanged( |