- Revision
- 232218
- Author
- [email protected]
- Date
- 2018-05-25 17:13:43 -0700 (Fri, 25 May 2018)
Log Message
Setting drawsBackground to YES on a WKView doesn't take effect immediately
https://bugs.webkit.org/show_bug.cgi?id=185885
rdar://problem/39706506
Reviewed by Simon Fraser.
Source/WebCore:
* page/Frame.cpp:
(WebCore::Frame::createView): Always call updateBackgroundRecursively, it handles
invalid colors correctly already.
* page/FrameView.cpp:
(WebCore::FrameView::setTransparent): Call setNeedsLayout() since base background color
and transparent is used to update layers.
(WebCore::FrameView::setBaseBackgroundColor): Ditto.
(WebCore::FrameView::updateBackgroundRecursively): Schedule layout if needed.
* page/FrameView.h:
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::viewHasTransparentBackground const): Use baseBackgroundColor
instead of hardcoding white.
(WebCore::RenderLayerCompositor::rootBackgroundTransparencyChanged): Fixed incorrect changed logging.
Source/WebKit:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _initializeWithConfiguration:]): Removed setBackgroundExtendsBeyondPage(true)
since it is now the default.
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::setDrawsBackground): Make sure updateLayer gets called on the web view
by calling setNeedsDisplay:YES.
(WebKit::WebViewImpl::setBackgroundColor): Ditto.
(WebKit::WebViewImpl::updateLayer): Removed dead code.
* UIProcess/WebPageProxy.h: Make m_backgroundExtendsBeyondPage default to true. WebKit was
always turning this on during WKWebView initializtion, which would cause the scroll
shadow layer to be created, flash black because of no background, then destroyed soon
after once WebKit's message to turn it on got delivered.
* WebProcess/WebPage/WebPage.cpp:
(WebPage::WebPage): Call setBackgroundExtendsBeyondPage earlier to avoid creating the scroll
shadow layer, since backgroundShouldExtendBeyondPage defautls to false in WebCore for WK1.
(WebKit::WebPage::setDrawsBackground): Use updateBackgroundRecursively to propagate the
correct base background color.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (232217 => 232218)
--- trunk/Source/WebCore/ChangeLog 2018-05-26 00:06:08 UTC (rev 232217)
+++ trunk/Source/WebCore/ChangeLog 2018-05-26 00:13:43 UTC (rev 232218)
@@ -1,3 +1,25 @@
+2018-05-25 Timothy Hatcher <[email protected]>
+
+ Setting drawsBackground to YES on a WKView doesn't take effect immediately
+ https://bugs.webkit.org/show_bug.cgi?id=185885
+ rdar://problem/39706506
+
+ Reviewed by Simon Fraser.
+
+ * page/Frame.cpp:
+ (WebCore::Frame::createView): Always call updateBackgroundRecursively, it handles
+ invalid colors correctly already.
+ * page/FrameView.cpp:
+ (WebCore::FrameView::setTransparent): Call setNeedsLayout() since base background color
+ and transparent is used to update layers.
+ (WebCore::FrameView::setBaseBackgroundColor): Ditto.
+ (WebCore::FrameView::updateBackgroundRecursively): Schedule layout if needed.
+ * page/FrameView.h:
+ * rendering/RenderLayerCompositor.cpp:
+ (WebCore::RenderLayerCompositor::viewHasTransparentBackground const): Use baseBackgroundColor
+ instead of hardcoding white.
+ (WebCore::RenderLayerCompositor::rootBackgroundTransparencyChanged): Fixed incorrect changed logging.
+
2018-05-25 Youenn Fablet <[email protected]>
Migrate From-Origin to Cross-Origin-Resource-Policy
Modified: trunk/Source/WebCore/page/Frame.cpp (232217 => 232218)
--- trunk/Source/WebCore/page/Frame.cpp 2018-05-26 00:06:08 UTC (rev 232217)
+++ trunk/Source/WebCore/page/Frame.cpp 2018-05-26 00:13:43 UTC (rev 232218)
@@ -935,8 +935,7 @@
setView(frameView.copyRef());
- if (backgroundColor.isValid())
- frameView->updateBackgroundRecursively(backgroundColor, transparent);
+ frameView->updateBackgroundRecursively(backgroundColor, transparent);
if (isMainFrame)
frameView->setParentVisible(true);
Modified: trunk/Source/WebCore/page/FrameView.cpp (232217 => 232218)
--- trunk/Source/WebCore/page/FrameView.cpp 2018-05-26 00:06:08 UTC (rev 232217)
+++ trunk/Source/WebCore/page/FrameView.cpp 2018-05-26 00:13:43 UTC (rev 232218)
@@ -2894,6 +2894,7 @@
return;
renderView()->compositor().rootBackgroundTransparencyChanged();
+ setNeedsLayout();
}
bool FrameView::hasOpaqueBackground() const
@@ -2909,7 +2910,7 @@
void FrameView::setBaseBackgroundColor(const Color& backgroundColor)
{
bool wasOpaque = m_baseBackgroundColor.isOpaque();
-
+
if (!backgroundColor.isValid())
m_baseBackgroundColor = Color::white;
else
@@ -2919,6 +2920,7 @@
return;
recalculateScrollbarOverlayStyle();
+ setNeedsLayout();
if (m_baseBackgroundColor.isOpaque() != wasOpaque)
renderView()->compositor().rootBackgroundTransparencyChanged();
@@ -2930,6 +2932,8 @@
if (FrameView* view = frame->view()) {
view->setTransparent(transparent);
view->setBaseBackgroundColor(backgroundColor);
+ if (view->needsLayout())
+ view->layoutContext().scheduleLayout();
}
}
}
Modified: trunk/Source/WebCore/page/FrameView.h (232217 => 232218)
--- trunk/Source/WebCore/page/FrameView.h 2018-05-26 00:06:08 UTC (rev 232217)
+++ trunk/Source/WebCore/page/FrameView.h 2018-05-26 00:13:43 UTC (rev 232218)
@@ -187,7 +187,7 @@
WEBCORE_EXPORT Color baseBackgroundColor() const;
WEBCORE_EXPORT void setBaseBackgroundColor(const Color&);
- void updateBackgroundRecursively(const Color&, bool);
+ WEBCORE_EXPORT void updateBackgroundRecursively(const Color&, bool);
enum ExtendedBackgroundModeFlags {
ExtendedBackgroundModeNone = 0,
Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (232217 => 232218)
--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2018-05-26 00:06:08 UTC (rev 232217)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2018-05-26 00:13:43 UTC (rev 232218)
@@ -3084,11 +3084,13 @@
Color documentBackgroundColor = m_renderView.frameView().documentBackgroundColor();
if (!documentBackgroundColor.isValid())
- documentBackgroundColor = Color::white;
+ documentBackgroundColor = m_renderView.frameView().baseBackgroundColor();
+ ASSERT(documentBackgroundColor.isValid());
+
if (backgroundColor)
*backgroundColor = documentBackgroundColor;
-
+
return !documentBackgroundColor.isOpaque();
}
@@ -3120,7 +3122,7 @@
bool isTransparent = viewHasTransparentBackground();
- LOG(Compositing, "RenderLayerCompositor %p rootBackgroundTransparencyChanged. isTransparent=%d, changed=%d", this, isTransparent, m_viewBackgroundIsTransparent == isTransparent);
+ LOG(Compositing, "RenderLayerCompositor %p rootBackgroundTransparencyChanged. isTransparent=%d, changed=%d", this, isTransparent, m_viewBackgroundIsTransparent != isTransparent);
if (m_viewBackgroundIsTransparent == isTransparent)
return;
Modified: trunk/Source/WebKit/ChangeLog (232217 => 232218)
--- trunk/Source/WebKit/ChangeLog 2018-05-26 00:06:08 UTC (rev 232217)
+++ trunk/Source/WebKit/ChangeLog 2018-05-26 00:13:43 UTC (rev 232218)
@@ -1,3 +1,29 @@
+2018-05-25 Timothy Hatcher <[email protected]>
+
+ Setting drawsBackground to YES on a WKView doesn't take effect immediately
+ https://bugs.webkit.org/show_bug.cgi?id=185885
+ rdar://problem/39706506
+
+ Reviewed by Simon Fraser.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _initializeWithConfiguration:]): Removed setBackgroundExtendsBeyondPage(true)
+ since it is now the default.
+ * UIProcess/Cocoa/WebViewImpl.mm:
+ (WebKit::WebViewImpl::setDrawsBackground): Make sure updateLayer gets called on the web view
+ by calling setNeedsDisplay:YES.
+ (WebKit::WebViewImpl::setBackgroundColor): Ditto.
+ (WebKit::WebViewImpl::updateLayer): Removed dead code.
+ * UIProcess/WebPageProxy.h: Make m_backgroundExtendsBeyondPage default to true. WebKit was
+ always turning this on during WKWebView initializtion, which would cause the scroll
+ shadow layer to be created, flash black because of no background, then destroyed soon
+ after once WebKit's message to turn it on got delivered.
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebPage::WebPage): Call setBackgroundExtendsBeyondPage earlier to avoid creating the scroll
+ shadow layer, since backgroundShouldExtendBeyondPage defautls to false in WebCore for WK1.
+ (WebKit::WebPage::setDrawsBackground): Use updateBackgroundRecursively to propagate the
+ correct base background color.
+
2018-05-25 Youenn Fablet <[email protected]>
Migrate From-Origin to Cross-Origin-Resource-Policy
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (232217 => 232218)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2018-05-26 00:06:08 UTC (rev 232217)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2018-05-26 00:13:43 UTC (rev 232218)
@@ -702,8 +702,6 @@
[self _updateAccessibilityEventsEnabled];
#endif
- _page->setBackgroundExtendsBeyondPage(true);
-
if (NSString *applicationNameForUserAgent = configuration.applicationNameForUserAgent)
_page->setApplicationNameForUserAgent(applicationNameForUserAgent);
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (232217 => 232218)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2018-05-26 00:06:08 UTC (rev 232217)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2018-05-26 00:13:43 UTC (rev 232218)
@@ -1393,6 +1393,9 @@
void WebViewImpl::setDrawsBackground(bool drawsBackground)
{
m_page->setDrawsBackground(drawsBackground);
+
+ // Make sure updateLayer gets called on the web view.
+ [m_view setNeedsDisplay:YES];
}
bool WebViewImpl::drawsBackground() const
@@ -1403,6 +1406,9 @@
void WebViewImpl::setBackgroundColor(NSColor *backgroundColor)
{
m_backgroundColor = backgroundColor;
+
+ // Make sure updateLayer gets called on the web view.
+ [m_view setNeedsDisplay:YES];
}
NSColor *WebViewImpl::backgroundColor() const
@@ -1634,12 +1640,6 @@
[m_view layer].backgroundColor = CGColorGetConstantColor(draws ? kCGColorWhite : kCGColorClear);
else
[m_view layer].backgroundColor = [m_backgroundColor CGColor];
-
- // If asynchronous geometry updates have been sent by forceAsyncDrawingAreaSizeUpdate,
- // then subsequent calls to setFrameSize should not result in us waiting for the did
- // udpate response if setFrameSize is called.
- if (frameSizeUpdatesDisabled())
- return;
}
void WebViewImpl::drawRect(CGRect rect)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (232217 => 232218)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2018-05-26 00:06:08 UTC (rev 232217)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2018-05-26 00:13:43 UTC (rev 232218)
@@ -2077,7 +2077,7 @@
bool m_enableVerticalRubberBanding { true };
bool m_enableHorizontalRubberBanding { true };
- bool m_backgroundExtendsBeyondPage { false };
+ bool m_backgroundExtendsBeyondPage { true };
bool m_shouldRecordNavigationSnapshots { false };
bool m_isShowingNavigationGestureSnapshot { false };
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (232217 => 232218)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2018-05-26 00:06:08 UTC (rev 232217)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2018-05-26 00:13:43 UTC (rev 232218)
@@ -461,6 +461,8 @@
m_mainFrame = WebFrame::createWithCoreMainFrame(this, &m_page->mainFrame());
m_drawingArea->updatePreferences(parameters.store);
+ setBackgroundExtendsBeyondPage(parameters.backgroundExtendsBeyondPage);
+
#if ENABLE(GEOLOCATION)
WebCore::provideGeolocationTo(m_page.get(), *new WebGeolocationClient(*this));
#endif
@@ -522,8 +524,6 @@
else
m_scrollbarOverlayStyle = std::optional<ScrollbarOverlayStyle>();
- setBackgroundExtendsBeyondPage(parameters.backgroundExtendsBeyondPage);
-
setTopContentInset(parameters.topContentInset);
m_userAgent = parameters.userAgent;
@@ -2651,9 +2651,10 @@
m_drawsBackground = drawsBackground;
- for (Frame* coreFrame = m_mainFrame->coreFrame(); coreFrame; coreFrame = coreFrame->tree().traverseNext()) {
- if (FrameView* view = coreFrame->view())
- view->setTransparent(!drawsBackground);
+ if (FrameView* frameView = mainFrameView()) {
+ Color backgroundColor = drawsBackground ? Color::white : Color::transparent;
+ bool isTransparent = !drawsBackground;
+ frameView->updateBackgroundRecursively(backgroundColor, isTransparent);
}
m_drawingArea->pageBackgroundTransparencyChanged();