summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
diff options
context:
space:
mode:
authorsuzhe@chromium.org <suzhe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-11 03:36:24 +0000
committersuzhe@chromium.org <suzhe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-11 03:36:24 +0000
commitf96cb05502a32c59e9d0fa158aa0441dea81be69 (patch)
tree6a5155b98ed669a92fd5f844c22882bb2e202012 /chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
parent3554ee417f54aa874716878a9af08d5db4dc7ce6 (diff)
downloadchromium_src-f96cb05502a32c59e9d0fa158aa0441dea81be69.zip
chromium_src-f96cb05502a32c59e9d0fa158aa0441dea81be69.tar.gz
chromium_src-f96cb05502a32c59e9d0fa158aa0441dea81be69.tar.bz2
[Linux]Fix text justification of omnibox.
Without this CL, the omnibox inherits the default behavior of GtkTextView on handling text direction and justification, that is: 1. If the justification is set to left justification, then the content will be left justified if the content's text direction is LTR, otherwise it'll be right justified. 2. If the justification is set to right justification, then the content will be right justified if the content's text direction is LTR, otherwise it'll be left justified. And if the content doesn't have a strong text direction, the keymap's direction will be used. If the keymap doesn't have a strong text direction either, the widget's direction (UI language direction) will be used. This behavior is different than Chrome windows. On windows, if the UI language direction is LTR, then the content is always left justified, otherwise it's always right justified. To achieve the same behavior, this CL adjust the justification automatically according to the content's (or keymap's) text direction and the widget direction, to make sure the justification is always in sync with the UI language direction. BUG=34724 Text in omnibox and find bar is not right justified correct under RTL locale. TEST=Run chrome with LTR locale, the text in omnibox should always be left justified, regardless of the text's direction. With RTL locale, the text should always be right justified. It matches the behavior of windows version. Review URL: http://codereview.chromium.org/595021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38737 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/autocomplete_edit_view_gtk.h')
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_gtk.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
index 7923551..7549c6c 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
@@ -301,6 +301,18 @@ class AutocompleteEditViewGtk : public AutocompleteEditView,
}
gboolean HandleExposeEvent(GdkEventExpose* expose);
+ static void HandleWidgetDirectionChangedThunk(
+ GtkWidget* widget, GtkTextDirection previous_direction, gpointer self) {
+ return reinterpret_cast<AutocompleteEditViewGtk*>(self)->
+ AdjustTextJustification();
+ }
+
+ static void HandleKeymapDirectionChangedThunk(GdkKeymap* keymap,
+ gpointer self) {
+ return reinterpret_cast<AutocompleteEditViewGtk*>(self)->
+ AdjustTextJustification();
+ }
+
// Gets the GTK_TEXT_WINDOW_WIDGET coordinates for |text_view_| that bound the
// given iters.
gfx::Rect WindowBoundsFromIters(GtkTextIter* iter1, GtkTextIter* iter2);
@@ -348,6 +360,15 @@ class AutocompleteEditViewGtk : public AutocompleteEditView,
// Set the selection to |range|.
void SetSelectedRange(const CharRange& range);
+ // Adjust the text justification according to the text direction of the widget
+ // and |text_buffer_|'s content, to make sure the real text justification is
+ // always in sync with the UI language direction.
+ void AdjustTextJustification();
+
+ // Get the text direction of |text_buffer_|'s content, by searching the first
+ // character that has a strong direction.
+ PangoDirection GetContentDirection();
+
// The widget we expose, used for vertically centering the real text edit,
// since the height will change based on the font / font size, etc.
OwnedWidgetGtk alignment_;