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

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

Issue 11535014: Replace StyleRange with BreakList; update RenderText, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add GetNextBreak and AdvanceIterators convenience methods; cleanup. Created 7 years, 11 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 #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 "chrome/browser/autocomplete/autocomplete_match.h" 8 #include "chrome/browser/autocomplete/autocomplete_match.h"
9 #include "third_party/skia/include/core/SkColor.h" 9 #include "third_party/skia/include/core/SkColor.h"
10 #include "ui/base/animation/animation_delegate.h" 10 #include "ui/base/animation/animation_delegate.h"
11 #include "ui/base/animation/slide_animation.h" 11 #include "ui/base/animation/slide_animation.h"
12 #include "ui/gfx/font.h" 12 #include "ui/gfx/font.h"
13 #include "ui/gfx/rect.h" 13 #include "ui/gfx/rect.h"
14 #include "ui/views/controls/image_view.h" 14 #include "ui/views/controls/image_view.h"
15 #include "ui/views/view.h" 15 #include "ui/views/view.h"
16 16
17 class OmniboxResultViewModel; 17 class OmniboxResultViewModel;
18 18
19 namespace gfx { 19 namespace gfx {
20 class Canvas; 20 class Canvas;
21 class RenderText;
21 } 22 }
22 23
23 class OmniboxResultView : public views::View, 24 class OmniboxResultView : public views::View,
24 private ui::AnimationDelegate { 25 private ui::AnimationDelegate {
25 public: 26 public:
26 // Keep these ordered from least dominant (normal) to most dominant 27 // Keep these ordered from least dominant (normal) to most dominant
27 // (selected). 28 // (selected).
28 enum ResultViewState { 29 enum ResultViewState {
29 NORMAL = 0, 30 NORMAL = 0,
30 HOVERED, 31 HOVERED,
31 SELECTED, 32 SELECTED,
32 NUM_STATES 33 NUM_STATES
33 }; 34 };
34 35
35 enum ColorKind { 36 enum ColorKind {
36 BACKGROUND = 0, 37 BACKGROUND = 0,
37 TEXT, 38 TEXT,
38 DIMMED_TEXT, 39 DIMMED_TEXT,
39 URL, 40 URL,
40 DIVIDER, 41 DIVIDER,
41 NUM_KINDS 42 NUM_KINDS
42 }; 43 };
43 44
44 OmniboxResultView(OmniboxResultViewModel* model, 45 OmniboxResultView(OmniboxResultViewModel* model,
45 int model_index, 46 int model_index,
46 const gfx::Font& font, 47 const gfx::Font& font);
47 const gfx::Font& bold_font);
48 virtual ~OmniboxResultView(); 48 virtual ~OmniboxResultView();
49 49
50 SkColor GetColor(ResultViewState state, ColorKind kind) const; 50 SkColor GetColor(ResultViewState state, ColorKind kind) const;
51 51
52 // Updates the match used to paint the contents of this result view. We copy 52 // Updates the match used to paint the contents of this result view. We copy
53 // the match so that we can continue to paint the last result even after the 53 // the match so that we can continue to paint the last result even after the
54 // model has changed. 54 // model has changed.
55 void SetMatch(const AutocompleteMatch& match); 55 void SetMatch(const AutocompleteMatch& match);
56 56
57 void ShowKeyword(bool show_keyword); 57 void ShowKeyword(bool show_keyword);
(...skipping 27 matching lines...) Expand all
85 85
86 const gfx::Rect& text_bounds() const { return text_bounds_; } 86 const gfx::Rect& text_bounds() const { return text_bounds_; }
87 87
88 void set_edge_item_padding(int value) { edge_item_padding_ = value; } 88 void set_edge_item_padding(int value) { edge_item_padding_ = value; }
89 void set_item_padding(int value) { item_padding_ = value; } 89 void set_item_padding(int value) { item_padding_ = value; }
90 void set_minimum_text_vertical_padding(int value) { 90 void set_minimum_text_vertical_padding(int value) {
91 minimum_text_vertical_padding_ = value; 91 minimum_text_vertical_padding_ = value;
92 } 92 }
93 93
94 private: 94 private:
95 struct ClassificationData;
96 typedef std::vector<ClassificationData> Classifications;
97
98 struct RunData; 95 struct RunData;
99 typedef std::vector<RunData> Runs; 96 typedef std::vector<RunData> Runs;
97 typedef std::vector<gfx::RenderText*> Classifications;
100 98
101 // Common initialization code of the colors returned by GetColors(). 99 // Common initialization code of the colors returned by GetColors().
102 static void CommonInitColors(const ui::NativeTheme* theme, 100 static void CommonInitColors(const ui::NativeTheme* theme,
103 SkColor colors[][NUM_KINDS]); 101 SkColor colors[][NUM_KINDS]);
104 102
105 // Predicate functions for use when sorting the runs. 103 // Predicate functions for use when sorting the runs.
106 static bool SortRunsLogically(const RunData& lhs, const RunData& rhs); 104 static bool SortRunsLogically(const RunData& lhs, const RunData& rhs);
107 static bool SortRunsVisually(const RunData& lhs, const RunData& rhs); 105 static bool SortRunsVisually(const RunData& lhs, const RunData& rhs);
108 106
109 gfx::ImageSkia GetIcon() const; 107 gfx::ImageSkia GetIcon() const;
(...skipping 27 matching lines...) Expand all
137 135
138 // Default values cached here, may be overridden using the setters above. 136 // Default values cached here, may be overridden using the setters above.
139 int edge_item_padding_; 137 int edge_item_padding_;
140 int item_padding_; 138 int item_padding_;
141 int minimum_text_vertical_padding_; 139 int minimum_text_vertical_padding_;
142 140
143 // This row's model and model index. 141 // This row's model and model index.
144 OmniboxResultViewModel* model_; 142 OmniboxResultViewModel* model_;
145 size_t model_index_; 143 size_t model_index_;
146 144
147 const gfx::Font normal_font_; 145 const gfx::Font font_;
148 const gfx::Font bold_font_; 146 int font_height_;
149 147
150 // Width of the ellipsis in the normal font. 148 // Width of the ellipsis in the normal font.
151 int ellipsis_width_; 149 int ellipsis_width_;
152 150
153 // A context used for mirroring regions. 151 // A context used for mirroring regions.
154 class MirroringContext; 152 class MirroringContext;
155 scoped_ptr<MirroringContext> mirroring_context_; 153 scoped_ptr<MirroringContext> mirroring_context_;
156 154
157 AutocompleteMatch match_; 155 AutocompleteMatch match_;
158 156
159 gfx::Rect text_bounds_; 157 gfx::Rect text_bounds_;
160 gfx::Rect icon_bounds_; 158 gfx::Rect icon_bounds_;
161 159
162 gfx::Rect keyword_text_bounds_; 160 gfx::Rect keyword_text_bounds_;
163 scoped_ptr<views::ImageView> keyword_icon_; 161 scoped_ptr<views::ImageView> keyword_icon_;
164 162
165 scoped_ptr<ui::SlideAnimation> animation_; 163 scoped_ptr<ui::SlideAnimation> animation_;
166 164
167 DISALLOW_COPY_AND_ASSIGN(OmniboxResultView); 165 DISALLOW_COPY_AND_ASSIGN(OmniboxResultView);
168 }; 166 };
169 167
170 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_RESULT_VIEW_H_ 168 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_RESULT_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698