Chromium Code Reviews| 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/location_bar/location_bar_view.h" | 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 640 if (ShouldShowKeywordBubble()) { | 640 if (ShouldShowKeywordBubble()) { |
| 641 // The selected keyword view can collapse completely. | 641 // The selected keyword view can collapse completely. |
| 642 } else if (ShouldShowEVBubble()) { | 642 } else if (ShouldShowEVBubble()) { |
| 643 leading_width += kBubblePadding + | 643 leading_width += kBubblePadding + |
| 644 ev_bubble_view_->GetMinimumSizeForLabelText( | 644 ev_bubble_view_->GetMinimumSizeForLabelText( |
| 645 GetToolbarModel()->GetEVCertName()).width(); | 645 GetToolbarModel()->GetEVCertName()).width(); |
| 646 } else if (!origin_chip_view_->visible()) { | 646 } else if (!origin_chip_view_->visible()) { |
| 647 leading_width += | 647 leading_width += |
| 648 kItemPadding + location_icon_view_->GetMinimumSize().width(); | 648 kItemPadding + location_icon_view_->GetMinimumSize().width(); |
| 649 } | 649 } |
| 650 leading_width += kItemPadding - GetEditLeadingInternalSpace(); | 650 const int edge_padding = kItemPadding - views::Textfield::kTextPadding; |
| 651 leading_width += edge_padding - GetEditLeadingInternalSpace(); | |
| 651 | 652 |
| 652 // Compute width of omnibox-trailing content. | 653 // Compute width of omnibox-trailing content. |
| 653 int trailing_width = search_button_->visible() ? | 654 int trailing_width = search_button_->visible() ? |
| 654 (search_button_->GetMinimumSize().width() + kSearchButtonInset) : | 655 (search_button_->GetMinimumSize().width() + kSearchButtonInset) : |
| 655 horizontal_edge_thickness; | 656 horizontal_edge_thickness; |
| 656 trailing_width += IncrementalMinimumWidth(star_view_) + | 657 trailing_width += IncrementalMinimumWidth(star_view_) + |
| 657 IncrementalMinimumWidth(translate_icon_view_) + | 658 IncrementalMinimumWidth(translate_icon_view_) + |
|
Peter Kasting
2014/09/05 22:56:49
Nit: I think the old indenting was more correct
msw
2014/09/05 23:46:55
This was done by git cl format, not me, but I've r
| |
| 658 IncrementalMinimumWidth(open_pdf_in_reader_view_) + | 659 IncrementalMinimumWidth(open_pdf_in_reader_view_) + |
| 659 IncrementalMinimumWidth(manage_passwords_icon_view_) + | 660 IncrementalMinimumWidth(manage_passwords_icon_view_) + |
| 660 IncrementalMinimumWidth(zoom_view_) + | 661 IncrementalMinimumWidth(zoom_view_) + |
| 661 IncrementalMinimumWidth(generated_credit_card_view_) + | 662 IncrementalMinimumWidth(generated_credit_card_view_) + |
| 662 IncrementalMinimumWidth(mic_search_view_) + kItemPadding; | 663 IncrementalMinimumWidth(mic_search_view_) + edge_padding; |
| 663 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 664 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
| 664 i != page_action_views_.end(); ++i) | 665 i != page_action_views_.end(); ++i) |
| 665 trailing_width += IncrementalMinimumWidth((*i)); | 666 trailing_width += IncrementalMinimumWidth((*i)); |
| 666 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); | 667 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); |
| 667 i != content_setting_views_.end(); ++i) | 668 i != content_setting_views_.end(); ++i) |
| 668 trailing_width += IncrementalMinimumWidth((*i)); | 669 trailing_width += IncrementalMinimumWidth((*i)); |
| 669 | 670 |
| 670 min_size.set_width( | 671 min_size.set_width( |
| 671 leading_width + omnibox_view_->GetMinimumSize().width() + trailing_width); | 672 leading_width + omnibox_view_->GetMinimumSize().width() + trailing_width); |
| 672 return min_size; | 673 return min_size; |
| 673 } | 674 } |
| 674 | 675 |
| 675 void LocationBarView::Layout() { | 676 void LocationBarView::Layout() { |
| 676 if (!IsInitialized()) | 677 if (!IsInitialized()) |
| 677 return; | 678 return; |
| 678 | 679 |
| 679 origin_chip_view_->SetVisible(GetToolbarModel()->ShouldShowOriginChip()); | 680 origin_chip_view_->SetVisible(GetToolbarModel()->ShouldShowOriginChip()); |
| 680 selected_keyword_view_->SetVisible(false); | 681 selected_keyword_view_->SetVisible(false); |
| 681 location_icon_view_->SetVisible(false); | 682 location_icon_view_->SetVisible(false); |
| 682 ev_bubble_view_->SetVisible(false); | 683 ev_bubble_view_->SetVisible(false); |
| 683 keyword_hint_view_->SetVisible(false); | 684 keyword_hint_view_->SetVisible(false); |
| 684 | 685 |
| 686 const int edge_padding = kItemPadding - views::Textfield::kTextPadding; | |
| 685 LocationBarLayout leading_decorations( | 687 LocationBarLayout leading_decorations( |
| 686 LocationBarLayout::LEFT_EDGE, | 688 LocationBarLayout::LEFT_EDGE, |
| 687 kItemPadding - GetEditLeadingInternalSpace()); | 689 edge_padding - GetEditLeadingInternalSpace()); |
| 688 LocationBarLayout trailing_decorations(LocationBarLayout::RIGHT_EDGE, | 690 LocationBarLayout trailing_decorations(LocationBarLayout::RIGHT_EDGE, |
| 689 kItemPadding); | 691 edge_padding); |
| 690 | 692 |
| 691 const int origin_chip_preferred_width = | 693 const int origin_chip_preferred_width = |
| 692 origin_chip_view_->GetPreferredSize().width(); | 694 origin_chip_view_->GetPreferredSize().width(); |
| 693 const int origin_chip_width = | 695 const int origin_chip_width = |
| 694 origin_chip_view_->visible() ? origin_chip_preferred_width : 0; | 696 origin_chip_view_->visible() ? origin_chip_preferred_width : 0; |
| 695 // Always give the origin chip view its desired size and lay it out, even when | 697 // Always give the origin chip view its desired size and lay it out, even when |
| 696 // it's not visible, so we can calculate the correct animation values below | 698 // it's not visible, so we can calculate the correct animation values below |
| 697 // when switching to tabs that have the origin chip hidden. | 699 // when switching to tabs that have the origin chip hidden. |
| 698 origin_chip_view_->SetBounds(0, 0, origin_chip_preferred_width, height()); | 700 origin_chip_view_->SetBounds(0, 0, origin_chip_preferred_width, height()); |
| 699 origin_chip_view_->Layout(); | 701 origin_chip_view_->Layout(); |
| (...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1699 | 1701 |
| 1700 void LocationBarView::ModelChanged(const SearchModel::State& old_state, | 1702 void LocationBarView::ModelChanged(const SearchModel::State& old_state, |
| 1701 const SearchModel::State& new_state) { | 1703 const SearchModel::State& new_state) { |
| 1702 const bool visible = !GetToolbarModel()->input_in_progress() && | 1704 const bool visible = !GetToolbarModel()->input_in_progress() && |
| 1703 new_state.voice_search_supported; | 1705 new_state.voice_search_supported; |
| 1704 if (mic_search_view_->visible() != visible) { | 1706 if (mic_search_view_->visible() != visible) { |
| 1705 mic_search_view_->SetVisible(visible); | 1707 mic_search_view_->SetVisible(visible); |
| 1706 Layout(); | 1708 Layout(); |
| 1707 } | 1709 } |
| 1708 } | 1710 } |
| OLD | NEW |