| Index: chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.mm
|
| diff --git a/chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.mm b/chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.mm
|
| index 706f3709916b2682b5b212f43e863c7d9a69f320..5bf329811640f3fc8f40d4084df3f1609dbce99f 100644
|
| --- a/chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.mm
|
| +++ b/chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.mm
|
| @@ -71,9 +71,9 @@ class FullscreenObserver : public WebContentsObserver {
|
|
|
| @interface TabContentsController (TabContentsContainerViewDelegate)
|
| - (BOOL)contentsInFullscreenCaptureMode;
|
| -// Computes and returns the frame to use for the contents view within the
|
| -// container view.
|
| -- (NSRect)frameForContentsView;
|
| +// Computes and returns the frame to use for the contents view using the size of
|
| +// |container| as the target size.
|
| +- (NSRect)frameForContentsViewIn:(NSView*)container;
|
|
|
| // Returns YES if the content view should be resized.
|
| - (BOOL)shouldResizeContentView;
|
| @@ -130,7 +130,7 @@ class FullscreenObserver : public WebContentsObserver {
|
| }
|
|
|
| ScopedCAActionDisabler disabler;
|
| - [contentsView setFrame:[delegate_ frameForContentsView]];
|
| + [contentsView setFrame:[delegate_ frameForContentsViewIn:self]];
|
| }
|
|
|
| // Update the background layer's color whenever the view needs to repaint.
|
| @@ -217,18 +217,10 @@ class FullscreenObserver : public WebContentsObserver {
|
| [self setView:view];
|
| }
|
|
|
| -- (void)ensureContentsSizeDoesNotChange {
|
| - NSView* contentsContainer = [self view];
|
| - NSArray* subviews = [contentsContainer subviews];
|
| - if ([subviews count] > 0) {
|
| - NSView* currentSubview = [subviews objectAtIndex:0];
|
| - [currentSubview setAutoresizingMask:NSViewNotSizable];
|
| - }
|
| -}
|
| -
|
| -- (void)ensureContentsVisible {
|
| +- (void)ensureContentsVisibleInSuperview:(NSView*)superview {
|
| if (!contents_)
|
| return;
|
| +
|
| ScopedCAActionDisabler disabler;
|
| NSView* contentsContainer = [self view];
|
| NSArray* subviews = [contentsContainer subviews];
|
| @@ -244,7 +236,7 @@ class FullscreenObserver : public WebContentsObserver {
|
| }
|
|
|
| if ([self shouldResizeContentView])
|
| - [contentsNativeView setFrame:[self frameForContentsView]];
|
| + [contentsNativeView setFrame:[self frameForContentsViewIn:superview]];
|
|
|
| if ([subviews count] == 0) {
|
| [contentsContainer addSubview:contentsNativeView];
|
| @@ -252,6 +244,10 @@ class FullscreenObserver : public WebContentsObserver {
|
| [contentsContainer replaceSubview:[subviews objectAtIndex:0]
|
| with:contentsNativeView];
|
| }
|
| +
|
| + [contentsNativeView setAutoresizingMask:NSViewNotSizable];
|
| + [contentsContainer setFrame:[superview bounds]];
|
| + [superview addSubview:contentsContainer];
|
| [contentsNativeView setAutoresizingMask:NSViewWidthSizable|
|
| NSViewHeightSizable];
|
|
|
| @@ -276,8 +272,10 @@ class FullscreenObserver : public WebContentsObserver {
|
|
|
| content::RenderWidgetHostView* const fullscreenView =
|
| contents_->GetFullscreenRenderWidgetHostView();
|
| - if (fullscreenView)
|
| - [fullscreenView->GetNativeView() setFrame:[self frameForContentsView]];
|
| + if (fullscreenView) {
|
| + [fullscreenView->GetNativeView()
|
| + setFrame:[self frameForContentsViewIn:[self view]]];
|
| + }
|
| }
|
|
|
| - (void)changeWebContents:(WebContents*)newContents {
|
| @@ -329,14 +327,14 @@ class FullscreenObserver : public WebContentsObserver {
|
| // the view is different.
|
| if ([self webContents] != updatedContents) {
|
| [self changeWebContents:updatedContents];
|
| - [self ensureContentsVisible];
|
| + [self ensureContentsVisibleInSuperview:[[self view] superview]];
|
| }
|
| }
|
|
|
| - (void)toggleFullscreenWidget:(BOOL)enterFullscreen {
|
| isEmbeddingFullscreenWidget_ = enterFullscreen &&
|
| contents_ && contents_->GetFullscreenRenderWidgetHostView();
|
| - [self ensureContentsVisible];
|
| + [self ensureContentsVisibleInSuperview:[[self view] superview]];
|
| }
|
|
|
| - (BOOL)contentsInFullscreenCaptureMode {
|
| @@ -353,11 +351,8 @@ class FullscreenObserver : public WebContentsObserver {
|
| return YES;
|
| }
|
|
|
| -- (NSRect)frameForContentsView {
|
| - const NSSize containerSize = [[self view] frame].size;
|
| - gfx::Rect rect;
|
| - rect.set_width(containerSize.width);
|
| - rect.set_height(containerSize.height);
|
| +- (NSRect)frameForContentsViewIn:(NSView*)container {
|
| + gfx::Rect rect([container bounds]);
|
|
|
| // In most cases, the contents view is simply sized to fill the container
|
| // view's bounds. Only WebContentses that are in fullscreen mode and being
|
|
|