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

Unified Diff: chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc

Issue 22679003: InstantExtended(gtk): Hide top match if told to so. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc
diff --git a/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc b/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc
index 23ab592f21028d2cebd792d253dace6104bddc8c..6d9b3a0858e6992755f2d5984856a22f01858283 100644
--- a/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc
+++ b/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc
@@ -347,18 +347,20 @@ void OmniboxPopupViewGtk::InvalidateLine(size_t line) {
// of having to query the width of the window?
GdkWindow* gdk_window = gtk_widget_get_window(GTK_WIDGET(window_));
GdkRectangle line_rect = GetRectForLine(
- line, GetWindowRect(gdk_window).width()).ToGdkRectangle();
+ line - GetHiddenMatchCount(),
+ GetWindowRect(gdk_window).width()).ToGdkRectangle();
gdk_window_invalidate_rect(gdk_window, &line_rect, FALSE);
}
void OmniboxPopupViewGtk::UpdatePopupAppearance() {
const AutocompleteResult& result = model_->result();
- if (result.empty()) {
+ const size_t hidden_matches = GetHiddenMatchCount();
+ if (result.size() <= hidden_matches) {
Hide();
return;
}
- Show(result.size());
+ Show(result.size() - hidden_matches);
gtk_widget_queue_draw(window_);
}
@@ -468,7 +470,7 @@ void OmniboxPopupViewGtk::StackWindow() {
size_t OmniboxPopupViewGtk::LineFromY(int y) {
size_t line = std::max(y - kBorderThickness, 0) / kHeightPerResult;
- return std::min(line, model_->result().size() - 1);
+ return std::min(line + GetHiddenMatchCount(), model_->result().size() - 1);
}
void OmniboxPopupViewGtk::AcceptLine(size_t line,
@@ -540,6 +542,10 @@ void OmniboxPopupViewGtk::GetVisibleMatchForInput(
*is_selected_keyword = false;
}
+size_t OmniboxPopupViewGtk::GetHiddenMatchCount() {
+ return model_->result().ShouldHideTopMatch() ? 1 : 0;
+}
+
gboolean OmniboxPopupViewGtk::HandleMotion(GtkWidget* widget,
GdkEventMotion* event) {
// TODO(deanm): Windows has a bunch of complicated logic here.
@@ -617,8 +623,10 @@ gboolean OmniboxPopupViewGtk::HandleExpose(GtkWidget* widget,
pango_layout_set_height(layout_, kHeightPerResult * PANGO_SCALE);
- for (size_t i = 0; i < result.size(); ++i) {
- gfx::Rect line_rect = GetRectForLine(i, window_rect.width());
+ const size_t hidden_matches = GetHiddenMatchCount();
+ for (size_t i = hidden_matches; i < result.size(); ++i) {
+ gfx::Rect line_rect = GetRectForLine(i - hidden_matches,
+ window_rect.width());
// Only repaint and layout damaged lines.
if (!line_rect.Intersects(damage_rect))
continue;
« no previous file with comments | « chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698