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 de4dc59d50c805f2b089f6e25cba08cbd5c36074..307d9a58c01d8cc4024a0bffc27a7ef825bfe742 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 6e8d31ab971274a6a36eba1452342fa327d39e93..c962d345c1c39bdc7d8d1f5581b42a9d188d67a1 100644 (file)
@@ -1775,6 +1775,7 @@ __ZNK7WebCore4Page14renderTreeSizeEv
 __ZNK7WebCore4Page15visibilityStateEv
 __ZNK7WebCore4Page16hasSeenAnyPluginEv
 __ZNK7WebCore4Page17viewportArgumentsEv
+__ZNK7WebCore4Page27pageExtendedBackgroundColorEv
 __ZNK7WebCore4Page34inLowQualityImageInterpolationModeEv
 __ZNK7WebCore4Page9groupNameEv
 __ZNK7WebCore4Page9pageCountEv
index 0cef459e50b5a919113406a2399bf16aa5052a3a..d1df772c017b9a05e2ff8a3b5037445a97280636 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 54a52c65bb4b8a0b13117ddb83cdd26582a96740..ff206a5163bbf3f579c6cb2fedc7338cbbe540e3 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 606e0b7ed56efd429b97e2735869fbeb5939d362..29ba0a5534a6d0b74cb17afceceec8063e072516 100644 (file)
@@ -297,6 +297,7 @@ public:
     void didPaintBacking(RenderLayerBacking*);
 
     void setRootExtendedBackgroundColor(const Color&);
+    Color rootExtendedBackgroundColor() const { return m_rootExtendedBackgroundColor; }
 
 private:
     class OverlapMap;
index 65adcceeb46a7323a5c5ee91bfe260c4e50a0df5..32652d758d6711a5abc48a6632c09b95588418e6 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 f7d40e1f9b13007b20433c614042a603d16327d5..f8d9db2b230056eca6be0271c4c1bcc9d0dd9cfa 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 1656c8a7354263cd73376e8b180bad804be4bf25..4103935f59c7ce66a407a5587ee5075ccb8c3d84 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 2abcca8513cc5bb4942804333e3d1125e7fdd100..ab90620831aec011b9af77d891a366ce13c510b0 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 cf7952b027415f6fdd46d16e929c7bfb86954806..08785856bad82ec88cca978316a56488c05a188b 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 d0259fea225a8ad0f97e9016c1d737bdb3d17527..b774f367fb0262aa3caae7665531c93087432907 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 0b50a5a3c7177041896a5101c6788f6fdeea719b..533c06d3d4a69ee676fa139d07c6f749f9472049 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 a0f30b7af941da13a8334cb282691ca3bfde5ab6..f6795b19abc49a87282cbc411347cd2dfca3601f 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());