From d51921d4f3cd2e9aeec45bb25660f1e0a6ed6ba9 Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Mon, 9 May 2011 14:38:17 -0400 Subject: [PATCH] Closes #664. Fixed: web view sizing bug when loading contents prior to adding the view to the display tree. --- AppKit/CPWebView.j | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/AppKit/CPWebView.j b/AppKit/CPWebView.j index f43d6e7bd..b383a36a5 100644 --- a/AppKit/CPWebView.j +++ b/AppKit/CPWebView.j @@ -229,7 +229,8 @@ CPWebViewAppKitScrollMaxPollCount = 3; - (void)viewDidUnhide { - // Catch up on resizing which happened while hidden. + // Sizing cannot properly happen while we're hidden because the iframe is inaccessible. + // So now that it is accessible again, make sure to catch up. [_frameView setFrameSize:[_scrollView contentSize]]; [self _resizeWebFrame]; [self _scheduleContentSizeCheck]; @@ -262,6 +263,14 @@ CPWebViewAppKitScrollMaxPollCount = 3; - (void)_resizeWebFrame { + // When a webview is not in the DOM we can't inspect its contents for sizing information. + // If we try, we might end up setting the fallback frame size which will then become + // somewhat sticky. + if (![self _isVisible]) + { + return; + } + if (_effectiveScrollMode === CPWebViewScrollAppKit) { var visibleRect = [_frameView visibleRect];