[WPE] Add API for webview background color configuration
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Feb 2019 09:55:42 +0000 (09:55 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Feb 2019 09:55:42 +0000 (09:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192305

Source/WebCore:

Reviewed by Michael Catanzaro.

Adapt the FrameView API to allow a default non-white background color.

* page/Frame.cpp:
(WebCore::Frame::createView): Replace isTransparent argument with a background color one.
* page/Frame.h:
* page/FrameView.cpp:
(WebCore::FrameView::recalculateBaseBackgroundColor): Use Color::transparent if m_isTransparent is true.
(WebCore::FrameView::updateBackgroundRecursively): Allow the fallback background color to be non-white, this is
used only in non-dark-mode-css build configurations.
* page/FrameView.h:
* testing/Internals.cpp:
(WebCore::Internals::setViewIsTransparent): Use Color::transparent if transparent is true.

Source/WebKit:

Reviewed by Michael Catanzaro.

In the case of WPE we need to send the background color to the web process to be used as the background color of
the page. This patch adapts the GTK+ implementation to do the same, since it's a lot simpler. The patch also
removes the SetDrawsBackground message in favor of the new SetBackgroundColor message that receives an optional
color.

* PlatformWPE.cmake: Add new WPE API for WebKitColor boxed type.
* Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
(WebKit::CoordinatedGraphicsScene::paintToCurrentGLContext): Remove background rendering and opacity handling.
* Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h:
* Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
(WebKit::ThreadedCompositor::renderLayerTree): Remove drawsBakground and always clear the context with
transparent color.
* Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode const): Replace drawsBackground with backgroundColor.
(WebKit::WebPageCreationParameters::decode): Ditto.
* Shared/WebPageCreationParameters.h:
* SourcesWPE.txt:
* UIProcess/API/glib/WebKitWebView.cpp:
* UIProcess/API/gtk/WebKitWebViewGtk.cpp:
(webkit_web_view_set_background_color):
(webkit_web_view_get_background_color):
* UIProcess/API/wpe/WebKitColor.cpp: Added.
(webkit_color_copy):
(webkit_color_free):
(webkitColorToWebCoreColor):
(webkitColorFillFromWebCoreColor):
(webkit_color_parse):
* UIProcess/API/wpe/WebKitColor.h: Added.
* UIProcess/API/wpe/WebKitColorPrivate.h: Added.
* UIProcess/API/wpe/WebKitWebView.h: Implement webkit_web_view_set_background_color API.
* UIProcess/API/wpe/WebKitWebViewWPE.cpp: Ditto.
(webkit_web_view_set_background_color):
(webkit_web_view_get_background_color):
* UIProcess/API/wpe/docs/wpe-0.1-sections.txt: Add new symbols.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::setDrawsBackground): Set a transparent background color when false is passed.
(WebKit::WebPageProxy::setBackgroundColor): Send background color to the WebProcess.
(WebKit::WebPageProxy::creationParameters): Replace drawsBackground with backgroundColor.
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::drawsBackground const):
(WebKit::WebPageProxy::backgroundColor const):
* UIProcess/cairo/BackingStoreCairo.cpp:
(WebKit::BackingStore::incorporateUpdate): Remove GTK+ code to handle background color.
* UIProcess/gtk/AcceleratedBackingStore.cpp:
* UIProcess/gtk/AcceleratedBackingStore.h: Make paint() pure virtual and remove the implementation.
* UIProcess/gtk/AcceleratedBackingStoreWayland.cpp:
(WebKit::AcceleratedBackingStoreWayland::paint): Dot not call AcceleratedBackingStore::paint() now that is pure virtual.
* UIProcess/gtk/AcceleratedBackingStoreX11.cpp:
(WebKit::AcceleratedBackingStoreX11::paint): Ditto.
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::transitionToCommittedForNewPage): Use background color as provided by the
UIProcess when creating the FrameView.
* WebProcess/WebPage/AcceleratedDrawingArea.cpp:
* WebProcess/WebPage/AcceleratedDrawingArea.h:
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
* WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
(WebKit::ThreadedCoordinatedLayerTreeHost::setIsDiscardable):
* WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h:
* WebProcess/WebPage/DrawingArea.h:
* WebProcess/WebPage/DrawingAreaImpl.cpp:
(WebKit::DrawingAreaImpl::display): Remove special case for transparent background.
* WebProcess/WebPage/LayerTreeHost.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setBackgroundColor): New API for background color configuration. Proxies to FrameView and DrawingArea.
* WebProcess/WebPage/WebPage.h:
(WebKit::WebPage::backgroundColor const): Read-only access to the current background color.
* WebProcess/WebPage/WebPage.messages.in: Replace SetDrawsBackground message with SetBackgroundColor.

Source/WebKitLegacy/win:

Patch by Philippe Normand <pnormand@igalia.com> on 2019-02-26
Reviewed by Michael Catanzaro.

* WebCoreSupport/WebFrameLoaderClient.cpp:
(WebFrameLoaderClient::transitionToCommittedForNewPage): Create
FrameView with background color.

Tools:

Patch by Philippe Normand <pnormand@igalia.com> on 2019-02-26
Reviewed by Michael Catanzaro.

* MiniBrowser/wpe/main.cpp:
(main): Add a new option to configure the webview background
color. Example: --bg-color=transparent.
* TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp:
(testWebViewBackgroundColor): Enable background color API tests for WPE.
(beforeAll): Ditto.

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

53 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/Frame.cpp
Source/WebCore/page/Frame.h
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameView.h
Source/WebCore/testing/Internals.cpp
Source/WebKit/ChangeLog
Source/WebKit/PlatformWPE.cmake
Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp
Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h
Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp
Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h
Source/WebKit/Shared/WebPageCreationParameters.cpp
Source/WebKit/Shared/WebPageCreationParameters.h
Source/WebKit/SourcesWPE.txt
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
Source/WebKit/UIProcess/API/gtk/WebKitWebViewGtk.cpp
Source/WebKit/UIProcess/API/wpe/WebKitColor.cpp [new file with mode: 0644]
Source/WebKit/UIProcess/API/wpe/WebKitColor.h [new file with mode: 0644]
Source/WebKit/UIProcess/API/wpe/WebKitColorPrivate.h [new file with mode: 0644]
Source/WebKit/UIProcess/API/wpe/WebKitWebView.h
Source/WebKit/UIProcess/API/wpe/WebKitWebViewWPE.cpp
Source/WebKit/UIProcess/API/wpe/docs/wpe-0.1-sections.txt
Source/WebKit/UIProcess/API/wpe/docs/wpe-docs.sgml
Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/cairo/BackingStoreCairo.cpp
Source/WebKit/UIProcess/gtk/AcceleratedBackingStore.cpp
Source/WebKit/UIProcess/gtk/AcceleratedBackingStore.h
Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreWayland.cpp
Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreX11.cpp
Source/WebKit/UIProcess/win/WebView.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.cpp
Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.h
Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp
Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h
Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp
Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h
Source/WebKit/WebProcess/WebPage/DrawingArea.h
Source/WebKit/WebProcess/WebPage/DrawingAreaImpl.cpp
Source/WebKit/WebProcess/WebPage/LayerTreeHost.h
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/WebPage.messages.in
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKitLegacy/win/WebFrame.cpp
Tools/ChangeLog
Tools/MiniBrowser/wpe/main.cpp
Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp

index e5df921..2cb6e2b 100644 (file)
@@ -1,3 +1,23 @@
+2019-02-26  Philippe Normand  <pnormand@igalia.com> and Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [WPE] Add API for webview background color configuration
+        https://bugs.webkit.org/show_bug.cgi?id=192305
+
+        Reviewed by Michael Catanzaro.
+
+        Adapt the FrameView API to allow a default non-white background color.
+
+        * page/Frame.cpp:
+        (WebCore::Frame::createView): Replace isTransparent argument with a background color one.
+        * page/Frame.h:
+        * page/FrameView.cpp:
+        (WebCore::FrameView::recalculateBaseBackgroundColor): Use Color::transparent if m_isTransparent is true.
+        (WebCore::FrameView::updateBackgroundRecursively): Allow the fallback background color to be non-white, this is
+        used only in non-dark-mode-css build configurations.
+        * page/FrameView.h:
+        * testing/Internals.cpp:
+        (WebCore::Internals::setViewIsTransparent): Use Color::transparent if transparent is true.
+
 2019-02-25  Yongjun Zhang  <yongjun_zhang@apple.com>
 
         scalableNativeWebpageParameters() is not preserved on new page navigation.
index d8aeb2f..6e74ec7 100644 (file)
@@ -934,7 +934,7 @@ RefPtr<Range> Frame::rangeForPoint(const IntPoint& framePoint)
     return nullptr;
 }
 
-void Frame::createView(const IntSize& viewportSize, bool transparent,
+void Frame::createView(const IntSize& viewportSize, const Optional<Color>& backgroundColor,
     const IntSize& fixedLayoutSize, const IntRect& fixedVisibleContentRect,
     bool useFixedLayout, ScrollbarMode horizontalScrollbarMode, bool horizontalLock,
     ScrollbarMode verticalScrollbarMode, bool verticalLock)
@@ -965,7 +965,7 @@ void Frame::createView(const IntSize& viewportSize, bool transparent,
 
     setView(frameView.copyRef());
 
-    frameView->updateBackgroundRecursively(transparent);
+    frameView->updateBackgroundRecursively(backgroundColor);
 
     if (isMainFrame)
         frameView->setParentVisible(true);
index 83dc483..6c0d84a 100644 (file)
@@ -129,7 +129,7 @@ public:
     WEBCORE_EXPORT void initWithSimpleHTMLDocument(const String& style, const URL&);
 #endif
     WEBCORE_EXPORT void setView(RefPtr<FrameView>&&);
-    WEBCORE_EXPORT void createView(const IntSize&, bool transparent,
+    WEBCORE_EXPORT void createView(const IntSize&, const Optional<Color>& backgroundColor,
         const IntSize& fixedLayoutSize, const IntRect& fixedVisibleContentRect,
         bool useFixedLayout = false, ScrollbarMode = ScrollbarAuto, bool horizontalLock = false,
         ScrollbarMode = ScrollbarAuto, bool verticalLock = false);
index 9b24777..e18827f 100644 (file)
@@ -398,7 +398,10 @@ void FrameView::recalculateBaseBackgroundColor()
         return;
 
     m_usesDarkAppearance = usingDarkAppearance;
-    updateBackgroundRecursively(m_isTransparent);
+    Optional<Color> backgroundColor;
+    if (m_isTransparent)
+        backgroundColor = Color(Color::transparent);
+    updateBackgroundRecursively(backgroundColor);
 }
 #endif
 
@@ -2993,18 +2996,18 @@ void FrameView::setBaseBackgroundColor(const Color& backgroundColor)
     setNeedsCompositingConfigurationUpdate();
 }
 
-void FrameView::updateBackgroundRecursively(bool transparent)
+void FrameView::updateBackgroundRecursively(const Optional<Color>& backgroundColor)
 {
 #if ENABLE(DARK_MODE_CSS) && PLATFORM(MAC)
-    Color backgroundColor = transparent ? Color::transparent : RenderTheme::singleton().systemColor(CSSValueAppleSystemControlBackground, styleColorOptions());
+    Color baseBackgroundColor = backgroundColor.valueOr(RenderTheme::singleton().systemColor(CSSValueAppleSystemControlBackground, styleColorOptions()));
 #else
-    Color backgroundColor = transparent ? Color::transparent : Color::white;
+    Color baseBackgroundColor = backgroundColor.valueOr(Color::white);
 #endif
 
     for (auto* frame = m_frame.ptr(); frame; frame = frame->tree().traverseNext(m_frame.ptr())) {
         if (FrameView* view = frame->view()) {
-            view->setTransparent(transparent);
-            view->setBaseBackgroundColor(backgroundColor);
+            view->setTransparent(!baseBackgroundColor.isVisible());
+            view->setBaseBackgroundColor(baseBackgroundColor);
             if (view->needsLayout())
                 view->layoutContext().scheduleLayout();
         }
index e0d1878..c3f8843 100644 (file)
@@ -192,7 +192,7 @@ public:
 
     WEBCORE_EXPORT Color baseBackgroundColor() const;
     WEBCORE_EXPORT void setBaseBackgroundColor(const Color&);
-    WEBCORE_EXPORT void updateBackgroundRecursively(bool);
+    WEBCORE_EXPORT void updateBackgroundRecursively(const Optional<Color>& backgroundColor);
 
     enum ExtendedBackgroundModeFlags {
         ExtendedBackgroundModeNone          = 0,
index cf8a685..a0c3359 100644 (file)
@@ -1714,7 +1714,10 @@ ExceptionOr<void> Internals::setViewIsTransparent(bool transparent)
     Document* document = contextDocument();
     if (!document || !document->view())
         return Exception { InvalidAccessError };
-    document->view()->updateBackgroundRecursively(transparent);
+    Optional<Color> backgroundColor;
+    if (transparent)
+        backgroundColor = Color(Color::transparent);
+    document->view()->updateBackgroundRecursively(backgroundColor);
     return { };
 }
 
index a07b747..da6bd5b 100644 (file)
@@ -1,3 +1,80 @@
+2019-02-26  Philippe Normand <pnormand@igalia.com> and Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [WPE] Add API for webview background color configuration
+        https://bugs.webkit.org/show_bug.cgi?id=192305
+
+        Reviewed by Michael Catanzaro.
+
+        In the case of WPE we need to send the background color to the web process to be used as the background color of
+        the page. This patch adapts the GTK+ implementation to do the same, since it's a lot simpler. The patch also
+        removes the SetDrawsBackground message in favor of the new SetBackgroundColor message that receives an optional
+        color.
+
+        * PlatformWPE.cmake: Add new WPE API for WebKitColor boxed type.
+        * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
+        (WebKit::CoordinatedGraphicsScene::paintToCurrentGLContext): Remove background rendering and opacity handling.
+        * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h:
+        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
+        (WebKit::ThreadedCompositor::renderLayerTree): Remove drawsBakground and always clear the context with
+        transparent color.
+        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
+        * Shared/WebPageCreationParameters.cpp:
+        (WebKit::WebPageCreationParameters::encode const): Replace drawsBackground with backgroundColor.
+        (WebKit::WebPageCreationParameters::decode): Ditto.
+        * Shared/WebPageCreationParameters.h:
+        * SourcesWPE.txt:
+        * UIProcess/API/glib/WebKitWebView.cpp:
+        * UIProcess/API/gtk/WebKitWebViewGtk.cpp:
+        (webkit_web_view_set_background_color):
+        (webkit_web_view_get_background_color):
+        * UIProcess/API/wpe/WebKitColor.cpp: Added.
+        (webkit_color_copy):
+        (webkit_color_free):
+        (webkitColorToWebCoreColor):
+        (webkitColorFillFromWebCoreColor):
+        (webkit_color_parse):
+        * UIProcess/API/wpe/WebKitColor.h: Added.
+        * UIProcess/API/wpe/WebKitColorPrivate.h: Added.
+        * UIProcess/API/wpe/WebKitWebView.h: Implement webkit_web_view_set_background_color API.
+        * UIProcess/API/wpe/WebKitWebViewWPE.cpp: Ditto.
+        (webkit_web_view_set_background_color):
+        (webkit_web_view_get_background_color):
+        * UIProcess/API/wpe/docs/wpe-0.1-sections.txt: Add new symbols.
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::setDrawsBackground): Set a transparent background color when false is passed.
+        (WebKit::WebPageProxy::setBackgroundColor): Send background color to the WebProcess.
+        (WebKit::WebPageProxy::creationParameters): Replace drawsBackground with backgroundColor.
+        * UIProcess/WebPageProxy.h:
+        (WebKit::WebPageProxy::drawsBackground const):
+        (WebKit::WebPageProxy::backgroundColor const):
+        * UIProcess/cairo/BackingStoreCairo.cpp:
+        (WebKit::BackingStore::incorporateUpdate): Remove GTK+ code to handle background color.
+        * UIProcess/gtk/AcceleratedBackingStore.cpp:
+        * UIProcess/gtk/AcceleratedBackingStore.h: Make paint() pure virtual and remove the implementation.
+        * UIProcess/gtk/AcceleratedBackingStoreWayland.cpp:
+        (WebKit::AcceleratedBackingStoreWayland::paint): Dot not call AcceleratedBackingStore::paint() now that is pure virtual.
+        * UIProcess/gtk/AcceleratedBackingStoreX11.cpp:
+        (WebKit::AcceleratedBackingStoreX11::paint): Ditto.
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::transitionToCommittedForNewPage): Use background color as provided by the
+        UIProcess when creating the FrameView.
+        * WebProcess/WebPage/AcceleratedDrawingArea.cpp:
+        * WebProcess/WebPage/AcceleratedDrawingArea.h:
+        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
+        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
+        * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
+        (WebKit::ThreadedCoordinatedLayerTreeHost::setIsDiscardable):
+        * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h:
+        * WebProcess/WebPage/DrawingArea.h:
+        * WebProcess/WebPage/DrawingAreaImpl.cpp:
+        (WebKit::DrawingAreaImpl::display): Remove special case for transparent background.
+        * WebProcess/WebPage/LayerTreeHost.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::setBackgroundColor): New API for background color configuration. Proxies to FrameView and DrawingArea.
+        * WebProcess/WebPage/WebPage.h:
+        (WebKit::WebPage::backgroundColor const): Read-only access to the current background color.
+        * WebProcess/WebPage/WebPage.messages.in: Replace SetDrawsBackground message with SetBackgroundColor.
+
 2019-02-25  Yongjun Zhang  <yongjun_zhang@apple.com>
 
         scalableNativeWebpageParameters() is not preserved on new page navigation.
index 53c13a1..b5e4e0a 100644 (file)
@@ -96,6 +96,7 @@ set(WPE_API_INSTALLED_HEADERS
     ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitBackForwardList.h
     ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitBackForwardListItem.h
     ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitCredential.h
+    ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitColor.h
     ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitContextMenu.h
     ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitContextMenuActions.h
     ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitContextMenuItem.h
index a5f15f0..da2f8a5 100644 (file)
@@ -65,7 +65,7 @@ void CoordinatedGraphicsScene::applyStateChanges(const Vector<CoordinatedGraphic
         commitSceneState(state.nicosia);
 }
 
-void CoordinatedGraphicsScene::paintToCurrentGLContext(const TransformationMatrix& matrix, float opacity, const FloatRect& clipRect, const Color& backgroundColor, bool drawsBackground, TextureMapper::PaintFlags PaintFlags)
+void CoordinatedGraphicsScene::paintToCurrentGLContext(const TransformationMatrix& matrix, const FloatRect& clipRect, TextureMapper::PaintFlags PaintFlags)
 {
     updateSceneState();
 
@@ -78,18 +78,8 @@ void CoordinatedGraphicsScene::paintToCurrentGLContext(const TransformationMatri
     m_textureMapper->beginPainting(PaintFlags);
     m_textureMapper->beginClip(TransformationMatrix(), clipRect);
 
-    if (drawsBackground) {
-        RGBA32 rgba = makeRGBA32FromFloats(backgroundColor.red(),
-            backgroundColor.green(), backgroundColor.blue(),
-            backgroundColor.alpha() * opacity);
-        m_textureMapper->drawSolidColor(clipRect, TransformationMatrix(), Color(rgba), true);
-    } else
-        m_textureMapper->clearColor(m_viewBackgroundColor);
-
-    if (currentRootLayer->opacity() != opacity || currentRootLayer->transform() != matrix) {
-        currentRootLayer->setOpacity(opacity);
+    if (currentRootLayer->transform() != matrix)
         currentRootLayer->setTransform(matrix);
-    }
 
     currentRootLayer->paint();
     m_fpsCounter.updateFPSAndDisplay(*m_textureMapper, clipRect.location(), matrix);
index d4bb582..2e6b335 100644 (file)
@@ -72,7 +72,7 @@ public:
     virtual ~CoordinatedGraphicsScene();
 
     void applyStateChanges(const Vector<WebCore::CoordinatedGraphicsState>&);
-    void paintToCurrentGLContext(const WebCore::TransformationMatrix&, float, const WebCore::FloatRect&, const WebCore::Color& backgroundColor, bool drawsBackground, WebCore::TextureMapper::PaintFlags = 0);
+    void paintToCurrentGLContext(const WebCore::TransformationMatrix&, const WebCore::FloatRect&, WebCore::TextureMapper::PaintFlags = 0);
     void detach();
 
     // The painting thread must lock the main thread to use below two methods, because two methods access members that the main thread manages. See m_client.
@@ -82,9 +82,6 @@ public:
     bool isActive() const { return m_isActive; }
     void setActive(bool active) { m_isActive = active; }
 
-    void setViewBackgroundColor(const WebCore::Color& color) { m_viewBackgroundColor = color; }
-    WebCore::Color viewBackgroundColor() const { return m_viewBackgroundColor; }
-
 private:
     void commitSceneState(const WebCore::CoordinatedGraphicsState::NicosiaState&);
     void updateSceneState();
@@ -113,7 +110,6 @@ private:
     std::unique_ptr<WebCore::TextureMapperLayer> m_rootLayer;
 
     Nicosia::PlatformLayer::LayerID m_rootLayerID { 0 };
-    WebCore::Color m_viewBackgroundColor { WebCore::Color::white };
 
     WebCore::TextureMapperFPSCounter m_fpsCounter;
 };
index 7522f84..805f233 100644 (file)
@@ -156,13 +156,6 @@ void ThreadedCompositor::setViewportSize(const IntSize& viewportSize, float scal
     m_compositingRunLoop->scheduleUpdate();
 }
 
-void ThreadedCompositor::setDrawsBackground(bool drawsBackground)
-{
-    LockHolder locker(m_attributes.lock);
-    m_attributes.drawsBackground = drawsBackground;
-    m_compositingRunLoop->scheduleUpdate();
-}
-
 void ThreadedCompositor::updateViewport()
 {
     m_compositingRunLoop->scheduleUpdate();
@@ -194,8 +187,8 @@ void ThreadedCompositor::renderLayerTree()
     WebCore::IntSize viewportSize;
     WebCore::IntPoint scrollPosition;
     float scaleFactor;
-    bool drawsBackground;
     bool needsResize;
+
     Vector<WebCore::CoordinatedGraphicsState> states;
 
     {
@@ -203,7 +196,6 @@ void ThreadedCompositor::renderLayerTree()
         viewportSize = m_attributes.viewportSize;
         scrollPosition = m_attributes.scrollPosition;
         scaleFactor = m_attributes.scaleFactor;
-        drawsBackground = m_attributes.drawsBackground;
         needsResize = m_attributes.needsResize;
 
         states = WTFMove(m_attributes.states);
@@ -247,14 +239,11 @@ void ThreadedCompositor::renderLayerTree()
     viewportTransform.scale(scaleFactor);
     viewportTransform.translate(-scrollPosition.x(), -scrollPosition.y());
 
-    if (!drawsBackground) {
-        glClearColor(0, 0, 0, 0);
-        glClear(GL_COLOR_BUFFER_BIT);
-    }
+    glClearColor(0, 0, 0, 0);
+    glClear(GL_COLOR_BUFFER_BIT);
 
     m_scene->applyStateChanges(states);
-    m_scene->paintToCurrentGLContext(viewportTransform, 1, FloatRect { FloatPoint { }, viewportSize },
-        Color::transparent, !drawsBackground, m_paintFlags);
+    m_scene->paintToCurrentGLContext(viewportTransform, FloatRect { FloatPoint { }, viewportSize }, m_paintFlags);
 
     m_context->swapBuffers();
 
index 6d70538..b631fc0 100644 (file)
@@ -70,7 +70,6 @@ public:
     void setScaleFactor(float);
     void setScrollPosition(const WebCore::IntPoint&, float scale);
     void setViewportSize(const WebCore::IntSize&, float scale);
-    void setDrawsBackground(bool);
 
     void updateSceneState(const WebCore::CoordinatedGraphicsState&);
 
@@ -112,9 +111,7 @@ private:
         WebCore::IntSize viewportSize;
         WebCore::IntPoint scrollPosition;
         float scaleFactor { 1 };
-        bool drawsBackground { true };
         bool needsResize { false };
-
         Vector<WebCore::CoordinatedGraphicsState> states;
 
         bool clientRendersNextFrame { false };
index 4983e8e..db1b381 100644 (file)
@@ -39,7 +39,6 @@ void WebPageCreationParameters::encode(IPC::Encoder& encoder) const
     encoder.encodeEnum(drawingAreaType);
     encoder << drawingAreaIdentifier;
     encoder << pageGroupData;
-    encoder << drawsBackground;
     encoder << isEditable;
     encoder << underlayColor;
     encoder << useFixedLayout;
@@ -126,6 +125,7 @@ void WebPageCreationParameters::encode(IPC::Encoder& encoder) const
 #if ENABLE(CONTENT_EXTENSIONS)
     encoder << contentRuleLists;
 #endif
+    encoder << backgroundColor;
 }
 
 Optional<WebPageCreationParameters> WebPageCreationParameters::decode(IPC::Decoder& decoder)
@@ -149,8 +149,6 @@ Optional<WebPageCreationParameters> WebPageCreationParameters::decode(IPC::Decod
     if (!pageGroupData)
         return WTF::nullopt;
     parameters.pageGroupData = WTFMove(*pageGroupData);
-    if (!decoder.decode(parameters.drawsBackground))
-        return WTF::nullopt;
     if (!decoder.decode(parameters.isEditable))
         return WTF::nullopt;
     if (!decoder.decode(parameters.underlayColor))
@@ -368,6 +366,12 @@ Optional<WebPageCreationParameters> WebPageCreationParameters::decode(IPC::Decod
     parameters.contentRuleLists = WTFMove(*contentRuleLists);
 #endif
 
+    Optional<Optional<WebCore::Color>> backgroundColor;
+    decoder >> backgroundColor;
+    if (!backgroundColor)
+        return WTF::nullopt;
+    parameters.backgroundColor = WTFMove(*backgroundColor);
+
     return WTFMove(parameters);
 }
 
index 4fe3b10..976c886 100644 (file)
@@ -74,7 +74,6 @@ struct WebPageCreationParameters {
     DrawingAreaIdentifier drawingAreaIdentifier;
     WebPageGroupData pageGroupData;
 
-    bool drawsBackground;
     bool isEditable;
 
     WebCore::Color underlayColor;
@@ -194,6 +193,8 @@ struct WebPageCreationParameters {
 #if ENABLE(CONTENT_EXTENSIONS)
     Vector<std::pair<String, WebCompiledContentRuleListData>> contentRuleLists;
 #endif
+
+    Optional<WebCore::Color> backgroundColor;
 };
 
 } // namespace WebKit
index 91333e4..9c958bf 100644 (file)
@@ -172,6 +172,7 @@ UIProcess/API/glib/WebKitWindowProperties.cpp @no-unify
 
 UIProcess/API/wpe/PageClientImpl.cpp @no-unify
 UIProcess/API/wpe/ScrollGestureController.cpp @no-unify
+UIProcess/API/wpe/WebKitColor.cpp @no-unify
 UIProcess/API/wpe/WebKitScriptDialogWPE.cpp @no-unify
 UIProcess/API/wpe/WebKitWebViewBackend.cpp @no-unify
 UIProcess/API/wpe/WebKitWebViewWPE.cpp @no-unify
index 752a3a4..871af11 100644 (file)
@@ -687,7 +687,8 @@ static void validate(WKWebViewConfiguration *configuration)
 
     _page = [_contentView page];
     [self _dispatchSetDeviceOrientation:deviceOrientation()];
-    _page->setDrawsBackground(self.opaque);
+    if (!self.opaque)
+        _page->setBackgroundColor(WebCore::Color(WebCore::Color::transparent));
 
     [_contentView layer].anchorPoint = CGPointZero;
     [_contentView setFrame:bounds];
@@ -2502,7 +2503,10 @@ static WebCore::FloatPoint constrainContentOffset(WebCore::FloatPoint contentOff
     if (!_page)
         return;
 
-    _page->setDrawsBackground(opaque);
+    Optional<WebCore::Color> backgroundColor;
+    if (!opaque)
+        backgroundColor = WebCore::Color(WebCore::Color::transparent);
+    _page->setBackgroundColor(backgroundColor);
     [self _updateScrollViewBackground];
 }
 
index 87d022d..97716db 100644 (file)
@@ -3988,74 +3988,6 @@ void webkitWebViewWebProcessTerminated(WebKitWebView* webView, WebKitWebProcessT
     g_signal_emit(webView, signals[WEB_PROCESS_TERMINATED], 0, reason);
 }
 
-#if PLATFORM(GTK)
-/**
- * webkit_web_view_set_background_color:
- * @web_view: a #WebKitWebView
- * @rgba: a #GdkRGBA
- *
- * Sets the color that will be used to draw the @web_view background before
- * the actual contents are rendered. Note that if the web page loaded in @web_view
- * specifies a background color, it will take precedence over the @rgba color.
- * By default the @web_view background color is opaque white.
- * Note that the parent window must have a RGBA visual and
- * #GtkWidget:app-paintable property set to %TRUE for backgrounds colors to work.
- *
- * <informalexample><programlisting>
- * static void browser_window_set_background_color (BrowserWindow *window,
- *                                                  const GdkRGBA *rgba)
- * {
- *     WebKitWebView *web_view;
- *     GdkScreen *screen = gtk_window_get_screen (GTK_WINDOW (window));
- *     GdkVisual *rgba_visual = gdk_screen_get_rgba_visual (screen);
- *
- *     if (!rgba_visual)
- *          return;
- *
- *     gtk_widget_set_visual (GTK_WIDGET (window), rgba_visual);
- *     gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
- *
- *     web_view = browser_window_get_web_view (window);
- *     webkit_web_view_set_background_color (web_view, rgba);
- * }
- * </programlisting></informalexample>
- *
- * Since: 2.8
- */
-void webkit_web_view_set_background_color(WebKitWebView* webView, const GdkRGBA* rgba)
-{
-    g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
-    g_return_if_fail(rgba);
-
-    Color color(*rgba);
-    auto& page = getPage(webView);
-    if (page.backgroundColor() == color)
-        return;
-
-    page.setBackgroundColor(color);
-    page.setDrawsBackground(color == Color::white);
-}
-
-/**
- * webkit_web_view_get_background_color:
- * @web_view: a #WebKitWebView
- * @rgba: (out): a #GdkRGBA to fill in with the background color
- *
- * Gets the color that is used to draw the @web_view background before
- * the actual contents are rendered.
- * For more information see also webkit_web_view_set_background_color()
- *
- * Since: 2.8
- */
-void webkit_web_view_get_background_color(WebKitWebView* webView, GdkRGBA* rgba)
-{
-    g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
-    g_return_if_fail(rgba);
-
-    *rgba = getPage(webView).backgroundColor();
-}
-#endif // PLATFORM(GTK)
-
 /*
  * webkit_web_view_is_editable:
  * @web_view: a #WebKitWebView
index 8cafc7b..4f0e151 100644 (file)
@@ -24,6 +24,7 @@
 #include "WebKitScriptDialogImpl.h"
 #include "WebKitWebViewBasePrivate.h"
 #include "WebKitWebViewPrivate.h"
+#include <WebCore/Color.h>
 #include <WebCore/GtkUtilities.h>
 #include <WebCore/PlatformDisplay.h>
 #include <WebCore/PlatformScreen.h>
@@ -361,3 +362,65 @@ GtkWidget* webkit_web_view_new_with_user_content_manager(WebKitUserContentManage
 
     return GTK_WIDGET(g_object_new(WEBKIT_TYPE_WEB_VIEW, "user-content-manager", userContentManager, nullptr));
 }
+
+/**
+ * webkit_web_view_set_background_color:
+ * @web_view: a #WebKitWebView
+ * @rgba: a #GdkRGBA
+ *
+ * Sets the color that will be used to draw the @web_view background before
+ * the actual contents are rendered. Note that if the web page loaded in @web_view
+ * specifies a background color, it will take precedence over the @rgba color.
+ * By default the @web_view background color is opaque white.
+ * Note that the parent window must have a RGBA visual and
+ * #GtkWidget:app-paintable property set to %TRUE for backgrounds colors to work.
+ *
+ * <informalexample><programlisting>
+ * static void browser_window_set_background_color (BrowserWindow *window,
+ *                                                  const GdkRGBA *rgba)
+ * {
+ *     WebKitWebView *web_view;
+ *     GdkScreen *screen = gtk_window_get_screen (GTK_WINDOW (window));
+ *     GdkVisual *rgba_visual = gdk_screen_get_rgba_visual (screen);
+ *
+ *     if (!rgba_visual)
+ *          return;
+ *
+ *     gtk_widget_set_visual (GTK_WIDGET (window), rgba_visual);
+ *     gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
+ *
+ *     web_view = browser_window_get_web_view (window);
+ *     webkit_web_view_set_background_color (web_view, rgba);
+ * }
+ * </programlisting></informalexample>
+ *
+ * Since: 2.8
+ */
+void webkit_web_view_set_background_color(WebKitWebView* webView, const GdkRGBA* rgba)
+{
+    g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+    g_return_if_fail(rgba);
+
+    auto& page = *webkitWebViewBaseGetPage(reinterpret_cast<WebKitWebViewBase*>(webView));
+    page.setBackgroundColor(WebCore::Color(*rgba));
+}
+
+/**
+ * webkit_web_view_get_background_color:
+ * @web_view: a #WebKitWebView
+ * @rgba: (out): a #GdkRGBA to fill in with the background color
+ *
+ * Gets the color that is used to draw the @web_view background before
+ * the actual contents are rendered.
+ * For more information see also webkit_web_view_set_background_color()
+ *
+ * Since: 2.8
+ */
+void webkit_web_view_get_background_color(WebKitWebView* webView, GdkRGBA* rgba)
+{
+    g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+    g_return_if_fail(rgba);
+
+    auto& page = *webkitWebViewBaseGetPage(reinterpret_cast<WebKitWebViewBase*>(webView));
+    *rgba = page.backgroundColor().valueOr(WebCore::Color::white);
+}
diff --git a/Source/WebKit/UIProcess/API/wpe/WebKitColor.cpp b/Source/WebKit/UIProcess/API/wpe/WebKitColor.cpp
new file mode 100644 (file)
index 0000000..b818f95
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2019 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebKitColor.h"
+
+#include "WebKitColorPrivate.h"
+
+/**
+ * SECTION: WebKitColor
+ * @Short_description: A boxed type representing a RGBA color
+ * @Title: WebKitColor
+ * @See_also: #WebKitWebView.
+ *
+ * A WebKitColor is a boxed type representing a RGBA color.
+ *
+ * Since: 2.24
+ */
+
+/**
+ * webkit_color_copy:
+ * @color: a #WebKitColor
+ *
+ * Make a copy of @color.
+ *
+ * Returns: (transfer full): A copy of passed in #WebKitColor.
+ *
+ * Since: 2.24
+ */
+WebKitColor* webkit_color_copy(WebKitColor* color)
+{
+    g_return_val_if_fail(color, nullptr);
+
+    WebKitColor* copy = static_cast<WebKitColor*>(fastZeroedMalloc(sizeof(WebKitColor)));
+    copy->red = color->red;
+    copy->green = color->green;
+    copy->blue = color->blue;
+    copy->alpha = color->alpha;
+    return copy;
+}
+
+/**
+ * webkit_color_free:
+ * @color: a #WebKitColor
+ *
+ * Free the #WebKitColor.
+ *
+ * Since: 2.24
+ */
+void webkit_color_free(WebKitColor* color)
+{
+    g_return_if_fail(color);
+
+    fastFree(color);
+}
+
+G_DEFINE_BOXED_TYPE(WebKitColor, webkit_color, webkit_color_copy, webkit_color_free);
+
+const WebCore::Color webkitColorToWebCoreColor(WebKitColor* color)
+{
+    return WebCore::Color(static_cast<float>(color->red), static_cast<float>(color->green),
+        static_cast<float>(color->blue), static_cast<float>(color->alpha));
+}
+
+void webkitColorFillFromWebCoreColor(const WebCore::Color& webCoreColor, WebKitColor* color)
+{
+    RELEASE_ASSERT(webCoreColor.isValid());
+
+    double r, g, b, a;
+    webCoreColor.getRGBA(r, g, b, a);
+    color->red = r;
+    color->green = g;
+    color->blue = b;
+    color->alpha = a;
+}
+
+/**
+ * webkit_color_parse:
+ * @color: a #WebKitColor to fill in
+ * @color_string: color representation as color nickname or HEX string
+ *
+ * Create a new #WebKitColor for the given @color_string
+ * representation. There are two valid representation types: standard color
+ * names (see https://htmlcolorcodes.com/color-names/ for instance) or HEX
+ * values.
+ *
+ * Returns: a #gboolean indicating if the @color was correctly filled in or not.
+ *
+ * Since: 2.24
+ */
+gboolean webkit_color_parse(WebKitColor* color, const gchar* colorString)
+{
+    g_return_val_if_fail(color, FALSE);
+    g_return_val_if_fail(colorString, FALSE);
+
+    auto webCoreColor = WebCore::Color(colorString);
+    if (!webCoreColor.isValid())
+        return FALSE;
+
+    webkitColorFillFromWebCoreColor(webCoreColor, color);
+    return TRUE;
+}
diff --git a/Source/WebKit/UIProcess/API/wpe/WebKitColor.h b/Source/WebKit/UIProcess/API/wpe/WebKitColor.h
new file mode 100644 (file)
index 0000000..f26d091
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2019 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#if !defined(__WEBKIT_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <wpe/webkit.h> can be included directly."
+#endif
+
+#ifndef WebKitColor_h
+#define WebKitColor_h
+
+#include <glib-object.h>
+#include <wpe/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+/**
+ * WebKitColor:
+ * @red: Red channel, between 0.0 and 1.0 inclusive
+ * @green: Green channel, between 0.0 and 1.0 inclusive
+ * @blue: Blue channel, between 0.0 and 1.0 inclusive
+ * @alpha: Alpha channel, between 0.0 and 1.0 inclusive
+ *
+ * A WebKitColor is a boxed type representing a RGBA color.
+ *
+ * Since: 2.24
+ */
+struct _WebKitColor {
+    gdouble red;
+    gdouble green;
+    gdouble blue;
+    gdouble alpha;
+};
+
+typedef struct _WebKitColor WebKitColor;
+
+#define WEBKIT_TYPE_COLOR (webkit_color_get_type())
+
+WEBKIT_API GType
+webkit_color_get_type     (void);
+
+WEBKIT_API gboolean
+webkit_color_parse        (WebKitColor *color, const gchar *color_string);
+
+G_END_DECLS
+
+#endif /* WebKitColor_h */
diff --git a/Source/WebKit/UIProcess/API/wpe/WebKitColorPrivate.h b/Source/WebKit/UIProcess/API/wpe/WebKitColorPrivate.h
new file mode 100644 (file)
index 0000000..239a116
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2019 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#pragma once
+
+#include "Color.h"
+#include "WebKitColor.h"
+
+void webkitColorFillFromWebCoreColor(const WebCore::Color&, WebKitColor*);
+const WebCore::Color webkitColorToWebCoreColor(WebKitColor*);
index 4102a75..2a4a620 100644 (file)
@@ -49,6 +49,7 @@
 #include <wpe/WebKitWebContext.h>
 #include <wpe/WebKitWebResource.h>
 #include <wpe/WebKitWebViewBackend.h>
+#include <wpe/WebKitColor.h>
 #include <wpe/WebKitWebViewSessionState.h>
 #include <wpe/WebKitWindowProperties.h>
 
@@ -517,6 +518,13 @@ WEBKIT_API void
 webkit_web_view_remove_frame_displayed_callback      (WebKitWebView               *web_view,
                                                       guint                        id);
 
+WEBKIT_API void
+webkit_web_view_set_background_color                 (WebKitWebView               *web_view,
+                                                      WebKitColor                 *color);
+WEBKIT_API void
+webkit_web_view_get_background_color                 (WebKitWebView               *web_view,
+                                                      WebKitColor                 *color);
+
 G_END_DECLS
 
 #endif
index a3495e8..9e5ce5c 100644 (file)
@@ -20,6 +20,7 @@
 #include "config.h"
 #include "WebKitWebView.h"
 
+#include "WebKitColorPrivate.h"
 #include "WebKitWebViewPrivate.h"
 
 gboolean webkitWebViewAuthenticate(WebKitWebView*, WebKitAuthenticationRequest*)
@@ -178,3 +179,44 @@ WebKitWebView* webkit_web_view_new_with_user_content_manager(WebKitWebViewBacken
         "user-content-manager", userContentManager,
         nullptr));
 }
+
+/**
+ * webkit_web_view_set_background_color:
+ * @web_view: a #WebKitWebView
+ * @backgroundColor: a #WebKitColor
+ *
+ * Sets the color that will be used to draw the @web_view background before
+ * the actual contents are rendered. Note that if the web page loaded in @web_view
+ * specifies a background color, it will take precedence over the background color.
+ * By default the @web_view background color is opaque white.
+ *
+ * Since: 2.24
+ */
+void webkit_web_view_set_background_color(WebKitWebView* webView, WebKitColor* backgroundColor)
+{
+    g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+    g_return_if_fail(backgroundColor);
+
+    auto& page = webkitWebViewGetPage(webView);
+    page.setBackgroundColor(webkitColorToWebCoreColor(backgroundColor));
+}
+
+/**
+ * webkit_web_view_get_background_color:
+ * @web_view: a #WebKitWebView
+ * @rgba: (out): a #WebKitColor to fill in with the background color
+ *
+ * Gets the color that is used to draw the @web_view background before the
+ * actual contents are rendered. For more information see also
+ * webkit_web_view_set_background_color().
+ *
+ * Since: 2.24
+ */
+void webkit_web_view_get_background_color(WebKitWebView* webView, WebKitColor* color)
+{
+    g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+    auto& page = webkitWebViewGetPage(webView);
+
+    auto& webCoreColor = page.backgroundColor();
+    webkitColorFillFromWebCoreColor(webCoreColor.valueOr(WebCore::Color::white), color);
+}
index eae29cb..18c91c8 100644 (file)
@@ -247,6 +247,8 @@ webkit_web_view_restore_session_state
 webkit_web_view_get_main_resource
 webkit_web_view_add_frame_displayed_callback
 webkit_web_view_remove_frame_displayed_callback
+webkit_web_view_get_background_color
+webkit_web_view_set_background_color
 
 <SUBSECTION WebKitJavascriptResult>
 WebKitJavascriptResult
@@ -308,6 +310,16 @@ webkit_web_view_backend_get_type
 </SECTION>
 
 <SECTION>
+<FILE>WebKitColor</FILE>
+WEBKIT_TYPE_COLOR
+WebKitColor
+webkit_color_parse
+
+<SUBSECTION Private>
+webkit_color_get_type
+</SECTION>
+
+<SECTION>
 <FILE>WebKitAuthenticationRequest</FILE>
 WebKitAuthenticationRequest
 WebKitAuthenticationScheme
index 5f6bcc1..f6eb38d 100644 (file)
@@ -55,6 +55,7 @@
     <xi:include href="xml/WebKitNetworkProxySettings.xml"/>
     <xi:include href="xml/WebKitAutomationSession.xml"/>
     <xi:include href="xml/WebKitApplicationInfo.xml"/>
+    <xi:include href="xml/WebKitColor.xml"/>
   </chapter>
 
   <chapter>
index a19f369..7da7358 100644 (file)
@@ -1454,7 +1454,10 @@ void WebViewImpl::didRelaunchProcess()
 
 void WebViewImpl::setDrawsBackground(bool drawsBackground)
 {
-    m_page->setDrawsBackground(drawsBackground);
+    Optional<WebCore::Color> backgroundColor;
+    if (!drawsBackground)
+        backgroundColor = WebCore::Color(WebCore::Color::transparent);
+    m_page->setBackgroundColor(backgroundColor);
 
     // Make sure updateLayer gets called on the web view.
     [m_view setNeedsDisplay:YES];
@@ -1462,7 +1465,8 @@ void WebViewImpl::setDrawsBackground(bool drawsBackground)
 
 bool WebViewImpl::drawsBackground() const
 {
-    return m_page->drawsBackground();
+    auto& backgroundColor = m_page->backgroundColor();
+    return !backgroundColor || backgroundColor.value().isVisible();
 }
 
 void WebViewImpl::setBackgroundColor(NSColor *backgroundColor)
@@ -1486,7 +1490,7 @@ NSColor *WebViewImpl::backgroundColor() const
 
 bool WebViewImpl::isOpaque() const
 {
-    return m_page->drawsBackground();
+    return drawsBackground();
 }
 
 void WebViewImpl::setShouldSuppressFirstResponderChanges(bool shouldSuppress)
index b4ce08b..4a61cf9 100644 (file)
@@ -429,7 +429,6 @@ WebPageProxy::WebPageProxy(PageClient& pageClient, WebProcessProxy& process, uin
     , m_cpuLimit(m_configuration->cpuLimit())
     , m_backForwardList(WebBackForwardList::create(*this))
     , m_waitsForPaintAfterViewDidMoveToWindow(m_configuration->waitsForPaintAfterViewDidMoveToWindow())
-    , m_drawsBackground(m_configuration->drawsBackground())
     , m_pageID(pageID)
     , m_controlledByAutomation(m_configuration->isControlledByAutomation())
 #if PLATFORM(COCOA)
@@ -448,6 +447,9 @@ WebPageProxy::WebPageProxy(PageClient& pageClient, WebProcessProxy& process, uin
 {
     RELEASE_LOG_IF_ALLOWED(Loading, "constructor: webPID = %i, pageID = %" PRIu64, m_process->processIdentifier(), m_pageID);
 
+    if (!m_configuration->drawsBackground())
+        m_backgroundColor = Color(Color::transparent);
+
     m_webProcessLifetimeTracker.addObserver(m_visitedLinkStore);
     m_webProcessLifetimeTracker.addObserver(m_websiteDataStore);
 
@@ -1559,15 +1561,14 @@ void WebPageProxy::createInspectorTargets()
     m_inspectorController->createInspectorTarget(pageTargetId, Inspector::InspectorTargetType::Page);
 }
 
-void WebPageProxy::setDrawsBackground(bool drawsBackground)
+void WebPageProxy::setBackgroundColor(const Optional<Color>& color)
 {
-    if (m_drawsBackground == drawsBackground)
+    if (m_backgroundColor == color)
         return;
 
-    m_drawsBackground = drawsBackground;
-
+    m_backgroundColor = color;
     if (isValid())
-        m_process->send(Messages::WebPage::SetDrawsBackground(drawsBackground), m_pageID);
+        m_process->send(Messages::WebPage::SetBackgroundColor(color), m_pageID);
 }
 
 void WebPageProxy::setTopContentInset(float contentInset)
@@ -6863,7 +6864,6 @@ WebPageCreationParameters WebPageProxy::creationParameters(WebProcessProxy& proc
     parameters.drawingAreaIdentifier = drawingArea.identifier();
     parameters.store = preferencesStore();
     parameters.pageGroupData = m_pageGroup->data();
-    parameters.drawsBackground = m_drawsBackground;
     parameters.isEditable = m_isEditable;
     parameters.underlayColor = m_underlayColor;
     parameters.useFixedLayout = m_useFixedLayout;
@@ -6967,6 +6967,7 @@ WebPageCreationParameters WebPageProxy::creationParameters(WebProcessProxy& proc
 #endif
 
     parameters.needsFontAttributes = m_needsFontAttributes;
+    parameters.backgroundColor = m_backgroundColor;
 
     process.addWebUserContentControllerProxy(m_userContentController, parameters);
 
index fa70e76..633d35c 100644 (file)
@@ -521,9 +521,6 @@ public:
 
     bool canShowMIMEType(const String& mimeType);
 
-    bool drawsBackground() const { return m_drawsBackground; }
-    void setDrawsBackground(bool);
-
     String currentURL() const;
 
     float topContentInset() const { return m_topContentInset; }
@@ -766,11 +763,12 @@ public:
 
 #if PLATFORM(GTK)
     PlatformWidget viewWidget();
-    const WebCore::Color& backgroundColor() const { return m_backgroundColor; }
-    void setBackgroundColor(const WebCore::Color& color) { m_backgroundColor = color; }
     bool makeGLContextCurrent();
 #endif
 
+    const Optional<WebCore::Color>& backgroundColor() const { return m_backgroundColor; }
+    void setBackgroundColor(const Optional<WebCore::Color>&);
+
 #if PLATFORM(WIN)
     PlatformWidget viewWidget();
 #endif
@@ -2120,8 +2118,6 @@ private:
 
     LayerHostingMode m_layerHostingMode { LayerHostingMode::InProcess };
 
-    bool m_drawsBackground { true };
-
     WebCore::Color m_underlayColor;
     WebCore::Color m_pageExtendedBackgroundColor;
 
@@ -2220,9 +2216,10 @@ private:
 
 #if PLATFORM(GTK)
     String m_accessibilityPlugID;
-    WebCore::Color m_backgroundColor { WebCore::Color::white };
 #endif
 
+    Optional<WebCore::Color> m_backgroundColor;
+
     unsigned m_pendingLearnOrIgnoreWordMessageCount { 0 };
 
     bool m_mainFrameHasCustomContentProvider { false };
index e111c2b..18294d3 100644 (file)
 #include <WebCore/RefPtrCairo.h>
 #include <cairo.h>
 
-#if PLATFORM(GTK)
-#include <gtk/gtk.h>
-#endif
-
 #if PLATFORM(GTK) && PLATFORM(X11) && defined(GDK_WINDOWING_X11)
 #include <WebCore/BackingStoreBackendCairoX11.h>
 #include <WebCore/PlatformDisplayX11.h>
@@ -97,24 +93,6 @@ void BackingStore::incorporateUpdate(ShareableBitmap* bitmap, const UpdateInfo&
     for (const auto& updateRect : updateInfo.updateRects) {
         IntRect srcRect = updateRect;
         srcRect.move(-updateRectLocation.x(), -updateRectLocation.y());
-#if PLATFORM(GTK)
-        if (!m_webPageProxy.drawsBackground()) {
-            const WebCore::Color color = m_webPageProxy.backgroundColor();
-            if (color.isVisible()) {
-                // When the application sets the background color through m_webPageProxy.backgroundColor(), we update the surface in 2 steps.
-                //   1. Fill the surface by m_webPageProxy.backgroundColor().
-                //   2. Composite webpage's bitmap which has a transparent background.
-                // In step 1, we use CompositeCopy as m_webPageProxy.backgroundColor() may not be opaque.
-                // On the other hand, in step 2, bitmap should be composited by CompositeSourceOver
-                // because it should be blended with m_webPageProxy.backgroundColor().
-                graphicsContext.fillRect(srcRect, color);
-                graphicsContext.setCompositeOperation(WebCore::CompositeSourceOver);
-                bitmap->paint(graphicsContext, deviceScaleFactor(), updateRect.location(), srcRect);
-                graphicsContext.setCompositeOperation(WebCore::CompositeCopy);
-                continue;
-            }
-        }
-#endif
         bitmap->paint(graphicsContext, deviceScaleFactor(), updateRect.location(), srcRect);
     }
 }
index ecf345f..eb62d6d 100644 (file)
@@ -59,26 +59,4 @@ AcceleratedBackingStore::AcceleratedBackingStore(WebPageProxy& webPage)
 {
 }
 
-bool AcceleratedBackingStore::paint(cairo_t* cr, const IntRect& clipRect)
-{
-    if (m_webPage.drawsBackground())
-        return true;
-
-    const WebCore::Color& color = m_webPage.backgroundColor();
-    if (!color.isOpaque()) {
-        cairo_rectangle(cr, clipRect.x(), clipRect.y(), clipRect.width(), clipRect.height());
-        cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
-        cairo_fill(cr);
-    }
-
-    if (color.isVisible()) {
-        setSourceRGBAFromColor(cr, color);
-        cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
-        cairo_rectangle(cr, clipRect.x(), clipRect.y(), clipRect.width(), clipRect.height());
-        cairo_fill(cr);
-    }
-
-    return true;
-}
-
 } // namespace WebKit
index e350507..48db533 100644 (file)
@@ -45,7 +45,7 @@ public:
     virtual ~AcceleratedBackingStore() = default;
 
     virtual void update(const LayerTreeContext&) { }
-    virtual bool paint(cairo_t*, const WebCore::IntRect&);
+    virtual bool paint(cairo_t*, const WebCore::IntRect&) = 0;
     virtual bool makeContextCurrent() { return false; }
 
 protected:
index f01bab3..60f5ca7 100644 (file)
@@ -110,7 +110,6 @@ bool AcceleratedBackingStoreWayland::paint(cairo_t* cr, const IntRect& clipRect)
         return false;
 
     cairo_save(cr);
-    AcceleratedBackingStore::paint(cr, clipRect);
 
 #if GTK_CHECK_VERSION(3, 16, 0)
     if (m_gdkGLContext) {
index 27d72c1..82ce8c6 100644 (file)
@@ -186,7 +186,6 @@ bool AcceleratedBackingStoreX11::paint(cairo_t* cr, const IntRect& clipRect)
         return false;
 
     cairo_save(cr);
-    AcceleratedBackingStore::paint(cr, clipRect);
 
     // The surface can be modified by the web process at any time, so we mark it
     // as dirty to ensure we always render the updated contents as soon as possible.
index 0f9f9d4..a9e4185 100644 (file)
@@ -451,7 +451,8 @@ LRESULT WebView::onKeyEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPara
 
 static void drawPageBackground(HDC dc, const WebPageProxy* page, const RECT& rect)
 {
-    if (!page->drawsBackground())
+    auto& backgroundColor = page->backgroundColor();
+    if (!backgroundColor || backgroundColor.value().isVisible())
         return;
 
     ::FillRect(dc, &rect, reinterpret_cast<HBRUSH>(COLOR_WINDOW + 1));
index a6f1a44..3de19b1 100644 (file)
@@ -1409,7 +1409,6 @@ void WebFrameLoaderClient::transitionToCommittedForNewPage()
     WebPage* webPage = m_frame->page();
 
     bool isMainFrame = m_frame->isMainFrame();
-    bool isTransparent = !webPage->drawsBackground();
     bool shouldUseFixedLayout = isMainFrame && webPage->useFixedLayout();
     bool shouldDisableScrolling = isMainFrame && !webPage->mainFrameIsScrollable();
     bool shouldHideScrollbars = shouldDisableScrolling;
@@ -1434,7 +1433,7 @@ void WebFrameLoaderClient::transitionToCommittedForNewPage()
     bool horizontalLock = shouldHideScrollbars || webPage->alwaysShowsHorizontalScroller();
     bool verticalLock = shouldHideScrollbars || webPage->alwaysShowsVerticalScroller();
 
-    m_frame->coreFrame()->createView(webPage->size(), isTransparent,
+    m_frame->coreFrame()->createView(webPage->size(), webPage->backgroundColor(),
         webPage->fixedLayoutSize(), fixedVisibleContentRect, shouldUseFixedLayout,
         horizontalScrollbarMode, horizontalLock, verticalScrollbarMode, verticalLock);
 
index deb4bd7..304db88 100644 (file)
@@ -93,14 +93,6 @@ void AcceleratedDrawingArea::scroll(const IntRect& scrollRect, const IntSize& sc
         m_layerTreeHost->scrollNonCompositedContents(scrollRect);
 }
 
-void AcceleratedDrawingArea::pageBackgroundTransparencyChanged()
-{
-    if (m_layerTreeHost)
-        m_layerTreeHost->pageBackgroundTransparencyChanged();
-    else if (m_previousLayerTreeHost)
-        m_previousLayerTreeHost->pageBackgroundTransparencyChanged();
-}
-
 void AcceleratedDrawingArea::setLayerTreeStateIsFrozen(bool isFrozen)
 {
     if (m_layerTreeStateIsFrozen == isFrozen)
index 0927d44..f7ef9f6 100644 (file)
@@ -43,7 +43,6 @@ protected:
     void setNeedsDisplay() override;
     void setNeedsDisplayInRect(const WebCore::IntRect&) override;
     void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta) override;
-    void pageBackgroundTransparencyChanged() override;
     void setLayerTreeStateIsFrozen(bool) override;
     bool layerTreeStateIsFrozen() const override { return m_layerTreeStateIsFrozen; }
     LayerTreeHost* layerTreeHost() const override { return m_layerTreeHost.get(); }
index 1520f52..93b7a2d 100644 (file)
@@ -224,10 +224,6 @@ void CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged()
     m_webPage.corePage()->pageOverlayController().didChangeDeviceScaleFactor();
 }
 
-void CoordinatedLayerTreeHost::pageBackgroundTransparencyChanged()
-{
-}
-
 GraphicsLayerFactory* CoordinatedLayerTreeHost::graphicsLayerFactory()
 {
     return &m_coordinator;
index 0a8bec8..ea97453 100644 (file)
@@ -55,7 +55,6 @@ protected:
     void sizeDidChange(const WebCore::IntSize& newSize) override;
 
     void deviceOrPageScaleFactorChanged() override;
-    void pageBackgroundTransparencyChanged() override;
 
     void setVisibleContentsRect(const WebCore::FloatRect&);
     void renderNextFrame(bool);
index 823b7fa..100fc64 100644 (file)
@@ -184,17 +184,6 @@ void ThreadedCoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged()
     m_compositor->setScaleFactor(m_webPage.deviceScaleFactor() * m_viewportController.pageScaleFactor());
 }
 
-void ThreadedCoordinatedLayerTreeHost::pageBackgroundTransparencyChanged()
-{
-    if (m_isDiscardable) {
-        m_discardableSyncActions.add(DiscardableSyncActions::UpdateBackground);
-        return;
-    }
-
-    CoordinatedLayerTreeHost::pageBackgroundTransparencyChanged();
-    m_compositor->setDrawsBackground(m_webPage.drawsBackground());
-}
-
 void ThreadedCoordinatedLayerTreeHost::sizeDidChange(const IntSize& size)
 {
     if (m_isDiscardable) {
@@ -286,9 +275,6 @@ void ThreadedCoordinatedLayerTreeHost::setIsDiscardable(bool discardable)
     if (m_discardableSyncActions.isEmpty())
         return;
 
-    if (m_discardableSyncActions.contains(DiscardableSyncActions::UpdateBackground))
-        pageBackgroundTransparencyChanged();
-
     if (m_discardableSyncActions.contains(DiscardableSyncActions::UpdateSize)) {
         // Size changes already sets the scale factor and updates the viewport.
         sizeDidChange(m_webPage.size());
index b784681..2287616 100644 (file)
@@ -57,7 +57,6 @@ private:
     void scrollNonCompositedContents(const WebCore::IntRect& scrollRect) override;
     void sizeDidChange(const WebCore::IntSize&) override;
     void deviceOrPageScaleFactorChanged() override;
-    void pageBackgroundTransparencyChanged() override;
 
     void contentsSizeChanged(const WebCore::IntSize&) override;
     void didChangeViewportAttributes(WebCore::ViewportAttributes&&) override;
@@ -143,8 +142,7 @@ private:
     enum class DiscardableSyncActions {
         UpdateSize = 1 << 1,
         UpdateViewport = 1 << 2,
-        UpdateScale = 1 << 3,
-        UpdateBackground = 1 << 4
+        UpdateScale = 1 << 3
     };
 
     CompositorClient m_compositorClient;
index a358031..7bf2df0 100644 (file)
@@ -81,7 +81,6 @@ public:
     virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta) = 0;
 
     // FIXME: These should be pure virtual.
-    virtual void pageBackgroundTransparencyChanged() { }
     virtual void forceRepaint() { }
     virtual bool forceRepaintAsync(CallbackID) { return false; }
     virtual void setLayerTreeStateIsFrozen(bool) { }
index dde6aa0..44eb2db 100644 (file)
@@ -410,8 +410,7 @@ void DrawingAreaImpl::display(UpdateInfo& updateInfo)
     updateInfo.viewSize = m_webPage.size();
     updateInfo.deviceScaleFactor = m_webPage.corePage()->deviceScaleFactor();
 
-    // Always render the whole page when we don't render the background.
-    IntRect bounds = m_webPage.drawsBackground() ? m_dirtyRegion.bounds() : m_webPage.bounds();
+    IntRect bounds = m_dirtyRegion.bounds();
     ASSERT(m_webPage.bounds().contains(bounds));
 
     IntSize bitmapSize = bounds.size();
@@ -424,16 +423,11 @@ void DrawingAreaImpl::display(UpdateInfo& updateInfo)
     if (!bitmap->createHandle(updateInfo.bitmapHandle))
         return;
 
-    Vector<IntRect> rects;
-    if (m_webPage.drawsBackground()) {
-        rects = m_dirtyRegion.rects();
-
-        if (shouldPaintBoundsRect(bounds, rects)) {
-            rects.clear();
-            rects.append(bounds);
-        }
-    } else
+    Vector<IntRect> rects = m_dirtyRegion.rects();
+    if (shouldPaintBoundsRect(bounds, rects)) {
+        rects.clear();
         rects.append(bounds);
+    }
 
     updateInfo.scrollRect = m_scrollRect;
     updateInfo.scrollOffset = m_scrollOffset;
index 85dd458..53c3982 100644 (file)
@@ -74,7 +74,6 @@ public:
     virtual void forceRepaint() = 0;
     virtual bool forceRepaintAsync(CallbackID) { return false; }
     virtual void sizeDidChange(const WebCore::IntSize& newSize) = 0;
-    virtual void pageBackgroundTransparencyChanged() = 0;
 
     virtual void pauseRendering();
     virtual void resumeRendering();
index 575b0a1..6ab3a30 100644 (file)
@@ -520,8 +520,6 @@ WebPage::WebPage(uint64_t pageID, WebPageCreationParameters&& parameters)
 
     setUseFixedLayout(parameters.useFixedLayout);
 
-    setDrawsBackground(parameters.drawsBackground);
-
     setUnderlayColor(parameters.underlayColor);
 
     setPaginationMode(parameters.paginationMode);
@@ -648,6 +646,8 @@ WebPage::WebPage(uint64_t pageID, WebPageCreationParameters&& parameters)
 #if USE(AUDIO_SESSION)
     PlatformMediaSessionManager::setShouldDeactivateAudioSession(true);
 #endif
+
+    setBackgroundColor(parameters.backgroundColor);
 }
 
 #if ENABLE(WEB_RTC)
@@ -2918,19 +2918,16 @@ void WebPage::setIndicating(bool indicating)
 }
 #endif
 
-void WebPage::setDrawsBackground(bool drawsBackground)
+void WebPage::setBackgroundColor(const Optional<WebCore::Color>& backgroundColor)
 {
-    if (m_drawsBackground == drawsBackground)
+    if (m_backgroundColor == backgroundColor)
         return;
 
-    m_drawsBackground = drawsBackground;
+    m_backgroundColor = backgroundColor;
 
-    if (FrameView* frameView = mainFrameView()) {
-        bool isTransparent = !drawsBackground;
-        frameView->updateBackgroundRecursively(isTransparent);
-    }
+    if (FrameView* frameView = mainFrameView())
+        frameView->updateBackgroundRecursively(backgroundColor);
 
-    m_drawingArea->pageBackgroundTransparencyChanged();
     m_drawingArea->setNeedsDisplay();
 }
 
index 9e87c19..582c15f 100644 (file)
@@ -501,8 +501,6 @@ public:
     
     void postInjectedBundleMessage(const String& messageName, const UserData&);
 
-    bool drawsBackground() const { return m_drawsBackground; }
-
     void setUnderlayColor(const WebCore::Color& color) { m_underlayColor = color; }
     WebCore::Color underlayColor() const { return m_underlayColor; }
 
@@ -1149,6 +1147,8 @@ public:
     bool requestDOMPasteAccess();
     WebCore::IntRect rectForElementAtInteractionLocation() const;
 
+    const Optional<WebCore::Color>& backgroundColor() const { return m_backgroundColor; }
+
 private:
     WebPage(uint64_t pageID, WebPageCreationParameters&&);
 
@@ -1285,7 +1285,7 @@ private:
     void setIndicating(bool);
 #endif
 
-    void setDrawsBackground(bool);
+    void setBackgroundColor(const Optional<WebCore::Color>&);
 
 #if PLATFORM(COCOA)
     void setTopContentInsetFenced(float, IPC::Attachment);
@@ -1784,7 +1784,7 @@ private:
     bool m_isSuspendedUnderLock { false };
 
     HashSet<String, ASCIICaseInsensitiveHash> m_mimeTypesWithCustomContentProviders;
-    WebCore::Color m_backgroundColor { WebCore::Color::white };
+    Optional<WebCore::Color> m_backgroundColor { WebCore::Color::white };
 
     HashSet<unsigned> m_activeRenderingSuppressionTokens;
     unsigned m_maximumRenderingSuppressionToken { 0 };
index a52bb23..019f6b0 100644 (file)
@@ -25,7 +25,7 @@ messages -> WebPage LegacyReceiver {
     SetActivityState(OptionSet<WebCore::ActivityState::Flag> activityState, WebKit::ActivityStateChangeID activityStateChangeID, Vector<WebKit::CallbackID> callbackIDs)
     SetLayerHostingMode(enum:uint8_t WebKit::LayerHostingMode layerHostingMode)
 
-    SetDrawsBackground(bool drawsBackground)
+    SetBackgroundColor(Optional<WebCore::Color> color)
 
     AddConsoleMessage(uint64_t frameID, enum:uint8_t JSC::MessageSource messageSource, enum:uint8_t JSC::MessageLevel messageLevel, String message, uint64_t requestID)
     SendCSPViolationReport(uint64_t frameID, URL reportURL, IPC::FormDataReference reportData)
index b233617..1b61b55 100644 (file)
@@ -1,3 +1,14 @@
+2019-02-26  Philippe Normand  <pnormand@igalia.com>
+
+        [WPE] Add API for webview background color configuration
+        https://bugs.webkit.org/show_bug.cgi?id=192305
+
+        Reviewed by Michael Catanzaro.
+
+        * WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebFrameLoaderClient::transitionToCommittedForNewPage): Create
+        FrameView with background color.
+
 2019-02-20  Darin Adler  <darin@apple.com>
 
         Finish removing String::format
index c1452e8..11595b2 100644 (file)
@@ -985,10 +985,12 @@ void WebFrameLoaderClient::transitionToCommittedForNewPage()
 
     RECT pixelRect;
     view->frameRect(&pixelRect);
-    bool transparent = view->transparent();
+    Optional<Color> backgroundColor;
+    if (view->transparent())
+        backgroundColor = Color(Color::transparent);
     FloatRect logicalFrame(pixelRect);
     logicalFrame.scale(1.0f / view->deviceScaleFactor());
-    core(m_webFrame)->createView(enclosingIntRect(logicalFrame).size(), transparent, /* fixedLayoutSize */ { }, /* fixedVisibleContentRect */ { });
+    core(m_webFrame)->createView(enclosingIntRect(logicalFrame).size(), backgroundColor, /* fixedLayoutSize */ { }, /* fixedVisibleContentRect */ { });
 }
 
 void WebFrameLoaderClient::didSaveToPageCache()
index 04b6fea..4ad3166 100644 (file)
@@ -2089,7 +2089,10 @@ void WebFrame::updateBackground()
     if (!coreFrame || !coreFrame->view())
         return;
 
-    coreFrame->view()->updateBackgroundRecursively(webView()->transparent());
+    Optional<Color> backgroundColor;
+    if (webView()->transparent())
+        backgroundColor = Color(Color::transparent);
+    coreFrame->view()->updateBackgroundRecursively(backgroundColor);
 }
 
 // IWebFrame2
index 9cf097e..a3bae19 100644 (file)
@@ -1,3 +1,17 @@
+2019-02-26  Philippe Normand  <pnormand@igalia.com>
+
+        [WPE] Add API for webview background color configuration
+        https://bugs.webkit.org/show_bug.cgi?id=192305
+
+        Reviewed by Michael Catanzaro.
+
+        * MiniBrowser/wpe/main.cpp:
+        (main): Add a new option to configure the webview background
+        color. Example: --bg-color=transparent.
+        * TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp:
+        (testWebViewBackgroundColor): Enable background color API tests for WPE.
+        (beforeAll): Ditto.
+
 2019-02-25  Yongjun Zhang  <yongjun_zhang@apple.com>
 
         scalableNativeWebpageParameters() is not preserved on new page navigation.
index 863c4c0..0deaa0e 100644 (file)
@@ -43,6 +43,7 @@ static const char* contentFilter;
 static const char* cookiesFile;
 static const char* cookiesPolicy;
 static const char* proxy;
+const char* bgColor;
 
 static const GOptionEntry commandLineOptions[] =
 {
@@ -55,6 +56,7 @@ static const GOptionEntry commandLineOptions[] =
     { "ignore-host", 0, 0, G_OPTION_ARG_STRING_ARRAY, &ignoreHosts, "Set proxy ignore hosts", "HOSTS" },
     { "ignore-tls-errors", 0, 0, G_OPTION_ARG_NONE, &ignoreTLSErrors, "Ignore TLS errors", nullptr },
     { "content-filter", 0, 0, G_OPTION_ARG_FILENAME, &contentFilter, "JSON with content filtering rules", "FILE" },
+    { "bg-color", 0, 0, G_OPTION_ARG_STRING, &bgColor, "Window background color. Default: white", "COLOR" },
     { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &uriArguments, nullptr, "[URL]" },
     { nullptr, 0, 0, G_OPTION_ARG_NONE, nullptr, nullptr, nullptr }
 };
@@ -254,6 +256,10 @@ int main(int argc, char *argv[])
     if (ignoreTLSErrors)
         webkit_web_context_set_tls_errors_policy(webContext, WEBKIT_TLS_ERRORS_POLICY_IGNORE);
 
+    WebKitColor color;
+    if (bgColor && webkit_color_parse(&color, bgColor))
+        webkit_web_view_set_background_color(webView, &color);
+
     if (uriArguments) {
         GFile* file = g_file_new_for_commandline_arg(uriArguments[0]);
         char* url = g_file_get_uri(file);
index 54f197b..d0531b4 100644 (file)
@@ -1133,11 +1133,16 @@ static void testWebViewIsPlayingAudio(IsPlayingAudioWebViewTest* test, gconstpoi
     g_assert_false(webkit_web_view_is_playing_audio(test->m_webView));
 }
 
-#if PLATFORM(GTK)
 static void testWebViewBackgroundColor(WebViewTest* test, gconstpointer)
 {
+#if PLATFORM(GTK)
+#define ColorType GdkRGBA
+#elif PLATFORM(WPE)
+#define ColorType WebKitColor
+#endif
+
     // White is the default background.
-    GdkRGBA rgba;
+    ColorType rgba;
     webkit_web_view_get_background_color(test->m_webView, &rgba);
     g_assert_cmpfloat(rgba.red, ==, 1);
     g_assert_cmpfloat(rgba.green, ==, 1);
@@ -1155,10 +1160,23 @@ static void testWebViewBackgroundColor(WebViewTest* test, gconstpointer)
     g_assert_cmpfloat(rgba.blue, ==, 0);
     g_assert_cmpfloat(rgba.alpha, ==, 0.5);
 
+#if PLATFORM(WPE)
+    ColorType color;
+    g_assert(webkit_color_parse(&color, "red"));
+    g_assert_cmpfloat(color.red, ==, 1);
+    webkit_web_view_set_background_color(test->m_webView, &color);
+    webkit_web_view_get_background_color(test->m_webView, &rgba);
+    g_assert_cmpfloat(rgba.red, ==, 1);
+    g_assert_cmpfloat(rgba.green, ==, 0);
+    g_assert_cmpfloat(rgba.blue, ==, 0);
+    g_assert_cmpfloat(rgba.alpha, ==, 1);
+#endif
+
     // The actual rendering can't be tested using unit tests, use
     // MiniBrowser --bg-color="<color-value>" for manually testing this API.
 }
 
+#if PLATFORM(GTK)
 static void testWebViewPreferredSize(WebViewTest* test, gconstpointer)
 {
     test->loadHtml("<html style='width: 325px; height: 615px'></html>", nullptr);
@@ -1363,8 +1381,8 @@ void beforeAll()
     NotificationWebViewTest::add("WebKitWebView", "notification-initial-permission-disallowed", testWebViewNotificationInitialPermissionDisallowed);
 #endif
     IsPlayingAudioWebViewTest::add("WebKitWebView", "is-playing-audio", testWebViewIsPlayingAudio);
-#if PLATFORM(GTK)
     WebViewTest::add("WebKitWebView", "background-color", testWebViewBackgroundColor);
+#if PLATFORM(GTK)
     WebViewTest::add("WebKitWebView", "preferred-size", testWebViewPreferredSize);
 #endif
     WebViewTitleTest::add("WebKitWebView", "title-change", testWebViewTitleChange);