| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/views/bookmark_bar_view.h" | 5 #include "chrome/browser/views/bookmark_bar_view.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "app/gfx/canvas.h" | 9 #include "app/gfx/canvas.h" |
| 10 #include "app/gfx/text_elider.h" | 10 #include "app/gfx/text_elider.h" |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 } | 536 } |
| 537 | 537 |
| 538 void BookmarkBarView::DidChangeBounds(const gfx::Rect& previous, | 538 void BookmarkBarView::DidChangeBounds(const gfx::Rect& previous, |
| 539 const gfx::Rect& current) { | 539 const gfx::Rect& current) { |
| 540 Layout(); | 540 Layout(); |
| 541 } | 541 } |
| 542 | 542 |
| 543 void BookmarkBarView::ViewHierarchyChanged(bool is_add, | 543 void BookmarkBarView::ViewHierarchyChanged(bool is_add, |
| 544 View* parent, | 544 View* parent, |
| 545 View* child) { | 545 View* child) { |
| 546 if (is_add && child == this && height() > 0) { | 546 if (is_add && child == this) { |
| 547 // We only layout while parented. When we become parented, if our bounds | 547 // We may get inserted into a hierarchy with a profile - this typically |
| 548 // haven't changed, DidChangeBounds won't get invoked and we won't layout. | 548 // occurs when the bar's contents get populated fast enough that the |
| 549 // Therefore we always force a layout when added. | 549 // buttons are created before the bar is attached to a frame. |
| 550 Layout(); | 550 UpdateButtonColors(); |
| 551 |
| 552 if (height() > 0) { |
| 553 // We only layout while parented. When we become parented, if our bounds |
| 554 // haven't changed, DidChangeBounds won't get invoked and we won't layout. |
| 555 // Therefore we always force a layout when added. |
| 556 Layout(); |
| 557 } |
| 551 } | 558 } |
| 552 } | 559 } |
| 553 | 560 |
| 554 void BookmarkBarView::Paint(gfx::Canvas* canvas) { | 561 void BookmarkBarView::Paint(gfx::Canvas* canvas) { |
| 555 if (IsDetachedStyle()) { | 562 if (IsDetachedStyle()) { |
| 556 // Draw the background to match the new tab page. | 563 // Draw the background to match the new tab page. |
| 557 ThemeProvider* tp = GetThemeProvider(); | 564 ThemeProvider* tp = GetThemeProvider(); |
| 558 canvas->FillRectInt( | 565 canvas->FillRectInt( |
| 559 tp->GetColor(BrowserThemeProvider::COLOR_NTP_BACKGROUND), | 566 tp->GetColor(BrowserThemeProvider::COLOR_NTP_BACKGROUND), |
| 560 0, 0, width(), height()); | 567 0, 0, width(), height()); |
| (...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1705 for (int i = 0; i < GetBookmarkButtonCount(); i++) { | 1712 for (int i = 0; i < GetBookmarkButtonCount(); i++) { |
| 1706 views::TextButton* button = GetBookmarkButton(i); | 1713 views::TextButton* button = GetBookmarkButton(i); |
| 1707 button->SetEnabledColor(GetThemeProvider()->GetColor( | 1714 button->SetEnabledColor(GetThemeProvider()->GetColor( |
| 1708 BrowserThemeProvider::COLOR_BOOKMARK_TEXT)); | 1715 BrowserThemeProvider::COLOR_BOOKMARK_TEXT)); |
| 1709 } | 1716 } |
| 1710 other_bookmarked_button()->SetEnabledColor(GetThemeProvider()->GetColor( | 1717 other_bookmarked_button()->SetEnabledColor(GetThemeProvider()->GetColor( |
| 1711 BrowserThemeProvider::COLOR_BOOKMARK_TEXT)); | 1718 BrowserThemeProvider::COLOR_BOOKMARK_TEXT)); |
| 1712 } | 1719 } |
| 1713 } | 1720 } |
| 1714 | 1721 |
| OLD | NEW |