| 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 <Carbon/Carbon.h> | 5 #import <Carbon/Carbon.h> |
| 6 | 6 |
| 7 #include "chrome/browser/tab_contents/tab_contents_view_mac.h" | 7 #include "chrome/browser/tab_contents/tab_contents_view_mac.h" |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 - (void)registerDragTypes; | 49 - (void)registerDragTypes; |
| 50 - (void)setCurrentDragOperation:(NSDragOperation)operation; | 50 - (void)setCurrentDragOperation:(NSDragOperation)operation; |
| 51 - (void)startDragWithDropData:(const WebDropData&)dropData | 51 - (void)startDragWithDropData:(const WebDropData&)dropData |
| 52 dragOperationMask:(NSDragOperation)operationMask | 52 dragOperationMask:(NSDragOperation)operationMask |
| 53 image:(NSImage*)image | 53 image:(NSImage*)image |
| 54 offset:(NSPoint)offset; | 54 offset:(NSPoint)offset; |
| 55 - (void)cancelDeferredClose; | 55 - (void)cancelDeferredClose; |
| 56 - (void)clearTabContentsView; | 56 - (void)clearTabContentsView; |
| 57 - (void)closeTabAfterEvent; | 57 - (void)closeTabAfterEvent; |
| 58 - (void)viewDidBecomeFirstResponder:(NSNotification*)notification; | 58 - (void)viewDidBecomeFirstResponder:(NSNotification*)notification; |
| 59 // Notify the RenderWidgetHost that the frame was updated so it can resize |
| 60 // its contents. |
| 61 - (void)renderWidgetHostWasResized; |
| 59 @end | 62 @end |
| 60 | 63 |
| 61 namespace tab_contents_view_mac { | 64 namespace tab_contents_view_mac { |
| 62 TabContentsView* CreateTabContentsView(TabContents* tab_contents) { | 65 TabContentsView* CreateTabContentsView(TabContents* tab_contents) { |
| 63 return new TabContentsViewMac(tab_contents); | 66 return new TabContentsViewMac(tab_contents); |
| 64 } | 67 } |
| 65 } | 68 } |
| 66 | 69 |
| 67 TabContentsViewMac::TabContentsViewMac(TabContents* tab_contents) | 70 TabContentsViewMac::TabContentsViewMac(TabContents* tab_contents) |
| 68 : tab_contents_(tab_contents), | 71 : tab_contents_(tab_contents), |
| 69 preferred_width_(0), | 72 preferred_width_(0), |
| 70 overlaid_view_(nil) { | 73 overlaid_view_(nil) { |
| 71 } | 74 } |
| 72 | 75 |
| 73 TabContentsViewMac::~TabContentsViewMac() { | 76 TabContentsViewMac::~TabContentsViewMac() { |
| 74 // This handles the case where a renderer close call was deferred | 77 // This handles the case where a renderer close call was deferred |
| 75 // while the user was operating a UI control which resulted in a | 78 // while the user was operating a UI control which resulted in a |
| 76 // close. In that case, the Cocoa view outlives the | 79 // close. In that case, the Cocoa view outlives the |
| 77 // TabContentsViewMac instance due to Cocoa retain count. | 80 // TabContentsViewMac instance due to Cocoa retain count. |
| 78 [cocoa_view_ cancelDeferredClose]; | 81 [cocoa_view_ cancelDeferredClose]; |
| 79 [cocoa_view_ clearTabContentsView]; | 82 [cocoa_view_ clearTabContentsView]; |
| 80 } | 83 } |
| 81 | 84 |
| 82 void TabContentsViewMac::CreateView(const gfx::Size& initial_size) { | 85 void TabContentsViewMac::CreateView(const gfx::Size& initial_size) { |
| 83 TabContentsViewCocoa* view = | 86 TabContentsViewCocoa* view = |
| 84 [[TabContentsViewCocoa alloc] initWithTabContentsViewMac:this]; | 87 [[TabContentsViewCocoa alloc] initWithTabContentsViewMac:this]; |
| 85 [view setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; | |
| 86 cocoa_view_.reset(view); | 88 cocoa_view_.reset(view); |
| 87 } | 89 } |
| 88 | 90 |
| 89 RenderWidgetHostView* TabContentsViewMac::CreateViewForWidget( | 91 RenderWidgetHostView* TabContentsViewMac::CreateViewForWidget( |
| 90 RenderWidgetHost* render_widget_host) { | 92 RenderWidgetHost* render_widget_host) { |
| 91 if (render_widget_host->view()) { | 93 if (render_widget_host->view()) { |
| 92 // During testing, the view will already be set up in most cases to the | 94 // During testing, the view will already be set up in most cases to the |
| 93 // test view, so we don't want to clobber it with a real one. To verify that | 95 // test view, so we don't want to clobber it with a real one. To verify that |
| 94 // this actually is happening (and somebody isn't accidentally creating the | 96 // this actually is happening (and somebody isn't accidentally creating the |
| 95 // view twice), we check for the RVH Factory, which will be set when we're | 97 // view twice), we check for the RVH Factory, which will be set when we're |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 initWithContents:[self tabContents] | 503 initWithContents:[self tabContents] |
| 502 view:self | 504 view:self |
| 503 dropData:&dropData | 505 dropData:&dropData |
| 504 image:image | 506 image:image |
| 505 offset:offset | 507 offset:offset |
| 506 pasteboard:[NSPasteboard pasteboardWithName:NSDragPboard] | 508 pasteboard:[NSPasteboard pasteboardWithName:NSDragPboard] |
| 507 dragOperationMask:operationMask]); | 509 dragOperationMask:operationMask]); |
| 508 [dragSource_ startDrag]; | 510 [dragSource_ startDrag]; |
| 509 } | 511 } |
| 510 | 512 |
| 513 - (void)setFrameWithDeferredUpdate:(NSRect)frameRect { |
| 514 [super setFrame:frameRect]; |
| 515 [self performSelector:@selector(renderWidgetHostWasResized) |
| 516 withObject:nil |
| 517 afterDelay:0]; |
| 518 } |
| 519 |
| 520 - (void)renderWidgetHostWasResized { |
| 521 TabContents* tabContents = [self tabContents]; |
| 522 if (tabContents->render_view_host()) |
| 523 tabContents->render_view_host()->WasResized(); |
| 524 } |
| 525 |
| 511 // NSDraggingSource methods | 526 // NSDraggingSource methods |
| 512 | 527 |
| 513 // Returns what kind of drag operations are available. This is a required | 528 // Returns what kind of drag operations are available. This is a required |
| 514 // method for NSDraggingSource. | 529 // method for NSDraggingSource. |
| 515 - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal { | 530 - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal { |
| 516 if (dragSource_.get()) | 531 if (dragSource_.get()) |
| 517 return [dragSource_ draggingSourceOperationMaskForLocal:isLocal]; | 532 return [dragSource_ draggingSourceOperationMaskForLocal:isLocal]; |
| 518 // No web drag source - this is the case for dragging a file from the | 533 // No web drag source - this is the case for dragging a file from the |
| 519 // downloads manager. Default to copy operation. Note: It is desirable to | 534 // downloads manager. Default to copy operation. Note: It is desirable to |
| 520 // allow the user to either move or copy, but this requires additional | 535 // allow the user to either move or copy, but this requires additional |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 [[[notification userInfo] objectForKey:kSelectionDirection] | 606 [[[notification userInfo] objectForKey:kSelectionDirection] |
| 592 unsignedIntegerValue]; | 607 unsignedIntegerValue]; |
| 593 if (direction == NSDirectSelection) | 608 if (direction == NSDirectSelection) |
| 594 return; | 609 return; |
| 595 | 610 |
| 596 [self tabContents]-> | 611 [self tabContents]-> |
| 597 FocusThroughTabTraversal(direction == NSSelectingPrevious); | 612 FocusThroughTabTraversal(direction == NSSelectingPrevious); |
| 598 } | 613 } |
| 599 | 614 |
| 600 @end | 615 @end |
| OLD | NEW |