Set background color of WK2's UIScrollView to the pageExtendedBackgroundColor
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Mar 2014 22:48:42 +0000 (22:48 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Mar 2014 22:48:42 +0000 (22:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=129919

Reviewed by Benjamin Poulain.

Source/WebCore:

WK2 needs to be able to ask for the pageExtendedBackgroundColor, so this patch
adds a function to Page that will return it

* WebCore.exp.in:
* page/Page.cpp:
(WebCore::Page::pageExtendedBackgroundColor):
* page/Page.h:
* rendering/RenderLayerCompositor.h:
(WebCore::RenderLayerCompositor::rootExtendedBackgroundColor):

Source/WebKit2:

Make the pageExtendedBackgroundColor part of a RemoteLayerTreeTransaction.
* Shared/mac/RemoteLayerTreeTransaction.h:
(WebKit::RemoteLayerTreeTransaction::pageExtendedBackgroundColor):
(WebKit::RemoteLayerTreeTransaction::setPageExtendedBackgroundColor):
* Shared/mac/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::encode):
(WebKit::RemoteLayerTreeTransaction::decode):

Set the background color of the UIScrollView based on the
pageExtendedBackgroundColor.
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _didCommitLayerTree:WebKit::]):

For the sake of PLATFORM(MAC), continue to support the fact that this color can be
set via a message from the WebProcess or the new RemoteLayerTreeTransaction.
* UIProcess/WebPageProxy.h:

Cache the pageExtendedBackgroundColor as provided by the
RemoteLayerTreeTransaction.
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::didCommitLayerTree):

It’s not necessary to do anything here in non-Mac platforms anymore.
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::pageExtendedBackgroundColorDidChange):

Include the pageExtendedBackgroundColor in the RemoteLayerTreeTransaction.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::willCommitLayerTree):

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

13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/rendering/RenderLayerCompositor.h
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h
Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index de4dc59..307d9a5 100644 (file)
@@ -1,3 +1,20 @@
+2014-03-10  Beth Dakin  <bdakin@apple.com>
+
+        Set background color of WK2's UIScrollView to the pageExtendedBackgroundColor
+        https://bugs.webkit.org/show_bug.cgi?id=129919
+
+        Reviewed by Benjamin Poulain.
+
+        WK2 needs to be able to ask for the pageExtendedBackgroundColor, so this patch 
+        adds a function to Page that will return it
+
+        * WebCore.exp.in:
+        * page/Page.cpp:
+        (WebCore::Page::pageExtendedBackgroundColor):
+        * page/Page.h:
+        * rendering/RenderLayerCompositor.h:
+        (WebCore::RenderLayerCompositor::rootExtendedBackgroundColor):
+
 2014-03-10  Benjamin Poulain  <bpoulain@apple.com>
 
         Generalize unobscured rect to all ports
index 6e8d31a..c962d34 100644 (file)
@@ -1775,6 +1775,7 @@ __ZNK7WebCore4Page14renderTreeSizeEv
 __ZNK7WebCore4Page15visibilityStateEv
 __ZNK7WebCore4Page16hasSeenAnyPluginEv
 __ZNK7WebCore4Page17viewportArgumentsEv
+__ZNK7WebCore4Page27pageExtendedBackgroundColorEv
 __ZNK7WebCore4Page34inLowQualityImageInterpolationModeEv
 __ZNK7WebCore4Page9groupNameEv
 __ZNK7WebCore4Page9pageCountEv
index 0cef459..d1df772 100644 (file)
@@ -1271,6 +1271,19 @@ void Page::removeLayoutMilestones(LayoutMilestones milestones)
     m_requestedLayoutMilestones &= ~milestones;
 }
 
+Color Page::pageExtendedBackgroundColor() const
+{
+    FrameView* frameView = mainFrame().view();
+    if (!frameView)
+        return Color();
+
+    RenderView* renderView = frameView->renderView();
+    if (!renderView)
+        return Color();
+
+    return renderView->compositor().rootExtendedBackgroundColor();
+}
+
 // These are magical constants that might be tweaked over time.
 static double gMinimumPaintedAreaRatio = 0.1;
 static double gMaximumUnpaintedAreaRatio = 0.04;
index 54a52c6..ff206a5 100644 (file)
@@ -62,6 +62,7 @@ class BackForwardClient;
 class Chrome;
 class ChromeClient;
 class ClientRectList;
+class Color;
 class ContextMenuClient;
 class ContextMenuController;
 class Document;
@@ -355,6 +356,8 @@ public:
     int headerHeight() const { return m_headerHeight; }
     int footerHeight() const { return m_footerHeight; }
 
+    Color pageExtendedBackgroundColor() const;
+
     bool isCountingRelevantRepaintedObjects() const;
     void startCountingRelevantRepaintedObjects();
     void resetRelevantPaintedObjectCounter();
index 606e0b7..29ba0a5 100644 (file)
@@ -297,6 +297,7 @@ public:
     void didPaintBacking(RenderLayerBacking*);
 
     void setRootExtendedBackgroundColor(const Color&);
+    Color rootExtendedBackgroundColor() const { return m_rootExtendedBackgroundColor; }
 
 private:
     class OverlapMap;
index 65adcce..32652d7 100644 (file)
@@ -1,3 +1,40 @@
+2014-03-10  Beth Dakin  <bdakin@apple.com>
+
+        Set background color of WK2's UIScrollView to the pageExtendedBackgroundColor
+        https://bugs.webkit.org/show_bug.cgi?id=129919
+
+        Reviewed by Benjamin Poulain.
+
+        Make the pageExtendedBackgroundColor part of a RemoteLayerTreeTransaction.
+        * Shared/mac/RemoteLayerTreeTransaction.h:
+        (WebKit::RemoteLayerTreeTransaction::pageExtendedBackgroundColor):
+        (WebKit::RemoteLayerTreeTransaction::setPageExtendedBackgroundColor):
+        * Shared/mac/RemoteLayerTreeTransaction.mm:
+        (WebKit::RemoteLayerTreeTransaction::encode):
+        (WebKit::RemoteLayerTreeTransaction::decode):
+
+        Set the background color of the UIScrollView based on the 
+        pageExtendedBackgroundColor.
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _didCommitLayerTree:WebKit::]):
+
+        For the sake of PLATFORM(MAC), continue to support the fact that this color can be 
+        set via a message from the WebProcess or the new RemoteLayerTreeTransaction.
+        * UIProcess/WebPageProxy.h:
+
+        Cache the pageExtendedBackgroundColor as provided by the 
+        RemoteLayerTreeTransaction.
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::didCommitLayerTree):
+
+        It’s not necessary to do anything here in non-Mac platforms anymore.
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::pageExtendedBackgroundColorDidChange):
+
+        Include the pageExtendedBackgroundColor in the RemoteLayerTreeTransaction.
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::willCommitLayerTree):
+
 2014-03-10  Benjamin Poulain  <bpoulain@apple.com>
 
         Generalize unobscured rect to all ports
index f7d40e1..f8d9db2 100644 (file)
@@ -161,6 +161,9 @@ public:
 
     WebCore::IntSize contentsSize() const { return m_contentsSize; }
     void setContentsSize(const WebCore::IntSize& size) { m_contentsSize = size; };
+    
+    WebCore::Color pageExtendedBackgroundColor() const { return m_pageExtendedBackgroundColor; }
+    void setPageExtendedBackgroundColor(WebCore::Color color) { m_pageExtendedBackgroundColor = color; }
 
     double pageScaleFactor() const { return m_pageScaleFactor; }
     void setPageScaleFactor(double pageScaleFactor) { m_pageScaleFactor = pageScaleFactor; }
@@ -191,6 +194,7 @@ private:
     Vector<WebCore::GraphicsLayer::PlatformLayerID> m_videoLayerIDsPendingFullscreen;
 
     WebCore::IntSize m_contentsSize;
+    WebCore::Color m_pageExtendedBackgroundColor;
     double m_pageScaleFactor;
     double m_minimumScaleFactor;
     double m_maximumScaleFactor;
index 1656c8a..4103935 100644 (file)
@@ -414,6 +414,7 @@ void RemoteLayerTreeTransaction::encode(IPC::ArgumentEncoder& encoder) const
     encoder << m_videoLayerIDsPendingFullscreen;
 
     encoder << m_contentsSize;
+    encoder << m_pageExtendedBackgroundColor;
     encoder << m_pageScaleFactor;
     encoder << m_minimumScaleFactor;
     encoder << m_maximumScaleFactor;
@@ -464,6 +465,9 @@ bool RemoteLayerTreeTransaction::decode(IPC::ArgumentDecoder& decoder, RemoteLay
 
     if (!decoder.decode(result.m_contentsSize))
         return false;
+    
+    if (!decoder.decode(result.m_pageExtendedBackgroundColor))
+        return false;
 
     if (!decoder.decode(result.m_pageScaleFactor))
         return false;
index 2abcca8..ab90620 100644 (file)
     if (!layerTreeTransaction.scaleWasSetByUIProcess() && ![_scrollView isZooming] && ![_scrollView isZoomBouncing] && ![_scrollView _isAnimatingZoom])
         [_scrollView setZoomScale:layerTreeTransaction.pageScaleFactor()];
 
+    if (UIColor *pageExtendedBackgroundColor = [self _pageExtendedBackgroundColor]) {
+        if ([self _backgroundExtendsBeyondPage])
+            [_scrollView setBackgroundColor:pageExtendedBackgroundColor];
+    }
+
     if (_gestureController)
         _gestureController->setRenderTreeSize(layerTreeTransaction.renderTreeSize());
 
index cf7952b..0878585 100644 (file)
@@ -423,6 +423,9 @@ public:
     WebCore::Color underlayColor() const { return m_underlayColor; }
     void setUnderlayColor(const WebCore::Color&);
 
+    // At this time, m_pageExtendedBackgroundColor can be set via pageExtendedBackgroundColorDidChange() which is a message
+    // from the UIProcess, or by didCommitLayerTree(). When PLATFORM(MAC) adopts UI side compositing, we should get rid of
+    // the message entirely.
     WebCore::Color pageExtendedBackgroundColor() const { return m_pageExtendedBackgroundColor; }
 
     void viewWillStartLiveResize();
index d0259fe..b774f36 100644 (file)
@@ -31,6 +31,7 @@
 #import "DataReference.h"
 #import "NativeWebKeyboardEvent.h"
 #import "PageClient.h"
+#import "RemoteLayerTreeTransaction.h"
 #import "ViewUpdateDispatcherMessages.h"
 #import "WKBrowsingContextControllerInternal.h"
 #import "WebKitSystemInterfaceIOS.h"
@@ -251,6 +252,8 @@ void WebPageProxy::setViewportConfigurationMinimumLayoutSize(const WebCore::IntS
 
 void WebPageProxy::didCommitLayerTree(const WebKit::RemoteLayerTreeTransaction& layerTreeTransaction)
 {
+    m_pageExtendedBackgroundColor = layerTreeTransaction.pageExtendedBackgroundColor();
+
     m_pageClient.didCommitLayerTree(layerTreeTransaction);
 }
 
index 0b50a5a..533c06d 100644 (file)
@@ -872,7 +872,11 @@ Color WebChromeClient::underlayColor() const
 
 void WebChromeClient::pageExtendedBackgroundColorDidChange(Color backgroundColor) const
 {
+#if PLATFORM(MAC)
     m_page->send(Messages::WebPageProxy::PageExtendedBackgroundColorDidChange(backgroundColor));
+#else
+    UNUSED_PARAM(backgroundColor);
+#endif
 }
 
 void WebChromeClient::numWheelEventHandlersChanged(unsigned count)
index a0f30b7..f6795b1 100644 (file)
@@ -2633,6 +2633,7 @@ void WebPage::willCommitLayerTree(RemoteLayerTreeTransaction& layerTransaction)
     layerTransaction.setContentsSize(corePage()->mainFrame().view()->contentsSize());
     layerTransaction.setPageScaleFactor(corePage()->pageScaleFactor());
     layerTransaction.setRenderTreeSize(corePage()->renderTreeSize());
+    layerTransaction.setPageExtendedBackgroundColor(corePage()->pageExtendedBackgroundColor());
 #if PLATFORM(IOS)
     layerTransaction.setLastVisibleContentRectUpdateID(m_lastVisibleContentRectUpdateID);
     layerTransaction.setScaleWasSetByUIProcess(scaleWasSetByUIProcess());