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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 AddChildView(ev_bubble_view_); | 274 AddChildView(ev_bubble_view_); |
275 | 275 |
276 // Initialize the Omnibox view. | 276 // Initialize the Omnibox view. |
277 location_entry_.reset(CreateOmniboxView(this, model_, profile_, | 277 location_entry_.reset(CreateOmniboxView(this, model_, profile_, |
278 command_updater_, is_popup_mode_, this, font, font_y_offset)); | 278 command_updater_, is_popup_mode_, this, font, font_y_offset)); |
279 SetLocationEntryFocusable(true); | 279 SetLocationEntryFocusable(true); |
280 location_entry_view_ = location_entry_->AddToView(this); | 280 location_entry_view_ = location_entry_->AddToView(this); |
281 | 281 |
282 // Initialize the inline autocomplete view which is visible only when IME is | 282 // Initialize the inline autocomplete view which is visible only when IME is |
283 // turned on. Use the same font with the omnibox and highlighted background. | 283 // turned on. Use the same font with the omnibox and highlighted background. |
284 ime_inline_autocomplete_view_ = new views::Label(); | 284 ime_inline_autocomplete_view_ = new views::Label(string16(), font); |
| 285 ime_inline_autocomplete_view_->set_border( |
| 286 views::Border::CreateEmptyBorder(font_y_offset, 0, 0, 0)); |
285 ime_inline_autocomplete_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 287 ime_inline_autocomplete_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
286 ime_inline_autocomplete_view_->SetAutoColorReadabilityEnabled(false); | 288 ime_inline_autocomplete_view_->SetAutoColorReadabilityEnabled(false); |
287 ime_inline_autocomplete_view_->set_background( | 289 ime_inline_autocomplete_view_->set_background( |
288 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor( | 290 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor( |
289 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused))); | 291 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused))); |
290 ime_inline_autocomplete_view_->SetEnabledColor( | 292 ime_inline_autocomplete_view_->SetEnabledColor( |
291 GetNativeTheme()->GetSystemColor( | 293 GetNativeTheme()->GetSystemColor( |
292 ui::NativeTheme::kColorId_TextfieldSelectionColor)); | 294 ui::NativeTheme::kColorId_TextfieldSelectionColor)); |
293 ime_inline_autocomplete_view_->SetFont(font); | |
294 ime_inline_autocomplete_view_->SetVisible(false); | 295 ime_inline_autocomplete_view_->SetVisible(false); |
295 AddChildView(ime_inline_autocomplete_view_); | 296 AddChildView(ime_inline_autocomplete_view_); |
296 | 297 |
297 const SkColor text_color = GetColor(ToolbarModel::NONE, TEXT); | 298 const SkColor text_color = GetColor(ToolbarModel::NONE, TEXT); |
298 selected_keyword_view_ = new SelectedKeywordView( | 299 selected_keyword_view_ = new SelectedKeywordView( |
299 bubble_font, bubble_font_y_offset, text_color, background_color, | 300 bubble_font, bubble_font_y_offset, text_color, background_color, |
300 profile_); | 301 profile_); |
301 AddChildView(selected_keyword_view_); | 302 AddChildView(selected_keyword_view_); |
302 | 303 |
303 suggested_text_view_ = new views::Label(string16(), font); | 304 suggested_text_view_ = new views::Label(string16(), font); |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 omnibox_views->SetHorizontalMargins(0, omnibox_views_margin); | 916 omnibox_views->SetHorizontalMargins(0, omnibox_views_margin); |
916 | 917 |
917 // Layout |ime_inline_autocomplete_view_| next to the user input. | 918 // Layout |ime_inline_autocomplete_view_| next to the user input. |
918 if (ime_inline_autocomplete_view_->visible()) { | 919 if (ime_inline_autocomplete_view_->visible()) { |
919 int width = | 920 int width = |
920 ime_inline_autocomplete_view_->font().GetStringWidth( | 921 ime_inline_autocomplete_view_->font().GetStringWidth( |
921 ime_inline_autocomplete_view_->text()) + | 922 ime_inline_autocomplete_view_->text()) + |
922 ime_inline_autocomplete_view_->GetInsets().width(); | 923 ime_inline_autocomplete_view_->GetInsets().width(); |
923 // All the target languages (IMEs) are LTR, and we do not need to support | 924 // All the target languages (IMEs) are LTR, and we do not need to support |
924 // RTL so far. In other words, no testable RTL environment so far. | 925 // RTL so far. In other words, no testable RTL environment so far. |
925 int x; | 926 int x = location_needed_width; |
926 if (width > entry_width) { | 927 if (width > entry_width) |
927 x = 0; | 928 x = 0; |
928 } else if (location_needed_width + width > entry_width) { | 929 else if (location_needed_width + width > entry_width) |
929 x = entry_width - width; | 930 x = entry_width - width; |
930 } else { | |
931 x = location_needed_width; | |
932 } | |
933 location_bounds.set_width(x); | 931 location_bounds.set_width(x); |
934 ime_inline_autocomplete_view_->SetBounds( | 932 ime_inline_autocomplete_view_->SetBounds( |
935 location_bounds.right(), | 933 location_bounds.right(), location_bounds.y(), |
936 location_bounds.y(), | |
937 std::min(width, entry_width), | 934 std::min(width, entry_width), |
938 location_bounds.height()); | 935 ime_inline_autocomplete_view_->GetPreferredSize().height()); |
939 } | 936 } |
940 | 937 |
941 location_entry_view_->SetBoundsRect(location_bounds); | 938 location_entry_view_->SetBoundsRect(location_bounds); |
942 } | 939 } |
943 | 940 |
944 void LocationBarView::OnPaint(gfx::Canvas* canvas) { | 941 void LocationBarView::OnPaint(gfx::Canvas* canvas) { |
945 View::OnPaint(canvas); | 942 View::OnPaint(canvas); |
946 | 943 |
947 // Maximized popup windows don't draw the horizontal edges. We implement this | 944 // Maximized popup windows don't draw the horizontal edges. We implement this |
948 // by simply expanding the paint area outside the view by the edge thickness. | 945 // by simply expanding the paint area outside the view by the edge thickness. |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1549 int LocationBarView::GetInternalHeight(bool use_preferred_size) { | 1546 int LocationBarView::GetInternalHeight(bool use_preferred_size) { |
1550 int total_height = | 1547 int total_height = |
1551 use_preferred_size ? GetPreferredSize().height() : height(); | 1548 use_preferred_size ? GetPreferredSize().height() : height(); |
1552 return std::max(total_height - (vertical_edge_thickness() * 2), 0); | 1549 return std::max(total_height - (vertical_edge_thickness() * 2), 0); |
1553 } | 1550 } |
1554 | 1551 |
1555 bool LocationBarView::HasValidSuggestText() const { | 1552 bool LocationBarView::HasValidSuggestText() const { |
1556 return suggested_text_view_->visible() && | 1553 return suggested_text_view_->visible() && |
1557 !suggested_text_view_->size().IsEmpty(); | 1554 !suggested_text_view_->size().IsEmpty(); |
1558 } | 1555 } |
OLD | NEW |