| 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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 | 306 |
| 307 DrawString(canvas, match_.description, match_.description_class, true, x, | 307 DrawString(canvas, match_.description, match_.description_class, true, x, |
| 308 text_bounds_.y()); | 308 text_bounds_.y()); |
| 309 } | 309 } |
| 310 } | 310 } |
| 311 | 311 |
| 312 void AutocompleteResultView::Layout() { | 312 void AutocompleteResultView::Layout() { |
| 313 icon_bounds_.SetRect(LocationBarView::kEdgeItemPadding, | 313 icon_bounds_.SetRect(LocationBarView::kEdgeItemPadding, |
| 314 (height() - icon_size_) / 2, icon_size_, icon_size_); | 314 (height() - icon_size_) / 2, icon_size_, icon_size_); |
| 315 int text_x = icon_bounds_.right() + LocationBarView::kItemPadding; | 315 int text_x = icon_bounds_.right() + LocationBarView::kItemPadding; |
| 316 int font_height = std::max(normal_font_.height(), bold_font_.height()); | 316 int font_height = std::max(normal_font_.GetHeight(), bold_font_.GetHeight()); |
| 317 text_bounds_.SetRect(text_x, std::max(0, (height() - font_height) / 2), | 317 text_bounds_.SetRect(text_x, std::max(0, (height() - font_height) / 2), |
| 318 std::max(bounds().width() - text_x - LocationBarView::kEdgeItemPadding, | 318 std::max(bounds().width() - text_x - LocationBarView::kEdgeItemPadding, |
| 319 0), font_height); | 319 0), font_height); |
| 320 } | 320 } |
| 321 | 321 |
| 322 gfx::Size AutocompleteResultView::GetPreferredSize() { | 322 gfx::Size AutocompleteResultView::GetPreferredSize() { |
| 323 return gfx::Size(0, GetPreferredHeight(normal_font_, bold_font_)); | 323 return gfx::Size(0, GetPreferredHeight(normal_font_, bold_font_)); |
| 324 } | 324 } |
| 325 | 325 |
| 326 // static | 326 // static |
| 327 int AutocompleteResultView::GetPreferredHeight( | 327 int AutocompleteResultView::GetPreferredHeight( |
| 328 const gfx::Font& font, | 328 const gfx::Font& font, |
| 329 const gfx::Font& bold_font) { | 329 const gfx::Font& bold_font) { |
| 330 int text_height = std::max(font.height(), bold_font.height()) + | 330 int text_height = std::max(font.GetHeight(), bold_font.GetHeight()) + |
| 331 (kTextVerticalPadding * 2); | 331 (kTextVerticalPadding * 2); |
| 332 int icon_height = icon_size_ + (kIconVerticalPadding * 2); | 332 int icon_height = icon_size_ + (kIconVerticalPadding * 2); |
| 333 return std::max(icon_height, text_height); | 333 return std::max(icon_height, text_height); |
| 334 } | 334 } |
| 335 | 335 |
| 336 // static | 336 // static |
| 337 bool AutocompleteResultView::SortRunsLogically(const RunData& lhs, | 337 bool AutocompleteResultView::SortRunsLogically(const RunData& lhs, |
| 338 const RunData& rhs) { | 338 const RunData& rhs) { |
| 339 return lhs.run_start < rhs.run_start; | 339 return lhs.run_start < rhs.run_start; |
| 340 } | 340 } |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 int flags = gfx::Canvas::NO_ELLIPSIS; // We've already elided. | 502 int flags = gfx::Canvas::NO_ELLIPSIS; // We've already elided. |
| 503 if (reverse_visible_order) { | 503 if (reverse_visible_order) { |
| 504 std::reverse(i->classifications.begin(), i->classifications.end()); | 504 std::reverse(i->classifications.begin(), i->classifications.end()); |
| 505 if (i->is_rtl) | 505 if (i->is_rtl) |
| 506 flags |= gfx::Canvas::FORCE_RTL_DIRECTIONALITY; | 506 flags |= gfx::Canvas::FORCE_RTL_DIRECTIONALITY; |
| 507 } | 507 } |
| 508 for (Classifications::const_iterator j(i->classifications.begin()); | 508 for (Classifications::const_iterator j(i->classifications.begin()); |
| 509 j != i->classifications.end(); ++j) { | 509 j != i->classifications.end(); ++j) { |
| 510 int left = mirroring_context_->mirrored_left_coord(x, x + j->pixel_width); | 510 int left = mirroring_context_->mirrored_left_coord(x, x + j->pixel_width); |
| 511 canvas->DrawStringInt(j->text, *j->font, j->color, left, y, | 511 canvas->DrawStringInt(j->text, *j->font, j->color, left, y, |
| 512 j->pixel_width, j->font->height(), flags); | 512 j->pixel_width, j->font->GetHeight(), flags); |
| 513 x += j->pixel_width; | 513 x += j->pixel_width; |
| 514 } | 514 } |
| 515 } | 515 } |
| 516 | 516 |
| 517 return x; | 517 return x; |
| 518 } | 518 } |
| 519 | 519 |
| 520 void AutocompleteResultView::Elide(Runs* runs, int remaining_width) const { | 520 void AutocompleteResultView::Elide(Runs* runs, int remaining_width) const { |
| 521 // The complexity of this function is due to edge cases like the following: | 521 // The complexity of this function is due to edge cases like the following: |
| 522 // We have 100 px of available space, an initial classification that takes 86 | 522 // We have 100 px of available space, an initial classification that takes 86 |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 // bubble appear at the same height as the Star bubble. | 1002 // bubble appear at the same height as the Star bubble. |
| 1003 location_bar_bounds.Inset(LocationBarView::kNormalHorizontalEdgeThickness, | 1003 location_bar_bounds.Inset(LocationBarView::kNormalHorizontalEdgeThickness, |
| 1004 0); | 1004 0); |
| 1005 } | 1005 } |
| 1006 gfx::Point location_bar_origin(location_bar_bounds.origin()); | 1006 gfx::Point location_bar_origin(location_bar_bounds.origin()); |
| 1007 views::View::ConvertPointToScreen(location_bar_, &location_bar_origin); | 1007 views::View::ConvertPointToScreen(location_bar_, &location_bar_origin); |
| 1008 location_bar_bounds.set_origin(location_bar_origin); | 1008 location_bar_bounds.set_origin(location_bar_origin); |
| 1009 return bubble_border_->GetBounds( | 1009 return bubble_border_->GetBounds( |
| 1010 location_bar_bounds, gfx::Size(location_bar_bounds.width(), h)); | 1010 location_bar_bounds, gfx::Size(location_bar_bounds.width(), h)); |
| 1011 } | 1011 } |
| OLD | NEW |