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

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_result_view.h

Issue 795933009: [AiS] for desktop, two lines and font sytles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge from master Created 5 years, 9 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
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 #ifndef CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_RESULT_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_RESULT_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_RESULT_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_RESULT_VIEW_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
11 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service.h" 11 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service.h"
12 #include "components/omnibox/autocomplete_match.h" 12 #include "components/omnibox/autocomplete_match.h"
13 #include "components/omnibox/suggestion_answer.h"
13 #include "third_party/skia/include/core/SkColor.h" 14 #include "third_party/skia/include/core/SkColor.h"
14 #include "ui/gfx/animation/animation_delegate.h" 15 #include "ui/gfx/animation/animation_delegate.h"
15 #include "ui/gfx/animation/slide_animation.h" 16 #include "ui/gfx/animation/slide_animation.h"
16 #include "ui/gfx/font_list.h" 17 #include "ui/gfx/font_list.h"
17 #include "ui/gfx/geometry/rect.h" 18 #include "ui/gfx/geometry/rect.h"
19 #include "ui/native_theme/native_theme.h"
18 #include "ui/views/controls/image_view.h" 20 #include "ui/views/controls/image_view.h"
19 #include "ui/views/view.h" 21 #include "ui/views/view.h"
20 22
21 class LocationBarView; 23 class LocationBarView;
22 class OmniboxPopupContentsView; 24 class OmniboxPopupContentsView;
23 25
24 namespace gfx { 26 namespace gfx {
25 class Canvas; 27 class Canvas;
26 class RenderText; 28 class RenderText;
27 } 29 }
(...skipping 12 matching lines...) Expand all
40 42
41 enum ColorKind { 43 enum ColorKind {
42 BACKGROUND = 0, 44 BACKGROUND = 0,
43 TEXT, 45 TEXT,
44 DIMMED_TEXT, 46 DIMMED_TEXT,
45 URL, 47 URL,
46 DIVIDER, 48 DIVIDER,
47 NUM_KINDS 49 NUM_KINDS
48 }; 50 };
49 51
52 struct StateColors {
Peter Kasting 2015/03/18 00:36:19 Why did you choose to do this with a struct rather
dschuyler 2015/03/18 01:02:36 Is this patch more like what you were hoping for?
53 ui::NativeTheme::ColorId normal;
54 ui::NativeTheme::ColorId hovered;
55 ui::NativeTheme::ColorId selected;
56 };
57
58 // The minimum distance between the top and bottom of the text and the
59 // top or bottom of the row.
60 static const int kMinimumTextVerticalPadding = 3;
61
50 OmniboxResultView(OmniboxPopupContentsView* model, 62 OmniboxResultView(OmniboxPopupContentsView* model,
51 int model_index, 63 int model_index,
52 LocationBarView* location_bar_view, 64 LocationBarView* location_bar_view,
53 const gfx::FontList& font_list); 65 const gfx::FontList& font_list);
54 ~OmniboxResultView() override; 66 ~OmniboxResultView() override;
55 67
56 SkColor GetColor(ResultViewState state, ColorKind kind) const; 68 SkColor GetColor(ResultViewState state, ColorKind kind) const;
57 69
58 // Updates the match used to paint the contents of this result view. We copy 70 // Updates the match used to paint the contents of this result view. We copy
59 // the match so that we can continue to paint the last result even after the 71 // the match so that we can continue to paint the last result even after the
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // |classifications| and |force_dim| are used to style the text. 122 // |classifications| and |force_dim| are used to style the text.
111 scoped_ptr<gfx::RenderText> CreateClassifiedRenderText( 123 scoped_ptr<gfx::RenderText> CreateClassifiedRenderText(
112 const base::string16& text, 124 const base::string16& text,
113 const ACMatchClassifications& classifications, 125 const ACMatchClassifications& classifications,
114 bool force_dim) const; 126 bool force_dim) const;
115 127
116 const gfx::Rect& text_bounds() const { return text_bounds_; } 128 const gfx::Rect& text_bounds() const { return text_bounds_; }
117 129
118 void set_edge_item_padding(int value) { edge_item_padding_ = value; } 130 void set_edge_item_padding(int value) { edge_item_padding_ = value; }
119 void set_item_padding(int value) { item_padding_ = value; } 131 void set_item_padding(int value) { item_padding_ = value; }
120 void set_minimum_text_vertical_padding(int value) {
121 minimum_text_vertical_padding_ = value;
122 }
123 132
124 private: 133 private:
125 // views::View: 134 // views::View:
126 const char* GetClassName() const override; 135 const char* GetClassName() const override;
127 136
128 gfx::ImageSkia GetIcon() const; 137 gfx::ImageSkia GetIcon() const;
129 const gfx::ImageSkia* GetKeywordIcon() const; 138 const gfx::ImageSkia* GetKeywordIcon() const;
130 139
131 // Whether to render only the keyword match. Returns true if |match_| has an 140 // Whether to render only the keyword match. Returns true if |match_| has an
132 // associated keyword match that has been animated so close to the start that 141 // associated keyword match that has been animated so close to the start that
(...skipping 15 matching lines...) Expand all
148 // gfx::AnimationDelegate: 157 // gfx::AnimationDelegate:
149 void AnimationProgressed(const gfx::Animation* animation) override; 158 void AnimationProgressed(const gfx::Animation* animation) override;
150 159
151 // Returns the offset at which the contents of the |match| should be displayed 160 // Returns the offset at which the contents of the |match| should be displayed
152 // within the text bounds. The directionality of UI and match contents is used 161 // within the text bounds. The directionality of UI and match contents is used
153 // to determine the offset relative to the correct edge. 162 // to determine the offset relative to the correct edge.
154 int GetDisplayOffset(const AutocompleteMatch& match, 163 int GetDisplayOffset(const AutocompleteMatch& match,
155 bool is_ui_rtl, 164 bool is_ui_rtl,
156 bool is_match_contents_rtl) const; 165 bool is_match_contents_rtl) const;
157 166
167 int StyleAnswerText(gfx::RenderText* render_text,
168 int offset,
169 const SuggestionAnswer::TextField& text_field) const;
170
171 int GetAnswerLineHeight() const;
172 int GetContentLineHeight() const;
173 SkColor GetStateColor(const StateColors& state_colors) const;
174 void AppendAnswerText(gfx::RenderText* render_text,
175 const SuggestionAnswer::TextField& text_field);
176
158 static int default_icon_size_; 177 static int default_icon_size_;
159 178
160 // Default values cached here, may be overridden using the setters above. 179 // Default values cached here, may be overridden using the setters above.
161 int edge_item_padding_; 180 int edge_item_padding_;
162 int item_padding_; 181 int item_padding_;
163 int minimum_text_vertical_padding_;
164 182
165 // This row's model and model index. 183 // This row's model and model index.
166 OmniboxPopupContentsView* model_; 184 OmniboxPopupContentsView* model_;
167 size_t model_index_; 185 size_t model_index_;
168 186
169 LocationBarView* location_bar_view_; 187 LocationBarView* location_bar_view_;
170 // Note: image_service_ may be null in some unit tests. 188 // Note: image_service_ may be null in some unit tests.
171 BitmapFetcherService* image_service_; 189 BitmapFetcherService* image_service_;
172 190
173 const gfx::FontList font_list_; 191 const gfx::FontList font_list_;
(...skipping 27 matching lines...) Expand all
201 mutable scoped_ptr<gfx::RenderText> keyword_description_rendertext_; 219 mutable scoped_ptr<gfx::RenderText> keyword_description_rendertext_;
202 220
203 mutable int separator_width_; 221 mutable int separator_width_;
204 222
205 base::WeakPtrFactory<OmniboxResultView> weak_ptr_factory_; 223 base::WeakPtrFactory<OmniboxResultView> weak_ptr_factory_;
206 224
207 DISALLOW_COPY_AND_ASSIGN(OmniboxResultView); 225 DISALLOW_COPY_AND_ASSIGN(OmniboxResultView);
208 }; 226 };
209 227
210 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_RESULT_VIEW_H_ 228 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_RESULT_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698