| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bookmarks/bookmark_bar_view.h" | 5 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 static_cast<int>( | 672 static_cast<int>( |
| 673 (chrome::kNTPBookmarkBarHeight - chrome::kBookmarkBarHeight) * | 673 (chrome::kNTPBookmarkBarHeight - chrome::kBookmarkBarHeight) * |
| 674 (1 - size_animation_->GetCurrentValue()))); | 674 (1 - size_animation_->GetCurrentValue()))); |
| 675 } else { | 675 } else { |
| 676 prefsize.set_height(static_cast<int>(chrome::kBookmarkBarHeight * | 676 prefsize.set_height(static_cast<int>(chrome::kBookmarkBarHeight * |
| 677 size_animation_->GetCurrentValue())); | 677 size_animation_->GetCurrentValue())); |
| 678 } | 678 } |
| 679 return prefsize; | 679 return prefsize; |
| 680 } | 680 } |
| 681 | 681 |
| 682 bool BookmarkBarView::HitTestRect(const gfx::Rect& rect) const { | |
| 683 // If bookmark bar is attached and omnibox popup is open (on top of the bar), | |
| 684 // force hit-testing to fail. This prevents hovers/clicks just above the | |
| 685 // omnibox popup from activating the top few pixels of items on the bookmark | |
| 686 // bar. | |
| 687 if (!IsDetached() && browser_view_ && | |
| 688 browser_view_->GetLocationBar()->GetOmniboxView()->model()-> | |
| 689 popup_model()->IsOpen()) { | |
| 690 return false; | |
| 691 } | |
| 692 return DetachableToolbarView::HitTestRect(rect); | |
| 693 } | |
| 694 | |
| 695 gfx::Size BookmarkBarView::GetMinimumSize() const { | 682 gfx::Size BookmarkBarView::GetMinimumSize() const { |
| 696 // The minimum width of the bookmark bar should at least contain the overflow | 683 // The minimum width of the bookmark bar should at least contain the overflow |
| 697 // button, by which one can access all the Bookmark Bar items, and the "Other | 684 // button, by which one can access all the Bookmark Bar items, and the "Other |
| 698 // Bookmarks" folder, along with appropriate margins and button padding. | 685 // Bookmarks" folder, along with appropriate margins and button padding. |
| 699 int width = kLeftMargin; | 686 int width = kLeftMargin; |
| 700 | 687 |
| 701 int height = chrome::kBookmarkBarHeight; | 688 int height = chrome::kBookmarkBarHeight; |
| 702 if (IsDetached()) { | 689 if (IsDetached()) { |
| 703 double current_state = 1 - size_animation_->GetCurrentValue(); | 690 double current_state = 1 - size_animation_->GetCurrentValue(); |
| 704 width += 2 * static_cast<int>(kNewtabHorizontalPadding * current_state); | 691 width += 2 * static_cast<int>(kNewtabHorizontalPadding * current_state); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 } | 910 } |
| 924 | 911 |
| 925 void BookmarkBarView::OnThemeChanged() { | 912 void BookmarkBarView::OnThemeChanged() { |
| 926 UpdateColors(); | 913 UpdateColors(); |
| 927 } | 914 } |
| 928 | 915 |
| 929 const char* BookmarkBarView::GetClassName() const { | 916 const char* BookmarkBarView::GetClassName() const { |
| 930 return kViewClassName; | 917 return kViewClassName; |
| 931 } | 918 } |
| 932 | 919 |
| 920 bool BookmarkBarView::CanAcceptEvent(const ui::Event& event) { |
| 921 // If bookmark bar is attached and omnibox popup is open (on top of the bar), |
| 922 // do not allow the bookmark bar to accept events. This prevents, for example, |
| 923 // hovers/clicks just above the omnibox popup from activating the top few |
| 924 // pixels of items on the bookmark bar. |
| 925 if (!IsDetached() && browser_view_ && |
| 926 browser_view_->GetLocationBar()->GetOmniboxView()->model()-> |
| 927 popup_model()->IsOpen()) { |
| 928 return false; |
| 929 } |
| 930 |
| 931 return View::CanAcceptEvent(event); |
| 932 } |
| 933 |
| 933 void BookmarkBarView::GetAccessibleState(ui::AXViewState* state) { | 934 void BookmarkBarView::GetAccessibleState(ui::AXViewState* state) { |
| 934 state->role = ui::AX_ROLE_TOOLBAR; | 935 state->role = ui::AX_ROLE_TOOLBAR; |
| 935 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_BOOKMARKS); | 936 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_BOOKMARKS); |
| 936 } | 937 } |
| 937 | 938 |
| 938 void BookmarkBarView::AnimationProgressed(const gfx::Animation* animation) { | 939 void BookmarkBarView::AnimationProgressed(const gfx::Animation* animation) { |
| 939 // |browser_view_| can be NULL during tests. | 940 // |browser_view_| can be NULL during tests. |
| 940 if (browser_view_) | 941 if (browser_view_) |
| 941 browser_view_->ToolbarSizeChanged(true); | 942 browser_view_->ToolbarSizeChanged(true); |
| 942 } | 943 } |
| (...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1829 DCHECK(apps_page_shortcut_); | 1830 DCHECK(apps_page_shortcut_); |
| 1830 // Only perform layout if required. | 1831 // Only perform layout if required. |
| 1831 bool visible = chrome::ShouldShowAppsShortcutInBookmarkBar( | 1832 bool visible = chrome::ShouldShowAppsShortcutInBookmarkBar( |
| 1832 browser_->profile(), browser_->host_desktop_type()); | 1833 browser_->profile(), browser_->host_desktop_type()); |
| 1833 if (apps_page_shortcut_->visible() == visible) | 1834 if (apps_page_shortcut_->visible() == visible) |
| 1834 return; | 1835 return; |
| 1835 apps_page_shortcut_->SetVisible(visible); | 1836 apps_page_shortcut_->SetVisible(visible); |
| 1836 UpdateBookmarksSeparatorVisibility(); | 1837 UpdateBookmarksSeparatorVisibility(); |
| 1837 Layout(); | 1838 Layout(); |
| 1838 } | 1839 } |
| OLD | NEW |