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

Side by Side Diff: chrome/browser/ui/views/find_bar_host.cc

Issue 7285005: Make Windows FindBar stay within window bounds for narrow windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/find_bar_host.h" 5 #include "chrome/browser/ui/views/find_bar_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 9 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
10 #include "chrome/browser/ui/find_bar/find_tab_helper.h" 10 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 if (!find_bar_controller_->tab_contents() || 118 if (!find_bar_controller_->tab_contents() ||
119 !find_bar_controller_-> 119 !find_bar_controller_->
120 tab_contents()->find_tab_helper()->find_ui_active()) { 120 tab_contents()->find_tab_helper()->find_ui_active()) {
121 return; 121 return;
122 } 122 }
123 123
124 gfx::Rect new_pos = GetDialogPosition(selection_rect); 124 gfx::Rect new_pos = GetDialogPosition(selection_rect);
125 SetDialogPosition(new_pos, no_redraw); 125 SetDialogPosition(new_pos, no_redraw);
126 126
127 // May need to redraw our frame to accommodate bookmark bar styles. 127 // May need to redraw our frame to accommodate bookmark bar styles.
128 view()->Layout(); // Bounds may have changed.
128 view()->SchedulePaint(); 129 view()->SchedulePaint();
129 } 130 }
130 131
131 void FindBarHost::SetFindText(const string16& find_text) { 132 void FindBarHost::SetFindText(const string16& find_text) {
132 find_bar_view()->SetFindText(find_text); 133 find_bar_view()->SetFindText(find_text);
133 } 134 }
134 135
135 void FindBarHost::UpdateUIForFindResult(const FindNotificationDetails& result, 136 void FindBarHost::UpdateUIForFindResult(const FindNotificationDetails& result,
136 const string16& find_text) { 137 const string16& find_text) {
137 // Make sure match count is clear. It may get set again in UpdateForResult 138 // Make sure match count is clear. It may get set again in UpdateForResult
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 224
224 string16 FindBarHost::GetFindSelectedText() { 225 string16 FindBarHost::GetFindSelectedText() {
225 return find_bar_view()->GetFindSelectedText(); 226 return find_bar_view()->GetFindSelectedText();
226 } 227 }
227 228
228 string16 FindBarHost::GetMatchCountText() { 229 string16 FindBarHost::GetMatchCountText() {
229 return find_bar_view()->GetMatchCountText(); 230 return find_bar_view()->GetMatchCountText();
230 } 231 }
231 232
232 int FindBarHost::GetWidth() { 233 int FindBarHost::GetWidth() {
233 NOTIMPLEMENTED(); 234 return view()->width();
234 return 0;
235 } 235 }
236 236
237 //////////////////////////////////////////////////////////////////////////////// 237 ////////////////////////////////////////////////////////////////////////////////
238 // Overridden from DropdownBarHost: 238 // Overridden from DropdownBarHost:
239 239
240 gfx::Rect FindBarHost::GetDialogPosition(gfx::Rect avoid_overlapping_rect) { 240 gfx::Rect FindBarHost::GetDialogPosition(gfx::Rect avoid_overlapping_rect) {
241 // Find the area we have to work with (after accounting for scrollbars, etc). 241 // Find the area we have to work with (after accounting for scrollbars, etc).
242 gfx::Rect widget_bounds; 242 gfx::Rect widget_bounds;
243 GetWidgetBounds(&widget_bounds); 243 GetWidgetBounds(&widget_bounds);
244 if (widget_bounds.IsEmpty()) 244 if (widget_bounds.IsEmpty())
245 return gfx::Rect(); 245 return gfx::Rect();
246 246
247 // Ask the view how large an area it needs to draw on. 247 // Ask the view how large an area it needs to draw on.
248 gfx::Size prefsize = view()->GetPreferredSize(); 248 gfx::Size prefsize = view()->GetPreferredSize();
249 249
250 // Limit width to the available area.
251 if (widget_bounds.width() < prefsize.width())
252 prefsize.set_width(widget_bounds.width());
253
250 // Place the view in the top right corner of the widget boundaries (top left 254 // Place the view in the top right corner of the widget boundaries (top left
251 // for RTL languages). 255 // for RTL languages).
252 gfx::Rect view_location; 256 gfx::Rect view_location;
253 int x = widget_bounds.x(); 257 int x = widget_bounds.x();
254 if (!base::i18n::IsRTL()) 258 if (!base::i18n::IsRTL())
255 x += widget_bounds.width() - prefsize.width(); 259 x += widget_bounds.width() - prefsize.width();
256 int y = widget_bounds.y(); 260 int y = widget_bounds.y();
257 view_location.SetRect(x, y, prefsize.width(), prefsize.height()); 261 view_location.SetRect(x, y, prefsize.width(), prefsize.height());
258 262
259 // When we get Find results back, we specify a selection rect, which we 263 // When we get Find results back, we specify a selection rect, which we
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 315
312 DropdownBarHost::UnregisterAccelerators(); 316 DropdownBarHost::UnregisterAccelerators();
313 } 317 }
314 318
315 //////////////////////////////////////////////////////////////////////////////// 319 ////////////////////////////////////////////////////////////////////////////////
316 // private: 320 // private:
317 321
318 FindBarView* FindBarHost::find_bar_view() { 322 FindBarView* FindBarHost::find_bar_view() {
319 return static_cast<FindBarView*>(view()); 323 return static_cast<FindBarView*>(view());
320 } 324 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/dropdown_bar_host_win.cc ('k') | chrome/browser/ui/views/find_bar_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698