OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/toolbar/toolbar_actions_bar.h" | 5 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/profiler/scoped_tracker.h" | 9 #include "base/profiler/scoped_tracker.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
257 if (!toolbar_actions_.empty() && !suppress_layout_ && | 257 if (!toolbar_actions_.empty() && !suppress_layout_ && |
258 model_->actions_initialized()) { | 258 model_->actions_initialized()) { |
259 DCHECK_LE(visible_icons, toolbar_actions_.size()); | 259 DCHECK_LE(visible_icons, toolbar_actions_.size()); |
260 DCHECK_EQ(model_->toolbar_items().size(), toolbar_actions_.size()); | 260 DCHECK_EQ(model_->toolbar_items().size(), toolbar_actions_.size()); |
261 } | 261 } |
262 #endif | 262 #endif |
263 | 263 |
264 return visible_icons; | 264 return visible_icons; |
265 } | 265 } |
266 | 266 |
267 gfx::Rect ToolbarActionsBar::GetFrameForIndex(size_t index) const { | 267 size_t ToolbarActionsBar::GetStartIndexInBounds() const { |
268 size_t start_index = in_overflow_mode() ? | 268 return in_overflow_mode() ? |
269 toolbar_actions_.size() - GetIconCount() : 0u; | 269 main_bar_->GetEndIndexInBounds() : 0u; |
Peter Kasting
2015/09/15 00:13:38
Nit: Don't add 'u' here unless the code won't comp
Devlin
2015/09/15 18:22:39
Done.
| |
270 } | |
271 | |
272 size_t ToolbarActionsBar::GetEndIndexInBounds() const { | |
273 return in_overflow_mode() ? | |
274 toolbar_actions_.size() : WidthToIconCount(delegate_->GetWidth()); | |
275 } | |
276 | |
277 bool ToolbarActionsBar::NeedsOverflow() const { | |
278 DCHECK(!in_overflow_mode()); | |
279 return GetEndIndexInBounds() != toolbar_actions_.size(); | |
280 } | |
281 | |
282 gfx::Rect ToolbarActionsBar::GetFrameForIndex( | |
283 size_t index) const { | |
284 size_t start_index = GetStartIndexInBounds(); | |
270 | 285 |
271 // If the index is for an action that is before range we show (i.e., is for | 286 // If the index is for an action that is before range we show (i.e., is for |
272 // a button that's on the main bar, and this is the overflow), send back an | 287 // a button that's on the main bar, and this is the overflow), send back an |
273 // empty rect. | 288 // empty rect. |
274 if (index < start_index) | 289 if (index < start_index) |
275 return gfx::Rect(); | 290 return gfx::Rect(); |
276 | 291 |
277 size_t relative_index = index - start_index; | 292 size_t relative_index = index - start_index; |
278 int icons_per_overflow_row = platform_settings().icons_per_overflow_menu_row; | 293 int icons_per_overflow_row = platform_settings().icons_per_overflow_menu_row; |
279 size_t row_index = in_overflow_mode() ? | 294 size_t row_index = in_overflow_mode() ? |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
707 for (ToolbarActionViewController* action : toolbar_actions_) { | 722 for (ToolbarActionViewController* action : toolbar_actions_) { |
708 if (action->GetId() == action_id) | 723 if (action->GetId() == action_id) |
709 return action; | 724 return action; |
710 } | 725 } |
711 return nullptr; | 726 return nullptr; |
712 } | 727 } |
713 | 728 |
714 content::WebContents* ToolbarActionsBar::GetCurrentWebContents() { | 729 content::WebContents* ToolbarActionsBar::GetCurrentWebContents() { |
715 return browser_->tab_strip_model()->GetActiveWebContents(); | 730 return browser_->tab_strip_model()->GetActiveWebContents(); |
716 } | 731 } |
OLD | NEW |