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

Side by Side Diff: chrome/browser/ui/views/infobars/infobar_container_view.cc

Issue 6788014: Fix DCHECK() in infobar animation. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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 | Annotate | Revision Log
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/views/infobars/infobar_container_view.h" 5 #include "chrome/browser/ui/views/infobars/infobar_container_view.h"
6 6
7 #include "chrome/browser/ui/view_ids.h" 7 #include "chrome/browser/ui/view_ids.h"
8 #include "chrome/browser/ui/views/infobars/infobar_view.h" 8 #include "chrome/browser/ui/views/infobars/infobar_view.h"
9 #include "grit/generated_resources.h" 9 #include "grit/generated_resources.h"
10 #include "ui/base/accessibility/accessible_view_state.h" 10 #include "ui/base/accessibility/accessible_view_state.h"
11 #include "ui/base/l10n/l10n_util.h" 11 #include "ui/base/l10n/l10n_util.h"
12 12
13 InfoBarContainerView::InfoBarContainerView(Delegate* delegate) 13 InfoBarContainerView::InfoBarContainerView(Delegate* delegate)
14 : InfoBarContainer(delegate) { 14 : InfoBarContainer(delegate) {
15 SetID(VIEW_ID_INFO_BAR_CONTAINER); 15 SetID(VIEW_ID_INFO_BAR_CONTAINER);
16 } 16 }
17 17
18 InfoBarContainerView::~InfoBarContainerView() { 18 InfoBarContainerView::~InfoBarContainerView() {
19 } 19 }
20 20
21 int InfoBarContainerView::VerticalOverlap() { 21 int InfoBarContainerView::GetVerticalOverlap() {
22 return GetVerticalOverlap(NULL); 22 return GetVerticalOverlap(NULL);
23 } 23 }
24 24
25 gfx::Size InfoBarContainerView::GetPreferredSize() { 25 gfx::Size InfoBarContainerView::GetPreferredSize() {
26 // We do not have a preferred width (we will expand to fit the available width 26 // We do not have a preferred width (we will expand to fit the available width
27 // of the delegate). 27 // of the delegate).
28 int total_height; 28 int total_height;
29 GetVerticalOverlap(&total_height); 29 GetVerticalOverlap(&total_height);
30 return gfx::Size(0, total_height); 30 return gfx::Size(0, total_height);
31 } 31 }
32 32
33 void InfoBarContainerView::Layout() { 33 void InfoBarContainerView::Layout() {
34 int top = GetVerticalOverlap(NULL); 34 int top = GetVerticalOverlap();
35 35
36 for (int i = 0; i < child_count(); ++i) { 36 for (int i = 0; i < child_count(); ++i) {
37 View* child = GetChildViewAt(i); 37 View* child = GetChildViewAt(i);
38 gfx::Size ps = child->GetPreferredSize(); 38 top -= static_cast<InfoBarView*>(child)->tab_height();
39 top -= static_cast<InfoBarView*>(child)->AnimatedTabHeight(); 39 int child_height = child->GetPreferredSize().height();
40 child->SetBounds(0, top, width(), ps.height()); 40 child->SetBounds(0, top, width(), child_height);
41 top += ps.height(); 41 top += child_height;
42 } 42 }
43 } 43 }
44 44
45 void InfoBarContainerView::GetAccessibleState(ui::AccessibleViewState* state) { 45 void InfoBarContainerView::GetAccessibleState(ui::AccessibleViewState* state) {
46 state->role = ui::AccessibilityTypes::ROLE_GROUPING; 46 state->role = ui::AccessibilityTypes::ROLE_GROUPING;
47 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_INFOBAR_CONTAINER); 47 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_INFOBAR_CONTAINER);
48 } 48 }
49 49
50 void InfoBarContainerView::PlatformSpecificAddInfoBar(InfoBar* infobar) { 50 void InfoBarContainerView::PlatformSpecificAddInfoBar(InfoBar* infobar) {
51 AddChildView(static_cast<InfoBarView*>(infobar)); 51 AddChildView(static_cast<InfoBarView*>(infobar));
52 } 52 }
53 53
54 void InfoBarContainerView::PlatformSpecificRemoveInfoBar(InfoBar* infobar) { 54 void InfoBarContainerView::PlatformSpecificRemoveInfoBar(InfoBar* infobar) {
55 RemoveChildView(static_cast<InfoBarView*>(infobar)); 55 RemoveChildView(static_cast<InfoBarView*>(infobar));
56 } 56 }
57 57
58 int InfoBarContainerView::GetVerticalOverlap(int* total_height) { 58 int InfoBarContainerView::GetVerticalOverlap(int* total_height) {
59 // Our |total_height| is the sum of the preferred heights of the InfoBars 59 // Our |total_height| is the sum of the preferred heights of the InfoBars
60 // contained within us plus the |vertical_overlap|. 60 // contained within us plus the |vertical_overlap|.
61 int vertical_overlap = 0; 61 int vertical_overlap = 0;
62 int next_child_y = 0; 62 int next_child_y = 0;
63 63
64 for (int i = 0; i < child_count(); ++i) { 64 for (int i = 0; i < child_count(); ++i) {
65 View* child = GetChildViewAt(i); 65 View* child = GetChildViewAt(i);
66 gfx::Size ps = child->GetPreferredSize(); 66 next_child_y -= static_cast<InfoBarView*>(child)->tab_height();
67 next_child_y -= static_cast<InfoBarView*>(child)->AnimatedTabHeight();
68 vertical_overlap = std::max(vertical_overlap, -next_child_y); 67 vertical_overlap = std::max(vertical_overlap, -next_child_y);
69 next_child_y += child->GetPreferredSize().height(); 68 next_child_y += child->GetPreferredSize().height();
70 } 69 }
71 70
72 if (total_height) 71 if (total_height)
73 *total_height = next_child_y + vertical_overlap; 72 *total_height = next_child_y + vertical_overlap;
74 return vertical_overlap; 73 return vertical_overlap;
75 } 74 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/infobars/infobar_container_view.h ('k') | chrome/browser/ui/views/infobars/infobar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698