diff options
author | xji@chromium.org <xji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-11 21:25:37 +0000 |
---|---|---|
committer | xji@chromium.org <xji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-11 21:25:37 +0000 |
commit | a8b102fe2539665d1d5a7fa2bc6f192ac853e962 (patch) | |
tree | ec4ad1694b34262acaddfe2dac13a7162a14631e /chrome/browser/views | |
parent | 07c83fd88c98778035fb5b5102fa4983b39fa860 (diff) | |
download | chromium_src-a8b102fe2539665d1d5a7fa2bc6f192ac853e962.zip chromium_src-a8b102fe2539665d1d5a7fa2bc6f192ac853e962.tar.gz chromium_src-a8b102fe2539665d1d5a7fa2bc6f192ac853e962.tar.bz2 |
This CL revert the fix for issue 2780 - RTL: Omnibar - message "Press Tab to search Google" doesn't show correctly in a "New Tab" for RTL locales.
(http://crbug.com/2780)
Previous fix at http://codereview.chromium.org/100360 may have regressed the startup time by about 5ms/6.7% due to multiple call of PosFromChar().
Ts regression chart is at:
http://build.chromium.org/buildbot/perf/xp-release-dual-core/startup/report.html?history=150
I am reverting the CL while working on solutions.
Review URL: http://codereview.chromium.org/113221
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15784 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/location_bar_view.cc | 50 |
1 files changed, 4 insertions, 46 deletions
diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc index 8490c58..c53a7e9 100644 --- a/chrome/browser/views/location_bar_view.cc +++ b/chrome/browser/views/location_bar_view.cc @@ -435,54 +435,12 @@ int LocationBarView::TopMargin() const { } int LocationBarView::TextDisplayWidth() { - // location_entry_->PosFromChar(location_entry_->GetTextLength()) returns - // 1. The rightmost position for LTR UI, in which the layout and the - // alignment are both left-to-right. Or - // 2. The leftmost position for a text if the layout and the alignment of the - // text are both right-to-left. - // - // But there are two problems: - // 1. In our current RTL UI, text in Omnibox is right aligned, but the layout - // is left-to-right. Please see http://crbug.com/6573 for detailed - // information. - // 2. In both LTR and RTL UI, there is the following problem in - // PosFromChar(), which I do not know the reason. - // location_entry_->PosFromChar(location_entry_->GetTextLength()) might - // return 0. For example, type 'h' in omnibox which should display the first - // matched list, say "http://www.google.com/", with "ttp://www.google.com/" - // highlighted, in omnibox. location_entry_->GetTextLength() returns 22, - // which is the length of "http://www.google.com/". But - // location_entry_->PosFromChar(i) returns 0 when i is greater than 1. - // location_entry_->PosFromChar(i) should return the right position after the - // last character when i is greater than 22. - // - // Due to the above 2 problems, we do not use - // location_entry_->PosFromChar(location_entry_->GetTextLength()) to compute - // text display width. Instead, we compute and compare each character's - // position to find out the leftmost position for RTL UI, or the rightmost - // position for LTR UI. + POINT last_char_position = + location_entry_->PosFromChar(location_entry_->GetTextLength()); POINT scroll_position; location_entry_->GetScrollPos(&scroll_position); - - int max_text_length = location_entry_->GetTextLength(); - if (UILayoutIsRightToLeft()) { - int leftmost_position = location_entry_->PosFromChar(0).x; - for (int i = 1; i <= max_text_length; ++i) { - int x = location_entry_->PosFromChar(i).x; - if (x && x < leftmost_position) - leftmost_position = x; - } - return location_entry_view_->width() - leftmost_position - - scroll_position.x; - } else { - int rightmost_position = location_entry_->PosFromChar(max_text_length).x; - for (int i = 0; i < max_text_length; ++i) { - int x = location_entry_->PosFromChar(i).x; - if (x > rightmost_position) - rightmost_position = x; - } - return rightmost_position + scroll_position.x; - } + const int position_x = last_char_position.x + scroll_position.x; + return UILayoutIsRightToLeft() ? width() - position_x : position_x; } bool LocationBarView::UsePref(int pref_width, int text_width, int max_width) { |