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 |
682 gfx::Size BookmarkBarView::GetMinimumSize() const { | 695 gfx::Size BookmarkBarView::GetMinimumSize() const { |
683 // The minimum width of the bookmark bar should at least contain the overflow | 696 // The minimum width of the bookmark bar should at least contain the overflow |
684 // button, by which one can access all the Bookmark Bar items, and the "Other | 697 // button, by which one can access all the Bookmark Bar items, and the "Other |
685 // Bookmarks" folder, along with appropriate margins and button padding. | 698 // Bookmarks" folder, along with appropriate margins and button padding. |
686 int width = kLeftMargin; | 699 int width = kLeftMargin; |
687 | 700 |
688 int height = chrome::kBookmarkBarHeight; | 701 int height = chrome::kBookmarkBarHeight; |
689 if (IsDetached()) { | 702 if (IsDetached()) { |
690 double current_state = 1 - size_animation_->GetCurrentValue(); | 703 double current_state = 1 - size_animation_->GetCurrentValue(); |
691 width += 2 * static_cast<int>(kNewtabHorizontalPadding * current_state); | 704 width += 2 * static_cast<int>(kNewtabHorizontalPadding * current_state); |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 } | 923 } |
911 | 924 |
912 void BookmarkBarView::OnThemeChanged() { | 925 void BookmarkBarView::OnThemeChanged() { |
913 UpdateColors(); | 926 UpdateColors(); |
914 } | 927 } |
915 | 928 |
916 const char* BookmarkBarView::GetClassName() const { | 929 const char* BookmarkBarView::GetClassName() const { |
917 return kViewClassName; | 930 return kViewClassName; |
918 } | 931 } |
919 | 932 |
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 | |
934 void BookmarkBarView::GetAccessibleState(ui::AXViewState* state) { | 933 void BookmarkBarView::GetAccessibleState(ui::AXViewState* state) { |
935 state->role = ui::AX_ROLE_TOOLBAR; | 934 state->role = ui::AX_ROLE_TOOLBAR; |
936 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_BOOKMARKS); | 935 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_BOOKMARKS); |
937 } | 936 } |
938 | 937 |
939 void BookmarkBarView::AnimationProgressed(const gfx::Animation* animation) { | 938 void BookmarkBarView::AnimationProgressed(const gfx::Animation* animation) { |
940 // |browser_view_| can be NULL during tests. | 939 // |browser_view_| can be NULL during tests. |
941 if (browser_view_) | 940 if (browser_view_) |
942 browser_view_->ToolbarSizeChanged(true); | 941 browser_view_->ToolbarSizeChanged(true); |
943 } | 942 } |
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1830 DCHECK(apps_page_shortcut_); | 1829 DCHECK(apps_page_shortcut_); |
1831 // Only perform layout if required. | 1830 // Only perform layout if required. |
1832 bool visible = chrome::ShouldShowAppsShortcutInBookmarkBar( | 1831 bool visible = chrome::ShouldShowAppsShortcutInBookmarkBar( |
1833 browser_->profile(), browser_->host_desktop_type()); | 1832 browser_->profile(), browser_->host_desktop_type()); |
1834 if (apps_page_shortcut_->visible() == visible) | 1833 if (apps_page_shortcut_->visible() == visible) |
1835 return; | 1834 return; |
1836 apps_page_shortcut_->SetVisible(visible); | 1835 apps_page_shortcut_->SetVisible(visible); |
1837 UpdateBookmarksSeparatorVisibility(); | 1836 UpdateBookmarksSeparatorVisibility(); |
1838 Layout(); | 1837 Layout(); |
1839 } | 1838 } |
OLD | NEW |