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

Side by Side Diff: chrome/browser/gtk/find_bar_gtk.cc

Issue 1073005: Move RTL related functions from app/l10n_util to base/i18n/rtl... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/gtk/extension_popup_gtk.cc ('k') | chrome/browser/gtk/first_run_bubble.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/gtk/find_bar_gtk.h" 5 #include "chrome/browser/gtk/find_bar_gtk.h"
6 6
7 #include <gdk/gdkkeysyms.h> 7 #include <gdk/gdkkeysyms.h>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
11 #include "base/i18n/rtl.h"
11 #include "base/string_util.h" 12 #include "base/string_util.h"
12 #include "chrome/browser/browser.h" 13 #include "chrome/browser/browser.h"
13 #include "chrome/browser/find_bar_controller.h" 14 #include "chrome/browser/find_bar_controller.h"
14 #include "chrome/browser/gtk/browser_window_gtk.h" 15 #include "chrome/browser/gtk/browser_window_gtk.h"
15 #include "chrome/browser/gtk/cairo_cached_surface.h" 16 #include "chrome/browser/gtk/cairo_cached_surface.h"
16 #include "chrome/browser/gtk/custom_button.h" 17 #include "chrome/browser/gtk/custom_button.h"
17 #include "chrome/browser/gtk/gtk_floating_container.h" 18 #include "chrome/browser/gtk/gtk_floating_container.h"
18 #include "chrome/browser/gtk/gtk_theme_provider.h" 19 #include "chrome/browser/gtk/gtk_theme_provider.h"
19 #include "chrome/browser/gtk/gtk_util.h" 20 #include "chrome/browser/gtk/gtk_util.h"
20 #include "chrome/browser/gtk/nine_box.h" 21 #include "chrome/browser/gtk/nine_box.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 67
67 // Returns a list of points that either form the outline of the status bubble 68 // Returns a list of points that either form the outline of the status bubble
68 // (|type| == FRAME_MASK) or form the inner border around the inner edge 69 // (|type| == FRAME_MASK) or form the inner border around the inner edge
69 // (|type| == FRAME_STROKE). 70 // (|type| == FRAME_STROKE).
70 std::vector<GdkPoint> MakeFramePolygonPoints(int width, 71 std::vector<GdkPoint> MakeFramePolygonPoints(int width,
71 int height, 72 int height,
72 FrameType type) { 73 FrameType type) {
73 using gtk_util::MakeBidiGdkPoint; 74 using gtk_util::MakeBidiGdkPoint;
74 std::vector<GdkPoint> points; 75 std::vector<GdkPoint> points;
75 76
76 bool ltr = l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT; 77 bool ltr = !base::i18n::IsRTL();
77 // If we have a stroke, we have to offset some of our points by 1 pixel. 78 // If we have a stroke, we have to offset some of our points by 1 pixel.
78 // We have to inset by 1 pixel when we draw horizontal lines that are on the 79 // We have to inset by 1 pixel when we draw horizontal lines that are on the
79 // bottom or when we draw vertical lines that are closer to the end (end is 80 // bottom or when we draw vertical lines that are closer to the end (end is
80 // right for ltr). 81 // right for ltr).
81 int y_off = (type == FRAME_MASK) ? 0 : -1; 82 int y_off = (type == FRAME_MASK) ? 0 : -1;
82 // We use this one for LTR. 83 // We use this one for LTR.
83 int x_off_l = ltr ? y_off : 0; 84 int x_off_l = ltr ? y_off : 0;
84 // We use this one for RTL. 85 // We use this one for RTL.
85 int x_off_r = !ltr ? -y_off : 0; 86 int x_off_r = !ltr ? -y_off : 0;
86 87
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 398
398 void FindBarGtk::AudibleAlert() { 399 void FindBarGtk::AudibleAlert() {
399 // This call causes a lot of weird bugs, especially when using the custom 400 // This call causes a lot of weird bugs, especially when using the custom
400 // frame. TODO(estade): if people complain, re-enable it. See 401 // frame. TODO(estade): if people complain, re-enable it. See
401 // http://crbug.com/27635 and others. 402 // http://crbug.com/27635 and others.
402 // 403 //
403 // gtk_widget_error_bell(widget()); 404 // gtk_widget_error_bell(widget());
404 } 405 }
405 406
406 gfx::Rect FindBarGtk::GetDialogPosition(gfx::Rect avoid_overlapping_rect) { 407 gfx::Rect FindBarGtk::GetDialogPosition(gfx::Rect avoid_overlapping_rect) {
407 bool ltr = l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT; 408 bool ltr = !base::i18n::IsRTL();
408 // 15 is the size of the scrollbar, copied from ScrollbarThemeChromium. 409 // 15 is the size of the scrollbar, copied from ScrollbarThemeChromium.
409 // The height is not used. 410 // The height is not used.
410 // At very low browser widths we can wind up with a negative |dialog_bounds| 411 // At very low browser widths we can wind up with a negative |dialog_bounds|
411 // width, so clamp it to 0. 412 // width, so clamp it to 0.
412 gfx::Rect dialog_bounds = gfx::Rect(ltr ? 0 : 15, 0, 413 gfx::Rect dialog_bounds = gfx::Rect(ltr ? 0 : 15, 0,
413 std::max(0, widget()->parent->allocation.width - (ltr ? 15 : 0)), 0); 414 std::max(0, widget()->parent->allocation.width - (ltr ? 15 : 0)), 0);
414 415
415 GtkRequisition req; 416 GtkRequisition req;
416 gtk_widget_size_request(container_, &req); 417 gtk_widget_size_request(container_, &req);
417 gfx::Size prefsize(req.width, req.height); 418 gfx::Size prefsize(req.width, req.height);
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 gtk_util::DrawThemedToolbarBackground(widget, cr, e, tabstrip_origin, 832 gtk_util::DrawThemedToolbarBackground(widget, cr, e, tabstrip_origin,
832 bar->theme_provider_); 833 bar->theme_provider_);
833 834
834 // During chrome theme mode, we need to draw the border around content_hbox 835 // During chrome theme mode, we need to draw the border around content_hbox
835 // now instead of when we render |border_bin_|. We don't use stacked event 836 // now instead of when we render |border_bin_|. We don't use stacked event
836 // boxes to simulate the effect because we need to blend them with this 837 // boxes to simulate the effect because we need to blend them with this
837 // background. 838 // background.
838 GtkAllocation border_allocation = bar->border_bin_->allocation; 839 GtkAllocation border_allocation = bar->border_bin_->allocation;
839 840
840 // Blit the left part of the background image once on the left. 841 // Blit the left part of the background image once on the left.
841 bool rtl = l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT; 842 bool rtl = base::i18n::IsRTL();
842 CairoCachedSurface* background_left = bar->theme_provider_->GetSurfaceNamed( 843 CairoCachedSurface* background_left = bar->theme_provider_->GetSurfaceNamed(
843 rtl ? IDR_FIND_BOX_BACKGROUND_LEFT_RTL : IDR_FIND_BOX_BACKGROUND_LEFT, 844 rtl ? IDR_FIND_BOX_BACKGROUND_LEFT_RTL : IDR_FIND_BOX_BACKGROUND_LEFT,
844 widget); 845 widget);
845 background_left->SetSource(cr, border_allocation.x, border_allocation.y); 846 background_left->SetSource(cr, border_allocation.x, border_allocation.y);
846 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT); 847 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
847 cairo_rectangle(cr, border_allocation.x, border_allocation.y, 848 cairo_rectangle(cr, border_allocation.x, border_allocation.y,
848 background_left->Width(), background_left->Height()); 849 background_left->Width(), background_left->Height());
849 cairo_fill(cr); 850 cairo_fill(cr);
850 851
851 // Blit the center part of the background image in all the space between. 852 // Blit the center part of the background image in all the space between.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 930
930 // static 931 // static
931 gboolean FindBarGtk::OnFocusOut(GtkWidget* entry, GdkEventFocus* event, 932 gboolean FindBarGtk::OnFocusOut(GtkWidget* entry, GdkEventFocus* event,
932 FindBarGtk* find_bar) { 933 FindBarGtk* find_bar) {
933 g_signal_handlers_disconnect_by_func( 934 g_signal_handlers_disconnect_by_func(
934 gdk_keymap_get_for_display(gtk_widget_get_display(entry)), 935 gdk_keymap_get_for_display(gtk_widget_get_display(entry)),
935 reinterpret_cast<gpointer>(&OnKeymapDirectionChanged), find_bar); 936 reinterpret_cast<gpointer>(&OnKeymapDirectionChanged), find_bar);
936 937
937 return FALSE; // Continue propagation. 938 return FALSE; // Continue propagation.
938 } 939 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/extension_popup_gtk.cc ('k') | chrome/browser/gtk/first_run_bubble.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698