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

Side by Side Diff: chrome/browser/ui/panels/panel_overflow_strip.cc

Issue 8827011: Panel strip refactor cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/panels/panel_overflow_strip.h ('k') | chrome/browser/ui/panels/panel_strip.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/panels/panel_overflow_strip.h" 5 #include "chrome/browser/ui/panels/panel_overflow_strip.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/ui/panels/panel_manager.h" 8 #include "chrome/browser/ui/panels/panel_manager.h"
9 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" 9 #include "chrome/browser/ui/panels/panel_mouse_watcher.h"
10 #include "chrome/browser/ui/panels/panel_strip.h" 10 #include "chrome/browser/ui/panels/panel_strip.h"
(...skipping 23 matching lines...) Expand all
34 } 34 }
35 35
36 void PanelOverflowStrip::SetDisplayArea(const gfx::Rect& display_area) { 36 void PanelOverflowStrip::SetDisplayArea(const gfx::Rect& display_area) {
37 if (display_area_ == display_area) 37 if (display_area_ == display_area)
38 return; 38 return;
39 39
40 display_area_ = display_area; 40 display_area_ = display_area;
41 Refresh(); 41 Refresh();
42 } 42 }
43 43
44 void PanelOverflowStrip::AddPanel(Panel* panel, bool is_new) { 44 void PanelOverflowStrip::AddPanel(Panel* panel) {
45 // TODO(jianli): consider using other container to improve the perf for 45 // TODO(jianli): consider using other container to improve the perf for
46 // inserting to the front. http://crbug.com/106222 46 // inserting to the front. http://crbug.com/106222
47 if (is_new) 47 DCHECK_EQ(Panel::IN_OVERFLOW, panel->expansion_state());
48 // Newly created panels that were temporarily in the panel strip
49 // are added to the back of the overflow, whereas panels that are
50 // bumped from the panel strip by other panels go to the front
51 // of overflow.
52 if (panel->has_temporary_layout()) {
53 panel->set_has_temporary_layout(false);
48 panels_.push_back(panel); 54 panels_.push_back(panel);
49 else 55 DoRefresh(panels_.size() - 1, panels_.size() - 1);
56 } else {
50 panels_.insert(panels_.begin(), panel); 57 panels_.insert(panels_.begin(), panel);
58 Refresh();
59 }
51 60
52 if (panels_.size() == 1) 61 if (panels_.size() == 1)
53 panel_manager_->mouse_watcher()->AddObserver(this); 62 panel_manager_->mouse_watcher()->AddObserver(this);
54
55 panel->SetExpansionState(Panel::IN_OVERFLOW);
56
57 if (is_new) {
58 // When the overflow panel is added to the back, only need to refresh
59 // itself.
60 DoRefresh(panels_.size() - 1, panels_.size() - 1);
61 } else {
62 // When the overflow panel is added to the front, refresh all.
63 Refresh();
64 }
65 } 63 }
66 64
67 bool PanelOverflowStrip::Remove(Panel* panel) { 65 bool PanelOverflowStrip::Remove(Panel* panel) {
68 size_t index = 0; 66 size_t index = 0;
69 for (Panels::iterator iter = panels_.begin(); iter != panels_.end(); 67 for (Panels::iterator iter = panels_.begin(); iter != panels_.end();
70 ++iter, ++index) { 68 ++iter, ++index) {
71 if (*iter == panel) { 69 if (*iter == panel) {
72 panels_.erase(iter); 70 panels_.erase(iter);
73 DoRefresh(index, panels_.size() - 1); 71 DoRefresh(index, panels_.size() - 1);
74 panel_manager_->OnPanelRemoved(panel); 72 panel_manager_->OnPanelRemoved(panel);
(...skipping 11 matching lines...) Expand all
86 84
87 // Start from the bottom to avoid reshuffling. 85 // Start from the bottom to avoid reshuffling.
88 for (Panels::reverse_iterator iter = panels_copy.rbegin(); 86 for (Panels::reverse_iterator iter = panels_copy.rbegin();
89 iter != panels_copy.rend(); ++iter) 87 iter != panels_copy.rend(); ++iter)
90 (*iter)->Close(); 88 (*iter)->Close();
91 } 89 }
92 90
93 void PanelOverflowStrip::OnPanelExpansionStateChanged( 91 void PanelOverflowStrip::OnPanelExpansionStateChanged(
94 Panel* panel, Panel::ExpansionState old_state) { 92 Panel* panel, Panel::ExpansionState old_state) {
95 DCHECK(panel->expansion_state() == Panel::IN_OVERFLOW); 93 DCHECK(panel->expansion_state() == Panel::IN_OVERFLOW);
94 panel_manager_->panel_strip()->Remove(panel);
95 AddPanel(panel);
96 panel->SetAppIconVisibility(false);
96 } 97 }
97 98
98 void PanelOverflowStrip::Refresh() { 99 void PanelOverflowStrip::Refresh() {
99 if (panels_.empty()) 100 if (panels_.empty())
100 return; 101 return;
101 DoRefresh(0, panels_.size() - 1); 102 DoRefresh(0, panels_.size() - 1);
102 } 103 }
103 104
104 void PanelOverflowStrip::DoRefresh(size_t start_index, size_t end_index) { 105 void PanelOverflowStrip::DoRefresh(size_t start_index, size_t end_index) {
105 if (panels_.empty()) 106 if (panels_.empty())
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 } 211 }
211 212
212 overflow_panel->SetPanelBoundsInstantly(bounds); 213 overflow_panel->SetPanelBoundsInstantly(bounds);
213 } 214 }
214 } 215 }
215 216
216 void PanelOverflowStrip::OnFullScreenModeChanged(bool is_full_screen) { 217 void PanelOverflowStrip::OnFullScreenModeChanged(bool is_full_screen) {
217 for (size_t i = 0; i < panels_.size(); ++i) 218 for (size_t i = 0; i < panels_.size(); ++i)
218 panels_[i]->FullScreenModeChanged(is_full_screen); 219 panels_[i]->FullScreenModeChanged(is_full_screen);
219 } 220 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_overflow_strip.h ('k') | chrome/browser/ui/panels/panel_strip.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698