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