WKScrollView background color does not match WKWebView before content is loaded.
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Apr 2019 18:51:28 +0000 (18:51 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Apr 2019 18:51:28 +0000 (18:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196745
rdar://problem/49750810

Reviewed by Megan Gardner.

* UIProcess/API/Cocoa/WKWebView.mm:
(scrollViewBackgroundColor): Default to _contentView.backgroundColor on invalid base color.
(-[WKWebView _processDidExit]): Reset to _contentView.backgroundColor.
(-[WKWebView setBackgroundColor:]): Call _updateScrollViewBackground since it can use
_contentView.backgroundColor and it has changed.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244142 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

index 063c8b8..58de1a1 100644 (file)
@@ -1,3 +1,17 @@
+2019-04-10  Timothy Hatcher  <timothy@apple.com>
+
+        WKScrollView background color does not match WKWebView before content is loaded.
+        https://bugs.webkit.org/show_bug.cgi?id=196745
+        rdar://problem/49750810
+
+        Reviewed by Megan Gardner.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (scrollViewBackgroundColor): Default to _contentView.backgroundColor on invalid base color.
+        (-[WKWebView _processDidExit]): Reset to _contentView.backgroundColor.
+        (-[WKWebView setBackgroundColor:]): Call _updateScrollViewBackground since it can use
+        _contentView.backgroundColor and it has changed.
+
 2019-04-10  Megan Gardner  <megan_gardner@apple.com>
 
         Fix text autoscrolling when typing in modern webkit
index 69a6a30..c9e098d 100644 (file)
@@ -1697,7 +1697,7 @@ static WebCore::Color scrollViewBackgroundColor(WKWebView *webView)
     WebCore::Color color = baseScrollViewBackgroundColor(webView);
 
     if (!color.isValid())
-        color = WebCore::Color::white;
+        color = [webView->_contentView backgroundColor].CGColor;
 
     CGFloat zoomScale = contentZoomScale(webView);
     CGFloat minimumZoomScale = [webView->_scrollView minimumZoomScale];
@@ -1862,7 +1862,7 @@ static WebCore::Color scrollViewBackgroundColor(WKWebView *webView)
     [self _processWillSwapOrDidExit];
 
     [_contentView setFrame:self.bounds];
-    [_scrollView setBackgroundColor:[UIColor whiteColor]];
+    [_scrollView setBackgroundColor:[_contentView backgroundColor]];
     [_scrollView setContentOffset:[self _initialContentOffsetForScrollView]];
     [_scrollView setZoomScale:1];
     _gestureController = nullptr;
@@ -2541,6 +2541,7 @@ static WebCore::FloatPoint constrainContentOffset(WebCore::FloatPoint contentOff
 {
     [super setBackgroundColor:backgroundColor];
     [_contentView setBackgroundColor:backgroundColor];
+    [self _updateScrollViewBackground];
 }
 
 - (BOOL)_allowsDoubleTapGestures