| 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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 if (!avoid_overlapping_rect.IsEmpty()) { | 293 if (!avoid_overlapping_rect.IsEmpty()) { |
| 294 // For comparison (with the Intersects function below) we need to account | 294 // For comparison (with the Intersects function below) we need to account |
| 295 // for the fact that we draw the Find widget relative to the Chrome frame, | 295 // for the fact that we draw the Find widget relative to the Chrome frame, |
| 296 // whereas the selection rect is relative to the page. | 296 // whereas the selection rect is relative to the page. |
| 297 GetWidgetPositionNative(&avoid_overlapping_rect); | 297 GetWidgetPositionNative(&avoid_overlapping_rect); |
| 298 } | 298 } |
| 299 | 299 |
| 300 gfx::Rect new_pos = FindBarController::GetLocationForFindbarView( | 300 gfx::Rect new_pos = FindBarController::GetLocationForFindbarView( |
| 301 view_location, widget_bounds, avoid_overlapping_rect); | 301 view_location, widget_bounds, avoid_overlapping_rect); |
| 302 | 302 |
| 303 // While we are animating, the Find window will grow bottoms up so we need to | |
| 304 // re-position the widget so that it appears to grow out of the toolbar. | |
| 305 if (animation_offset() > 0) | |
| 306 new_pos.Offset(0, std::min(0, -animation_offset())); | |
| 307 | |
| 308 return new_pos; | 303 return new_pos; |
| 309 } | 304 } |
| 310 | 305 |
| 311 void FindBarHost::SetDialogPosition(const gfx::Rect& new_pos) { | 306 void FindBarHost::SetDialogPosition(const gfx::Rect& new_pos) { |
| 307 DropdownBarHost::SetDialogPosition(new_pos); |
| 308 |
| 312 if (new_pos.IsEmpty()) | 309 if (new_pos.IsEmpty()) |
| 313 return; | 310 return; |
| 314 | 311 |
| 315 if (!host()->IsVisible()) | |
| 316 host()->Show(); | |
| 317 host()->SetBounds(new_pos); | |
| 318 | |
| 319 // Tell the immersive mode controller about the find bar's new bounds. The | 312 // Tell the immersive mode controller about the find bar's new bounds. The |
| 320 // immersive mode controller uses the bounds to keep the top-of-window views | 313 // immersive mode controller uses the bounds to keep the top-of-window views |
| 321 // revealed when the mouse is hovered over the find bar. | 314 // revealed when the mouse is hovered over the find bar. |
| 322 browser_view()->immersive_mode_controller()->OnFindBarVisibleBoundsChanged( | 315 browser_view()->immersive_mode_controller()->OnFindBarVisibleBoundsChanged( |
| 323 host()->GetWindowBoundsInScreen()); | 316 host()->GetWindowBoundsInScreen()); |
| 324 } | 317 } |
| 325 | 318 |
| 326 void FindBarHost::GetWidgetBounds(gfx::Rect* bounds) { | 319 void FindBarHost::GetWidgetBounds(gfx::Rect* bounds) { |
| 327 DCHECK(bounds); | 320 DCHECK(bounds); |
| 328 // The BrowserView does Layout for the components that we care about | 321 // The BrowserView does Layout for the components that we care about |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 | 353 |
| 361 //////////////////////////////////////////////////////////////////////////////// | 354 //////////////////////////////////////////////////////////////////////////////// |
| 362 // private: | 355 // private: |
| 363 | 356 |
| 364 void FindBarHost::GetWidgetPositionNative(gfx::Rect* avoid_overlapping_rect) { | 357 void FindBarHost::GetWidgetPositionNative(gfx::Rect* avoid_overlapping_rect) { |
| 365 gfx::Rect frame_rect = host()->GetTopLevelWidget()->GetWindowBoundsInScreen(); | 358 gfx::Rect frame_rect = host()->GetTopLevelWidget()->GetWindowBoundsInScreen(); |
| 366 gfx::Rect webcontents_rect = | 359 gfx::Rect webcontents_rect = |
| 367 find_bar_controller_->web_contents()->GetViewBounds(); | 360 find_bar_controller_->web_contents()->GetViewBounds(); |
| 368 avoid_overlapping_rect->Offset(0, webcontents_rect.y() - frame_rect.y()); | 361 avoid_overlapping_rect->Offset(0, webcontents_rect.y() - frame_rect.y()); |
| 369 } | 362 } |
| OLD | NEW |