OLD | NEW |
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_POPUP_CONTENTS_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ |
7 | 7 |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 9 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
10 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" | 10 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 74 |
75 protected: | 75 protected: |
76 OmniboxPopupContentsView(const gfx::FontList& font_list, | 76 OmniboxPopupContentsView(const gfx::FontList& font_list, |
77 OmniboxView* omnibox_view, | 77 OmniboxView* omnibox_view, |
78 OmniboxEditModel* edit_model, | 78 OmniboxEditModel* edit_model, |
79 LocationBarView* location_bar_view); | 79 LocationBarView* location_bar_view); |
80 ~OmniboxPopupContentsView() override; | 80 ~OmniboxPopupContentsView() override; |
81 | 81 |
82 LocationBarView* location_bar_view() { return location_bar_view_; } | 82 LocationBarView* location_bar_view() { return location_bar_view_; } |
83 | 83 |
84 virtual void PaintResultViews(gfx::Canvas* canvas); | |
85 | |
86 // Calculates the height needed to show all the results in the model. | 84 // Calculates the height needed to show all the results in the model. |
87 virtual int CalculatePopupHeight(); | 85 virtual int CalculatePopupHeight(); |
88 virtual OmniboxResultView* CreateResultView(int model_index, | 86 virtual OmniboxResultView* CreateResultView(int model_index, |
89 const gfx::FontList& font_list); | 87 const gfx::FontList& font_list); |
90 | 88 |
91 private: | 89 private: |
92 class AutocompletePopupWidget; | 90 class AutocompletePopupWidget; |
93 | 91 |
94 // views::View: | 92 // views::View: |
95 const char* GetClassName() const override; | 93 const char* GetClassName() const override; |
96 void OnPaint(gfx::Canvas* canvas) override; | 94 void OnPaint(gfx::Canvas* canvas) override; |
97 // This method should not be triggered directly as we paint our children | |
98 // in an un-conventional way inside OnPaint. We use a separate canvas to | |
99 // paint the children. Hence we override this method to a no-op so that | |
100 // the view hierarchy does not "accidentally" trigger this. | |
101 void PaintChildren(gfx::Canvas* canvas, | 95 void PaintChildren(gfx::Canvas* canvas, |
102 const views::CullSet& cull_set) override; | 96 const views::CullSet& cull_set) override; |
103 | 97 |
104 // views::ViewTargeterDelegate: | 98 // views::ViewTargeterDelegate: |
105 views::View* TargetForRect(views::View* root, const gfx::Rect& rect) override; | 99 views::View* TargetForRect(views::View* root, const gfx::Rect& rect) override; |
106 | 100 |
107 // Call immediately after construction. | 101 // Call immediately after construction. |
108 void Init(); | 102 void Init(); |
109 | 103 |
110 // Returns true if the model has a match at the specified index. | 104 // Returns true if the model has a match at the specified index. |
111 bool HasMatchAt(size_t index) const; | 105 bool HasMatchAt(size_t index) const; |
112 | 106 |
113 // Returns the match at the specified index within the popup model. | 107 // Returns the match at the specified index within the popup model. |
114 const AutocompleteMatch& GetMatchAtIndex(size_t index) const; | 108 const AutocompleteMatch& GetMatchAtIndex(size_t index) const; |
115 | 109 |
116 // Fill a path for the contents' roundrect. |bounding_rect| is the rect that | |
117 // bounds the path. | |
118 void MakeContentsPath(gfx::Path* path, const gfx::Rect& bounding_rect); | |
119 | |
120 // Find the index of the match under the given |point|, specified in window | 110 // Find the index of the match under the given |point|, specified in window |
121 // coordinates. Returns OmniboxPopupModel::kNoMatch if there isn't a match at | 111 // coordinates. Returns OmniboxPopupModel::kNoMatch if there isn't a match at |
122 // the specified point. | 112 // the specified point. |
123 size_t GetIndexForPoint(const gfx::Point& point); | 113 size_t GetIndexForPoint(const gfx::Point& point); |
124 | 114 |
125 // Processes a located event (e.g. mouse/gesture) and sets the selection/hover | 115 // Processes a located event (e.g. mouse/gesture) and sets the selection/hover |
126 // state of a line in the list. | 116 // state of a line in the list. |
127 void UpdateLineEvent(const ui::LocatedEvent& event, | 117 void UpdateLineEvent(const ui::LocatedEvent& event, |
128 bool should_set_selected_line); | 118 bool should_set_selected_line); |
129 | 119 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 161 |
172 // When the dropdown is not wide enough while displaying postfix suggestions, | 162 // When the dropdown is not wide enough while displaying postfix suggestions, |
173 // we use the width of widest match contents to shift the suggestions so that | 163 // we use the width of widest match contents to shift the suggestions so that |
174 // the widest suggestion just reaches the end edge. | 164 // the widest suggestion just reaches the end edge. |
175 int max_match_contents_width_; | 165 int max_match_contents_width_; |
176 | 166 |
177 DISALLOW_COPY_AND_ASSIGN(OmniboxPopupContentsView); | 167 DISALLOW_COPY_AND_ASSIGN(OmniboxPopupContentsView); |
178 }; | 168 }; |
179 | 169 |
180 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ | 170 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ |
OLD | NEW |