Commit ba268401 authored by tapted's avatar tapted Committed by Commit bot

Mac: Don't allow RenderWidgetHostViewCocoa to participate in autolayout.

WebContentsViewCocoa has a hook to resize all subviews to match its
size. The problem is that the size of a RenderWidgetHostViewCocoa is
allowed to get out of sync with its superview while waiting for a
WebContents paint to be committed. If an autolayout is triggered while
waiting for that commit, the WebContents thinks it's been resized and
spawns a new paint.

Since r424609, for 10.11+, Chrome stopped replacing the NSThemeFrame
(which AppKit does not support) and instead started using
NSFullSizeContentViewWindowMask. This seems to opt the window into
additional autolayout triggers, coming from CoreAnimation. This can
engage the code to "re-sync" the sizes of the RenderWidgetHostViewCocoa
and WebContentsViewCocoa when it wasn't done previously.

To fix, "re-sync" sizes in an override of -setFrameSize: rather than
-resizeSubviewsWithOldSize:. This ensures a re-sync only occurs when the
size of the WebContentsViewCocoa changes.

BUG=655112, 655665, 264207
TBR=sky@chromium.org

Review-Url: https://codereview.chromium.org/2442573003
Cr-Commit-Position: refs/heads/master@{#427290}
parent 66e25541
......@@ -2561,13 +2561,7 @@ IN_PROC_BROWSER_TEST_F(ClickModifierTest, DISABLED_HrefShiftMiddleClickTest) {
RunTest(browser(), GetHrefURL(), modifiers, button, disposition);
}
// TODO(crbug.com/655112): Fails on Mac 10.11 Tests.
#if defined(OS_MACOSX)
#define MAYBE_GetSizeForNewRenderView DISABLED_GetSizeForNewRenderView
#else
#define MAYBE_GetSizeForNewRenderView GetSizeForNewRenderView
#endif
IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_GetSizeForNewRenderView) {
IN_PROC_BROWSER_TEST_F(BrowserTest, GetSizeForNewRenderView) {
// The instant extended NTP has javascript that does not work with
// ui_test_utils::NavigateToURL. The NTP rvh reloads when the browser tries
// to navigate away from the page, which causes the WebContents to end up in
......
......@@ -656,13 +656,20 @@ void WebContentsViewMac::CloseTab() {
webContents->UpdateWebContentsVisibility(viewVisible);
}
// When the subviews require a layout, their size should be reset to the size
// of this view. (It is possible for the size to get out of sync as an
// optimization in preparation for an upcoming WebContentsView resize.
// http://crbug.com/264207)
- (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize {
for (NSView* subview in self.subviews)
[subview setFrame:self.bounds];
// Subviews do not participate in auto layout unless the the size this view
// changes. This allows RenderWidgetHostViewMac::SetBounds(..) to select a
// size of the subview that differs from its superview in preparation for an
// upcoming WebContentsView resize.
// See http://crbug.com/264207 and http://crbug.com/655112.
}
- (void)setFrameSize:(NSSize)newSize {
[super setFrameSize:newSize];
// Perform manual layout of subviews, e.g., when the window size changes.
for (NSView* subview in [self subviews])
[subview setFrame:[self bounds]];
}
- (void)viewWillMoveToWindow:(NSWindow*)newWindow {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment