| OLD | NEW |
| 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
| 8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
| 9 #include "chrome/browser/ui/cocoa/browser_window_controller.h" | 9 #include "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 10 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" | 10 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 NSEvent* event = [NSApp currentEvent]; | 226 NSEvent* event = [NSApp currentEvent]; |
| 227 if ([event type] != NSKeyDown && [event type] != NSKeyUp) | 227 if ([event type] != NSKeyDown && [event type] != NSKeyUp) |
| 228 return NO; | 228 return NO; |
| 229 | 229 |
| 230 // Forward the event to the renderer. | 230 // Forward the event to the renderer. |
| 231 // TODO(rohitrao): Should this call -[BaseView keyEvent:]? Is there code in | 231 // TODO(rohitrao): Should this call -[BaseView keyEvent:]? Is there code in |
| 232 // that function that we want to keep or avoid? Calling | 232 // that function that we want to keep or avoid? Calling |
| 233 // |ForwardKeyboardEvent()| directly ignores edit commands, which breaks | 233 // |ForwardKeyboardEvent()| directly ignores edit commands, which breaks |
| 234 // cmd-up/down if we ever decide to include |moveToBeginningOfDocument:| in | 234 // cmd-up/down if we ever decide to include |moveToBeginningOfDocument:| in |
| 235 // the list above. | 235 // the list above. |
| 236 RenderViewHost* render_view_host = contents->render_view_host(); | 236 RenderViewHost* render_view_host = |
| 237 contents->tab_contents()->render_view_host(); |
| 237 render_view_host->ForwardKeyboardEvent(NativeWebKeyboardEvent(event)); | 238 render_view_host->ForwardKeyboardEvent(NativeWebKeyboardEvent(event)); |
| 238 return YES; | 239 return YES; |
| 239 } | 240 } |
| 240 | 241 |
| 241 return NO; | 242 return NO; |
| 242 } | 243 } |
| 243 | 244 |
| 244 // Methods from FindBar | 245 // Methods from FindBar |
| 245 - (void)showFindBar:(BOOL)animate { | 246 - (void)showFindBar:(BOOL)animate { |
| 246 // Save the currently-focused view. |findBarView_| is in the view | 247 // Save the currently-focused view. |findBarView_| is in the view |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 gfx::Rect view_rect(NSRectToCGRect(frame)); | 460 gfx::Rect view_rect(NSRectToCGRect(frame)); |
| 460 | 461 |
| 461 if (!findBarBridge_ || !findBarBridge_->GetFindBarController()) | 462 if (!findBarBridge_ || !findBarBridge_->GetFindBarController()) |
| 462 return frame.origin.x; | 463 return frame.origin.x; |
| 463 TabContentsWrapper* contents = | 464 TabContentsWrapper* contents = |
| 464 findBarBridge_->GetFindBarController()->tab_contents(); | 465 findBarBridge_->GetFindBarController()->tab_contents(); |
| 465 if (!contents) | 466 if (!contents) |
| 466 return frame.origin.x; | 467 return frame.origin.x; |
| 467 | 468 |
| 468 // Get the size of the container. | 469 // Get the size of the container. |
| 469 gfx::Rect container_rect(contents->view()->GetContainerSize()); | 470 gfx::Rect container_rect( |
| 471 contents->tab_contents()->view()->GetContainerSize()); |
| 470 | 472 |
| 471 // Position the FindBar on the top right corner. | 473 // Position the FindBar on the top right corner. |
| 472 view_rect.set_x( | 474 view_rect.set_x( |
| 473 container_rect.width() - view_rect.width() - kRightEdgeOffset); | 475 container_rect.width() - view_rect.width() - kRightEdgeOffset); |
| 474 // Convert from Cocoa coordinates (Y growing up) to Y growing down. | 476 // Convert from Cocoa coordinates (Y growing up) to Y growing down. |
| 475 // Notice that the view frame's Y offset is relative to the whole window, | 477 // Notice that the view frame's Y offset is relative to the whole window, |
| 476 // while GetLocationForFindbarView() expects it relative to the | 478 // while GetLocationForFindbarView() expects it relative to the |
| 477 // content's boundaries. |maxY_| has the correct placement in Cocoa coords, | 479 // content's boundaries. |maxY_| has the correct placement in Cocoa coords, |
| 478 // so we just have to invert the Y coordinate. | 480 // so we just have to invert the Y coordinate. |
| 479 view_rect.set_y(maxY_ - view_rect.bottom()); | 481 view_rect.set_y(maxY_ - view_rect.bottom()); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 } | 532 } |
| 531 } | 533 } |
| 532 | 534 |
| 533 // Has to happen after |ClearResults()| above. | 535 // Has to happen after |ClearResults()| above. |
| 534 BOOL buttonsEnabled = [text length] > 0 ? YES : NO; | 536 BOOL buttonsEnabled = [text length] > 0 ? YES : NO; |
| 535 [previousButton_ setEnabled:buttonsEnabled]; | 537 [previousButton_ setEnabled:buttonsEnabled]; |
| 536 [nextButton_ setEnabled:buttonsEnabled]; | 538 [nextButton_ setEnabled:buttonsEnabled]; |
| 537 } | 539 } |
| 538 | 540 |
| 539 @end | 541 @end |
| OLD | NEW |