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

Side by Side Diff: chrome/browser/ui/views/toolbar/browser_actions_container.cc

Issue 492503004: Fix BrowserActionContainer chevron visibility regression (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 6 years, 3 months 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
« no previous file with comments | « no previous file | chrome/browser/ui/views/toolbar/browser_actions_container_browsertest.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/views/toolbar/browser_actions_container.h" 5 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "chrome/browser/extensions/extension_action_manager.h" 9 #include "chrome/browser/extensions/extension_action_manager.h"
10 #include "chrome/browser/extensions/extension_util.h" 10 #include "chrome/browser/extensions/extension_util.h"
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 BrowserActionsContainerObserver* observer) { 311 BrowserActionsContainerObserver* observer) {
312 observers_.AddObserver(observer); 312 observers_.AddObserver(observer);
313 } 313 }
314 314
315 void BrowserActionsContainer::RemoveObserver( 315 void BrowserActionsContainer::RemoveObserver(
316 BrowserActionsContainerObserver* observer) { 316 BrowserActionsContainerObserver* observer) {
317 observers_.RemoveObserver(observer); 317 observers_.RemoveObserver(observer);
318 } 318 }
319 319
320 gfx::Size BrowserActionsContainer::GetPreferredSize() const { 320 gfx::Size BrowserActionsContainer::GetPreferredSize() const {
321 size_t icon_count = GetIconCount(); 321 // Note: We can't use GetIconCount() for the main bar, since we may also
322 // have to include items that are in the chevron's overflow.
323 size_t icon_count =
324 in_overflow_mode() ? GetIconCount() : browser_action_views_.size();
322 325
323 // If there are no actions to show, or we are in overflow mode and the main 326 // If there are no actions to show, or we are in overflow mode and the main
324 // container is already showing them all, then no further work is required. 327 // container is already showing them all, then no further work is required.
325 if (icon_count == 0) 328 if (icon_count == 0)
326 return gfx::Size(); 329 return gfx::Size();
327 330
328 if (in_overflow_mode()) { 331 if (in_overflow_mode()) {
329 // When in overflow, y is multiline, so the pixel count is IconHeight() 332 // When in overflow, y is multiline, so the pixel count is IconHeight()
330 // times the number of rows needed. 333 // times the number of rows needed.
331 return gfx::Size( 334 return gfx::Size(
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 size_t absolute_model_size = 1100 size_t absolute_model_size =
1098 model_size == -1 ? extensions.size() : model_size; 1101 model_size == -1 ? extensions.size() : model_size;
1099 1102
1100 // The main container will try to show |model_size| icons, but reduce if there 1103 // The main container will try to show |model_size| icons, but reduce if there
1101 // aren't enough displayable icons to do so. 1104 // aren't enough displayable icons to do so.
1102 size_t main_displayed = std::min(displayable_icon_count, absolute_model_size); 1105 size_t main_displayed = std::min(displayable_icon_count, absolute_model_size);
1103 // The overflow will display the extras, if any. 1106 // The overflow will display the extras, if any.
1104 return in_overflow_mode() ? 1107 return in_overflow_mode() ?
1105 displayable_icon_count - main_displayed : main_displayed; 1108 displayable_icon_count - main_displayed : main_displayed;
1106 } 1109 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/toolbar/browser_actions_container_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698