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

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_view_views.cc

Issue 2855793003: Fix RTL URL rendering in Omnibox (domain off screen on long URL). (Closed)
Patch Set: Fix comment nit. Created 3 years, 7 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
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/omnibox/omnibox_view_views.h" 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 saved_selection_for_focus_change_ = GetSelectedRange(); 775 saved_selection_for_focus_change_ = GetSelectedRange();
776 776
777 views::Textfield::OnBlur(); 777 views::Textfield::OnBlur();
778 model()->OnWillKillFocus(); 778 model()->OnWillKillFocus();
779 779
780 // If ZeroSuggest is active, and there is evidence that there is a text 780 // If ZeroSuggest is active, and there is evidence that there is a text
781 // update to show, revert to ensure that update is shown now. Otherwise, 781 // update to show, revert to ensure that update is shown now. Otherwise,
782 // at least call CloseOmniboxPopup(), so that if ZeroSuggest is in the 782 // at least call CloseOmniboxPopup(), so that if ZeroSuggest is in the
783 // midst of running but hasn't yet opened the popup, it will be halted. 783 // midst of running but hasn't yet opened the popup, it will be halted.
784 // If we fully reverted in this case, we'd lose the cursor/highlight 784 // If we fully reverted in this case, we'd lose the cursor/highlight
785 // information saved above. 785 // information saved above. Note: popup_model() can be null in tests.
786 if (!model()->user_input_in_progress() && model()->popup_model()->IsOpen() && 786 if (!model()->user_input_in_progress() && model()->popup_model() &&
787 text() != model()->PermanentText()) 787 model()->popup_model()->IsOpen() && text() != model()->PermanentText())
788 RevertAll(); 788 RevertAll();
789 else 789 else
790 CloseOmniboxPopup(); 790 CloseOmniboxPopup();
791 791
792 // Tell the model to reset itself. 792 // Tell the model to reset itself.
793 model()->OnKillFocus(); 793 model()->OnKillFocus();
794 794
795 // Make sure the beginning of the text is visible. 795 // When deselected, elide and reset scroll position. After eliding, the old
796 SelectRange(gfx::Range(0)); 796 // scroll offset is meaningless (since the string is guaranteed to fit within
797 797 // the view). The scroll must be reset or the text may be rendered partly or
798 GetRenderText()->SetElideBehavior(gfx::ELIDE_TAIL); 798 // wholly off-screen.
799 //
800 // Important: Since the URL can contain bidirectional text, it is important to
801 // set the display offset directly to 0 (not simply scroll to the start of the
802 // text, since the start of the text may not be at the left edge).
803 gfx::RenderText* render_text = GetRenderText();
804 render_text->SetElideBehavior(gfx::ELIDE_TAIL);
805 render_text->SetDisplayOffset(0);
799 806
800 // Focus changes can affect the visibility of any keyword hint. 807 // Focus changes can affect the visibility of any keyword hint.
801 if (model()->is_keyword_hint()) 808 // |location_bar_view_| can be null in tests.
802 location_bar_view_->Layout(); 809 if (location_bar_view_) {
810 if (model()->is_keyword_hint())
811 location_bar_view_->Layout();
803 812
804 // The location bar needs to repaint without a focus ring. 813 // The location bar needs to repaint without a focus ring.
805 location_bar_view_->SchedulePaint(); 814 location_bar_view_->SchedulePaint();
815 }
806 } 816 }
807 817
808 bool OmniboxViewViews::IsCommandIdEnabled(int command_id) const { 818 bool OmniboxViewViews::IsCommandIdEnabled(int command_id) const {
809 if (command_id == IDS_APP_PASTE) 819 if (command_id == IDS_APP_PASTE)
810 return !read_only() && !GetClipboardText().empty(); 820 return !read_only() && !GetClipboardText().empty();
811 if (command_id == IDS_PASTE_AND_GO) 821 if (command_id == IDS_PASTE_AND_GO)
812 return !read_only() && model()->CanPasteAndGo(GetClipboardText()); 822 return !read_only() && model()->CanPasteAndGo(GetClipboardText());
813 return Textfield::IsCommandIdEnabled(command_id) || 823 return Textfield::IsCommandIdEnabled(command_id) ||
814 location_bar_view_->command_updater()->IsCommandEnabled(command_id); 824 location_bar_view_->command_updater()->IsCommandEnabled(command_id);
815 } 825 }
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); 1077 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO);
1068 1078
1069 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); 1079 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR);
1070 1080
1071 // Minor note: We use IDC_ for command id here while the underlying textfield 1081 // Minor note: We use IDC_ for command id here while the underlying textfield
1072 // is using IDS_ for all its command ids. This is because views cannot depend 1082 // is using IDS_ for all its command ids. This is because views cannot depend
1073 // on IDC_ for now. 1083 // on IDC_ for now.
1074 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, 1084 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES,
1075 IDS_EDIT_SEARCH_ENGINES); 1085 IDS_EDIT_SEARCH_ENGINES);
1076 } 1086 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698