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 #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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 if (widget_bounds.IsEmpty()) | 261 if (widget_bounds.IsEmpty()) |
262 return gfx::Rect(); | 262 return gfx::Rect(); |
263 | 263 |
264 // Ask the view how large an area it needs to draw on. | 264 // Ask the view how large an area it needs to draw on. |
265 gfx::Size prefsize = view()->GetPreferredSize(); | 265 gfx::Size prefsize = view()->GetPreferredSize(); |
266 | 266 |
267 // Limit width to the available area. | 267 // Limit width to the available area. |
268 if (widget_bounds.width() < prefsize.width()) | 268 if (widget_bounds.width() < prefsize.width()) |
269 prefsize.set_width(widget_bounds.width()); | 269 prefsize.set_width(widget_bounds.width()); |
270 | 270 |
| 271 // Don't show the find bar if |widget_bounds| is not tall enough. |
| 272 if (widget_bounds.height() < prefsize.height()) |
| 273 return gfx::Rect(); |
| 274 |
271 // Place the view in the top right corner of the widget boundaries (top left | 275 // Place the view in the top right corner of the widget boundaries (top left |
272 // for RTL languages). | 276 // for RTL languages). |
273 gfx::Rect view_location; | 277 gfx::Rect view_location; |
274 int x = widget_bounds.x(); | 278 int x = widget_bounds.x(); |
275 if (!base::i18n::IsRTL()) | 279 if (!base::i18n::IsRTL()) |
276 x += widget_bounds.width() - prefsize.width(); | 280 x += widget_bounds.width() - prefsize.width(); |
277 int y = widget_bounds.y(); | 281 int y = widget_bounds.y(); |
278 view_location.SetRect(x, y, prefsize.width(), prefsize.height()); | 282 view_location.SetRect(x, y, prefsize.width(), prefsize.height()); |
279 | 283 |
280 // When we get Find results back, we specify a selection rect, which we | 284 // When we get Find results back, we specify a selection rect, which we |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 gfx::Rect frame_rect = host()->GetTopLevelWidget()->GetWindowBoundsInScreen(); | 345 gfx::Rect frame_rect = host()->GetTopLevelWidget()->GetWindowBoundsInScreen(); |
342 content::WebContentsView* tab_view = | 346 content::WebContentsView* tab_view = |
343 find_bar_controller_->web_contents()->GetView(); | 347 find_bar_controller_->web_contents()->GetView(); |
344 gfx::Rect webcontents_rect = tab_view->GetViewBounds(); | 348 gfx::Rect webcontents_rect = tab_view->GetViewBounds(); |
345 avoid_overlapping_rect->Offset(0, webcontents_rect.y() - frame_rect.y()); | 349 avoid_overlapping_rect->Offset(0, webcontents_rect.y() - frame_rect.y()); |
346 } | 350 } |
347 | 351 |
348 FindBarView* FindBarHost::find_bar_view() { | 352 FindBarView* FindBarHost::find_bar_view() { |
349 return static_cast<FindBarView*>(view()); | 353 return static_cast<FindBarView*>(view()); |
350 } | 354 } |
OLD | NEW |