summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjennb@chromium.org <jennb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-10 02:51:20 +0000
committerjennb@chromium.org <jennb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-10 02:51:20 +0000
commitb58e23fc289abc04e51fef8b87cd0bad497332b2 (patch)
tree8d467ad895f3a9aaf1802ff11c58151be3a2ea72
parentff1de07210b17f20f93645692d889f2c283474ce (diff)
downloadchromium_src-b58e23fc289abc04e51fef8b87cd0bad497332b2.zip
chromium_src-b58e23fc289abc04e51fef8b87cd0bad497332b2.tar.gz
chromium_src-b58e23fc289abc04e51fef8b87cd0bad497332b2.tar.bz2
Add knowledge of current PanelStrip in Panel.
Removes the IN_OVERFLOW expansion state as that's now determined by the current PanelStrip. BUG=None TEST=Tests updated. Review URL: http://codereview.chromium.org/9368011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121386 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/panels/base_panel_browser_test.cc11
-rw-r--r--chrome/browser/ui/panels/base_panel_browser_test.h4
-rw-r--r--chrome/browser/ui/panels/docked_panel_strip.cc137
-rw-r--r--chrome/browser/ui/panels/docked_panel_strip.h13
-rw-r--r--chrome/browser/ui/panels/overflow_panel_strip.cc36
-rw-r--r--chrome/browser/ui/panels/overflow_panel_strip.h6
-rw-r--r--chrome/browser/ui/panels/panel.cc48
-rw-r--r--chrome/browser/ui/panels/panel.h18
-rw-r--r--chrome/browser/ui/panels/panel_browser_frame_view.cc7
-rw-r--r--chrome/browser/ui/panels/panel_browser_view.cc14
-rw-r--r--chrome/browser/ui/panels/panel_browser_window_gtk.cc4
-rw-r--r--chrome/browser/ui/panels/panel_manager.cc30
-rw-r--r--chrome/browser/ui/panels/panel_manager.h3
-rw-r--r--chrome/browser/ui/panels/panel_overflow_browsertest.cc469
-rw-r--r--chrome/browser/ui/panels/panel_strip.h10
-rw-r--r--chrome/browser/ui/panels/panel_window_controller_cocoa.mm15
-rw-r--r--chrome/common/chrome_notification_types.h7
17 files changed, 473 insertions, 359 deletions
diff --git a/chrome/browser/ui/panels/base_panel_browser_test.cc b/chrome/browser/ui/panels/base_panel_browser_test.cc
index e7dbd8f..58641a9 100644
--- a/chrome/browser/ui/panels/base_panel_browser_test.cc
+++ b/chrome/browser/ui/panels/base_panel_browser_test.cc
@@ -261,6 +261,17 @@ void BasePanelBrowserTest::WaitForBoundsAnimationFinished(Panel* panel) {
EXPECT_TRUE(!panel_testing->IsAnimatingBounds());
}
+void BasePanelBrowserTest::WaitForLayoutModeChanged(
+ Panel* panel, PanelStrip::Type layout_type) {
+ ui_test_utils::WindowedNotificationObserver signal(
+ chrome::NOTIFICATION_PANEL_CHANGED_LAYOUT_MODE,
+ content::Source<Panel>(panel));
+ if (panel->panel_strip()->type() == layout_type)
+ return;
+ signal.Wait();
+ EXPECT_EQ(layout_type, panel->panel_strip()->type());
+}
+
void BasePanelBrowserTest::WaitForExpansionStateChanged(
Panel* panel, Panel::ExpansionState expansion_state) {
ui_test_utils::WindowedNotificationObserver signal(
diff --git a/chrome/browser/ui/panels/base_panel_browser_test.h b/chrome/browser/ui/panels/base_panel_browser_test.h
index 9a08681..813f528 100644
--- a/chrome/browser/ui/panels/base_panel_browser_test.h
+++ b/chrome/browser/ui/panels/base_panel_browser_test.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.
@@ -10,6 +10,7 @@
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/ui/panels/auto_hiding_desktop_bar.h"
#include "chrome/browser/ui/panels/panel.h"
+#include "chrome/browser/ui/panels/panel_strip.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "ui/gfx/rect.h"
@@ -63,6 +64,7 @@ class BasePanelBrowserTest : public InProcessBrowserTest {
void WaitForPanelActiveState(Panel* panel, ActiveState state);
void WaitForWindowSizeAvailable(Panel* panel);
void WaitForBoundsAnimationFinished(Panel* panel);
+ void WaitForLayoutModeChanged(Panel* panel, PanelStrip::Type layout_type);
void WaitForExpansionStateChanged(Panel* panel,
Panel::ExpansionState expansion_state);
diff --git a/chrome/browser/ui/panels/docked_panel_strip.cc b/chrome/browser/ui/panels/docked_panel_strip.cc
index f629964..645c221 100644
--- a/chrome/browser/ui/panels/docked_panel_strip.cc
+++ b/chrome/browser/ui/panels/docked_panel_strip.cc
@@ -61,6 +61,7 @@ DockedPanelStrip::DockedPanelStrip(PanelManager* panel_manager)
panel_manager_(panel_manager),
minimized_panel_count_(0),
are_titlebars_up_(false),
+ disable_layout_refresh_(false),
dragging_panel_index_(kInvalidPanelIndex),
dragging_panel_original_x_(0),
delayed_titlebar_action_(NO_ACTION),
@@ -88,7 +89,7 @@ void DockedPanelStrip::SetDisplayArea(const gfx::Rect& display_area) {
}
void DockedPanelStrip::AddPanel(Panel* panel) {
- DCHECK_NE(Panel::IN_OVERFLOW, panel->expansion_state());
+ DCHECK_EQ(this, panel->panel_strip());
// Always update limits, even for exiting panels, in case the maximums changed
// while panel was out of the strip.
@@ -103,13 +104,39 @@ void DockedPanelStrip::AddPanel(Panel* panel) {
if (panel->initialized()) {
// Bump panels in the strip to make room for this panel.
+ // Prevent layout refresh when panel is removed from this strip.
+ disable_layout_refresh_ = true;
+ PanelStrip* overflow_strip = panel_manager_->overflow_strip();
int x;
while ((x = GetRightMostAvailablePosition() - width) < display_area_.x()) {
DCHECK(!panels_.empty());
- panels_.back()->SetExpansionState(Panel::IN_OVERFLOW);
+ panels_.back()->MoveToStrip(overflow_strip);
}
- int y = display_area_.bottom() - height;
+ disable_layout_refresh_ = false;
+
+ Panel::ExpansionState expansion_state_to_restore;
+ if (panel->expansion_state() == Panel::EXPANDED) {
+ expansion_state_to_restore = Panel::EXPANDED;
+ } else {
+ if (are_titlebars_up_) {
+ expansion_state_to_restore = Panel::TITLE_ONLY;
+ height = panel->TitleOnlyHeight();
+ } else {
+ expansion_state_to_restore = Panel::MINIMIZED;
+ height = Panel::kMinimizedPanelHeight;
+ }
+ IncrementMinimizedPanels();
+ }
+
+ int y =
+ GetBottomPositionForExpansionState(expansion_state_to_restore) - height;
panel->SetPanelBounds(gfx::Rect(x, y, width, height));
+
+ // Update the minimized state to reflect current titlebar mode.
+ // Do this AFTER setting panel bounds to avoid an extra bounds change.
+ if (panel->expansion_state() != Panel::EXPANDED)
+ panel->SetExpansionState(expansion_state_to_restore);
+
} else {
// Initialize the newly created panel. Does not bump any panels from strip.
if (height == 0 && width == 0) {
@@ -145,7 +172,6 @@ void DockedPanelStrip::AddPanel(Panel* panel) {
if (x < display_area_.x()) {
x = display_area_.x();
panel->set_has_temporary_layout(true);
- panel->set_draggable(false);
MessageLoop::current()->PostDelayedTask(
FROM_HERE,
base::Bind(&DockedPanelStrip::DelayedMovePanelToOverflow,
@@ -158,6 +184,9 @@ void DockedPanelStrip::AddPanel(Panel* panel) {
panel->Initialize(gfx::Rect(x, y, width, height));
}
+ // Set panel properties for this strip.
+ panel->SetAppIconVisibility(true);
+ panel->set_draggable(!panel->has_temporary_layout());
panel->ApplyVisualStyleForStrip(DOCKED_STRIP);
if (panel->has_temporary_layout())
@@ -200,9 +229,7 @@ bool DockedPanelStrip::RemovePanel(Panel* panel) {
DoRemove(panel);
- // Don't rearrange the strip if a panel is being moved from the panel strip
- // to the overflow strip.
- if (panel->expansion_state() != Panel::IN_OVERFLOW)
+ if (!disable_layout_refresh_)
RefreshLayout();
return true;
@@ -220,8 +247,7 @@ bool DockedPanelStrip::DoRemove(Panel* panel) {
if (iter == panels_.end())
return false;
- if (panel->expansion_state() == Panel::TITLE_ONLY ||
- panel->expansion_state() == Panel::MINIMIZED)
+ if (panel->expansion_state() != Panel::EXPANDED)
DecrementMinimizedPanels();
panels_.erase(iter);
@@ -364,12 +390,6 @@ void DockedPanelStrip::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_->overflow_strip()->RemovePanel(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)
@@ -377,18 +397,14 @@ void DockedPanelStrip::OnPanelExpansionStateChanged(Panel* panel) {
break;
case Panel::TITLE_ONLY:
size.set_height(panel->TitleOnlyHeight());
- if (old_state == Panel::EXPANDED || old_state == Panel::IN_OVERFLOW)
+ if (old_state == Panel::EXPANDED)
IncrementMinimizedPanels();
break;
case Panel::MINIMIZED:
size.set_height(Panel::kMinimizedPanelHeight);
- if (old_state == Panel::EXPANDED || old_state == Panel::IN_OVERFLOW)
+ if (old_state == Panel::EXPANDED)
IncrementMinimizedPanels();
break;
- case Panel::IN_OVERFLOW:
- if (old_state == Panel::TITLE_ONLY || old_state == Panel::MINIMIZED)
- DecrementMinimizedPanels();
- break;
default:
NOTREACHED();
break;
@@ -404,6 +420,7 @@ void DockedPanelStrip::OnPanelExpansionStateChanged(Panel* panel) {
}
void DockedPanelStrip::OnPanelAttentionStateChanged(Panel* panel) {
+ DCHECK_EQ(this, panel->panel_strip());
if (panel->IsDrawingAttention()) {
// Bring up the titlebar to get user's attention.
if (panel->expansion_state() == Panel::MINIMIZED)
@@ -415,6 +432,29 @@ void DockedPanelStrip::OnPanelAttentionStateChanged(Panel* panel) {
}
}
+void DockedPanelStrip::ActivatePanel(Panel* panel) {
+ DCHECK_EQ(this, panel->panel_strip());
+
+ // Make sure the panel is expanded when activated so the user input
+ // does not go into a collapsed window.
+ panel->SetExpansionState(Panel::EXPANDED);
+}
+
+void DockedPanelStrip::MinimizePanel(Panel* panel) {
+ DCHECK_EQ(this, panel->panel_strip());
+
+ if (panel->expansion_state() != Panel::EXPANDED)
+ return;
+
+ panel->SetExpansionState(panel->IsDrawingAttention() ?
+ Panel::TITLE_ONLY : Panel::MINIMIZED);
+}
+
+void DockedPanelStrip::RestorePanel(Panel* panel) {
+ DCHECK_EQ(this, panel->panel_strip());
+ panel->SetExpansionState(Panel::EXPANDED);
+}
+
void DockedPanelStrip::IncrementMinimizedPanels() {
minimized_panel_count_++;
if (minimized_panel_count_ == 1)
@@ -452,26 +492,30 @@ void DockedPanelStrip::ResizePanelWindow(
if (new_size != panel->restored_size())
panel->set_restored_size(new_size);
- // Only need to adjust bounds height when panel is expanded.
gfx::Rect bounds = panel->GetBounds();
- Panel::ExpansionState expansion_state = panel->expansion_state();
- if (new_height != bounds.height() &&
- expansion_state == Panel::EXPANDED) {
- bounds.set_y(bounds.bottom() - new_height);
- bounds.set_height(new_height);
- }
-
- // Only need to adjust width if panel is in the panel strip.
int delta_x = bounds.width() - new_width;
- if (delta_x != 0 && expansion_state != Panel::IN_OVERFLOW) {
- bounds.set_width(new_width);
- bounds.set_x(bounds.x() + delta_x);
- }
- if (bounds != panel->GetBounds())
- panel->SetPanelBounds(bounds);
+ // Only need to adjust current bounds if panel is in the dock.
+ if (panel->panel_strip() == this) {
+ // Only need to adjust bounds height when panel is expanded.
+ Panel::ExpansionState expansion_state = panel->expansion_state();
+ if (new_height != bounds.height() &&
+ expansion_state == Panel::EXPANDED) {
+ bounds.set_y(bounds.bottom() - new_height);
+ bounds.set_height(new_height);
+ }
+
+ if (delta_x != 0) {
+ bounds.set_width(new_width);
+ bounds.set_x(bounds.x() + delta_x);
+ }
+
+ if (bounds != panel->GetBounds())
+ panel->SetPanelBounds(bounds);
+ }
- // Only need to rearrange if panel's width changed.
+ // Only need to rearrange if panel's width changed. Rearrange even if panel
+ // is in overflow because there may now be room to fit that panel.
if (delta_x != 0)
RefreshLayout();
}
@@ -675,27 +719,22 @@ void DockedPanelStrip::RefreshLayout() {
#if defined(OS_WIN) || defined(OS_MACOSX)
// Add/remove panels from/to overflow. A change in work area or the
// resize/removal of a panel may affect how many panels fit in the strip.
+ OverflowPanelStrip* overflow_strip = panel_manager_->overflow_strip();
if (panel_index < panels_.size()) {
// Move panels to overflow in reverse to maintain their order.
+ // Prevent layout refresh when panel is removed from this strip.
+ disable_layout_refresh_ = true;
for (size_t overflow_index = panels_.size() - 1;
overflow_index >= panel_index; --overflow_index)
- panels_[overflow_index]->SetExpansionState(Panel::IN_OVERFLOW);
+ panels_[overflow_index]->MoveToStrip(overflow_strip);
+ disable_layout_refresh_ = false;
} else {
// Attempt to add more panels from overflow to the strip.
- OverflowPanelStrip* overflow_strip = panel_manager_->overflow_strip();
Panel* overflow_panel;
while ((overflow_panel = overflow_strip->first_panel()) &&
GetRightMostAvailablePosition() >=
display_area_.x() + overflow_panel->restored_size().width()) {
- // 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);
+ overflow_panel->MoveToStrip(this);
}
}
#endif
@@ -704,7 +743,7 @@ void DockedPanelStrip::RefreshLayout() {
void DockedPanelStrip::DelayedMovePanelToOverflow(Panel* panel) {
if (panels_in_temporary_layout_.erase(panel)) {
DCHECK(panel->has_temporary_layout());
- panel->SetExpansionState(Panel::IN_OVERFLOW);
+ panel->MoveToStrip(panel_manager_->overflow_strip());
}
}
diff --git a/chrome/browser/ui/panels/docked_panel_strip.h b/chrome/browser/ui/panels/docked_panel_strip.h
index 41588ec..e9cd8bf 100644
--- a/chrome/browser/ui/panels/docked_panel_strip.h
+++ b/chrome/browser/ui/panels/docked_panel_strip.h
@@ -43,18 +43,15 @@ class DockedPanelStrip : public PanelStrip,
// Adds a panel to the strip. The panel may be a newly created panel or one
// that is transitioning from another grouping of panels.
virtual void AddPanel(Panel* panel) OVERRIDE;
-
- // Returns |false| if the panel is not in the strip.
virtual bool RemovePanel(Panel* panel) OVERRIDE;
virtual void CloseAll() OVERRIDE;
-
- // Invoked when the window size of the given panel needs to be changed.
virtual void ResizePanelWindow(
Panel* panel,
const gfx::Size& preferred_window_size) OVERRIDE;
-
- // Invoked when a panel's attention state changes.
virtual void OnPanelAttentionStateChanged(Panel* panel) OVERRIDE;
+ virtual void ActivatePanel(Panel* panel) OVERRIDE;
+ virtual void MinimizePanel(Panel* panel) OVERRIDE;
+ virtual void RestorePanel(Panel* panel) OVERRIDE;
// Drags the given panel.
void StartDragging(Panel* panel);
@@ -160,6 +157,10 @@ class DockedPanelStrip : public PanelStrip,
int minimized_panel_count_;
bool are_titlebars_up_;
+ // |True| to temporarily prevent refreshing panel layout, e.g. while
+ // moving panels to overflow area to make room for a panel in this strip.
+ bool disable_layout_refresh_;
+
// Panel to drag.
size_t dragging_panel_index_;
diff --git a/chrome/browser/ui/panels/overflow_panel_strip.cc b/chrome/browser/ui/panels/overflow_panel_strip.cc
index 2306295..70d1c01 100644
--- a/chrome/browser/ui/panels/overflow_panel_strip.cc
+++ b/chrome/browser/ui/panels/overflow_panel_strip.cc
@@ -82,7 +82,7 @@ void OverflowPanelStrip::UpdateCurrentWidth() {
void OverflowPanelStrip::AddPanel(Panel* panel) {
// TODO(jianli): consider using other container to improve the perf for
// inserting to the front. http://crbug.com/106222
- DCHECK_EQ(Panel::IN_OVERFLOW, panel->expansion_state());
+ DCHECK_EQ(this, panel->panel_strip());
// Newly created panels that were temporarily in the panel strip
// are added to the back of the overflow, whereas panels that are
// bumped from the panel strip by other panels go to the front
@@ -96,6 +96,9 @@ void OverflowPanelStrip::AddPanel(Panel* panel) {
RefreshLayout();
}
+ // Set panel properties for this strip.
+ panel->SetAppIconVisibility(false);
+ panel->set_draggable(false);
panel->ApplyVisualStyleForStrip(OVERFLOW_STRIP);
if (num_panels() == 1) {
@@ -154,20 +157,29 @@ void OverflowPanelStrip::ResizePanelWindow(
// Overflow uses its own panel window sizes.
}
-void OverflowPanelStrip::OnPanelExpansionStateChanged(Panel* panel) {
- // Only care about new state being overflow.
- if (panel->expansion_state() != Panel::IN_OVERFLOW)
- return;
+void OverflowPanelStrip::OnPanelAttentionStateChanged(Panel* panel) {
+ DCHECK_EQ(this, panel->panel_strip());
+ UpdateOverflowIndicatorAttention();
+}
- panel_manager_->docked_strip()->RemovePanel(panel);
- AddPanel(panel);
- panel->SetAppIconVisibility(false);
- panel->set_draggable(false);
+void OverflowPanelStrip::ActivatePanel(Panel* panel) {
+ DCHECK_EQ(this, panel->panel_strip());
+ // Activating an overflow panel moves it to the docked panel strip.
+ PanelStrip* docked_strip = panel_manager_->docked_strip();
+ panel->MoveToStrip(docked_strip);
+ docked_strip->ActivatePanel(panel);
}
-void OverflowPanelStrip::OnPanelAttentionStateChanged(Panel* panel) {
- DCHECK(panel->expansion_state() == Panel::IN_OVERFLOW);
- UpdateOverflowIndicatorAttention();
+void OverflowPanelStrip::MinimizePanel(Panel* panel) {
+ DCHECK_EQ(this, panel->panel_strip());
+ // Overflow is already a minimized mode for a panel. Nothing more to do.
+}
+
+void OverflowPanelStrip::RestorePanel(Panel* panel) {
+ DCHECK_EQ(this, panel->panel_strip());
+ PanelStrip* docked_strip = panel_manager_->docked_strip();
+ panel->MoveToStrip(docked_strip);
+ docked_strip->RestorePanel(panel);
}
void OverflowPanelStrip::RefreshLayout() {
diff --git a/chrome/browser/ui/panels/overflow_panel_strip.h b/chrome/browser/ui/panels/overflow_panel_strip.h
index 250e8aa..af8f310 100644
--- a/chrome/browser/ui/panels/overflow_panel_strip.h
+++ b/chrome/browser/ui/panels/overflow_panel_strip.h
@@ -39,9 +39,9 @@ class OverflowPanelStrip : public PanelStrip,
Panel* panel,
const gfx::Size& preferred_window_size) OVERRIDE;
virtual void OnPanelAttentionStateChanged(Panel* panel) OVERRIDE;
-
- // Called when a panel's expansion state changes.
- void OnPanelExpansionStateChanged(Panel* panel);
+ virtual void ActivatePanel(Panel* panel) OVERRIDE;
+ virtual void MinimizePanel(Panel* panel) OVERRIDE;
+ virtual void RestorePanel(Panel* panel) OVERRIDE;
void OnFullScreenModeChanged(bool is_full_screen);
diff --git a/chrome/browser/ui/panels/panel.cc b/chrome/browser/ui/panels/panel.cc
index 1a34699..1008540 100644
--- a/chrome/browser/ui/panels/panel.cc
+++ b/chrome/browser/ui/panels/panel.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/panels/native_panel.h"
#include "chrome/browser/ui/panels/panel_manager.h"
+#include "chrome/browser/ui/panels/panel_strip.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/ui/window_sizer.h"
#include "chrome/browser/web_applications/web_app.h"
@@ -43,6 +44,7 @@ const Extension* Panel::GetExtensionFromBrowser(Browser* browser) {
Panel::Panel(Browser* browser, const gfx::Size& requested_size)
: browser_(browser),
+ panel_strip_(NULL),
initialized_(false),
has_temporary_layout_(false),
restored_size_(requested_size),
@@ -67,7 +69,7 @@ void Panel::Initialize(const gfx::Rect& bounds) {
void Panel::OnNativePanelClosed() {
if (auto_resizable_)
native_panel_->GetPanelBrowser()->tabstrip_model()->RemoveObserver(this);
- manager()->Remove(this);
+ panel_strip_->RemovePanel(this);
}
PanelManager* Panel::manager() const {
@@ -78,8 +80,13 @@ const Extension* Panel::GetExtension() const {
return GetExtensionFromBrowser(browser());
}
+// TODO(jennb): do not update restored_size here as there's no knowledge
+// at this point whether the bounds change is due to the content window
+// being resized vs a change in current display bounds, e.g. from overflow
+// size change. Change this when refactoring panel resize logic.
void Panel::SetPanelBounds(const gfx::Rect& bounds) {
- if (expansion_state_ == Panel::EXPANDED)
+ if (panel_strip_->type() == PanelStrip::DOCKED &&
+ expansion_state_ == Panel::EXPANDED)
restored_size_ = bounds.size();
native_panel_->SetPanelBounds(bounds);
@@ -91,7 +98,8 @@ void Panel::SetPanelBounds(const gfx::Rect& bounds) {
}
void Panel::SetPanelBoundsInstantly(const gfx::Rect& bounds) {
- if (expansion_state_ == Panel::EXPANDED)
+ if (panel_strip_->type() == PanelStrip::DOCKED &&
+ expansion_state_ == Panel::EXPANDED)
restored_size_ = bounds.size();
native_panel_->SetPanelBoundsInstantly(bounds);
@@ -137,6 +145,20 @@ void Panel::SetAppIconVisibility(bool visible) {
native_panel_->SetPanelAppIconVisibility(visible);
}
+void Panel::MoveToStrip(PanelStrip* new_strip) {
+ DCHECK_NE(panel_strip_, new_strip);
+ if (panel_strip_)
+ panel_strip_->RemovePanel(this);
+
+ panel_strip_ = new_strip;
+ panel_strip_->AddPanel(this);
+
+ content::NotificationService::current()->Notify(
+ chrome::NOTIFICATION_PANEL_CHANGED_LAYOUT_MODE,
+ content::Source<Panel>(this),
+ content::NotificationService::NoDetails());
+}
+
void Panel::SetExpansionState(ExpansionState new_state) {
if (expansion_state_ == new_state)
return;
@@ -164,8 +186,8 @@ void Panel::FullScreenModeChanged(bool is_full_screen) {
}
void Panel::Show() {
- // Don't show panel as active if it is in overflow state.
- if (expansion_state_ == IN_OVERFLOW)
+ // Don't show panel as active if it is in overflow.
+ if (PanelStrip::IN_OVERFLOW == panel_strip_->type())
ShowInactive();
else
native_panel_->ShowPanel();
@@ -187,9 +209,7 @@ void Panel::Close() {
}
void Panel::Activate() {
- // Make sure the panel is expanded when activated programmatically,
- // so the user input does not go into collapsed window.
- SetExpansionState(Panel::EXPANDED);
+ panel_strip_->ActivatePanel(this);
native_panel_->ActivatePanel();
}
@@ -210,7 +230,7 @@ void Panel::FlashFrame(bool flash) {
return;
native_panel_->DrawAttention(flash);
- manager()->OnPanelAttentionStateChanged(this);
+ panel_strip_->OnPanelAttentionStateChanged(this);
}
gfx::NativeWindow Panel::GetNativeHandle() {
@@ -299,17 +319,11 @@ void Panel::Maximize() {
}
void Panel::Minimize() {
- if (expansion_state_ != EXPANDED)
- return;
-
- if (IsDrawingAttention())
- SetExpansionState(TITLE_ONLY);
- else
- SetExpansionState(MINIMIZED);
+ panel_strip_->MinimizePanel(this);
}
void Panel::Restore() {
- SetExpansionState(EXPANDED);
+ panel_strip_->RestorePanel(this);
}
void Panel::EnterFullscreen(
diff --git a/chrome/browser/ui/panels/panel.h b/chrome/browser/ui/panels/panel.h
index 637ce47..65e6105 100644
--- a/chrome/browser/ui/panels/panel.h
+++ b/chrome/browser/ui/panels/panel.h
@@ -17,6 +17,7 @@
class NativePanel;
class PanelManager;
+class PanelStrip;
// Type of the panel strip which currently manages the panel location,
// visual state and size.
@@ -46,10 +47,7 @@ class Panel : public BrowserWindow,
// The panel is shown with the title-bar only.
TITLE_ONLY,
// The panel is shown with 3-pixel line.
- MINIMIZED,
- // The panel is put into the overflow area due to no space available in the
- // normal display area.
- IN_OVERFLOW
+ MINIMIZED
};
// The panel can be minimized to 4-pixel lines.
@@ -231,6 +229,14 @@ class Panel : public BrowserWindow,
NativePanel* native_panel() { return native_panel_; }
Browser* browser() const { return browser_; }
+
+ // May be NULL if panel is newly created and has not been positioned yet.
+ PanelStrip* panel_strip() const { return panel_strip_; }
+
+ // Moves the panel to the |new_strip|, removing the panel from its
+ // current strip.
+ void MoveToStrip(PanelStrip* new_strip);
+
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_; }
@@ -296,6 +302,10 @@ class Panel : public BrowserWindow,
Browser* browser_; // Weak, owned by native panel.
+ // Current collection of panels to which this panel belongs. This determines
+ // the panel's screen layout.
+ PanelStrip* panel_strip_; // Owned by PanelManager.
+
bool initialized_;
// Newly created panels may be placed in a temporary layout until their
diff --git a/chrome/browser/ui/panels/panel_browser_frame_view.cc b/chrome/browser/ui/panels/panel_browser_frame_view.cc
index bc437d4..e5c7c50 100644
--- a/chrome/browser/ui/panels/panel_browser_frame_view.cc
+++ b/chrome/browser/ui/panels/panel_browser_frame_view.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/ui/panels/panel_browser_view.h"
#include "chrome/browser/ui/panels/panel_manager.h"
#include "chrome/browser/ui/panels/panel_settings_menu_model.h"
+#include "chrome/browser/ui/panels/panel_strip.h"
#include "chrome/common/extensions/extension.h"
#include "content/public/browser/web_contents.h"
#include "grit/generated_resources.h"
@@ -499,7 +500,8 @@ void PanelBrowserFrameView::Layout() {
bool show_close_button = true;
bool show_settings_button = true;
bool show_title_label = true;
- if (panel_browser_view_->panel()->expansion_state() == Panel::IN_OVERFLOW) {
+ if (panel_browser_view_->panel()->panel_strip()->type() ==
+ PanelStrip::IN_OVERFLOW) {
if (width() <= IconOnlyWidth()) {
show_close_button = false;
show_settings_button = false;
@@ -881,7 +883,8 @@ void PanelBrowserFrameView::UpdateSettingsButtonVisibility(
DCHECK(has_settings_button_);
// The settings button is not shown in the overflow state.
- if (panel_browser_view_->panel()->expansion_state() == Panel::IN_OVERFLOW)
+ if (panel_browser_view_->panel()->panel_strip()->type() ==
+ PanelStrip::IN_OVERFLOW)
return;
bool is_settings_button_visible = focused || cursor_in_view;
diff --git a/chrome/browser/ui/panels/panel_browser_view.cc b/chrome/browser/ui/panels/panel_browser_view.cc
index 419d7be..0829d1c 100644
--- a/chrome/browser/ui/panels/panel_browser_view.cc
+++ b/chrome/browser/ui/panels/panel_browser_view.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/ui/panels/panel_bounds_animation.h"
#include "chrome/browser/ui/panels/panel_browser_frame_view.h"
#include "chrome/browser/ui/panels/panel_manager.h"
+#include "chrome/browser/ui/panels/panel_strip.h"
#include "chrome/browser/ui/views/frame/browser_frame.h"
#include "chrome/browser/ui/webui/chrome_web_ui.h"
#include "chrome/browser/ui/webui/task_manager_dialog.h"
@@ -494,7 +495,8 @@ bool PanelBrowserView::OnTitlebarMouseReleased() {
// Do not minimize the panel when we just clear the attention state. This is
// a hack to prevent the panel from being minimized when the user clicks on
// the title-bar to clear the attention.
- if (panel_->expansion_state() == Panel::EXPANDED &&
+ if (panel_->panel_strip()->type() == PanelStrip::DOCKED &&
+ panel_->expansion_state() == Panel::EXPANDED &&
base::TimeTicks::Now() - attention_cleared_time_ <
base::TimeDelta::FromMilliseconds(kSuspendMinimizeOnClickIntervalMs)) {
return true;
@@ -505,10 +507,12 @@ bool PanelBrowserView::OnTitlebarMouseReleased() {
base::TimeDelta::FromMilliseconds(kShortClickThresholdMs))
return true;
- Panel::ExpansionState new_expansion_state =
- (panel_->expansion_state() != Panel::EXPANDED) ? Panel::EXPANDED
- : Panel::MINIMIZED;
- panel_->SetExpansionState(new_expansion_state);
+ if (panel_->panel_strip()->type() == PanelStrip::DOCKED &&
+ panel_->expansion_state() == Panel::EXPANDED)
+ panel_->SetExpansionState(Panel::MINIMIZED);
+ else
+ panel_->Activate();
+
return true;
}
diff --git a/chrome/browser/ui/panels/panel_browser_window_gtk.cc b/chrome/browser/ui/panels/panel_browser_window_gtk.cc
index ea18ac1..58c69a9 100644
--- a/chrome/browser/ui/panels/panel_browser_window_gtk.cc
+++ b/chrome/browser/ui/panels/panel_browser_window_gtk.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/ui/panels/panel.h"
#include "chrome/browser/ui/panels/panel_bounds_animation.h"
#include "chrome/browser/ui/panels/panel_manager.h"
+#include "chrome/browser/ui/panels/panel_strip.h"
#include "chrome/browser/ui/panels/panel_settings_menu_model.h"
#include "chrome/common/chrome_notification_types.h"
#include "content/public/browser/notification_service.h"
@@ -641,7 +642,8 @@ gboolean PanelBrowserWindowGtk::OnTitlebarButtonReleaseEvent(
CleanupDragDrop();
- if (panel_->expansion_state() == Panel::EXPANDED) {
+ if (panel_->panel_strip()->type() == PanelStrip::DOCKED &&
+ panel_->expansion_state() == Panel::EXPANDED) {
if (base::Time::Now() < disableMinimizeUntilTime_)
return TRUE;
diff --git a/chrome/browser/ui/panels/panel_manager.cc b/chrome/browser/ui/panels/panel_manager.cc
index 921ea7e..ba0e69f 100644
--- a/chrome/browser/ui/panels/panel_manager.cc
+++ b/chrome/browser/ui/panels/panel_manager.cc
@@ -113,7 +113,7 @@ Panel* PanelManager::CreatePanel(Browser* browser) {
int width = browser->override_bounds().width();
int height = browser->override_bounds().height();
Panel* panel = new Panel(browser, gfx::Size(width, height));
- docked_strip_->AddPanel(panel);
+ panel->MoveToStrip(docked_strip_.get());
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_PANEL_ADDED,
@@ -147,19 +147,12 @@ void PanelManager::CheckFullScreenMode() {
overflow_strip_->OnFullScreenModeChanged(is_full_screen_);
}
-void PanelManager::Remove(Panel* panel) {
+void PanelManager::OnPanelRemoved(Panel* panel) {
#if defined(OS_WIN) || defined(OS_MACOSX)
- if (num_panels() == 1)
+ if (num_panels() == 0)
full_screen_mode_timer_.Stop();
#endif
- if (docked_strip_->RemovePanel(panel))
- return;
- bool removed = overflow_strip_->RemovePanel(panel);
- DCHECK(removed);
-}
-
-void PanelManager::OnPanelRemoved(Panel* panel) {
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_PANEL_REMOVED,
content::Source<Panel>(panel),
@@ -180,30 +173,23 @@ void PanelManager::EndDragging(bool cancelled) {
void PanelManager::OnPanelExpansionStateChanged(Panel* panel) {
docked_strip_->OnPanelExpansionStateChanged(panel);
- overflow_strip_->OnPanelExpansionStateChanged(panel);
-}
-
-void PanelManager::OnPanelAttentionStateChanged(Panel* panel) {
- if (panel->expansion_state() == Panel::IN_OVERFLOW)
- overflow_strip_->OnPanelAttentionStateChanged(panel);
- else
- docked_strip_->OnPanelAttentionStateChanged(panel);
}
void PanelManager::OnPreferredWindowSizeChanged(
Panel* panel, const gfx::Size& preferred_window_size) {
- if (!auto_sizing_enabled_)
+ if (!auto_sizing_enabled_) {
+ LOG(INFO) << "Resizing auto-resizable Panels is not supported yet.";
return;
+ }
docked_strip_->ResizePanelWindow(panel, preferred_window_size);
}
void PanelManager::ResizePanel(Panel* panel, const gfx::Size& new_size) {
// Explicit resizing is not allowed for auto-resizable panels for now.
// http://crbug.com/109343
- if (panel->auto_resizable()) {
- LOG(INFO) << "Resizing auto-resizable Panels is not supported yet.";
+ if (panel->auto_resizable())
return;
- }
+
docked_strip_->ResizePanelWindow(panel, new_size);
}
diff --git a/chrome/browser/ui/panels/panel_manager.h b/chrome/browser/ui/panels/panel_manager.h
index 120a4d34..1c21b24 100644
--- a/chrome/browser/ui/panels/panel_manager.h
+++ b/chrome/browser/ui/panels/panel_manager.h
@@ -52,9 +52,6 @@ class PanelManager : public AutoHidingDesktopBar::Observer {
// Invoked when a panel's expansion state changes.
void OnPanelExpansionStateChanged(Panel* panel);
- // Invoked when a panel is starting/stopping drawing an attention.
- void OnPanelAttentionStateChanged(Panel* panel);
-
// Invoked when the preferred window size of the given panel might need to
// get changed.
void OnPreferredWindowSizeChanged(
diff --git a/chrome/browser/ui/panels/panel_overflow_browsertest.cc b/chrome/browser/ui/panels/panel_overflow_browsertest.cc
index 3375fb1..2070651 100644
--- a/chrome/browser/ui/panels/panel_overflow_browsertest.cc
+++ b/chrome/browser/ui/panels/panel_overflow_browsertest.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/ui/panels/overflow_panel_strip.h"
#include "chrome/browser/ui/panels/panel.h"
#include "chrome/browser/ui/panels/panel_manager.h"
+#include "chrome/browser/ui/panels/panel_strip.h"
#include "chrome/browser/ui/panels/panel_overflow_indicator.h"
#include "chrome/browser/ui/panels/panel_settings_menu_model.h"
#include "chrome/browser/ui/panels/test_panel_mouse_watcher.h"
@@ -27,20 +28,24 @@ const int kMaxVisibleOverflowPanelsOnHoverForTesting = 6;
// when we do the overflow testing.
struct PanelData {
Panel* panel;
+ PanelStrip::Type layout_type;
Panel::ExpansionState expansion_state;
bool visible;
bool active;
explicit PanelData(Panel* panel)
: panel(panel),
+ layout_type(panel->panel_strip()->type()),
expansion_state(panel->expansion_state()),
visible(!panel->GetBounds().IsEmpty()),
active(panel->IsActive()) {
}
- PanelData(Panel* panel, Panel::ExpansionState expansion_state,
+ PanelData(Panel* panel, PanelStrip::Type layout_type,
+ Panel::ExpansionState expansion_state,
bool visible, bool active)
: panel(panel),
+ layout_type(layout_type),
expansion_state(expansion_state),
visible(visible),
active(active) {
@@ -48,6 +53,7 @@ struct PanelData {
bool operator==(const PanelData& another) const {
return panel == another.panel &&
+ layout_type == another.layout_type &&
expansion_state == another.expansion_state &&
visible == another.visible &&
active == another.active;
@@ -61,17 +67,28 @@ struct PanelData {
// For gtest printing.
::std::ostream& operator<<(::std::ostream& os, const PanelData& data);
::std::ostream& operator<<(::std::ostream& os, const PanelData& data) {
- return os << "(" << data.panel->browser()->app_name() << ", "
- << data.expansion_state << ", " << data.visible << ", "
+ return os << "("
+ << data.panel->browser()->app_name() << ", "
+ << data.layout_type << ", "
+ << data.expansion_state << ", "
+ << data.visible << ", "
<< data.active << ")";
}
class PanelDataList : public std::vector<PanelData> {
public:
- void Add(Panel* panel, Panel::ExpansionState expansion_state,
- bool visible, bool active) {
- push_back(PanelData(panel, expansion_state, visible, active));
+ void AddDocked(Panel* panel, Panel::ExpansionState expansion_state,
+ bool active) {
+ push_back(PanelData(panel, PanelStrip::DOCKED, expansion_state,
+ true, // docked is always visible
+ active));
+ }
+
+ void AddOverflow(Panel* panel, bool visible) {
+ push_back(PanelData(panel, PanelStrip::IN_OVERFLOW,
+ panel->expansion_state(), visible,
+ false)); // overflow is never active
}
};
@@ -152,7 +169,7 @@ class PanelOverflowBrowserTest : public BasePanelBrowserTest {
return expected_x == bounds.x() && expected_size == bounds.size();
}
- std::vector<Panel*> CreateOverflowPanels(int num_docked_panales,
+ std::vector<Panel*> CreateOverflowPanels(int num_docked_panels,
int num_overflow_panels,
const int* panel_widths) {
const int kTestPanelHeight = 200;
@@ -160,7 +177,7 @@ class PanelOverflowBrowserTest : public BasePanelBrowserTest {
// First, create panels to fill the docked strip.
int i = 0;
- for (; i < num_docked_panales; ++i) {
+ for (; i < num_docked_panels; ++i) {
CreatePanelParams params(
MakePanelName(i),
gfx::Rect(0, 0, panel_widths[i], kTestPanelHeight),
@@ -170,14 +187,14 @@ class PanelOverflowBrowserTest : public BasePanelBrowserTest {
}
// Then, create panels that would be placed in the overflow strip.
- int num_panels = num_docked_panales + num_overflow_panels;
+ int num_panels = num_docked_panels + num_overflow_panels;
for (; i < num_panels; ++i) {
CreatePanelParams params(
MakePanelName(i),
gfx::Rect(0, 0, panel_widths[i], kTestPanelHeight),
SHOW_AS_INACTIVE);
Panel* panel = CreatePanelWithParams(params);
- WaitForExpansionStateChanged(panel, Panel::IN_OVERFLOW);
+ WaitForLayoutModeChanged(panel, PanelStrip::IN_OVERFLOW);
panels.push_back(panel);
}
@@ -267,7 +284,7 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CheckPanelProperties) {
EXPECT_FALSE(panel4->draggable());
// Make sure last panel really did overflow.
- WaitForExpansionStateChanged(panel4, Panel::IN_OVERFLOW);
+ WaitForLayoutModeChanged(panel4, PanelStrip::IN_OVERFLOW);
EXPECT_FALSE(panel4->has_temporary_layout());
EXPECT_FALSE(panel4->draggable());
@@ -275,11 +292,12 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CheckPanelProperties) {
}
IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_UpdateDraggableStatus) {
+ PanelManager* panel_manager = PanelManager::GetInstance();
Panel* panel = CreatePanel("panel");
EXPECT_TRUE(panel->draggable());
- panel->SetExpansionState(Panel::IN_OVERFLOW);
+ panel->MoveToStrip(panel_manager->overflow_strip());
EXPECT_FALSE(panel->draggable());
- panel->SetExpansionState(Panel::EXPANDED);
+ panel->MoveToStrip(panel_manager->docked_strip());
EXPECT_TRUE(panel->draggable());
panel->Close();
}
@@ -312,7 +330,7 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CreateOverflowPanels) {
CreatePanelParams params(
"Panel3", gfx::Rect(0, 0, 255, 200), SHOW_AS_INACTIVE);
Panel* panel3 = CreatePanelWithParams(params);
- WaitForExpansionStateChanged(panel3, Panel::IN_OVERFLOW);
+ WaitForLayoutModeChanged(panel3, PanelStrip::IN_OVERFLOW);
EXPECT_EQ(4, panel_manager->num_panels());
EXPECT_EQ(3, docked_strip->num_panels());
@@ -325,7 +343,7 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CreateOverflowPanels) {
// Create 1 more overflow panel.
params.name = "Panel4";
Panel* panel4 = CreatePanelWithParams(params);
- WaitForExpansionStateChanged(panel4, Panel::IN_OVERFLOW);
+ WaitForLayoutModeChanged(panel4, PanelStrip::IN_OVERFLOW);
EXPECT_EQ(5, panel_manager->num_panels());
EXPECT_EQ(3, docked_strip->num_panels());
@@ -355,15 +373,15 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest,
EXPECT_EQ(3, docked_strip->num_panels());
EXPECT_EQ(5, overflow_strip->num_panels());
EXPECT_EQ(2, overflow_strip->overflow_indicator()->GetCount());
- EXPECT_EQ(Panel::IN_OVERFLOW, panels[3]->expansion_state());
+ EXPECT_EQ(PanelStrip::IN_OVERFLOW, panels[3]->panel_strip()->type());
EXPECT_TRUE(IsPanelVisible(panels[3]));
- EXPECT_EQ(Panel::IN_OVERFLOW, panels[4]->expansion_state());
+ EXPECT_EQ(PanelStrip::IN_OVERFLOW, panels[4]->panel_strip()->type());
EXPECT_TRUE(IsPanelVisible(panels[4]));
- EXPECT_EQ(Panel::IN_OVERFLOW, panels[5]->expansion_state());
+ EXPECT_EQ(PanelStrip::IN_OVERFLOW, panels[5]->panel_strip()->type());
EXPECT_TRUE(IsPanelVisible(panels[5]));
- EXPECT_EQ(Panel::IN_OVERFLOW, panels[6]->expansion_state());
+ EXPECT_EQ(PanelStrip::IN_OVERFLOW, panels[6]->panel_strip()->type());
EXPECT_FALSE(IsPanelVisible(panels[6]));
- EXPECT_EQ(Panel::IN_OVERFLOW, panels[7]->expansion_state());
+ EXPECT_EQ(PanelStrip::IN_OVERFLOW, panels[7]->panel_strip()->type());
EXPECT_FALSE(IsPanelVisible(panels[7]));
PanelManager::GetInstance()->CloseAll();
@@ -391,7 +409,7 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest,
EXPECT_EQ(Panel::EXPANDED, panel3->expansion_state());
EXPECT_FALSE(panel3->has_temporary_layout());
- WaitForExpansionStateChanged(overflow_panel, Panel::IN_OVERFLOW);
+ WaitForLayoutModeChanged(overflow_panel, PanelStrip::IN_OVERFLOW);
EXPECT_FALSE(overflow_panel->has_temporary_layout());
PanelManager::GetInstance()->CloseAll();
}
@@ -406,7 +424,7 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CloseOverflowPanels) {
// docked: P0, P1, P2
// overflow: P3, P4, P5
// overflow-on-overflow: P6, P7
- int num_docked_panales = 3;
+ int num_docked_panels = 3;
int num_overflow_panels = 5;
const int panel_widths[] = {
260, 250, 200, // docked
@@ -414,20 +432,20 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CloseOverflowPanels) {
240, 210 // overflow-on-overflow
};
std::vector<Panel*> panels = CreateOverflowPanels(
- num_docked_panales, num_overflow_panels, panel_widths);
+ num_docked_panels, num_overflow_panels, panel_widths);
PanelDataList expected_docked_list;
- expected_docked_list.Add(panels[0], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[1], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[2], Panel::EXPANDED, true, false);
+ expected_docked_list.AddDocked(panels[0], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[1], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[2], Panel::EXPANDED, false);
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
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);
- expected_overflow_list.Add(panels[6], Panel::IN_OVERFLOW, false, false);
- expected_overflow_list.Add(panels[7], Panel::IN_OVERFLOW, false, false);
+ expected_overflow_list.AddOverflow(panels[3], true);
+ expected_overflow_list.AddOverflow(panels[4], true);
+ expected_overflow_list.AddOverflow(panels[5], true);
+ expected_overflow_list.AddOverflow(panels[6], false);
+ expected_overflow_list.AddOverflow(panels[7], false);
EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData());
// Close an overflow-on-overflow panel. Expect only that panel is closed.
@@ -436,18 +454,18 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CloseOverflowPanels) {
// overflow-on-overflow: P7
CloseWindowAndWait(panels[6]->browser());
num_overflow_panels--;
- ASSERT_EQ(num_docked_panales + num_overflow_panels,
+ ASSERT_EQ(num_docked_panels + num_overflow_panels,
panel_manager->num_panels());
- EXPECT_EQ(num_docked_panales, docked_strip->num_panels());
+ EXPECT_EQ(num_docked_panels, docked_strip->num_panels());
EXPECT_EQ(num_overflow_panels, overflow_strip->num_panels());
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
expected_overflow_list.clear();
- 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);
- expected_overflow_list.Add(panels[7], Panel::IN_OVERFLOW, false, false);
+ expected_overflow_list.AddOverflow(panels[3], true);
+ expected_overflow_list.AddOverflow(panels[4], true);
+ expected_overflow_list.AddOverflow(panels[5], true);
+ expected_overflow_list.AddOverflow(panels[7], false);
EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData());
// Close an overflow panel. Expect an overflow-on-overflow panel to become
@@ -456,17 +474,17 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CloseOverflowPanels) {
// overflow: P3, P5, P7
CloseWindowAndWait(panels[4]->browser());
num_overflow_panels--;
- ASSERT_EQ(num_docked_panales + num_overflow_panels,
+ ASSERT_EQ(num_docked_panels + num_overflow_panels,
panel_manager->num_panels());
- EXPECT_EQ(num_docked_panales, docked_strip->num_panels());
+ EXPECT_EQ(num_docked_panels, docked_strip->num_panels());
EXPECT_EQ(num_overflow_panels, overflow_strip->num_panels());
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
expected_overflow_list.clear();
- expected_overflow_list.Add(panels[3], Panel::IN_OVERFLOW, true, false);
- expected_overflow_list.Add(panels[5], Panel::IN_OVERFLOW, true, false);
- expected_overflow_list.Add(panels[7], Panel::IN_OVERFLOW, true, false);
+ expected_overflow_list.AddOverflow(panels[3], true);
+ expected_overflow_list.AddOverflow(panels[5], true);
+ expected_overflow_list.AddOverflow(panels[7], true);
EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData());
// Close an overflow panel. Expect only that panel is closed.
@@ -474,16 +492,16 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CloseOverflowPanels) {
// overflow: P5, P7
CloseWindowAndWait(panels[3]->browser());
num_overflow_panels--;
- ASSERT_EQ(num_docked_panales + num_overflow_panels,
+ ASSERT_EQ(num_docked_panels + num_overflow_panels,
panel_manager->num_panels());
- EXPECT_EQ(num_docked_panales, docked_strip->num_panels());
+ EXPECT_EQ(num_docked_panels, docked_strip->num_panels());
EXPECT_EQ(num_overflow_panels, overflow_strip->num_panels());
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
expected_overflow_list.clear();
- expected_overflow_list.Add(panels[5], Panel::IN_OVERFLOW, true, false);
- expected_overflow_list.Add(panels[7], Panel::IN_OVERFLOW, true, false);
+ expected_overflow_list.AddOverflow(panels[5], true);
+ expected_overflow_list.AddOverflow(panels[7], true);
EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData());
panel_manager->CloseAll();
@@ -499,7 +517,7 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CloseDockedPanels) {
// docked: P0, P1, P2
// overflow: P3, P4, P5
// overflow-on-overflow: P6, P7, P8
- int num_docked_panales = 3;
+ int num_docked_panels = 3;
int num_overflow_panels = 6;
const int panel_widths[] = {
260, 250, 200, // docked
@@ -507,21 +525,21 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CloseDockedPanels) {
240, 210, 258 // overflow-on-overflow
};
std::vector<Panel*> panels = CreateOverflowPanels(
- num_docked_panales, num_overflow_panels, panel_widths);
+ num_docked_panels, num_overflow_panels, panel_widths);
PanelDataList expected_docked_list;
- expected_docked_list.Add(panels[0], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[1], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[2], Panel::EXPANDED, true, false);
+ expected_docked_list.AddDocked(panels[0], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[1], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[2], Panel::EXPANDED, false);
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
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);
- expected_overflow_list.Add(panels[6], Panel::IN_OVERFLOW, false, false);
- expected_overflow_list.Add(panels[7], Panel::IN_OVERFLOW, false, false);
- expected_overflow_list.Add(panels[8], Panel::IN_OVERFLOW, false, false);
+ expected_overflow_list.AddOverflow(panels[3], true);
+ expected_overflow_list.AddOverflow(panels[4], true);
+ expected_overflow_list.AddOverflow(panels[5], true);
+ expected_overflow_list.AddOverflow(panels[6], false);
+ expected_overflow_list.AddOverflow(panels[7], false);
+ expected_overflow_list.AddOverflow(panels[8], false);
EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData());
// Close a docked panel. Expect an overflow panel to move over and an
@@ -531,23 +549,23 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CloseDockedPanels) {
// overflow-on-overflow: P7, P8
CloseWindowAndWait(panels[1]->browser());
num_overflow_panels--;
- ASSERT_EQ(num_docked_panales + num_overflow_panels,
+ ASSERT_EQ(num_docked_panels + num_overflow_panels,
panel_manager->num_panels());
- EXPECT_EQ(num_docked_panales, docked_strip->num_panels());
+ EXPECT_EQ(num_docked_panels, docked_strip->num_panels());
EXPECT_EQ(num_overflow_panels, overflow_strip->num_panels());
expected_docked_list.clear();
- expected_docked_list.Add(panels[0], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[2], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[3], Panel::EXPANDED, true, false);
+ expected_docked_list.AddDocked(panels[0], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[2], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[3], Panel::EXPANDED, false);
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
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);
- expected_overflow_list.Add(panels[6], Panel::IN_OVERFLOW, true, false);
- expected_overflow_list.Add(panels[7], Panel::IN_OVERFLOW, false, false);
- expected_overflow_list.Add(panels[8], Panel::IN_OVERFLOW, false, false);
+ expected_overflow_list.AddOverflow(panels[4], true);
+ expected_overflow_list.AddOverflow(panels[5], true);
+ expected_overflow_list.AddOverflow(panels[6], true);
+ expected_overflow_list.AddOverflow(panels[7], false);
+ expected_overflow_list.AddOverflow(panels[8], false);
EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData());
// Close another docked panel. Remaining overflow panels cannot move over
@@ -556,15 +574,15 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CloseDockedPanels) {
// overflow: P4, P5, P6
// overflow-on-overflow: P7, P8
CloseWindowAndWait(panels[2]->browser());
- num_docked_panales--;
- ASSERT_EQ(num_docked_panales + num_overflow_panels,
+ num_docked_panels--;
+ ASSERT_EQ(num_docked_panels + num_overflow_panels,
panel_manager->num_panels());
- EXPECT_EQ(num_docked_panales, docked_strip->num_panels());
+ EXPECT_EQ(num_docked_panels, docked_strip->num_panels());
EXPECT_EQ(num_overflow_panels, overflow_strip->num_panels());
expected_docked_list.clear();
- expected_docked_list.Add(panels[0], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[3], Panel::EXPANDED, true, false);
+ expected_docked_list.AddDocked(panels[0], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[3], Panel::EXPANDED, false);
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData());
@@ -574,23 +592,23 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CloseDockedPanels) {
// docked: P0, P4, P5
// overflow: P6, P7, P8
CloseWindowAndWait(panels[3]->browser());
- num_docked_panales++;
+ num_docked_panels++;
num_overflow_panels -= 2;
- ASSERT_EQ(num_docked_panales + num_overflow_panels,
+ ASSERT_EQ(num_docked_panels + num_overflow_panels,
panel_manager->num_panels());
- EXPECT_EQ(num_docked_panales, docked_strip->num_panels());
+ EXPECT_EQ(num_docked_panels, docked_strip->num_panels());
EXPECT_EQ(num_overflow_panels, overflow_strip->num_panels());
expected_docked_list.clear();
- expected_docked_list.Add(panels[0], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[4], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[5], Panel::EXPANDED, true, false);
+ expected_docked_list.AddDocked(panels[0], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[4], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[5], Panel::EXPANDED, false);
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
expected_overflow_list.clear();
- expected_overflow_list.Add(panels[6], Panel::IN_OVERFLOW, true, false);
- expected_overflow_list.Add(panels[7], Panel::IN_OVERFLOW, true, false);
- expected_overflow_list.Add(panels[8], Panel::IN_OVERFLOW, true, false);
+ expected_overflow_list.AddOverflow(panels[6], true);
+ expected_overflow_list.AddOverflow(panels[7], true);
+ expected_overflow_list.AddOverflow(panels[8], true);
EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData());
// Close another docked panel. Expect one overflow panel to move over.
@@ -598,20 +616,20 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_CloseDockedPanels) {
// overflow: P7, P8
CloseWindowAndWait(panels[0]->browser());
num_overflow_panels--;
- ASSERT_EQ(num_docked_panales + num_overflow_panels,
+ ASSERT_EQ(num_docked_panels + num_overflow_panels,
panel_manager->num_panels());
- EXPECT_EQ(num_docked_panales, docked_strip->num_panels());
+ EXPECT_EQ(num_docked_panels, docked_strip->num_panels());
EXPECT_EQ(num_overflow_panels, overflow_strip->num_panels());
expected_docked_list.clear();
- expected_docked_list.Add(panels[4], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[5], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[6], Panel::EXPANDED, true, false);
+ expected_docked_list.AddDocked(panels[4], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[5], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[6], Panel::EXPANDED, false);
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
expected_overflow_list.clear();
- expected_overflow_list.Add(panels[7], Panel::IN_OVERFLOW, true, false);
- expected_overflow_list.Add(panels[8], Panel::IN_OVERFLOW, true, false);
+ expected_overflow_list.AddOverflow(panels[7], true);
+ expected_overflow_list.AddOverflow(panels[8], true);
EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData());
panel_manager->CloseAll();
@@ -658,7 +676,7 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest,
EXPECT_TRUE(overflow_panel->has_temporary_layout());
// Make sure the overflow panel actually moves to overflow.
- WaitForExpansionStateChanged(overflow_panel, Panel::IN_OVERFLOW);
+ WaitForLayoutModeChanged(overflow_panel, PanelStrip::IN_OVERFLOW);
EXPECT_EQ(0, docked_strip->num_temporary_layout_panels());
// Hack. Put the "falsely closed" panel back into the panel strip
@@ -683,17 +701,17 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_ActivateOverflowPanels) {
std::vector<Panel*> panels = CreateOverflowPanels(3, 5, panel_widths);
PanelDataList expected_docked_list;
- expected_docked_list.Add(panels[0], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[1], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[2], Panel::EXPANDED, true, false);
+ expected_docked_list.AddDocked(panels[0], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[1], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[2], Panel::EXPANDED, false);
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
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);
- expected_overflow_list.Add(panels[6], Panel::IN_OVERFLOW, false, false);
- expected_overflow_list.Add(panels[7], Panel::IN_OVERFLOW, false, false);
+ expected_overflow_list.AddOverflow(panels[3], true);
+ expected_overflow_list.AddOverflow(panels[4], true);
+ expected_overflow_list.AddOverflow(panels[5], true);
+ expected_overflow_list.AddOverflow(panels[6], false);
+ expected_overflow_list.AddOverflow(panels[7], false);
EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData());
// Activate an overflow panel. Expect one docked panel is swapped into the
@@ -703,20 +721,20 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_ActivateOverflowPanels) {
// overflow-on-overflow: P6, P7
panels[3]->Activate();
WaitForPanelActiveState(panels[3], SHOW_AS_ACTIVE);
- WaitForExpansionStateChanged(panels[3], Panel::EXPANDED);
+ WaitForLayoutModeChanged(panels[3], PanelStrip::DOCKED);
expected_docked_list.clear();
- expected_docked_list.Add(panels[0], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[1], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[3], Panel::EXPANDED, true, true);
+ expected_docked_list.AddDocked(panels[0], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[1], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[3], Panel::EXPANDED, true);
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
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);
- expected_overflow_list.Add(panels[6], Panel::IN_OVERFLOW, false, false);
- expected_overflow_list.Add(panels[7], Panel::IN_OVERFLOW, false, false);
+ expected_overflow_list.AddOverflow(panels[2], true);
+ expected_overflow_list.AddOverflow(panels[4], true);
+ expected_overflow_list.AddOverflow(panels[5], true);
+ expected_overflow_list.AddOverflow(panels[6], false);
+ expected_overflow_list.AddOverflow(panels[7], false);
EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData());
// Activate an overflow panel. Expect two docked panels are swapped into the
@@ -726,21 +744,21 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_ActivateOverflowPanels) {
// overflow-on-overflow: P5, P6, P7
panels[4]->Activate();
WaitForPanelActiveState(panels[4], SHOW_AS_ACTIVE);
- WaitForExpansionStateChanged(panels[4], Panel::EXPANDED);
+ WaitForLayoutModeChanged(panels[4], PanelStrip::DOCKED);
WaitForPanelActiveState(panels[3], SHOW_AS_INACTIVE);
expected_docked_list.clear();
- expected_docked_list.Add(panels[0], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[4], Panel::EXPANDED, true, true);
+ expected_docked_list.AddDocked(panels[0], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[4], Panel::EXPANDED, true);
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
expected_overflow_list.clear();
- expected_overflow_list.Add(panels[1], Panel::IN_OVERFLOW, true, false);
- expected_overflow_list.Add(panels[3], Panel::IN_OVERFLOW, true, false);
- expected_overflow_list.Add(panels[2], Panel::IN_OVERFLOW, true, false);
- expected_overflow_list.Add(panels[5], Panel::IN_OVERFLOW, false, false);
- expected_overflow_list.Add(panels[6], Panel::IN_OVERFLOW, false, false);
- expected_overflow_list.Add(panels[7], Panel::IN_OVERFLOW, false, false);
+ expected_overflow_list.AddOverflow(panels[1], true);
+ expected_overflow_list.AddOverflow(panels[3], true);
+ expected_overflow_list.AddOverflow(panels[2], true);
+ expected_overflow_list.AddOverflow(panels[5], false);
+ expected_overflow_list.AddOverflow(panels[6], false);
+ expected_overflow_list.AddOverflow(panels[7], false);
EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData());
// Activate an overflow-on-overflow panel. Expect one docked panel is swapped
@@ -750,21 +768,21 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_ActivateOverflowPanels) {
// overflow-on-overflow: P2, P5, P7
panels[6]->Activate();
WaitForPanelActiveState(panels[6], SHOW_AS_ACTIVE);
- WaitForExpansionStateChanged(panels[6], Panel::EXPANDED);
+ WaitForLayoutModeChanged(panels[6], PanelStrip::DOCKED);
WaitForPanelActiveState(panels[4], SHOW_AS_INACTIVE);
expected_docked_list.clear();
- expected_docked_list.Add(panels[0], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[6], Panel::EXPANDED, true, true);
+ expected_docked_list.AddDocked(panels[0], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[6], Panel::EXPANDED, true);
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
expected_overflow_list.clear();
- expected_overflow_list.Add(panels[4], Panel::IN_OVERFLOW, true, false);
- expected_overflow_list.Add(panels[1], Panel::IN_OVERFLOW, true, false);
- expected_overflow_list.Add(panels[3], Panel::IN_OVERFLOW, true, false);
- expected_overflow_list.Add(panels[2], Panel::IN_OVERFLOW, false, false);
- expected_overflow_list.Add(panels[5], Panel::IN_OVERFLOW, false, false);
- expected_overflow_list.Add(panels[7], Panel::IN_OVERFLOW, false, false);
+ expected_overflow_list.AddOverflow(panels[4], true);
+ expected_overflow_list.AddOverflow(panels[1], true);
+ expected_overflow_list.AddOverflow(panels[3], true);
+ expected_overflow_list.AddOverflow(panels[2], false);
+ expected_overflow_list.AddOverflow(panels[5], false);
+ expected_overflow_list.AddOverflow(panels[7], false);
EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData());
// Activate an overflow-on-overflow panel. No docked panel is swapped
@@ -774,21 +792,21 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_ActivateOverflowPanels) {
// overflow-on-overflow: P2, P5
panels[7]->Activate();
WaitForPanelActiveState(panels[7], SHOW_AS_ACTIVE);
- WaitForExpansionStateChanged(panels[7], Panel::EXPANDED);
+ WaitForLayoutModeChanged(panels[7], PanelStrip::DOCKED);
WaitForPanelActiveState(panels[6], SHOW_AS_INACTIVE);
expected_docked_list.clear();
- expected_docked_list.Add(panels[0], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[6], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[7], Panel::EXPANDED, true, true);
+ expected_docked_list.AddDocked(panels[0], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[6], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[7], Panel::EXPANDED, true);
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
expected_overflow_list.clear();
- expected_overflow_list.Add(panels[4], Panel::IN_OVERFLOW, true, false);
- expected_overflow_list.Add(panels[1], Panel::IN_OVERFLOW, true, false);
- expected_overflow_list.Add(panels[3], Panel::IN_OVERFLOW, true, false);
- expected_overflow_list.Add(panels[2], Panel::IN_OVERFLOW, false, false);
- expected_overflow_list.Add(panels[5], Panel::IN_OVERFLOW, false, false);
+ expected_overflow_list.AddOverflow(panels[4], true);
+ expected_overflow_list.AddOverflow(panels[1], true);
+ expected_overflow_list.AddOverflow(panels[3], true);
+ expected_overflow_list.AddOverflow(panels[2], false);
+ expected_overflow_list.AddOverflow(panels[5], false);
EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData());
PanelManager::GetInstance()->CloseAll();
@@ -807,14 +825,14 @@ IN_PROC_BROWSER_TEST_F(
std::vector<Panel*> panels = CreateOverflowPanels(3, 2, panel_widths);
PanelDataList expected_docked_list;
- expected_docked_list.Add(panels[0], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[1], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[2], Panel::EXPANDED, true, false);
+ expected_docked_list.AddDocked(panels[0], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[1], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[2], Panel::EXPANDED, false);
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
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.AddOverflow(panels[3], true);
+ expected_overflow_list.AddOverflow(panels[4], true);
// Minimize a docked panel and then bump it to overflow by activating an
// overflow panel.
@@ -823,17 +841,17 @@ IN_PROC_BROWSER_TEST_F(
panels[2]->SetExpansionState(Panel::MINIMIZED);
panels[3]->Activate();
WaitForPanelActiveState(panels[3], SHOW_AS_ACTIVE);
- WaitForExpansionStateChanged(panels[3], Panel::EXPANDED);
+ WaitForLayoutModeChanged(panels[3], PanelStrip::DOCKED);
expected_docked_list.clear();
- expected_docked_list.Add(panels[0], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[1], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[3], Panel::EXPANDED, true, true);
+ expected_docked_list.AddDocked(panels[0], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[1], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[3], Panel::EXPANDED, true);
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
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.AddOverflow(panels[2], true);
+ expected_overflow_list.AddOverflow(panels[4], true);
EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData());
// Reactivate the formerly minimized panel. It will return to the panel
@@ -842,17 +860,17 @@ IN_PROC_BROWSER_TEST_F(
// overflow: P3, P4
panels[2]->Activate();
WaitForPanelActiveState(panels[2], SHOW_AS_ACTIVE);
- WaitForExpansionStateChanged(panels[2], Panel::EXPANDED);
+ WaitForLayoutModeChanged(panels[2], PanelStrip::DOCKED);
expected_docked_list.clear();
- expected_docked_list.Add(panels[0], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[1], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[2], Panel::EXPANDED, true, true);
+ expected_docked_list.AddDocked(panels[0], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[1], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[2], Panel::EXPANDED, true);
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
expected_overflow_list.clear();
- 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.AddOverflow(panels[3], true);
+ expected_overflow_list.AddOverflow(panels[4], true);
EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData());
// Minimize a panel to title only mode, then bump it to overflow.
@@ -861,17 +879,17 @@ IN_PROC_BROWSER_TEST_F(
panels[2]->SetExpansionState(Panel::TITLE_ONLY);
panels[3]->Activate();
WaitForPanelActiveState(panels[3], SHOW_AS_ACTIVE);
- WaitForExpansionStateChanged(panels[3], Panel::EXPANDED);
+ WaitForLayoutModeChanged(panels[3], PanelStrip::DOCKED);
expected_docked_list.clear();
- expected_docked_list.Add(panels[0], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[1], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[3], Panel::EXPANDED, true, true);
+ expected_docked_list.AddDocked(panels[0], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[1], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[3], Panel::EXPANDED, true);
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
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.AddOverflow(panels[2], true);
+ expected_overflow_list.AddOverflow(panels[4], true);
EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData());
// Reactivate the formerly minimized panel. It will return to the panel
@@ -880,17 +898,17 @@ IN_PROC_BROWSER_TEST_F(
// overflow: P3, P4
panels[2]->Activate();
WaitForPanelActiveState(panels[2], SHOW_AS_ACTIVE);
- WaitForExpansionStateChanged(panels[2], Panel::EXPANDED);
+ WaitForLayoutModeChanged(panels[2], PanelStrip::DOCKED);
expected_docked_list.clear();
- expected_docked_list.Add(panels[0], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[1], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[2], Panel::EXPANDED, true, true);
+ expected_docked_list.AddDocked(panels[0], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[1], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[2], Panel::EXPANDED, true);
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
expected_overflow_list.clear();
- 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.AddOverflow(panels[3], true);
+ expected_overflow_list.AddOverflow(panels[4], true);
EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData());
PanelManager::GetInstance()->CloseAll();
@@ -911,15 +929,15 @@ IN_PROC_BROWSER_TEST_F(
std::vector<Panel*> panels = CreateOverflowPanels(3, 3, panel_widths);
PanelDataList expected_docked_list;
- expected_docked_list.Add(panels[0], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[1], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[2], Panel::EXPANDED, true, false);
+ expected_docked_list.AddDocked(panels[0], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[1], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[2], Panel::EXPANDED, false);
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
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);
+ expected_overflow_list.AddOverflow(panels[3], true);
+ expected_overflow_list.AddOverflow(panels[4], true);
+ expected_overflow_list.AddOverflow(panels[5], true);
// Test case 1: restoring minimized to minimized.
{
@@ -930,36 +948,36 @@ IN_PROC_BROWSER_TEST_F(
panels[2]->SetExpansionState(Panel::MINIMIZED);
panels[3]->Activate();
WaitForPanelActiveState(panels[3], SHOW_AS_ACTIVE);
- WaitForExpansionStateChanged(panels[3], Panel::EXPANDED);
+ WaitForLayoutModeChanged(panels[3], PanelStrip::DOCKED);
expected_docked_list.clear();
- expected_docked_list.Add(panels[0], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[1], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[3], Panel::EXPANDED, true, true);
+ expected_docked_list.AddDocked(panels[0], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[1], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[3], Panel::EXPANDED, true);
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
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);
+ expected_overflow_list.AddOverflow(panels[2], true);
+ expected_overflow_list.AddOverflow(panels[4], true);
+ expected_overflow_list.AddOverflow(panels[5], true);
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.
+ // return to the panel strip icocoa/n the minimized state.
// docked: P0, P1, P2
// overflow: P4, P5
CloseWindowAndWait(panels[3]->browser());
- WaitForExpansionStateChanged(panels[2], Panel::MINIMIZED);
+ WaitForLayoutModeChanged(panels[2], PanelStrip::DOCKED);
expected_docked_list.clear();
- expected_docked_list.Add(panels[0], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[1], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[2], Panel::MINIMIZED, true, false);
+ expected_docked_list.AddDocked(panels[0], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[1], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[2], Panel::MINIMIZED, false);
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
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);
+ expected_overflow_list.AddOverflow(panels[4], true);
+ expected_overflow_list.AddOverflow(panels[5], true);
EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData());
}
@@ -970,17 +988,17 @@ IN_PROC_BROWSER_TEST_F(
// overflow: P2, P5
panels[4]->Activate();
WaitForPanelActiveState(panels[4], SHOW_AS_ACTIVE);
- WaitForExpansionStateChanged(panels[4], Panel::EXPANDED);
+ WaitForLayoutModeChanged(panels[4], PanelStrip::DOCKED);
expected_docked_list.clear();
- expected_docked_list.Add(panels[0], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[1], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[4], Panel::EXPANDED, true, true);
+ expected_docked_list.AddDocked(panels[0], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[1], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[4], Panel::EXPANDED, true);
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
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);
+ expected_overflow_list.AddOverflow(panels[2], true);
+ expected_overflow_list.AddOverflow(panels[5], true);
EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData());
// Minimize another panel and hover the mouse over it. This should bring up
@@ -996,16 +1014,16 @@ IN_PROC_BROWSER_TEST_F(
// docked: P0, P1, P2
// overflow: P5
CloseWindowAndWait(panels[4]->browser());
- WaitForExpansionStateChanged(panels[2], Panel::TITLE_ONLY);
+ WaitForLayoutModeChanged(panels[2], PanelStrip::DOCKED);
expected_docked_list.clear();
- expected_docked_list.Add(panels[0], Panel::TITLE_ONLY, true, false);
- expected_docked_list.Add(panels[1], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[2], Panel::TITLE_ONLY, true, false);
+ expected_docked_list.AddDocked(panels[0], Panel::TITLE_ONLY, false);
+ expected_docked_list.AddDocked(panels[1], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[2], Panel::TITLE_ONLY, false);
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
expected_overflow_list.clear();
- expected_overflow_list.Add(panels[5], Panel::IN_OVERFLOW, true, false);
+ expected_overflow_list.AddOverflow(panels[5], true);
EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData());
}
@@ -1016,16 +1034,16 @@ IN_PROC_BROWSER_TEST_F(
// overflow: P2
panels[5]->Activate();
WaitForPanelActiveState(panels[5], SHOW_AS_ACTIVE);
- WaitForExpansionStateChanged(panels[5], Panel::EXPANDED);
+ WaitForLayoutModeChanged(panels[5], PanelStrip::DOCKED);
expected_docked_list.clear();
- expected_docked_list.Add(panels[0], Panel::TITLE_ONLY, true, false);
- expected_docked_list.Add(panels[1], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[5], Panel::EXPANDED, true, true);
+ expected_docked_list.AddDocked(panels[0], Panel::TITLE_ONLY, false);
+ expected_docked_list.AddDocked(panels[1], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[5], Panel::EXPANDED, true);
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
expected_overflow_list.clear();
- expected_overflow_list.Add(panels[2], Panel::IN_OVERFLOW, true, false);
+ expected_overflow_list.AddOverflow(panels[2], true);
EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData());
// Bring back the formerly title-only panel by shrinking a panel. It will
@@ -1036,10 +1054,10 @@ IN_PROC_BROWSER_TEST_F(
panels[5]->GetBounds().height() / 2));
expected_docked_list.clear();
- expected_docked_list.Add(panels[0], Panel::TITLE_ONLY, true, false);
- expected_docked_list.Add(panels[1], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[5], Panel::EXPANDED, true, true);
- expected_docked_list.Add(panels[2], Panel::TITLE_ONLY, true, false);
+ expected_docked_list.AddDocked(panels[0], Panel::TITLE_ONLY, false);
+ expected_docked_list.AddDocked(panels[1], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[5], Panel::EXPANDED, true);
+ expected_docked_list.AddDocked(panels[2], Panel::TITLE_ONLY, false);
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
expected_overflow_list.clear();
@@ -1056,13 +1074,13 @@ IN_PROC_BROWSER_TEST_F(
panels[5]->GetBounds().height() * 2));
expected_docked_list.clear();
- expected_docked_list.Add(panels[0], Panel::TITLE_ONLY, true, false);
- expected_docked_list.Add(panels[1], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[5], Panel::EXPANDED, true, true);
+ expected_docked_list.AddDocked(panels[0], Panel::TITLE_ONLY, false);
+ expected_docked_list.AddDocked(panels[1], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[5], Panel::EXPANDED, true);
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
expected_overflow_list.clear();
- expected_overflow_list.Add(panels[2], Panel::IN_OVERFLOW, true, false);
+ expected_overflow_list.AddOverflow(panels[2], true);
EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData());
// Move the mouse away. This should bring down all currently title-only
@@ -1079,17 +1097,17 @@ IN_PROC_BROWSER_TEST_F(
panels[5]->GetBounds().height() / 2));
expected_docked_list.clear();
- expected_docked_list.Add(panels[0], Panel::MINIMIZED, true, false);
- expected_docked_list.Add(panels[1], Panel::EXPANDED, true, false);
- expected_docked_list.Add(panels[5], Panel::EXPANDED, true, true);
- expected_docked_list.Add(panels[2], Panel::MINIMIZED, true, false);
+ expected_docked_list.AddDocked(panels[0], Panel::MINIMIZED, false);
+ expected_docked_list.AddDocked(panels[1], Panel::EXPANDED, false);
+ expected_docked_list.AddDocked(panels[5], Panel::EXPANDED, true);
+ expected_docked_list.AddDocked(panels[2], Panel::MINIMIZED, false);
EXPECT_EQ(expected_docked_list, GetAllDockedPanelData());
expected_overflow_list.clear();
EXPECT_EQ(expected_overflow_list, GetAllOverflowPanelData());
}
- PanelManager::GetInstance()->CloseAll();
+ panel_manager->CloseAll();
}
IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest,
@@ -1292,7 +1310,7 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_ResizePanel) {
panel_manager->OnPreferredWindowSizeChanged(panel4, new_size);
EXPECT_EQ(3, docked_strip->num_panels());
EXPECT_EQ(1, overflow_strip->num_panels());
- EXPECT_EQ(Panel::IN_OVERFLOW, panel4->expansion_state());
+ EXPECT_EQ(PanelStrip::IN_OVERFLOW, panel4->panel_strip()->type());
EXPECT_TRUE(IsPanelInOverflowStrip(panel4));
EXPECT_EQ(new_size, panel4->restored_size());
@@ -1303,7 +1321,8 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_ResizePanel) {
EXPECT_EQ(4, docked_strip->num_panels());
EXPECT_EQ(1, overflow_strip->num_panels());
EXPECT_EQ(Panel::EXPANDED, panel5->expansion_state());
- EXPECT_EQ(Panel::IN_OVERFLOW, panel4->expansion_state()); // no change
+ EXPECT_EQ(PanelStrip::DOCKED, panel5->panel_strip()->type());
+ EXPECT_EQ(PanelStrip::IN_OVERFLOW, panel4->panel_strip()->type()); // same
// Resize a panel from the middle of the strip so that it causes a
// panel to overflow.
@@ -1312,8 +1331,8 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_ResizePanel) {
panel_manager->OnPreferredWindowSizeChanged(panel3, gfx::Size(250, 200));
EXPECT_EQ(3, docked_strip->num_panels());
EXPECT_EQ(2, overflow_strip->num_panels());
- EXPECT_EQ(Panel::IN_OVERFLOW, panel4->expansion_state());
- EXPECT_EQ(Panel::IN_OVERFLOW, panel5->expansion_state());
+ EXPECT_EQ(PanelStrip::IN_OVERFLOW, panel4->panel_strip()->type());
+ EXPECT_EQ(PanelStrip::IN_OVERFLOW, panel5->panel_strip()->type());
const OverflowPanelStrip::Panels& overflow = overflow_strip->panels();
EXPECT_EQ(panel5, overflow[0]); // new overflow panel is first
EXPECT_EQ(panel4, overflow[1]);
@@ -1324,8 +1343,8 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_ResizePanel) {
panel_manager->OnPreferredWindowSizeChanged(panel3, gfx::Size(100, 200));
EXPECT_EQ(4, docked_strip->num_panels());
EXPECT_EQ(1, overflow_strip->num_panels());
- EXPECT_EQ(Panel::EXPANDED, panel5->expansion_state());
- EXPECT_EQ(Panel::IN_OVERFLOW, panel4->expansion_state());
+ EXPECT_EQ(PanelStrip::DOCKED, panel5->panel_strip()->type());
+ EXPECT_EQ(PanelStrip::IN_OVERFLOW, panel4->panel_strip()->type());
// Resize smaller again but not small enough to fit overflow panel.
// docked: P1 (250), P2 (100)*, P3 (100), P5 (100)
@@ -1333,7 +1352,7 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_ResizePanel) {
panel_manager->OnPreferredWindowSizeChanged(panel2, gfx::Size(100, 200));
EXPECT_EQ(4, docked_strip->num_panels());
EXPECT_EQ(1, overflow_strip->num_panels());
- EXPECT_EQ(Panel::IN_OVERFLOW, panel4->expansion_state()); // no change
+ EXPECT_EQ(PanelStrip::IN_OVERFLOW, panel4->panel_strip()->type()); // same
// Resize overflow panel bigger. It should stay in overflow and bounds
// should not change.
@@ -1344,7 +1363,7 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_ResizePanel) {
panel_manager->OnPreferredWindowSizeChanged(panel4, new_size);
EXPECT_EQ(4, docked_strip->num_panels());
EXPECT_EQ(1, overflow_strip->num_panels());
- EXPECT_EQ(Panel::IN_OVERFLOW, panel4->expansion_state());
+ EXPECT_EQ(PanelStrip::IN_OVERFLOW, panel4->panel_strip()->type());
EXPECT_EQ(bounds_before_resize, panel4->GetBounds());
EXPECT_EQ(new_size, panel4->restored_size());
@@ -1354,7 +1373,7 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_ResizePanel) {
panel_manager->OnPreferredWindowSizeChanged(panel4, gfx::Size(100, 200));
EXPECT_EQ(5, docked_strip->num_panels());
EXPECT_EQ(0, overflow_strip->num_panels());
- EXPECT_EQ(Panel::EXPANDED, panel4->expansion_state());
+ EXPECT_EQ(PanelStrip::DOCKED, panel4->panel_strip()->type());
// Resize a panel bigger, but not enough to cause overflow.
// docked: P1 (250), P2 (100), P3 (150)*, P5 (100), P4 (100)
@@ -1369,8 +1388,8 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_ResizePanel) {
panel_manager->OnPreferredWindowSizeChanged(panel2, gfx::Size(250, 200));
EXPECT_EQ(3, docked_strip->num_panels());
EXPECT_EQ(2, overflow_strip->num_panels());
- EXPECT_EQ(Panel::IN_OVERFLOW, panel4->expansion_state());
- EXPECT_EQ(Panel::IN_OVERFLOW, panel5->expansion_state());
+ EXPECT_EQ(PanelStrip::IN_OVERFLOW, panel4->panel_strip()->type());
+ EXPECT_EQ(PanelStrip::IN_OVERFLOW, panel5->panel_strip()->type());
const OverflowPanelStrip::Panels& overflow2 = overflow_strip->panels();
EXPECT_EQ(panel5, overflow2[0]); // strip order is preserved
EXPECT_EQ(panel4, overflow2[1]);
@@ -1408,7 +1427,7 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_OverflowIndicatorCount) {
gfx::Rect(0, 0, 250, 200),
SHOW_AS_INACTIVE);
Panel* panel = CreatePanelWithParams(params);
- WaitForExpansionStateChanged(panel, Panel::IN_OVERFLOW);
+ WaitForLayoutModeChanged(panel, PanelStrip::IN_OVERFLOW);
EXPECT_EQ(i + 1, overflow_strip->overflow_indicator()->GetCount());
panels.push_back(panel);
}
@@ -1470,7 +1489,7 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_OverflowIndicatorCount) {
// overflow: P1, P2, P6, (P7, P8, P9, P10)
panels[5]->Activate();
WaitForPanelActiveState(panels[5], SHOW_AS_ACTIVE);
- WaitForExpansionStateChanged(panels[5], Panel::EXPANDED);
+ WaitForLayoutModeChanged(panels[5], PanelStrip::DOCKED);
EXPECT_TRUE(IsPanelVisible(panels[6]));
EXPECT_FALSE(IsPanelVisible(panels[7]));
EXPECT_FALSE(IsPanelVisible(panels[8]));
@@ -1574,7 +1593,7 @@ IN_PROC_BROWSER_TEST_F(PanelOverflowBrowserTest, MAYBE_DrawOverflowAttention) {
// overflow: P2, P10, P8, (*P3, P4, P6, P7, P9, P11)
panels[5]->Activate();
WaitForPanelActiveState(panels[5], SHOW_AS_ACTIVE);
- WaitForExpansionStateChanged(panels[5], Panel::EXPANDED);
+ WaitForLayoutModeChanged(panels[5], PanelStrip::DOCKED);
EXPECT_EQ(3, docked_strip->num_panels());
EXPECT_EQ(9, overflow_strip->num_panels());
EXPECT_FALSE(IsPanelVisible(panels[3]));
diff --git a/chrome/browser/ui/panels/panel_strip.h b/chrome/browser/ui/panels/panel_strip.h
index 1f68c45..7cd7f87 100644
--- a/chrome/browser/ui/panels/panel_strip.h
+++ b/chrome/browser/ui/panels/panel_strip.h
@@ -42,7 +42,8 @@ class PanelStrip {
// Closes all panels in the collection. Panels will be removed after closing.
virtual void CloseAll() = 0;
- // Resizes the |panel| to the |preferred_window_size|.
+ // Resizes the |panel| to the |preferred_window_size| and updates the layout
+ // of other panels in the collection accordingly.
// |preferred_window_size| is the outer dimensions of the window, not
// the content area, and is in screen coordinates.
// The preferred size may be adjusted to fit layout constraints.
@@ -54,6 +55,13 @@ class PanelStrip {
// draw attention state.
virtual void OnPanelAttentionStateChanged(Panel* panel) = 0;
+ // Updates the display to show |panel| as active.
+ virtual void ActivatePanel(Panel* panel) = 0;
+
+ // Updates the display to show |panel| as minimized/restored.
+ virtual void MinimizePanel(Panel* panel) = 0;
+ virtual void RestorePanel(Panel* panel) = 0;
+
protected:
explicit PanelStrip(Type type);
virtual ~PanelStrip();
diff --git a/chrome/browser/ui/panels/panel_window_controller_cocoa.mm b/chrome/browser/ui/panels/panel_window_controller_cocoa.mm
index 766255d..b33833e 100644
--- a/chrome/browser/ui/panels/panel_window_controller_cocoa.mm
+++ b/chrome/browser/ui/panels/panel_window_controller_cocoa.mm
@@ -30,6 +30,7 @@
#include "chrome/browser/ui/panels/panel_browser_window_cocoa.h"
#include "chrome/browser/ui/panels/panel_manager.h"
#include "chrome/browser/ui/panels/panel_settings_menu_model.h"
+#include "chrome/browser/ui/panels/panel_strip.h"
#import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h"
#include "chrome/browser/ui/toolbar/encoding_menu_controller.h"
#include "chrome/common/chrome_notification_types.h"
@@ -468,7 +469,8 @@ enum {
// and there is relatively big portion of the panel to hide from view.
// Initialize animation differently in this case, using fast-pause-slow
// method, see below for more details.
- if (windowShim_->panel()->expansion_state() == Panel::MINIMIZED) {
+ if (distanceY > 0 &&
+ windowShim_->panel()->expansion_state() == Panel::MINIMIZED) {
animationStopToShowTitlebarOnly_ =
1.0 - (windowShim_->TitleOnlyHeight() - NSHeight(frame)) / distanceY;
if (animationStopToShowTitlebarOnly_ > 0.7) { // Relatively big movement.
@@ -490,7 +492,8 @@ enum {
- (void)animationDidEnd:(NSAnimation*)animation {
playingMinimizeAnimation_ = NO;
- if (windowShim_->panel()->expansion_state() == Panel::EXPANDED)
+ if (windowShim_->panel()->panel_strip()->type() == PanelStrip::DOCKED &&
+ windowShim_->panel()->expansion_state() == Panel::EXPANDED)
[self enableTabContentsViewAutosizing];
content::NotificationService::current()->Notify(
@@ -514,9 +517,8 @@ enum {
- (void)onTitlebarMouseClicked {
Panel* panel = windowShim_->panel();
- Panel::ExpansionState oldExpansionState = panel->expansion_state();
-
- if (oldExpansionState == Panel::EXPANDED) {
+ if (panel->panel_strip()->type() == PanelStrip::DOCKED &&
+ panel->expansion_state() == Panel::EXPANDED) {
if ([[self titlebarView] isDrawingAttention]) {
// Do not minimize if the Panel is drawing attention since user
// most likely simply wants to reset the 'draw attention' status.
@@ -524,9 +526,8 @@ enum {
return;
}
panel->SetExpansionState(Panel::MINIMIZED);
- // The Panel class ensures deactivaiton when it is minimized.
+ // The Panel class ensures deactivation when it is minimized.
} else {
- panel->SetExpansionState(Panel::EXPANDED);
panel->Activate();
}
}
diff --git a/chrome/common/chrome_notification_types.h b/chrome/common/chrome_notification_types.h
index 82898b2..b1bed0d 100644
--- a/chrome/common/chrome_notification_types.h
+++ b/chrome/common/chrome_notification_types.h
@@ -967,9 +967,14 @@ enum NotificationType {
// Used only in unit testing.
NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS,
- // Sent when panel is minimized/restored/shows title only etc.
+ // Sent when panel is switched between different layout modes, such
+ // as docked vs overflow, etc.
// The source is the Panel, no details.
// Used only in unit testing.
+ NOTIFICATION_PANEL_CHANGED_LAYOUT_MODE,
+
+ // Sent when panel is minimized/restored/shows title only etc.
+ // The source is the Panel, no details.
NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE,
// Sent when panel window size is known. This is for platforms where the