| OLD | NEW | 
|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/views/autocomplete/autocomplete_popup_contents_view.
      h" | 5 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.
      h" | 
| 6 | 6 | 
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" | 
| 8 #include "base/i18n/bidi_line_iterator.h" | 8 #include "base/i18n/bidi_line_iterator.h" | 
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" | 
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" | 
| (...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 830       // to that level. | 830       // to that level. | 
| 831       popup_->Close();  // This will eventually delete the popup. | 831       popup_->Close();  // This will eventually delete the popup. | 
| 832       popup_.reset(); | 832       popup_.reset(); | 
| 833     } | 833     } | 
| 834     return; | 834     return; | 
| 835   } | 835   } | 
| 836 | 836 | 
| 837   // Update the match cached by each row, in the process of doing so make sure | 837   // Update the match cached by each row, in the process of doing so make sure | 
| 838   // we have enough row views. | 838   // we have enough row views. | 
| 839   int total_child_height = 0; | 839   int total_child_height = 0; | 
| 840   size_t child_rv_count = GetChildViewCount(); | 840   size_t child_rv_count = child_count(); | 
| 841   if (opt_in_view_) { | 841   if (opt_in_view_) { | 
| 842     DCHECK(child_rv_count > 0); | 842     DCHECK(child_rv_count > 0); | 
| 843     child_rv_count--; | 843     child_rv_count--; | 
| 844   } | 844   } | 
| 845   for (size_t i = 0; i < model_->result().size(); ++i) { | 845   for (size_t i = 0; i < model_->result().size(); ++i) { | 
| 846     AutocompleteResultView* result_view; | 846     AutocompleteResultView* result_view; | 
| 847     if (i >= child_rv_count) { | 847     if (i >= child_rv_count) { | 
| 848       result_view = | 848       result_view = | 
| 849           new AutocompleteResultView(this, i, result_font_, result_bold_font_); | 849           new AutocompleteResultView(this, i, result_font_, result_bold_font_); | 
| 850       AddChildView(static_cast<int>(i), result_view); | 850       AddChildViewAt(result_view, static_cast<int>(i)); | 
| 851     } else { | 851     } else { | 
| 852       result_view = static_cast<AutocompleteResultView*>(GetChildViewAt(i)); | 852       result_view = static_cast<AutocompleteResultView*>(GetChildViewAt(i)); | 
| 853       result_view->SetVisible(true); | 853       result_view->SetVisible(true); | 
| 854     } | 854     } | 
| 855     result_view->set_match(GetMatchAtIndex(i)); | 855     result_view->set_match(GetMatchAtIndex(i)); | 
| 856     total_child_height += result_view->GetPreferredSize().height(); | 856     total_child_height += result_view->GetPreferredSize().height(); | 
| 857   } | 857   } | 
| 858   for (size_t i = model_->result().size(); i < child_rv_count; ++i) | 858   for (size_t i = model_->result().size(); i < child_rv_count; ++i) | 
| 859     GetChildViewAt(i)->SetVisible(false); | 859     GetChildViewAt(i)->SetVisible(false); | 
| 860 | 860 | 
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 984   // This looks slightly better in the corners than drawing the contents atop | 984   // This looks slightly better in the corners than drawing the contents atop | 
| 985   // the border. | 985   // the border. | 
| 986   PaintBorder(canvas); | 986   PaintBorder(canvas); | 
| 987 } | 987 } | 
| 988 | 988 | 
| 989 void AutocompletePopupContentsView::Layout() { | 989 void AutocompletePopupContentsView::Layout() { | 
| 990   UpdateBlurRegion(); | 990   UpdateBlurRegion(); | 
| 991 | 991 | 
| 992   // Size our children to the available content area. | 992   // Size our children to the available content area. | 
| 993   gfx::Rect contents_rect = GetContentsBounds(); | 993   gfx::Rect contents_rect = GetContentsBounds(); | 
| 994   int child_count = GetChildViewCount(); |  | 
| 995   int top = contents_rect.y(); | 994   int top = contents_rect.y(); | 
| 996   for (int i = 0; i < child_count; ++i) { | 995   for (int i = 0; i < child_count(); ++i) { | 
| 997     View* v = GetChildViewAt(i); | 996     View* v = GetChildViewAt(i); | 
| 998     if (v->IsVisible()) { | 997     if (v->IsVisible()) { | 
| 999       v->SetBounds(contents_rect.x(), top, contents_rect.width(), | 998       v->SetBounds(contents_rect.x(), top, contents_rect.width(), | 
| 1000                    v->GetPreferredSize().height()); | 999                    v->GetPreferredSize().height()); | 
| 1001       top = v->bounds().bottom(); | 1000       top = v->bounds().bottom(); | 
| 1002     } | 1001     } | 
| 1003   } | 1002   } | 
| 1004 | 1003 | 
| 1005   // We need to manually schedule a paint here since we are a layered window and | 1004   // We need to manually schedule a paint here since we are a layered window and | 
| 1006   // won't implicitly require painting until we ask for one. | 1005   // won't implicitly require painting until we ask for one. | 
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1064 views::View* AutocompletePopupContentsView::GetViewForPoint( | 1063 views::View* AutocompletePopupContentsView::GetViewForPoint( | 
| 1065     const gfx::Point& point) { | 1064     const gfx::Point& point) { | 
| 1066   // If there is no opt in view, then we want all mouse events. Otherwise let | 1065   // If there is no opt in view, then we want all mouse events. Otherwise let | 
| 1067   // any descendants of the opt-in view get mouse events. | 1066   // any descendants of the opt-in view get mouse events. | 
| 1068   if (!opt_in_view_) | 1067   if (!opt_in_view_) | 
| 1069     return this; | 1068     return this; | 
| 1070 | 1069 | 
| 1071   views::View* child = views::View::GetViewForPoint(point); | 1070   views::View* child = views::View::GetViewForPoint(point); | 
| 1072   views::View* ancestor = child; | 1071   views::View* ancestor = child; | 
| 1073   while (ancestor && ancestor != opt_in_view_) | 1072   while (ancestor && ancestor != opt_in_view_) | 
| 1074     ancestor = ancestor->GetParent(); | 1073     ancestor = ancestor->parent(); | 
| 1075   return ancestor ? child : this; | 1074   return ancestor ? child : this; | 
| 1076 } | 1075 } | 
| 1077 | 1076 | 
| 1078 | 1077 | 
| 1079 //////////////////////////////////////////////////////////////////////////////// | 1078 //////////////////////////////////////////////////////////////////////////////// | 
| 1080 // AutocompletePopupContentsView, private: | 1079 // AutocompletePopupContentsView, private: | 
| 1081 | 1080 | 
| 1082 bool AutocompletePopupContentsView::HasMatchAt(size_t index) const { | 1081 bool AutocompletePopupContentsView::HasMatchAt(size_t index) const { | 
| 1083   return index < model_->result().size(); | 1082   return index < model_->result().size(); | 
| 1084 } | 1083 } | 
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1155   edit_view_->OpenURL(url, disposition, match.transition, GURL(), index, | 1154   edit_view_->OpenURL(url, disposition, match.transition, GURL(), index, | 
| 1156                       is_keyword_hint ? string16() : keyword); | 1155                       is_keyword_hint ? string16() : keyword); | 
| 1157 } | 1156 } | 
| 1158 | 1157 | 
| 1159 size_t AutocompletePopupContentsView::GetIndexForPoint( | 1158 size_t AutocompletePopupContentsView::GetIndexForPoint( | 
| 1160     const gfx::Point& point) { | 1159     const gfx::Point& point) { | 
| 1161   if (!HitTest(point)) | 1160   if (!HitTest(point)) | 
| 1162     return AutocompletePopupModel::kNoMatch; | 1161     return AutocompletePopupModel::kNoMatch; | 
| 1163 | 1162 | 
| 1164   int nb_match = model_->result().size(); | 1163   int nb_match = model_->result().size(); | 
| 1165   DCHECK(nb_match <= GetChildViewCount()); | 1164   DCHECK(nb_match <= child_count()); | 
| 1166   for (int i = 0; i < nb_match; ++i) { | 1165   for (int i = 0; i < nb_match; ++i) { | 
| 1167     views::View* child = GetChildViewAt(i); | 1166     views::View* child = GetChildViewAt(i); | 
| 1168     gfx::Point point_in_child_coords(point); | 1167     gfx::Point point_in_child_coords(point); | 
| 1169     View::ConvertPointToView(this, child, &point_in_child_coords); | 1168     View::ConvertPointToView(this, child, &point_in_child_coords); | 
| 1170     if (child->HitTest(point_in_child_coords)) | 1169     if (child->HitTest(point_in_child_coords)) | 
| 1171       return i; | 1170       return i; | 
| 1172   } | 1171   } | 
| 1173   return AutocompletePopupModel::kNoMatch; | 1172   return AutocompletePopupModel::kNoMatch; | 
| 1174 } | 1173 } | 
| 1175 | 1174 | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 1201   opt_in_view_ = NULL; | 1200   opt_in_view_ = NULL; | 
| 1202   PromoCounter* counter = model_->profile()->GetInstantPromoCounter(); | 1201   PromoCounter* counter = model_->profile()->GetInstantPromoCounter(); | 
| 1203   DCHECK(counter); | 1202   DCHECK(counter); | 
| 1204   counter->Hide(); | 1203   counter->Hide(); | 
| 1205   if (opt_in) { | 1204   if (opt_in) { | 
| 1206     browser::ShowInstantConfirmDialogIfNecessary( | 1205     browser::ShowInstantConfirmDialogIfNecessary( | 
| 1207         location_bar_->GetWindow()->GetNativeWindow(), model_->profile()); | 1206         location_bar_->GetWindow()->GetNativeWindow(), model_->profile()); | 
| 1208   } | 1207   } | 
| 1209   UpdatePopupAppearance(); | 1208   UpdatePopupAppearance(); | 
| 1210 } | 1209 } | 
| OLD | NEW | 
|---|