| Index: chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc
|
| ===================================================================
|
| --- chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc (revision 119905)
|
| +++ chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc (working copy)
|
| @@ -52,6 +52,7 @@
|
|
|
| const SkAlpha kGlassPopupAlpha = 240;
|
| const SkAlpha kOpaquePopupAlpha = 255;
|
| +
|
| // The size delta between the font used for the edit and the result rows. Passed
|
| // to gfx::Font::DeriveFont.
|
| #if defined(OS_CHROMEOS)
|
| @@ -235,6 +236,13 @@
|
| set_border(bubble_border);
|
| // The contents is owned by the LocationBarView.
|
| set_parent_owned(false);
|
| +
|
| + for (size_t i = 0; i < AutocompleteResult::kMaxMatches; ++i) {
|
| + AutocompleteResultView* result_view =
|
| + CreateResultView(this, i, result_font_, result_bold_font_);
|
| + result_view->SetVisible(false);
|
| + AddChildViewAt(result_view, static_cast<int>(i));
|
| + }
|
| }
|
|
|
| AutocompletePopupContentsView::~AutocompletePopupContentsView() {
|
| @@ -280,7 +288,14 @@
|
| }
|
|
|
| void AutocompletePopupContentsView::InvalidateLine(size_t line) {
|
| - child_at(static_cast<int>(line))->SchedulePaint();
|
| + AutocompleteResultView* result = static_cast<AutocompleteResultView*>(
|
| + child_at(static_cast<int>(line)));
|
| + result->Invalidate();
|
| +
|
| + if (HasMatchAt(line) && GetMatchAtIndex(line).associated_keyword.get()) {
|
| + result->ShowKeyword(IsSelectedIndex(line) &&
|
| + model_->selected_line_state() == AutocompletePopupModel::KEYWORD);
|
| + }
|
| }
|
|
|
| void AutocompletePopupContentsView::UpdatePopupAppearance() {
|
| @@ -288,6 +303,7 @@
|
| // No matches, close any existing popup.
|
| if (popup_ != NULL) {
|
| size_animation_.Stop();
|
| +
|
| // NOTE: Do NOT use CloseNow() here, as we may be deep in a callstack
|
| // triggered by the popup receiving a message (e.g. LBUTTONUP), and
|
| // destroying the popup would cause us to read garbage when we unwind back
|
| @@ -305,19 +321,14 @@
|
| DCHECK_GT(child_rv_count, 0u);
|
| child_rv_count--;
|
| }
|
| - for (size_t i = 0; i < model_->result().size(); ++i) {
|
| - AutocompleteResultView* result_view;
|
| - if (i >= child_rv_count) {
|
| - result_view =
|
| - CreateResultView(this, i, result_font_, result_bold_font_);
|
| - AddChildViewAt(result_view, static_cast<int>(i));
|
| - } else {
|
| - result_view = static_cast<AutocompleteResultView*>(child_at(i));
|
| - result_view->SetVisible(true);
|
| - }
|
| - result_view->SetMatch(GetMatchAtIndex(i));
|
| + const size_t result_size = model_->result().size();
|
| + for (size_t i = 0; i < result_size; ++i) {
|
| + AutocompleteResultView* view = static_cast<AutocompleteResultView*>(
|
| + child_at(i));
|
| + view->SetMatch(GetMatchAtIndex(i));
|
| + view->SetVisible(true);
|
| }
|
| - for (size_t i = model_->result().size(); i < child_rv_count; ++i)
|
| + for (size_t i = result_size; i < child_rv_count; ++i)
|
| child_at(i)->SetVisible(false);
|
|
|
| PromoCounter* counter = profile_->GetInstantPromoCounter();
|
| @@ -395,11 +406,11 @@
|
| // AutocompletePopupContentsView, AutocompleteResultViewModel implementation:
|
|
|
| bool AutocompletePopupContentsView::IsSelectedIndex(size_t index) const {
|
| - return HasMatchAt(index) ? index == model_->selected_line() : false;
|
| + return index == model_->selected_line();
|
| }
|
|
|
| bool AutocompletePopupContentsView::IsHoveredIndex(size_t index) const {
|
| - return HasMatchAt(index) ? index == model_->hovered_line() : false;
|
| + return index == model_->hovered_line();
|
| }
|
|
|
| const SkBitmap* AutocompletePopupContentsView::GetIconIfExtensionMatch(
|
| @@ -435,7 +446,7 @@
|
|
|
| views::View* AutocompletePopupContentsView::GetEventHandlerForPoint(
|
| const gfx::Point& point) {
|
| - // If there is no opt in view, then we want all mouse events. Otherwise let
|
| + // If there is no opt in view then we want all mouse events. Otherwise, let
|
| // any descendants of the opt-in view get mouse events.
|
| if (!opt_in_view_)
|
| return this;
|
| @@ -646,10 +657,8 @@
|
| // extension, |match| and its contents. So copy the relevant match out to
|
| // make sure it stays alive until the call completes.
|
| AutocompleteMatch match = model_->result().match_at(index);
|
| - string16 keyword;
|
| - const bool is_keyword_hint = model_->GetKeywordForMatch(match, &keyword);
|
| omnibox_view_->OpenMatch(match, disposition, GURL(), index,
|
| - is_keyword_hint ? string16() : keyword);
|
| + match.keyword);
|
| }
|
|
|
| size_t AutocompletePopupContentsView::GetIndexForPoint(
|
|
|