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

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.cc

Issue 19666006: Supports FontList in Textfield. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removes ResourceBundle::Delegate::GetFontList. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/omnibox/omnibox_popup_contents_view.h" 5 #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h"
6 6
7 #include "chrome/browser/search/search.h" 7 #include "chrome/browser/search/search.h"
8 #include "chrome/browser/themes/theme_properties.h" 8 #include "chrome/browser/themes/theme_properties.h"
9 #include "chrome/browser/ui/omnibox/omnibox_popup_non_view.h" 9 #include "chrome/browser/ui/omnibox/omnibox_popup_non_view.h"
10 #include "chrome/browser/ui/omnibox/omnibox_view.h" 10 #include "chrome/browser/ui/omnibox/omnibox_view.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 virtual ~AutocompletePopupWidget() {} 46 virtual ~AutocompletePopupWidget() {}
47 47
48 private: 48 private:
49 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupWidget); 49 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupWidget);
50 }; 50 };
51 51
52 //////////////////////////////////////////////////////////////////////////////// 52 ////////////////////////////////////////////////////////////////////////////////
53 // OmniboxPopupContentsView, public: 53 // OmniboxPopupContentsView, public:
54 54
55 OmniboxPopupView* OmniboxPopupContentsView::Create( 55 OmniboxPopupView* OmniboxPopupContentsView::Create(
56 const gfx::Font& font, 56 const gfx::FontList& font_list,
57 OmniboxView* omnibox_view, 57 OmniboxView* omnibox_view,
58 OmniboxEditModel* edit_model, 58 OmniboxEditModel* edit_model,
59 LocationBarView* location_bar_view) { 59 LocationBarView* location_bar_view) {
60 #if defined(HTML_INSTANT_EXTENDED_POPUP) 60 #if defined(HTML_INSTANT_EXTENDED_POPUP)
61 if (chrome::IsInstantExtendedAPIEnabled()) 61 if (chrome::IsInstantExtendedAPIEnabled())
62 return new OmniboxPopupNonView(edit_model); 62 return new OmniboxPopupNonView(edit_model);
63 #endif 63 #endif
64 64
65 OmniboxPopupContentsView* view = NULL; 65 OmniboxPopupContentsView* view = NULL;
66 if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) { 66 if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) {
67 view = new TouchOmniboxPopupContentsView( 67 view = new TouchOmniboxPopupContentsView(
68 font, omnibox_view, edit_model, location_bar_view); 68 font_list, omnibox_view, edit_model, location_bar_view);
69 } else { 69 } else {
70 view = new OmniboxPopupContentsView( 70 view = new OmniboxPopupContentsView(
71 font, omnibox_view, edit_model, location_bar_view); 71 font_list, omnibox_view, edit_model, location_bar_view);
72 } 72 }
73 73
74 view->Init(); 74 view->Init();
75 return view; 75 return view;
76 } 76 }
77 77
78 OmniboxPopupContentsView::OmniboxPopupContentsView( 78 OmniboxPopupContentsView::OmniboxPopupContentsView(
79 const gfx::Font& font, 79 const gfx::FontList& font_list,
80 OmniboxView* omnibox_view, 80 OmniboxView* omnibox_view,
81 OmniboxEditModel* edit_model, 81 OmniboxEditModel* edit_model,
82 LocationBarView* location_bar_view) 82 LocationBarView* location_bar_view)
83 : model_(new OmniboxPopupModel(this, edit_model)), 83 : model_(new OmniboxPopupModel(this, edit_model)),
84 omnibox_view_(omnibox_view), 84 omnibox_view_(omnibox_view),
85 location_bar_view_(location_bar_view), 85 location_bar_view_(location_bar_view),
86 font_(font), 86 font_list_(font_list),
87 ignore_mouse_drag_(false), 87 ignore_mouse_drag_(false),
88 size_animation_(this), 88 size_animation_(this),
89 left_margin_(0), 89 left_margin_(0),
90 right_margin_(0), 90 right_margin_(0),
91 outside_vertical_padding_(0) { 91 outside_vertical_padding_(0) {
92 // The contents is owned by the LocationBarView. 92 // The contents is owned by the LocationBarView.
93 set_owned_by_client(); 93 set_owned_by_client();
94 94
95 ui::ThemeProvider* theme = location_bar_view_->GetThemeProvider(); 95 ui::ThemeProvider* theme = location_bar_view_->GetThemeProvider();
96 bottom_shadow_ = theme->GetImageSkiaNamed(IDR_BUBBLE_B); 96 bottom_shadow_ = theme->GetImageSkiaNamed(IDR_BUBBLE_B);
97 } 97 }
98 98
99 void OmniboxPopupContentsView::Init() { 99 void OmniboxPopupContentsView::Init() {
100 // This can't be done in the constructor as at that point we aren't 100 // This can't be done in the constructor as at that point we aren't
101 // necessarily our final class yet, and we may have subclasses 101 // necessarily our final class yet, and we may have subclasses
102 // overriding CreateResultView. 102 // overriding CreateResultView.
103 for (size_t i = 0; i < AutocompleteResult::kMaxMatches; ++i) { 103 for (size_t i = 0; i < AutocompleteResult::kMaxMatches; ++i) {
104 OmniboxResultView* result_view = CreateResultView(this, i, font_); 104 OmniboxResultView* result_view = CreateResultView(this, i, font_list_);
105 result_view->SetVisible(false); 105 result_view->SetVisible(false);
106 AddChildViewAt(result_view, static_cast<int>(i)); 106 AddChildViewAt(result_view, static_cast<int>(i));
107 } 107 }
108 } 108 }
109 109
110 OmniboxPopupContentsView::~OmniboxPopupContentsView() { 110 OmniboxPopupContentsView::~OmniboxPopupContentsView() {
111 // We don't need to do anything with |popup_| here. The OS either has already 111 // We don't need to do anything with |popup_| here. The OS either has already
112 // closed the window, in which case it's been deleted, or it will soon, in 112 // closed the window, in which case it's been deleted, or it will soon, in
113 // which case there's nothing we need to do. 113 // which case there's nothing we need to do.
114 } 114 }
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 410
411 return popup_height + 411 return popup_height +
412 views::NonClientFrameView::kClientEdgeThickness + // Top border. 412 views::NonClientFrameView::kClientEdgeThickness + // Top border.
413 outside_vertical_padding_ * 2 + // Padding. 413 outside_vertical_padding_ * 2 + // Padding.
414 bottom_shadow_->height() - kBorderInterior; // Bottom border. 414 bottom_shadow_->height() - kBorderInterior; // Bottom border.
415 } 415 }
416 416
417 OmniboxResultView* OmniboxPopupContentsView::CreateResultView( 417 OmniboxResultView* OmniboxPopupContentsView::CreateResultView(
418 OmniboxResultViewModel* model, 418 OmniboxResultViewModel* model,
419 int model_index, 419 int model_index,
420 const gfx::Font& font) { 420 const gfx::FontList& font_list) {
421 return new OmniboxResultView(model, model_index, location_bar_view_, font); 421 return new OmniboxResultView(model, model_index, location_bar_view_,
422 font_list);
422 } 423 }
423 424
424 //////////////////////////////////////////////////////////////////////////////// 425 ////////////////////////////////////////////////////////////////////////////////
425 // OmniboxPopupContentsView, views::View overrides, protected: 426 // OmniboxPopupContentsView, views::View overrides, protected:
426 427
427 void OmniboxPopupContentsView::OnPaint(gfx::Canvas* canvas) { 428 void OmniboxPopupContentsView::OnPaint(gfx::Canvas* canvas) {
428 gfx::Rect contents_bounds = GetContentsBounds(); 429 gfx::Rect contents_bounds = GetContentsBounds();
429 contents_bounds.set_height( 430 contents_bounds.set_height(
430 contents_bounds.height() - bottom_shadow_->height() + kBorderInterior); 431 contents_bounds.height() - bottom_shadow_->height() + kBorderInterior);
431 432
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 // OpenMatch() may close the popup, which will clear the result set and, by 513 // OpenMatch() may close the popup, which will clear the result set and, by
513 // extension, |match| and its contents. So copy the relevant match out to 514 // extension, |match| and its contents. So copy the relevant match out to
514 // make sure it stays alive until the call completes. 515 // make sure it stays alive until the call completes.
515 AutocompleteMatch match = model_->result().match_at(index); 516 AutocompleteMatch match = model_->result().match_at(index);
516 omnibox_view_->OpenMatch(match, disposition, GURL(), index); 517 omnibox_view_->OpenMatch(match, disposition, GURL(), index);
517 } 518 }
518 519
519 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { 520 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) {
520 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); 521 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i)));
521 } 522 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698