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 <Carbon/Carbon.h> | 5 #import <Carbon/Carbon.h> |
6 | 6 |
7 #import "content/browser/web_contents/web_contents_view_mac.h" | 7 #import "content/browser/web_contents/web_contents_view_mac.h" |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 | 649 |
650 - (void)updateWebContentsVisibility { | 650 - (void)updateWebContentsVisibility { |
651 WebContentsImpl* webContents = [self webContents]; | 651 WebContentsImpl* webContents = [self webContents]; |
652 if (!webContents || webContents->IsBeingDestroyed()) | 652 if (!webContents || webContents->IsBeingDestroyed()) |
653 return; | 653 return; |
654 | 654 |
655 const bool viewVisible = [self window] && ![self isHiddenOrHasHiddenAncestor]; | 655 const bool viewVisible = [self window] && ![self isHiddenOrHasHiddenAncestor]; |
656 webContents->UpdateWebContentsVisibility(viewVisible); | 656 webContents->UpdateWebContentsVisibility(viewVisible); |
657 } | 657 } |
658 | 658 |
659 // When the subviews require a layout, their size should be reset to the size | |
660 // of this view. (It is possible for the size to get out of sync as an | |
661 // optimization in preparation for an upcoming WebContentsView resize. | |
662 // http://crbug.com/264207) | |
663 - (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize { | 659 - (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize { |
664 for (NSView* subview in self.subviews) | 660 // Subviews do not participate in auto layout unless the the size this view |
665 [subview setFrame:self.bounds]; | 661 // changes. This allows RenderWidgetHostViewMac::SetBounds(..) to select a |
| 662 // size of the subview that differs from its superview in preparation for an |
| 663 // upcoming WebContentsView resize. |
| 664 // See http://crbug.com/264207 and http://crbug.com/655112. |
| 665 } |
| 666 |
| 667 - (void)setFrameSize:(NSSize)newSize { |
| 668 [super setFrameSize:newSize]; |
| 669 |
| 670 // Perform manual layout of subviews, e.g., when the window size changes. |
| 671 for (NSView* subview in [self subviews]) |
| 672 [subview setFrame:[self bounds]]; |
666 } | 673 } |
667 | 674 |
668 - (void)viewWillMoveToWindow:(NSWindow*)newWindow { | 675 - (void)viewWillMoveToWindow:(NSWindow*)newWindow { |
669 NSWindow* oldWindow = [self window]; | 676 NSWindow* oldWindow = [self window]; |
670 | 677 |
671 NSNotificationCenter* notificationCenter = | 678 NSNotificationCenter* notificationCenter = |
672 [NSNotificationCenter defaultCenter]; | 679 [NSNotificationCenter defaultCenter]; |
673 | 680 |
674 // Occlusion is highly undesirable for browser tests, since it will | 681 // Occlusion is highly undesirable for browser tests, since it will |
675 // flakily change test behavior. | 682 // flakily change test behavior. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 | 718 |
712 - (void)viewDidHide { | 719 - (void)viewDidHide { |
713 [self updateWebContentsVisibility]; | 720 [self updateWebContentsVisibility]; |
714 } | 721 } |
715 | 722 |
716 - (void)viewDidUnhide { | 723 - (void)viewDidUnhide { |
717 [self updateWebContentsVisibility]; | 724 [self updateWebContentsVisibility]; |
718 } | 725 } |
719 | 726 |
720 @end | 727 @end |
OLD | NEW |