summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-29 02:09:15 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-29 02:09:15 +0000
commit59b89cbe5228715a4cbbb17a77a739ffb16b02ae (patch)
tree41f33781d72ba864c8505aa8b0cd4d145449f98e /chrome/browser/gtk
parent97fce46c1ad6c8b4afa53e513c758bc0bd8bfc60 (diff)
downloadchromium_src-59b89cbe5228715a4cbbb17a77a739ffb16b02ae.zip
chromium_src-59b89cbe5228715a4cbbb17a77a739ffb16b02ae.tar.gz
chromium_src-59b89cbe5228715a4cbbb17a77a739ffb16b02ae.tar.bz2
Make find bar BIDI.
BUG=17475 TEST=obvious Review URL: http://codereview.chromium.org/159570 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21936 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r--chrome/browser/gtk/find_bar_gtk.cc41
-rw-r--r--chrome/browser/gtk/nine_box.cc36
2 files changed, 65 insertions, 12 deletions
diff --git a/chrome/browser/gtk/find_bar_gtk.cc b/chrome/browser/gtk/find_bar_gtk.cc
index 819458c..4436455 100644
--- a/chrome/browser/gtk/find_bar_gtk.cc
+++ b/chrome/browser/gtk/find_bar_gtk.cc
@@ -95,7 +95,6 @@ FindBarGtk::FindBarGtk(Browser* browser)
0, IDR_THEME_TOOLBAR, 0,
0, 0, 0, 0, 0, 0));
-
// Insert the widget into the browser gtk hierarchy.
window_->AddFindBar(this);
@@ -290,6 +289,12 @@ void FindBarGtk::SetFindText(const string16& find_text) {
void FindBarGtk::UpdateUIForFindResult(const FindNotificationDetails& result,
const string16& find_text) {
+ if (!result.selection_rect().IsEmpty()) {
+ int xposition = GetDialogPosition(result.selection_rect()).x();
+ if (xposition != slide_widget()->allocation.x)
+ gtk_fixed_move(GTK_FIXED(widget()), slide_widget(), xposition, 0);
+ }
+
// Once we find a match we no longer want to keep track of what had
// focus. EndFindSession will then set the focus to the page content.
if (result.number_of_matches() > 0)
@@ -330,12 +335,36 @@ void FindBarGtk::AudibleAlert() {
}
gfx::Rect FindBarGtk::GetDialogPosition(gfx::Rect avoid_overlapping_rect) {
- // TODO(estade): Logic for the positioning of the find bar should be factored
- // out of here and browser/views/* and into FindBarController.
- int xposition = widget()->allocation.width -
- slide_widget()->allocation.width - 50;
+ // TODO(estade): Logic for the positioning of the find bar might do better
+ // to share more code with Windows. Currently though they do some things we
+ // don't worry about, such as considering the state of the bookmark bar on
+ // the NTP. I've tried to stick as close to the windows function as possible
+ // here to make it easy to possibly unfork this down the road.
+
+ bool ltr = l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT;
+ // 15 is the size of the scrollbar, copied from ScrollbarThemeChromium.
+ // The height is not used.
+ gfx::Rect dialog_bounds = gfx::Rect(ltr ? 0 : 15, 0,
+ widget()->allocation.width -
+ (ltr ? 15 : 0),
+ 0);
+
+ GtkRequisition req;
+ gtk_widget_size_request(container_, &req);
+ gfx::Size prefsize(req.width, req.height);
+
+ gfx::Rect view_location(
+ ltr ? dialog_bounds.width() - prefsize.width() : dialog_bounds.x(),
+ dialog_bounds.y(), prefsize.width(), prefsize.height());
+
+ if (!avoid_overlapping_rect.IsEmpty()) {
+ // TODO(estade): move out of the way if need be.
+ }
+
+ if (view_location.x() < 0)
+ view_location.set_x(0);
- return gfx::Rect(xposition, 0, 1, 1);
+ return view_location;
}
void FindBarGtk::SetDialogPosition(const gfx::Rect& new_pos, bool no_redraw) {
diff --git a/chrome/browser/gtk/nine_box.cc b/chrome/browser/gtk/nine_box.cc
index 041fc3b..26e79b1 100644
--- a/chrome/browser/gtk/nine_box.cc
+++ b/chrome/browser/gtk/nine_box.cc
@@ -164,12 +164,13 @@ void NineBox::ChangeWhiteToTransparent() {
}
void NineBox::ContourWidget(GtkWidget* widget) const {
+ int width = widget->allocation.width;
+ int height = widget->allocation.height;
int x1 = gdk_pixbuf_get_width(images_[0]);
- int x2 = widget->allocation.width - gdk_pixbuf_get_width(images_[2]);
+ int x2 = width - gdk_pixbuf_get_width(images_[2]);
// Paint the left and right sides.
- GdkBitmap* mask = gdk_pixmap_new(NULL, widget->allocation.width,
- widget->allocation.height, 1);
+ GdkBitmap* mask = gdk_pixmap_new(NULL, width, height, 1);
gdk_pixbuf_render_threshold_alpha(images_[0], mask,
0, 0,
0, 0, -1, -1,
@@ -181,14 +182,37 @@ void NineBox::ContourWidget(GtkWidget* widget) const {
// Assume no transparency in the middle rectangle.
cairo_t* cr = gdk_cairo_create(mask);
- cairo_rectangle(cr, x1, 0, x2 - x1, widget->allocation.height);
+ cairo_rectangle(cr, x1, 0, x2 - x1, height);
cairo_fill(cr);
+ cairo_destroy(cr);
// Mask the widget's window's shape.
- gtk_widget_shape_combine_mask(widget, mask, 0, 0);
+ if (l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT) {
+ gtk_widget_shape_combine_mask(widget, mask, 0, 0);
+ } else {
+ GdkBitmap* flipped_mask = gdk_pixmap_new(NULL, width, height, 1);
+ cairo_t* flipped_cr = gdk_cairo_create(flipped_mask);
+
+ // Clear the target bitmap.
+ cairo_set_operator(flipped_cr, CAIRO_OPERATOR_CLEAR);
+ cairo_paint(flipped_cr);
+
+ // Apply flipping transformation.
+ cairo_translate(flipped_cr, width, 0.0f);
+ cairo_scale(flipped_cr, -1.0f, 1.0f);
+
+ // Paint the source bitmap onto the target.
+ cairo_set_operator(flipped_cr, CAIRO_OPERATOR_SOURCE);
+ gdk_cairo_set_source_pixmap(flipped_cr, mask, 0, 0);
+ cairo_paint(flipped_cr);
+ cairo_destroy(flipped_cr);
+
+ // Mask the widget.
+ gtk_widget_shape_combine_mask(widget, flipped_mask, 0, 0);
+ g_object_unref(flipped_mask);
+ }
g_object_unref(mask);
- cairo_destroy(cr);
}
void NineBox::Observe(NotificationType type, const NotificationSource& source,