summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc17
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_gtk.h4
-rw-r--r--chrome/browser/views/location_bar_view.cc3
3 files changed, 22 insertions, 2 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
index 2633037..26025e2 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
@@ -236,6 +236,23 @@ void AutocompleteEditViewGtk::SetFocus() {
gtk_widget_grab_focus(text_view_);
}
+int AutocompleteEditViewGtk::TextWidth() {
+ int horizontal_border_size =
+ gtk_text_view_get_border_window_size(GTK_TEXT_VIEW(text_view_),
+ GTK_TEXT_WINDOW_LEFT) +
+ gtk_text_view_get_border_window_size(GTK_TEXT_VIEW(text_view_),
+ GTK_TEXT_WINDOW_RIGHT) +
+ gtk_text_view_get_left_margin(GTK_TEXT_VIEW(text_view_)) +
+ gtk_text_view_get_right_margin(GTK_TEXT_VIEW(text_view_));
+ GtkTextIter end;
+ GdkRectangle last_char_bounds;
+ gtk_text_buffer_get_end_iter(
+ gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view_)), &end);
+ gtk_text_view_get_iter_location(GTK_TEXT_VIEW(text_view_),
+ &end, &last_char_bounds);
+ return last_char_bounds.x + last_char_bounds.width + horizontal_border_size;
+}
+
void AutocompleteEditViewGtk::SaveStateToTab(TabContents* tab) {
DCHECK(tab);
GetStateAccessor()->SetProperty(
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
index 112cdef..2f51e88 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
@@ -63,6 +63,10 @@ class AutocompleteEditViewGtk : public AutocompleteEditView,
// Grab keyboard input focus, putting focus on the location widget.
void SetFocus();
+ // Returns the width, in pixels, needed to display the current text. The
+ // returned value includes margins and borders.
+ int TextWidth();
+
// Implement the AutocompleteEditView interface.
virtual AutocompleteEditModel* model() { return model_.get(); }
virtual const AutocompleteEditModel* model() const { return model_.get(); }
diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc
index d33d68d..cfc892b 100644
--- a/chrome/browser/views/location_bar_view.cc
+++ b/chrome/browser/views/location_bar_view.cc
@@ -549,8 +549,7 @@ int LocationBarView::AvailableWidth(int location_bar_width) {
return std::max(
location_bar_width - font_.GetStringWidth(location_entry_->GetText()), 0);
#else
- NOTIMPLEMENTED();
- return location_bar_width;
+ return location_bar_width - location_entry_->TextWidth();
#endif
}