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

Side by Side Diff: chrome/browser/find_in_page_controller.cc

Issue 7344: Convert GetPreferredSize from:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 2 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/find_in_page_controller.h" 5 #include "chrome/browser/find_in_page_controller.h"
6 6
7 #include "chrome/browser/browser.h" 7 #include "chrome/browser/browser.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/find_in_page_view.h" 9 #include "chrome/browser/find_in_page_view.h"
10 #include "chrome/browser/find_notification_details.h" 10 #include "chrome/browser/find_notification_details.h"
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 555
556 gfx::Rect FindInPageController::GetDialogPosition( 556 gfx::Rect FindInPageController::GetDialogPosition(
557 gfx::Rect avoid_overlapping_rect) { 557 gfx::Rect avoid_overlapping_rect) {
558 // Find the area we have to work with (after accounting for scrollbars, etc). 558 // Find the area we have to work with (after accounting for scrollbars, etc).
559 gfx::Rect dialog_bounds; 559 gfx::Rect dialog_bounds;
560 GetDialogBounds(&dialog_bounds); 560 GetDialogBounds(&dialog_bounds);
561 if (dialog_bounds.IsEmpty()) 561 if (dialog_bounds.IsEmpty())
562 return gfx::Rect(); 562 return gfx::Rect();
563 563
564 // Ask the view how large an area it needs to draw on. 564 // Ask the view how large an area it needs to draw on.
565 CSize prefsize; 565 gfx::Size prefsize = view_->GetPreferredSize();
566 view_->GetPreferredSize(&prefsize);
567 566
568 // Place the view in the top right corner of the dialog boundaries (top left 567 // Place the view in the top right corner of the dialog boundaries (top left
569 // for RTL languages). 568 // for RTL languages).
570 gfx::Rect view_location; 569 gfx::Rect view_location;
571 int x = view_->UILayoutIsRightToLeft() ? 570 int x = view_->UILayoutIsRightToLeft() ?
572 dialog_bounds.x() : dialog_bounds.width() - prefsize.cx; 571 dialog_bounds.x() : dialog_bounds.width() - prefsize.width();
573 int y = dialog_bounds.y(); 572 int y = dialog_bounds.y();
574 view_location.SetRect(x, y, prefsize.cx, prefsize.cy); 573 view_location.SetRect(x, y, prefsize.width(), prefsize.height());
575 574
576 // Make sure we don't go out of bounds to the left (right in RTL) if the 575 // Make sure we don't go out of bounds to the left (right in RTL) if the
577 // window is too small to fit our dialog. 576 // window is too small to fit our dialog.
578 if (view_->UILayoutIsRightToLeft()) { 577 if (view_->UILayoutIsRightToLeft()) {
579 int boundary = dialog_bounds.width() - prefsize.cx; 578 int boundary = dialog_bounds.width() - prefsize.width();
580 view_location.set_x(std::min(view_location.x(), boundary)); 579 view_location.set_x(std::min(view_location.x(), boundary));
581 } else { 580 } else {
582 view_location.set_x(std::max(view_location.x(), dialog_bounds.x())); 581 view_location.set_x(std::max(view_location.x(), dialog_bounds.x()));
583 } 582 }
584 583
585 gfx::Rect new_pos = view_location; 584 gfx::Rect new_pos = view_location;
586 585
587 // When we get Find results back, we specify a selection rect, which we 586 // When we get Find results back, we specify a selection rect, which we
588 // should strive to avoid overlapping. But first, we need to offset the 587 // should strive to avoid overlapping. But first, we need to offset the
589 // selection rect (if one was provided). 588 // selection rect (if one was provided).
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 // TODO(finnur): Once we fix issue 1307173 we should not remember any old 683 // TODO(finnur): Once we fix issue 1307173 we should not remember any old
685 // accelerator targets and just Register and Unregister when needed. 684 // accelerator targets and just Register and Unregister when needed.
686 DCHECK(old_accel_target_for_esc_ != NULL); 685 DCHECK(old_accel_target_for_esc_ != NULL);
687 ChromeViews::Accelerator escape(VK_ESCAPE, false, false, false); 686 ChromeViews::Accelerator escape(VK_ESCAPE, false, false, false);
688 ChromeViews::AcceleratorTarget* current_target = 687 ChromeViews::AcceleratorTarget* current_target =
689 focus_manager_->GetTargetForAccelerator(escape); 688 focus_manager_->GetTargetForAccelerator(escape);
690 if (current_target == this) 689 if (current_target == this)
691 focus_manager_->RegisterAccelerator(escape, old_accel_target_for_esc_); 690 focus_manager_->RegisterAccelerator(escape, old_accel_target_for_esc_);
692 } 691 }
693 692
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698