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

Side by Side Diff: chrome/browser/ui/views/location_bar/location_bar_view.cc

Issue 516943003: Add textfield internal padding from FocusableBorder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restore Insets const ref. Created 6 years, 3 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
« no previous file with comments | « chrome/browser/ui/views/find_bar_view.cc ('k') | ui/app_list/views/folder_header_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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();
651 650
652 // Compute width of omnibox-trailing content. 651 // Compute width of omnibox-trailing content.
653 int trailing_width = search_button_->visible() ? 652 int trailing_width = search_button_->visible() ?
654 (search_button_->GetMinimumSize().width() + kSearchButtonInset) : 653 (search_button_->GetMinimumSize().width() + kSearchButtonInset) :
655 horizontal_edge_thickness; 654 horizontal_edge_thickness;
656 trailing_width += IncrementalMinimumWidth(star_view_) + 655 trailing_width += IncrementalMinimumWidth(star_view_) +
657 IncrementalMinimumWidth(translate_icon_view_) + 656 IncrementalMinimumWidth(translate_icon_view_) +
658 IncrementalMinimumWidth(open_pdf_in_reader_view_) + 657 IncrementalMinimumWidth(open_pdf_in_reader_view_) +
659 IncrementalMinimumWidth(manage_passwords_icon_view_) + 658 IncrementalMinimumWidth(manage_passwords_icon_view_) +
660 IncrementalMinimumWidth(zoom_view_) + 659 IncrementalMinimumWidth(zoom_view_) +
661 IncrementalMinimumWidth(generated_credit_card_view_) + 660 IncrementalMinimumWidth(generated_credit_card_view_) +
662 IncrementalMinimumWidth(mic_search_view_) + kItemPadding; 661 IncrementalMinimumWidth(mic_search_view_);
663 for (PageActionViews::const_iterator i(page_action_views_.begin()); 662 for (PageActionViews::const_iterator i(page_action_views_.begin());
664 i != page_action_views_.end(); ++i) 663 i != page_action_views_.end(); ++i)
665 trailing_width += IncrementalMinimumWidth((*i)); 664 trailing_width += IncrementalMinimumWidth((*i));
666 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); 665 for (ContentSettingViews::const_iterator i(content_setting_views_.begin());
667 i != content_setting_views_.end(); ++i) 666 i != content_setting_views_.end(); ++i)
668 trailing_width += IncrementalMinimumWidth((*i)); 667 trailing_width += IncrementalMinimumWidth((*i));
669 668
670 min_size.set_width( 669 min_size.set_width(leading_width + omnibox_view_->GetMinimumSize().width() +
671 leading_width + omnibox_view_->GetMinimumSize().width() + trailing_width); 670 2 * kItemPadding - omnibox_view_->GetInsets().width() + trailing_width);
672 return min_size; 671 return min_size;
673 } 672 }
674 673
675 void LocationBarView::Layout() { 674 void LocationBarView::Layout() {
676 if (!IsInitialized()) 675 if (!IsInitialized())
677 return; 676 return;
678 677
679 origin_chip_view_->SetVisible(GetToolbarModel()->ShouldShowOriginChip()); 678 origin_chip_view_->SetVisible(GetToolbarModel()->ShouldShowOriginChip());
680 selected_keyword_view_->SetVisible(false); 679 selected_keyword_view_->SetVisible(false);
681 location_icon_view_->SetVisible(false); 680 location_icon_view_->SetVisible(false);
682 ev_bubble_view_->SetVisible(false); 681 ev_bubble_view_->SetVisible(false);
683 keyword_hint_view_->SetVisible(false); 682 keyword_hint_view_->SetVisible(false);
684 683
685 LocationBarLayout leading_decorations( 684 LocationBarLayout leading_decorations(
686 LocationBarLayout::LEFT_EDGE, 685 LocationBarLayout::LEFT_EDGE,
687 kItemPadding - GetEditLeadingInternalSpace()); 686 kItemPadding - omnibox_view_->GetInsets().left() -
688 LocationBarLayout trailing_decorations(LocationBarLayout::RIGHT_EDGE, 687 GetEditLeadingInternalSpace());
689 kItemPadding); 688 LocationBarLayout trailing_decorations(
689 LocationBarLayout::RIGHT_EDGE,
690 kItemPadding - omnibox_view_->GetInsets().right());
690 691
691 const int origin_chip_preferred_width = 692 const int origin_chip_preferred_width =
692 origin_chip_view_->GetPreferredSize().width(); 693 origin_chip_view_->GetPreferredSize().width();
693 const int origin_chip_width = 694 const int origin_chip_width =
694 origin_chip_view_->visible() ? origin_chip_preferred_width : 0; 695 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 696 // 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 697 // it's not visible, so we can calculate the correct animation values below
697 // when switching to tabs that have the origin chip hidden. 698 // when switching to tabs that have the origin chip hidden.
698 origin_chip_view_->SetBounds(0, 0, origin_chip_preferred_width, height()); 699 origin_chip_view_->SetBounds(0, 0, origin_chip_preferred_width, height());
699 origin_chip_view_->Layout(); 700 origin_chip_view_->Layout();
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 base::i18n::LEFT_TO_RIGHT : base::i18n::RIGHT_TO_LEFT)) { 973 base::i18n::LEFT_TO_RIGHT : base::i18n::RIGHT_TO_LEFT)) {
973 // TODO(sky): Figure out why we need the +1. 974 // TODO(sky): Figure out why we need the +1.
974 suggested_text_bounds.set_x(location_bounds.x() + 1); 975 suggested_text_bounds.set_x(location_bounds.x() + 1);
975 // Use a margin to prevent omnibox text from overlapping suggest text. 976 // Use a margin to prevent omnibox text from overlapping suggest text.
976 omnibox_view_margin = suggested_text_bounds.width(); 977 omnibox_view_margin = suggested_text_bounds.width();
977 } 978 }
978 suggested_text_view_->SetBoundsRect(suggested_text_bounds); 979 suggested_text_view_->SetBoundsRect(suggested_text_bounds);
979 } 980 }
980 } 981 }
981 982
982 const gfx::Insets insets = omnibox_view_->GetInsets(); 983 omnibox_view_->SetBorder(
983 omnibox_view_->SetBorder(views::Border::CreateEmptyBorder( 984 views::Border::CreateEmptyBorder(0, 0, 0, omnibox_view_margin));
984 insets.top(), insets.left(), insets.bottom(), omnibox_view_margin));
985 985
986 // Layout |ime_inline_autocomplete_view_| next to the user input. 986 // Layout |ime_inline_autocomplete_view_| next to the user input.
987 if (ime_inline_autocomplete_view_->visible()) { 987 if (ime_inline_autocomplete_view_->visible()) {
988 int width = 988 int width =
989 gfx::GetStringWidth(ime_inline_autocomplete_view_->text(), 989 gfx::GetStringWidth(ime_inline_autocomplete_view_->text(),
990 ime_inline_autocomplete_view_->font_list()) + 990 ime_inline_autocomplete_view_->font_list()) +
991 ime_inline_autocomplete_view_->GetInsets().width(); 991 ime_inline_autocomplete_view_->GetInsets().width();
992 // All the target languages (IMEs) are LTR, and we do not need to support 992 // All the target languages (IMEs) are LTR, and we do not need to support
993 // RTL so far. In other words, no testable RTL environment so far. 993 // RTL so far. In other words, no testable RTL environment so far.
994 int x = location_needed_width; 994 int x = location_needed_width;
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
1699 1699
1700 void LocationBarView::ModelChanged(const SearchModel::State& old_state, 1700 void LocationBarView::ModelChanged(const SearchModel::State& old_state,
1701 const SearchModel::State& new_state) { 1701 const SearchModel::State& new_state) {
1702 const bool visible = !GetToolbarModel()->input_in_progress() && 1702 const bool visible = !GetToolbarModel()->input_in_progress() &&
1703 new_state.voice_search_supported; 1703 new_state.voice_search_supported;
1704 if (mic_search_view_->visible() != visible) { 1704 if (mic_search_view_->visible() != visible) {
1705 mic_search_view_->SetVisible(visible); 1705 mic_search_view_->SetVisible(visible);
1706 Layout(); 1706 Layout();
1707 } 1707 }
1708 } 1708 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/find_bar_view.cc ('k') | ui/app_list/views/folder_header_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698