OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/autocomplete/autocomplete_popup_contents_view.h" | 5 #include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h" |
6 | 6 |
7 #include "app/bidi_line_iterator.h" | 7 #include "app/bidi_line_iterator.h" |
8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
10 #include "app/theme_provider.h" | 10 #include "app/theme_provider.h" |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 ACMatchClassification(0, ACMatchClassification::NONE)); | 298 ACMatchClassification(0, ACMatchClassification::NONE)); |
299 x = DrawString(canvas, separator, classifications, true, x, | 299 x = DrawString(canvas, separator, classifications, true, x, |
300 text_bounds_.y()); | 300 text_bounds_.y()); |
301 | 301 |
302 DrawString(canvas, match_.description, match_.description_class, true, x, | 302 DrawString(canvas, match_.description, match_.description_class, true, x, |
303 text_bounds_.y()); | 303 text_bounds_.y()); |
304 } | 304 } |
305 } | 305 } |
306 | 306 |
307 void AutocompleteResultView::Layout() { | 307 void AutocompleteResultView::Layout() { |
308 icon_bounds_.SetRect(LocationBarView::kItemPadding, | 308 icon_bounds_.SetRect(LocationBarView::kEdgeItemPadding, |
309 (height() - icon_size_) / 2, icon_size_, icon_size_); | 309 (height() - icon_size_) / 2, icon_size_, icon_size_); |
310 int text_x = icon_bounds_.right() + LocationBarView::kItemPadding; | 310 int text_x = icon_bounds_.right() + LocationBarView::kItemPadding; |
311 int font_height = std::max(normal_font_.height(), bold_font_.height()); | 311 int font_height = std::max(normal_font_.height(), bold_font_.height()); |
312 text_bounds_.SetRect(text_x, std::max(0, (height() - font_height) / 2), | 312 text_bounds_.SetRect(text_x, std::max(0, (height() - font_height) / 2), |
313 std::max(0, bounds().width() - text_x - LocationBarView::kItemPadding), | 313 std::max(bounds().width() - text_x - LocationBarView::kEdgeItemPadding, |
314 font_height); | 314 0), font_height); |
315 } | 315 } |
316 | 316 |
317 gfx::Size AutocompleteResultView::GetPreferredSize() { | 317 gfx::Size AutocompleteResultView::GetPreferredSize() { |
318 int text_height = std::max(normal_font_.height(), bold_font_.height()) + | 318 int text_height = std::max(normal_font_.height(), bold_font_.height()) + |
319 (kTextVerticalPadding * 2); | 319 (kTextVerticalPadding * 2); |
320 int icon_height = icon_size_ + (kIconVerticalPadding * 2); | 320 int icon_height = icon_size_ + (kIconVerticalPadding * 2); |
321 return gfx::Size(0, std::max(icon_height, text_height)); | 321 return gfx::Size(0, std::max(icon_height, text_height)); |
322 } | 322 } |
323 | 323 |
324 // static | 324 // static |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 if (border) { | 681 if (border) { |
682 // Adjust for the border so that the bubble and location bar borders are | 682 // Adjust for the border so that the bubble and location bar borders are |
683 // aligned. | 683 // aligned. |
684 gfx::Insets insets; | 684 gfx::Insets insets; |
685 border->GetInsets(&insets); | 685 border->GetInsets(&insets); |
686 location_bar_bounds.Inset(insets.left(), 0, insets.right(), 0); | 686 location_bar_bounds.Inset(insets.left(), 0, insets.right(), 0); |
687 } else { | 687 } else { |
688 // The normal location bar is drawn using a background graphic that includes | 688 // The normal location bar is drawn using a background graphic that includes |
689 // the border, so we inset by enough to make the edges line up, and the | 689 // the border, so we inset by enough to make the edges line up, and the |
690 // bubble appear at the same height as the Star bubble. | 690 // bubble appear at the same height as the Star bubble. |
691 location_bar_bounds.Inset(LocationBarView::kEdgeThickness, 0); | 691 location_bar_bounds.Inset(LocationBarView::kNormalHorizontalEdgeThickness, |
| 692 0); |
692 } | 693 } |
693 gfx::Point location_bar_origin(location_bar_bounds.origin()); | 694 gfx::Point location_bar_origin(location_bar_bounds.origin()); |
694 views::View::ConvertPointToScreen(location_bar_, &location_bar_origin); | 695 views::View::ConvertPointToScreen(location_bar_, &location_bar_origin); |
695 location_bar_bounds.set_origin(location_bar_origin); | 696 location_bar_bounds.set_origin(location_bar_origin); |
696 gfx::Rect new_target_bounds(bubble_border_->GetBounds(location_bar_bounds, | 697 gfx::Rect new_target_bounds(bubble_border_->GetBounds(location_bar_bounds, |
697 gfx::Size(location_bar_bounds.width(), total_child_height))); | 698 gfx::Size(location_bar_bounds.width(), total_child_height))); |
698 | 699 |
699 // If we're animating and our target height changes, reset the animation. | 700 // If we're animating and our target height changes, reset the animation. |
700 // NOTE: If we just reset blindly on _every_ update, then when the user types | 701 // NOTE: If we just reset blindly on _every_ update, then when the user types |
701 // rapidly we could get "stuck" trying repeatedly to animate shrinking by the | 702 // rapidly we could get "stuck" trying repeatedly to animate shrinking by the |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 DCHECK(nb_match <= GetChildViewCount()); | 976 DCHECK(nb_match <= GetChildViewCount()); |
976 for (int i = 0; i < nb_match; ++i) { | 977 for (int i = 0; i < nb_match; ++i) { |
977 views::View* child = GetChildViewAt(i); | 978 views::View* child = GetChildViewAt(i); |
978 gfx::Point point_in_child_coords(point); | 979 gfx::Point point_in_child_coords(point); |
979 View::ConvertPointToView(this, child, &point_in_child_coords); | 980 View::ConvertPointToView(this, child, &point_in_child_coords); |
980 if (child->HitTest(point_in_child_coords)) | 981 if (child->HitTest(point_in_child_coords)) |
981 return i; | 982 return i; |
982 } | 983 } |
983 return AutocompletePopupModel::kNoMatch; | 984 return AutocompletePopupModel::kNoMatch; |
984 } | 985 } |
OLD | NEW |