| 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "chrome/browser/ui/cocoa/autofill/autofill_popup_view_bridge.h" | 7 #include "chrome/browser/ui/cocoa/autofill/autofill_popup_view_bridge.h" |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" | 10 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 [[window_ parentWindow] removeChildWindow:window_]; | 68 [[window_ parentWindow] removeChildWindow:window_]; |
| 69 | 69 |
| 70 [window_ close]; | 70 [window_ close]; |
| 71 } | 71 } |
| 72 | 72 |
| 73 void AutofillPopupViewBridge::Hide() { | 73 void AutofillPopupViewBridge::Hide() { |
| 74 delete this; | 74 delete this; |
| 75 } | 75 } |
| 76 | 76 |
| 77 void AutofillPopupViewBridge::Show() { | 77 void AutofillPopupViewBridge::Show() { |
| 78 SetInitialBounds(); | |
| 79 UpdateBoundsAndRedrawPopup(); | 78 UpdateBoundsAndRedrawPopup(); |
| 80 [[controller_->container_view() window] addChildWindow:window_ | 79 [[controller_->container_view() window] addChildWindow:window_ |
| 81 ordered:NSWindowAbove]; | 80 ordered:NSWindowAbove]; |
| 82 } | 81 } |
| 83 | 82 |
| 84 void AutofillPopupViewBridge::InvalidateRow(size_t row) { | 83 void AutofillPopupViewBridge::InvalidateRow(size_t row) { |
| 85 NSRect dirty_rect = | 84 NSRect dirty_rect = |
| 86 NSRectFromCGRect(controller_->GetRowBounds(row).ToCGRect()); | 85 NSRectFromCGRect(controller_->GetRowBounds(row).ToCGRect()); |
| 87 [view_ setNeedsDisplayInRect:dirty_rect]; | 86 [view_ setNeedsDisplayInRect:dirty_rect]; |
| 88 } | 87 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 104 } else { | 103 } else { |
| 105 // Popup is above the element which initiated it. | 104 // Popup is above the element which initiated it. |
| 106 frame.origin.y += kBorderWidth; | 105 frame.origin.y += kBorderWidth; |
| 107 } | 106 } |
| 108 | 107 |
| 109 // TODO(isherman): The view should support scrolling if the popup gets too | 108 // TODO(isherman): The view should support scrolling if the popup gets too |
| 110 // big to fit on the screen. | 109 // big to fit on the screen. |
| 111 [window_ setFrame:frame display:YES]; | 110 [window_ setFrame:frame display:YES]; |
| 112 } | 111 } |
| 113 | 112 |
| 114 void AutofillPopupViewBridge::SetInitialBounds() { | |
| 115 // The bounds rect in Chrome's screen coordinates. The popup should be | |
| 116 // positioned just below the element which initiated it. | |
| 117 gfx::Rect bounds(controller_->element_bounds().x(), | |
| 118 controller_->element_bounds().bottom(), | |
| 119 controller_->GetPopupRequiredWidth(), | |
| 120 controller_->GetPopupRequiredHeight()); | |
| 121 | |
| 122 // TODO(isherman): Position the popup correctly if it can't fit below the text | |
| 123 // field: http://crbug.com/164603 | |
| 124 | |
| 125 controller_->SetPopupBounds(bounds); | |
| 126 } | |
| 127 | |
| 128 AutofillPopupView* AutofillPopupView::Create( | 113 AutofillPopupView* AutofillPopupView::Create( |
| 129 AutofillPopupController* controller) { | 114 AutofillPopupController* controller) { |
| 130 return new AutofillPopupViewBridge(controller); | 115 return new AutofillPopupViewBridge(controller); |
| 131 } | 116 } |
| OLD | NEW |