| 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 "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" | 5 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 TabContentsController* const controller_; | 67 TabContentsController* const controller_; |
| 68 | 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(FullscreenObserver); | 69 DISALLOW_COPY_AND_ASSIGN(FullscreenObserver); |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 @interface TabContentsController (TabContentsContainerViewDelegate) | 72 @interface TabContentsController (TabContentsContainerViewDelegate) |
| 73 - (BOOL)contentsInFullscreenCaptureMode; | 73 - (BOOL)contentsInFullscreenCaptureMode; |
| 74 // Computes and returns the frame to use for the contents view within the | 74 // Computes and returns the frame to use for the contents view within the |
| 75 // container view. | 75 // container view. |
| 76 - (NSRect)frameForContentsView; | 76 - (NSRect)frameForContentsView; |
| 77 |
| 78 // Returns YES if the content view should be resized. |
| 79 - (BOOL)shouldResizeContentView; |
| 77 @end | 80 @end |
| 78 | 81 |
| 79 // An NSView with special-case handling for when the contents view does not | 82 // An NSView with special-case handling for when the contents view does not |
| 80 // expand to fill the entire tab contents area. See 'AutoEmbedFullscreen mode' | 83 // expand to fill the entire tab contents area. See 'AutoEmbedFullscreen mode' |
| 81 // in header file comments. | 84 // in header file comments. |
| 82 @interface TabContentsContainerView : NSView { | 85 @interface TabContentsContainerView : NSView { |
| 83 @private | 86 @private |
| 84 TabContentsController* delegate_; // weak | 87 TabContentsController* delegate_; // weak |
| 85 } | 88 } |
| 86 | 89 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 return backgroundColor; | 132 return backgroundColor; |
| 130 } | 133 } |
| 131 } | 134 } |
| 132 | 135 |
| 133 // Override auto-resizing logic to query the delegate for the exact frame to | 136 // Override auto-resizing logic to query the delegate for the exact frame to |
| 134 // use for the contents view. | 137 // use for the contents view. |
| 135 - (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize { | 138 - (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize { |
| 136 NSView* const contentsView = | 139 NSView* const contentsView = |
| 137 [[self subviews] count] > 0 ? [[self subviews] objectAtIndex:0] : nil; | 140 [[self subviews] count] > 0 ? [[self subviews] objectAtIndex:0] : nil; |
| 138 if (!contentsView || [contentsView autoresizingMask] == NSViewNotSizable || | 141 if (!contentsView || [contentsView autoresizingMask] == NSViewNotSizable || |
| 139 !delegate_) { | 142 !delegate_ || ![delegate_ shouldResizeContentView]) { |
| 140 return; | 143 return; |
| 141 } | 144 } |
| 142 | 145 |
| 143 ScopedCAActionDisabler disabler; | 146 ScopedCAActionDisabler disabler; |
| 144 [contentsView setFrame:[delegate_ frameForContentsView]]; | 147 [contentsView setFrame:[delegate_ frameForContentsView]]; |
| 145 } | 148 } |
| 146 | 149 |
| 147 // Update the background layer's color whenever the view needs to repaint. | 150 // Update the background layer's color whenever the view needs to repaint. |
| 148 - (void)setNeedsDisplayInRect:(NSRect)rect { | 151 - (void)setNeedsDisplayInRect:(NSRect)rect { |
| 149 [super setNeedsDisplayInRect:rect]; | 152 [super setNeedsDisplayInRect:rect]; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 NSView* contentsNativeView; | 227 NSView* contentsNativeView; |
| 225 content::RenderWidgetHostView* const fullscreenView = | 228 content::RenderWidgetHostView* const fullscreenView = |
| 226 isEmbeddingFullscreenWidget_ ? | 229 isEmbeddingFullscreenWidget_ ? |
| 227 contents_->GetFullscreenRenderWidgetHostView() : NULL; | 230 contents_->GetFullscreenRenderWidgetHostView() : NULL; |
| 228 if (fullscreenView) { | 231 if (fullscreenView) { |
| 229 contentsNativeView = fullscreenView->GetNativeView(); | 232 contentsNativeView = fullscreenView->GetNativeView(); |
| 230 } else { | 233 } else { |
| 231 isEmbeddingFullscreenWidget_ = NO; | 234 isEmbeddingFullscreenWidget_ = NO; |
| 232 contentsNativeView = contents_->GetNativeView(); | 235 contentsNativeView = contents_->GetNativeView(); |
| 233 } | 236 } |
| 234 if (!isEmbeddingFullscreenWidget_ || !blockFullscreenResize_) | 237 |
| 238 if ([self shouldResizeContentView]) |
| 235 [contentsNativeView setFrame:[self frameForContentsView]]; | 239 [contentsNativeView setFrame:[self frameForContentsView]]; |
| 236 | 240 |
| 237 if ([subviews count] == 0) { | 241 if ([subviews count] == 0) { |
| 238 [contentsContainer addSubview:contentsNativeView]; | 242 [contentsContainer addSubview:contentsNativeView]; |
| 239 } else if ([subviews objectAtIndex:0] != contentsNativeView) { | 243 } else if ([subviews objectAtIndex:0] != contentsNativeView) { |
| 240 [contentsContainer replaceSubview:[subviews objectAtIndex:0] | 244 [contentsContainer replaceSubview:[subviews objectAtIndex:0] |
| 241 with:contentsNativeView]; | 245 with:contentsNativeView]; |
| 242 } | 246 } |
| 243 [contentsNativeView setAutoresizingMask:NSViewWidthSizable| | 247 [contentsNativeView setAutoresizingMask:NSViewWidthSizable| |
| 244 NSViewHeightSizable]; | 248 NSViewHeightSizable]; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 rect.width(), static_cast<int>(y / captureSize.width()))); | 367 rect.width(), static_cast<int>(y / captureSize.width()))); |
| 364 } else { | 368 } else { |
| 365 rect.ClampToCenteredSize(gfx::Size( | 369 rect.ClampToCenteredSize(gfx::Size( |
| 366 static_cast<int>(x / captureSize.height()), rect.height())); | 370 static_cast<int>(x / captureSize.height()), rect.height())); |
| 367 } | 371 } |
| 368 } | 372 } |
| 369 | 373 |
| 370 return NSRectFromCGRect(rect.ToCGRect()); | 374 return NSRectFromCGRect(rect.ToCGRect()); |
| 371 } | 375 } |
| 372 | 376 |
| 377 - (BOOL)shouldResizeContentView { |
| 378 return !isEmbeddingFullscreenWidget_ || !blockFullscreenResize_; |
| 379 } |
| 380 |
| 373 @end | 381 @end |
| OLD | NEW |