Need API to control page underlay color
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Mar 2013 00:47:10 +0000 (00:47 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Mar 2013 00:47:10 +0000 (00:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=110918

Patch by Conrad Shultz <conrad_shultz@apple.com> on 2013-02-28
Reviewed by Simon Fraser.

Source/WebCore:

* page/ChromeClient.h:
(ChromeClient):
Declare underlayColor().

* platform/ScrollbarTheme.h:
(WebCore::ScrollbarTheme::setUpOverhangAreasLayerContents):
Have setUpOverhangAreasLayerContents() take a background color parameter.

* platform/mac/ScrollbarThemeMac.h:
(ScrollbarThemeMac):
Ditto.

* platform/mac/ScrollbarThemeMac.mm:
Include ColorMac.h.
(WebCore::ScrollbarThemeMac::setUpOverhangAreasLayerContents):
Use the passed-in background color, if valid, for the overhang area layer.

* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::updateOverflowControlsLayers):
Get the underlay color from the chrome client and pass it into setUpOverhangAreasLayerContents().

Source/WebKit2:

* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode):
Encode underlayColor.
(WebKit::WebPageCreationParameters::decode):
Decode underlayColor.

* Shared/WebPageCreationParameters.h:
(WebPageCreationParameters):
Add underlayColor member.

* UIProcess/API/mac/WKView.mm:
(-[WKView underlayColor]):
Accessor; retrieves the WebCore::Color from the WebPageProxy and converts it to an NSColor.
(-[WKView setUnderlayColor:]):
Mutator; converts the NSColor to a WebCore::Color and passes it to the WebPageProxy.

* UIProcess/API/mac/WKViewPrivate.h:
Add underlayColor @property.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::setUnderlayColor):
Mutator; dispatches SetUnderlayColor to WebPage.
(WebKit::WebPageProxy::creationParameters):
Set the parameters' underlayColor member appropriately.

* UIProcess/WebPageProxy.h:
Declare new member functions and variable.
(WebKit::WebPageProxy::underlayColor):
Accessor.

* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::underlayColor):
Return the associated WebPage's underlayColor.

* WebProcess/WebCoreSupport/WebChromeClient.h:
(WebChromeClient):
Declare underlayColor().

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
Apply any underlayColor that was supplied as part of the WebPageCreationParameters.

* WebProcess/WebPage/WebPage.h:
Declare new member functions and variable.
(WebKit::WebPage::underlayColor):
Accessor.

* WebProcess/WebPage/WebPage.messages.in:
Add SetUnderlayColor message.

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

18 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/ChromeClient.h
Source/WebCore/platform/ScrollbarTheme.h
Source/WebCore/platform/mac/ScrollbarThemeMac.h
Source/WebCore/platform/mac/ScrollbarThemeMac.mm
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPageCreationParameters.cpp
Source/WebKit2/Shared/WebPageCreationParameters.h
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in

index 64f6ec5..f49c32b 100644 (file)
@@ -1,3 +1,31 @@
+2013-02-28  Conrad Shultz  <conrad_shultz@apple.com>
+
+        Need API to control page underlay color
+        https://bugs.webkit.org/show_bug.cgi?id=110918
+
+        Reviewed by Simon Fraser.
+
+        * page/ChromeClient.h:
+        (ChromeClient):
+        Declare underlayColor().
+
+        * platform/ScrollbarTheme.h:
+        (WebCore::ScrollbarTheme::setUpOverhangAreasLayerContents):
+        Have setUpOverhangAreasLayerContents() take a background color parameter.
+
+        * platform/mac/ScrollbarThemeMac.h:
+        (ScrollbarThemeMac):
+        Ditto.
+
+        * platform/mac/ScrollbarThemeMac.mm:
+        Include ColorMac.h.
+        (WebCore::ScrollbarThemeMac::setUpOverhangAreasLayerContents):
+        Use the passed-in background color, if valid, for the overhang area layer.
+
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::updateOverflowControlsLayers):
+        Get the underlay color from the chrome client and pass it into setUpOverhangAreasLayerContents().
+
 2013-02-28  Beth Dakin  <bdakin@apple.com>
 
         RelevantRepaintedObjects heuristic should ensure there is some coverage in the 
index 5f6ce39..f1ecde8 100644 (file)
@@ -187,6 +187,8 @@ public:
     virtual void print(Frame*) = 0;
     virtual bool shouldRubberBandInDirection(ScrollDirection) const = 0;
 
+    virtual Color underlayColor() const { return Color(); }
+
 #if ENABLE(SQL_DATABASE)
     virtual void exceededDatabaseQuota(Frame*, const String& databaseName, DatabaseDetails) = 0;
 #endif
index 01ab09e..9f8c567 100644 (file)
@@ -90,7 +90,7 @@ public:
     virtual void paintOverhangAreas(ScrollView*, GraphicsContext*, const IntRect&, const IntRect&, const IntRect&) { }
 
 #if USE(ACCELERATED_COMPOSITING) && ENABLE(RUBBER_BANDING)
-    virtual void setUpOverhangAreasLayerContents(GraphicsLayer*) { }
+    virtual void setUpOverhangAreasLayerContents(GraphicsLayer*, const Color&) { }
     virtual void setUpContentShadowLayer(GraphicsLayer*) { }
 #endif
 
index d14da6d..a78cd66 100644 (file)
@@ -82,7 +82,7 @@ protected:
     int scrollbarPartToHIPressedState(ScrollbarPart);
 
 #if !PLATFORM(CHROMIUM) && USE(ACCELERATED_COMPOSITING) && ENABLE(RUBBER_BANDING)
-    virtual void setUpOverhangAreasLayerContents(GraphicsLayer*) OVERRIDE;
+    virtual void setUpOverhangAreasLayerContents(GraphicsLayer*, const Color&) OVERRIDE;
     virtual void setUpContentShadowLayer(GraphicsLayer*) OVERRIDE;
 #endif
 };
index 84fd0fe..6b8483b 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "ScrollbarThemeMac.h"
 
+#include "ColorMac.h"
 #include "ImageBuffer.h"
 #include "GraphicsLayer.h"
 #include "LocalCurrentGraphicsContext.h"
@@ -611,13 +612,12 @@ static RetainPtr<CGColorRef> linenBackgroundColor()
     return adoptCF(CGColorCreateWithPattern(colorSpace.get(), pattern.get(), &alpha));
 }
 
-void ScrollbarThemeMac::setUpOverhangAreasLayerContents(GraphicsLayer* graphicsLayer)
+void ScrollbarThemeMac::setUpOverhangAreasLayerContents(GraphicsLayer* graphicsLayer, const Color& backgroundColor)
 {
     static CGColorRef cachedLinenBackgroundColor = linenBackgroundColor().leakRef();
-
     // We operate on the CALayer directly here, since GraphicsLayer doesn't have the concept
     // of pattern images, and we know that WebCore won't touch this layer.
-    graphicsLayer->platformLayer().backgroundColor = cachedLinenBackgroundColor;
+    graphicsLayer->platformLayer().backgroundColor = backgroundColor.isValid() ? cachedCGColor(backgroundColor, ColorSpaceDeviceRGB) : cachedLinenBackgroundColor;
 }
 
 void ScrollbarThemeMac::setUpContentShadowLayer(GraphicsLayer* graphicsLayer)
index 3e07077..ef89fca 100644 (file)
@@ -2452,7 +2452,7 @@ void RenderLayerCompositor::updateOverflowControlsLayers()
             m_layerForOverhangAreas->setDrawsContent(false);
             m_layerForOverhangAreas->setSize(m_renderView->frameView()->frameRect().size());
 
-            ScrollbarTheme::theme()->setUpOverhangAreasLayerContents(m_layerForOverhangAreas.get());
+            ScrollbarTheme::theme()->setUpOverhangAreasLayerContents(m_layerForOverhangAreas.get(), this->page()->chrome()->client()->underlayColor());
 
             // We want the overhang areas layer to be positioned below the frame contents,
             // so insert it below the clip layer.
index cad98a0..b787396 100644 (file)
@@ -1,3 +1,60 @@
+2013-02-28  Conrad Shultz  <conrad_shultz@apple.com>
+
+        Need API to control page underlay color
+        https://bugs.webkit.org/show_bug.cgi?id=110918
+
+        Reviewed by Simon Fraser.
+
+        * Shared/WebPageCreationParameters.cpp:
+        (WebKit::WebPageCreationParameters::encode):
+        Encode underlayColor.
+        (WebKit::WebPageCreationParameters::decode):
+        Decode underlayColor.
+
+        * Shared/WebPageCreationParameters.h:
+        (WebPageCreationParameters):
+        Add underlayColor member.
+
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView underlayColor]):
+        Accessor; retrieves the WebCore::Color from the WebPageProxy and converts it to an NSColor.
+        (-[WKView setUnderlayColor:]):
+        Mutator; converts the NSColor to a WebCore::Color and passes it to the WebPageProxy.
+
+        * UIProcess/API/mac/WKViewPrivate.h:
+        Add underlayColor @property.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::setUnderlayColor):
+        Mutator; dispatches SetUnderlayColor to WebPage.
+        (WebKit::WebPageProxy::creationParameters):
+        Set the parameters' underlayColor member appropriately.
+
+        * UIProcess/WebPageProxy.h:
+        Declare new member functions and variable.
+        (WebKit::WebPageProxy::underlayColor):
+        Accessor.
+
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::underlayColor):
+        Return the associated WebPage's underlayColor.
+
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+        (WebChromeClient):
+        Declare underlayColor().
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::WebPage):
+        Apply any underlayColor that was supplied as part of the WebPageCreationParameters.
+
+        * WebProcess/WebPage/WebPage.h:
+        Declare new member functions and variable.
+        (WebKit::WebPage::underlayColor):
+        Accessor.
+
+        * WebProcess/WebPage/WebPage.messages.in:
+        Add SetUnderlayColor message.
+
 2013-02-28  Anders Carlsson  <andersca@apple.com>
 
         Add the notion of an allowed connection to SessionStorageNamespace
index ef2adff..c165552 100644 (file)
@@ -43,6 +43,7 @@ void WebPageCreationParameters::encode(CoreIPC::ArgumentEncoder& encoder) const
     encoder << pageGroupData;
     encoder << drawsBackground;
     encoder << drawsTransparentBackground;
+    encoder << underlayColor;
     encoder << areMemoryCacheClientCallsEnabled;
     encoder << useFixedLayout;
     encoder << fixedLayoutSize;
@@ -87,6 +88,8 @@ bool WebPageCreationParameters::decode(CoreIPC::ArgumentDecoder& decoder, WebPag
         return false;
     if (!decoder.decode(parameters.drawsTransparentBackground))
         return false;
+    if (!decoder.decode(parameters.underlayColor))
+        return false;
     if (!decoder.decode(parameters.areMemoryCacheClientCallsEnabled))
         return false;
     if (!decoder.decode(parameters.useFixedLayout))
index b7859bf..f0edefe 100644 (file)
@@ -62,6 +62,8 @@ struct WebPageCreationParameters {
     bool drawsBackground;
     bool drawsTransparentBackground;
 
+    WebCore::Color underlayColor;
+
     bool areMemoryCacheClientCallsEnabled;
 
     bool useFixedLayout;
index 493125b..ed548c6 100644 (file)
@@ -3292,6 +3292,20 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path)
     _data->_page->setMainFrameIsScrollable(!expandsToFit);
 }
 
+- (NSColor *)underlayColor
+{
+    Color webColor = _data->_page->underlayColor();
+    if (!webColor.isValid())
+        return nil;
+
+    return nsColor(webColor);
+}
+
+- (void)setUnderlayColor:(NSColor *)underlayColor
+{
+    _data->_page->setUnderlayColor(colorFromNSColor(underlayColor));
+}
+
 - (NSView*)fullScreenPlaceholderView
 {
 #if ENABLE(FULLSCREEN_API)
index 705b59d..6f93e1e 100644 (file)
@@ -53,6 +53,8 @@
 @property (readwrite) CGFloat minimumLayoutWidth;
 @property (readwrite) CGFloat minimumWidthForAutoLayout;
 
+@property(copy, nonatomic) NSColor *underlayColor;
+
 - (NSView*)fullScreenPlaceholderView;
 
 - (void)beginDeferringViewInWindowChanges;
index ab17926..2f206dd 100644 (file)
@@ -858,6 +858,17 @@ void WebPageProxy::setDrawsTransparentBackground(bool drawsTransparentBackground
         m_process->send(Messages::WebPage::SetDrawsTransparentBackground(drawsTransparentBackground), m_pageID);
 }
 
+void WebPageProxy::setUnderlayColor(const Color& color)
+{
+    if (m_underlayColor == color)
+        return;
+
+    m_underlayColor = color;
+
+    if (isValid())
+        m_process->send(Messages::WebPage::SetUnderlayColor(color), m_pageID);
+}
+
 void WebPageProxy::viewWillStartLiveResize()
 {
     if (!isValid())
@@ -3834,6 +3845,7 @@ WebPageCreationParameters WebPageProxy::creationParameters() const
     parameters.pageGroupData = m_pageGroup->data();
     parameters.drawsBackground = m_drawsBackground;
     parameters.drawsTransparentBackground = m_drawsTransparentBackground;
+    parameters.underlayColor = m_underlayColor;
     parameters.areMemoryCacheClientCallsEnabled = m_areMemoryCacheClientCallsEnabled;
     parameters.useFixedLayout = m_useFixedLayout;
     parameters.fixedLayoutSize = m_fixedLayoutSize;
index 66d95fa..b8c8e45 100644 (file)
@@ -318,6 +318,9 @@ public:
     bool drawsTransparentBackground() const { return m_drawsTransparentBackground; }
     void setDrawsTransparentBackground(bool);
 
+    WebCore::Color underlayColor() const { return m_underlayColor; }
+    void setUnderlayColor(const WebCore::Color&);
+
     void viewWillStartLiveResize();
     void viewWillEndLiveResize();
 
@@ -1136,6 +1139,8 @@ private:
     bool m_drawsBackground;
     bool m_drawsTransparentBackground;
 
+    WebCore::Color m_underlayColor;
+
     bool m_areMemoryCacheClientCallsEnabled;
 
     bool m_useFixedLayout;
index 61390c6..4697c06 100644 (file)
@@ -785,6 +785,11 @@ bool WebChromeClient::shouldRubberBandInDirection(WebCore::ScrollDirection direc
     return true;
 }
 
+Color WebChromeClient::underlayColor() const
+{
+    return m_page->underlayColor();
+}
+
 void WebChromeClient::numWheelEventHandlersChanged(unsigned count)
 {
     m_page->numWheelEventHandlersChanged(count);
index 76deca4..27294b2 100644 (file)
@@ -212,6 +212,8 @@ private:
     virtual void notifyScrollerThumbIsVisibleInRect(const WebCore::IntRect&) OVERRIDE;
     virtual void recommendedScrollbarStyleDidChange(int32_t newStyle) OVERRIDE;
     virtual bool shouldRubberBandInDirection(WebCore::ScrollDirection) const OVERRIDE;
+
+    virtual WebCore::Color underlayColor() const OVERRIDE;
     
     virtual void numWheelEventHandlersChanged(unsigned) OVERRIDE;
 
index 12fb402..c4c1d48 100644 (file)
@@ -347,6 +347,8 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
     setDrawsBackground(parameters.drawsBackground);
     setDrawsTransparentBackground(parameters.drawsTransparentBackground);
 
+    setUnderlayColor(parameters.underlayColor);
+
     setPaginationMode(parameters.paginationMode);
     setPaginationBehavesLikeColumns(parameters.paginationBehavesLikeColumns);
     setPageLength(parameters.pageLength);
index 7d1a8a0..96d5610 100644 (file)
@@ -328,6 +328,9 @@ public:
     bool drawsBackground() const { return m_drawsBackground; }
     bool drawsTransparentBackground() const { return m_drawsTransparentBackground; }
 
+    void setUnderlayColor(const WebCore::Color& color) { m_underlayColor = color; }
+    WebCore::Color underlayColor() const { return m_underlayColor; }
+
     void stopLoading();
     void stopLoadingFrame(uint64_t frameID);
     void setDefersLoading(bool deferLoading);
@@ -803,6 +806,8 @@ private:
     bool m_drawsBackground;
     bool m_drawsTransparentBackground;
 
+    WebCore::Color m_underlayColor;
+
     bool m_isInRedo;
     bool m_isClosed;
 
index 5ccefa2..12620ba 100644 (file)
@@ -29,6 +29,8 @@ messages -> WebPage LegacyReceiver {
     SetDrawsBackground(bool drawsBackground)
     SetDrawsTransparentBackground(bool drawsTransparentBackground)
 
+    SetUnderlayColor(WebCore::Color color)
+
     ViewWillStartLiveResize()
     ViewWillEndLiveResize()