WebKit Bugzilla
Attachment 358459 Details for
Bug 192305
: [WPE] Add API for webview background color configuration
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
WiP patch
0001-WIP.patch (text/plain), 47.50 KB, created by
Philippe Normand
on 2019-01-06 10:16:58 PST
(
hide
)
Description:
WiP patch
Filename:
MIME Type:
Creator:
Philippe Normand
Created:
2019-01-06 10:16:58 PST
Size:
47.50 KB
patch
obsolete
>From 8b3c41c4e34987d1385ad781e0fd1db5639332e6 Mon Sep 17 00:00:00 2001 >From: Philippe Normand <pnormand@igalia.com> >Date: Sun, 6 Jan 2019 18:06:40 +0000 >Subject: [PATCH xserver] WIP > >--- > Source/WebCore/page/Frame.cpp | 4 +- > Source/WebCore/page/Frame.h | 2 +- > Source/WebCore/page/FrameView.cpp | 5 +- > Source/WebCore/page/FrameView.h | 2 +- > Source/WebKit/PlatformWPE.cmake | 1 + > .../CoordinatedGraphicsScene.cpp | 17 +- > .../CoordinatedGraphicsScene.h | 4 +- > .../threadedcompositor/ThreadedCompositor.cpp | 14 +- > .../threadedcompositor/ThreadedCompositor.h | 3 +- > Source/WebKit/SourcesWPE.txt | 1 + > .../UIProcess/API/glib/WebKitWebView.cpp | 68 ------- > .../UIProcess/API/gtk/WebKitWebViewGtk.cpp | 69 +++++++ > .../WebKit/UIProcess/API/wpe/WebKitColor.cpp | 179 ++++++++++++++++++ > Source/WebKit/UIProcess/API/wpe/WebKitColor.h | 56 ++++++ > .../UIProcess/API/wpe/WebKitColorPrivate.h | 37 ++++ > .../WebKit/UIProcess/API/wpe/WebKitWebView.h | 7 + > .../UIProcess/API/wpe/WebKitWebViewWPE.cpp | 46 +++++ > .../API/wpe/docs/wpe-0.1-sections.txt | 16 ++ > Source/WebKit/UIProcess/WebPageProxy.cpp | 10 + > Source/WebKit/UIProcess/WebPageProxy.h | 6 +- > .../WebCoreSupport/WebFrameLoaderClient.cpp | 3 +- > .../WebPage/AcceleratedDrawingArea.cpp | 8 + > .../WebPage/AcceleratedDrawingArea.h | 1 + > .../CoordinatedLayerTreeHost.cpp | 5 + > .../CoordinatedLayerTreeHost.h | 1 + > .../ThreadedCoordinatedLayerTreeHost.cpp | 11 ++ > .../ThreadedCoordinatedLayerTreeHost.h | 1 + > .../WebKit/WebProcess/WebPage/DrawingArea.h | 1 + > .../WebKit/WebProcess/WebPage/LayerTreeHost.h | 1 + > Source/WebKit/WebProcess/WebPage/WebPage.cpp | 14 ++ > Source/WebKit/WebProcess/WebPage/WebPage.h | 3 + > .../WebProcess/WebPage/WebPage.messages.in | 1 + > Tools/MiniBrowser/wpe/main.cpp | 8 +- > .../Tests/WebKitGLib/TestWebKitWebView.cpp | 39 +++- > 34 files changed, 550 insertions(+), 94 deletions(-) > create mode 100644 Source/WebKit/UIProcess/API/wpe/WebKitColor.cpp > create mode 100644 Source/WebKit/UIProcess/API/wpe/WebKitColor.h > create mode 100644 Source/WebKit/UIProcess/API/wpe/WebKitColorPrivate.h > >diff --git a/Source/WebCore/page/Frame.cpp b/Source/WebCore/page/Frame.cpp >index 73bafdb4660..b4e0a350897 100644 >--- a/Source/WebCore/page/Frame.cpp >+++ b/Source/WebCore/page/Frame.cpp >@@ -902,7 +902,7 @@ RefPtr<Range> Frame::rangeForPoint(const IntPoint& framePoint) > return nullptr; > } > >-void Frame::createView(const IntSize& viewportSize, bool transparent, >+void Frame::createView(const IntSize& viewportSize, bool transparent, const Color& backgroundColor, > const IntSize& fixedLayoutSize, const IntRect& fixedVisibleContentRect, > bool useFixedLayout, ScrollbarMode horizontalScrollbarMode, bool horizontalLock, > ScrollbarMode verticalScrollbarMode, bool verticalLock) >@@ -933,7 +933,7 @@ void Frame::createView(const IntSize& viewportSize, bool transparent, > > setView(frameView.copyRef()); > >- frameView->updateBackgroundRecursively(transparent); >+ frameView->updateBackgroundRecursively(transparent, backgroundColor); > > if (isMainFrame) > frameView->setParentVisible(true); >diff --git a/Source/WebCore/page/Frame.h b/Source/WebCore/page/Frame.h >index 9faf2437f57..63cb12a71f8 100644 >--- a/Source/WebCore/page/Frame.h >+++ b/Source/WebCore/page/Frame.h >@@ -128,7 +128,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&, bool transparent, const Color& backgroundColor, > const IntSize& fixedLayoutSize, const IntRect& fixedVisibleContentRect, > bool useFixedLayout = false, ScrollbarMode = ScrollbarAuto, bool horizontalLock = false, > ScrollbarMode = ScrollbarAuto, bool verticalLock = false); >diff --git a/Source/WebCore/page/FrameView.cpp b/Source/WebCore/page/FrameView.cpp >index df0e105a51e..ae21e96857d 100644 >--- a/Source/WebCore/page/FrameView.cpp >+++ b/Source/WebCore/page/FrameView.cpp >@@ -3000,12 +3000,13 @@ void FrameView::setBaseBackgroundColor(const Color& backgroundColor) > renderView()->compositor().rootBackgroundColorOrTransparencyChanged(); > } > >-void FrameView::updateBackgroundRecursively(bool transparent) >+void FrameView::updateBackgroundRecursively(bool transparent, const Color& defaultBackgroundColor) > { > #if ENABLE(DARK_MODE_CSS) >+ UNUSED_PARAM(defaultBackgroundColor); > Color backgroundColor = transparent ? Color::transparent : RenderTheme::singleton().systemColor(CSSValueAppleSystemControlBackground, styleColorOptions()); > #else >- Color backgroundColor = transparent ? Color::transparent : Color::white; >+ Color backgroundColor = transparent ? Color::transparent : defaultBackgroundColor; > #endif > > for (auto* frame = m_frame.ptr(); frame; frame = frame->tree().traverseNext(m_frame.ptr())) { >diff --git a/Source/WebCore/page/FrameView.h b/Source/WebCore/page/FrameView.h >index 4f980094c08..dc721c8d4a8 100644 >--- a/Source/WebCore/page/FrameView.h >+++ b/Source/WebCore/page/FrameView.h >@@ -190,7 +190,7 @@ public: > > WEBCORE_EXPORT Color baseBackgroundColor() const; > WEBCORE_EXPORT void setBaseBackgroundColor(const Color&); >- WEBCORE_EXPORT void updateBackgroundRecursively(bool); >+ WEBCORE_EXPORT void updateBackgroundRecursively(bool, const Color& backgroundColor = Color::white); > > enum ExtendedBackgroundModeFlags { > ExtendedBackgroundModeNone = 0, >diff --git a/Source/WebKit/PlatformWPE.cmake b/Source/WebKit/PlatformWPE.cmake >index 1f675c44e4c..3cdefd2bed2 100644 >--- a/Source/WebKit/PlatformWPE.cmake >+++ b/Source/WebKit/PlatformWPE.cmake >@@ -97,6 +97,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 >diff --git a/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp b/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp >index 1b2ed1b0275..b8add4a42eb 100644 >--- a/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp >+++ b/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp >@@ -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, const Color& backgroundColor, bool drawsBackground, TextureMapper::PaintFlags PaintFlags) > { > updateSceneState(); > >@@ -78,18 +78,15 @@ 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)); >- } else >- m_textureMapper->clearColor(m_viewBackgroundColor); >+ auto& color = drawsBackground ? backgroundColor : m_viewBackgroundColor; >+ m_textureMapper->clearColor(color); > >- if (currentRootLayer->opacity() != opacity || currentRootLayer->transform() != matrix) { >+ float opacity = drawsBackground ? color.alphaAsFloat() : 1; >+ if (!drawsBackground && (currentRootLayer->opacity() != opacity)) > currentRootLayer->setOpacity(opacity); >+ >+ if (currentRootLayer->transform() != matrix) > currentRootLayer->setTransform(matrix); >- } > > currentRootLayer->paint(); > m_fpsCounter.updateFPSAndDisplay(*m_textureMapper, clipRect.location(), matrix); >diff --git a/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h b/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h >index d4bb58268fe..d68f4f9902b 100644 >--- a/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h >+++ b/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h >@@ -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&, const WebCore::Color& backgroundColor, bool drawsBackground, 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. >@@ -113,7 +113,7 @@ private: > std::unique_ptr<WebCore::TextureMapperLayer> m_rootLayer; > > Nicosia::PlatformLayer::LayerID m_rootLayerID { 0 }; >- WebCore::Color m_viewBackgroundColor { WebCore::Color::white }; >+ WebCore::Color m_viewBackgroundColor { WebCore::Color::transparent }; > > WebCore::TextureMapperFPSCounter m_fpsCounter; > }; >diff --git a/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp b/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp >index 7522f84ea8f..ddbef56f756 100644 >--- a/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp >+++ b/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp >@@ -163,6 +163,13 @@ void ThreadedCompositor::setDrawsBackground(bool drawsBackground) > m_compositingRunLoop->scheduleUpdate(); > } > >+void ThreadedCompositor::setBackgroundColor(const Color& backgroundColor) >+{ >+ LockHolder locker(m_attributes.lock); >+ m_attributes.backgroundColor = backgroundColor; >+ m_compositingRunLoop->scheduleUpdate(); >+} >+ > void ThreadedCompositor::updateViewport() > { > m_compositingRunLoop->scheduleUpdate(); >@@ -196,6 +203,8 @@ void ThreadedCompositor::renderLayerTree() > float scaleFactor; > bool drawsBackground; > bool needsResize; >+ WebCore::Color backgroundColor; >+ > Vector<WebCore::CoordinatedGraphicsState> states; > > { >@@ -205,6 +214,7 @@ void ThreadedCompositor::renderLayerTree() > scaleFactor = m_attributes.scaleFactor; > drawsBackground = m_attributes.drawsBackground; > needsResize = m_attributes.needsResize; >+ backgroundColor = m_attributes.backgroundColor; > > states = WTFMove(m_attributes.states); > >@@ -253,8 +263,8 @@ void ThreadedCompositor::renderLayerTree() > } > > m_scene->applyStateChanges(states); >- m_scene->paintToCurrentGLContext(viewportTransform, 1, FloatRect { FloatPoint { }, viewportSize }, >- Color::transparent, !drawsBackground, m_paintFlags); >+ m_scene->paintToCurrentGLContext(viewportTransform, FloatRect { FloatPoint { }, viewportSize }, >+ backgroundColor, drawsBackground, m_paintFlags); > > m_context->swapBuffers(); > >diff --git a/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h b/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h >index 6d7053850da..bc9ac616e38 100644 >--- a/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h >+++ b/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h >@@ -71,6 +71,7 @@ public: > void setScrollPosition(const WebCore::IntPoint&, float scale); > void setViewportSize(const WebCore::IntSize&, float scale); > void setDrawsBackground(bool); >+ void setBackgroundColor(const WebCore::Color&); > > void updateSceneState(const WebCore::CoordinatedGraphicsState&); > >@@ -114,7 +115,7 @@ private: > float scaleFactor { 1 }; > bool drawsBackground { true }; > bool needsResize { false }; >- >+ WebCore::Color backgroundColor; > Vector<WebCore::CoordinatedGraphicsState> states; > > bool clientRendersNextFrame { false }; >diff --git a/Source/WebKit/SourcesWPE.txt b/Source/WebKit/SourcesWPE.txt >index 8ee2fef42a6..87583bad1fa 100644 >--- a/Source/WebKit/SourcesWPE.txt >+++ b/Source/WebKit/SourcesWPE.txt >@@ -167,6 +167,7 @@ UIProcess/API/glib/WebKitWindowProperties.cpp @no-unify > UIProcess/API/wpe/CompositingManagerProxy.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 >diff --git a/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp b/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp >index 67201d89eaa..7a8a10f5c1c 100644 >--- a/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp >+++ b/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp >@@ -3969,74 +3969,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 >diff --git a/Source/WebKit/UIProcess/API/gtk/WebKitWebViewGtk.cpp b/Source/WebKit/UIProcess/API/gtk/WebKitWebViewGtk.cpp >index bc821799128..ed569e62dc0 100644 >--- a/Source/WebKit/UIProcess/API/gtk/WebKitWebViewGtk.cpp >+++ b/Source/WebKit/UIProcess/API/gtk/WebKitWebViewGtk.cpp >@@ -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> >@@ -359,3 +360,71 @@ 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); >+ >+ WebCore::Color color(*rgba); >+ auto& page = *webkitWebViewBaseGetPage(reinterpret_cast<WebKitWebViewBase*>(webView)); >+ if (page.backgroundColor() == color) >+ return; >+ >+ if (!color.isOpaque()) >+ page.setDrawsBackground(false); >+ page.setBackgroundColor(color); >+} >+ >+/** >+ * 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(); >+} >diff --git a/Source/WebKit/UIProcess/API/wpe/WebKitColor.cpp b/Source/WebKit/UIProcess/API/wpe/WebKitColor.cpp >new file mode 100644 >index 00000000000..4a4a6e13199 >--- /dev/null >+++ b/Source/WebKit/UIProcess/API/wpe/WebKitColor.cpp >@@ -0,0 +1,179 @@ >+/* >+ * 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 web view background color >+ * @Title: WebKitColor >+ * @See_also: #WebKitWebView. >+ * >+ * A WebKitColor is a boxed type wrapping a WebCore color. >+ * >+ * Since: 2.24 >+ */ >+ >+struct _WebKitColor { >+ _WebKitColor(const WebCore::Color& color) >+ : m_color(color) >+ { >+ } >+ >+ ~_WebKitColor() >+ { >+ } >+ >+ const WebCore::Color& color() const { return m_color; } >+ >+ WebCore::Color m_color; >+ int referenceCount { 1 }; >+}; >+ >+static WebKitColor* webkitColorRef(WebKitColor* color) >+{ >+ ASSERT(color); >+ g_atomic_int_inc(&color->referenceCount); >+ return color; >+} >+ >+G_DEFINE_BOXED_TYPE(WebKitColor, webkit_color, webkitColorRef, webkitColorUnref) >+ >+void webkitColorUnref(WebKitColor* color) >+{ >+ ASSERT(color); >+ if (g_atomic_int_dec_and_test(&color->referenceCount)) { >+ color->~WebKitColor(); >+ fastFree(color); >+ } >+} >+ >+WebKitColor* webkitColorFromColor(const WebCore::Color& color) >+{ >+ auto* result = static_cast<WebKitColor*>(fastMalloc(sizeof(WebKitColor))); >+ new (result) WebKitColor(color); >+ return result; >+} >+ >+const WebCore::Color& webkitColorGetColor(WebKitColor* backgroundColor) >+{ >+ return backgroundColor->color(); >+} >+ >+/** >+ * webkit_color_new_from_string: >+ * @colorString: 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 newly created #WebKitColor >+ * >+ * Since: 2.24 >+ */ >+WebKitColor* webkit_color_new_from_string(const char* colorString) >+{ >+ return webkitColorFromColor(WebCore::Color(colorString)); >+} >+ >+/** >+ * webkit_color_get_red_channel: >+ * @color: a #WebKitColor >+ * >+ * Provides read-only access to the red component of the color. >+ * >+ * Returns: a #gint clamped between 0 and 255. >+ * >+ * Since: 2.24 >+ */ >+gint webkit_color_get_red_channel(WebKitColor* color) >+{ >+ g_return_val_if_fail(color, 0); >+ return color->color().red(); >+} >+ >+/** >+ * webkit_color_get_green_channel: >+ * @color: a #WebKitColor >+ * >+ * Provides read-only access to the green component of the color. >+ * >+ * Returns: a #gint clamped between 0 and 255. >+ * >+ * Since: 2.24 >+ */ >+gint webkit_color_get_green_channel(WebKitColor* color) >+{ >+ g_return_val_if_fail(color, 0); >+ return color->color().green(); >+} >+ >+/** >+ * webkit_color_get_blue_channel: >+ * @color: a #WebKitColor >+ * >+ * Provides read-only access to the blue component of the color. >+ * >+ * Returns: a #gint clamped between 0 and 255. >+ * >+ * Since: 2.24 >+ */ >+gint webkit_color_get_blue_channel(WebKitColor* color) >+{ >+ g_return_val_if_fail(color, 0); >+ return color->color().blue(); >+} >+ >+/** >+ * webkit_color_get_alpha_channel: >+ * @color: a #WebKitColor >+ * >+ * Provides read-only access to the alpha component of the color. >+ * >+ * Returns: a #gint clamped between 0 and 255. >+ * >+ * Since: 2.24 >+ */ >+gint webkit_color_get_alpha_channel(WebKitColor* color) >+{ >+ g_return_val_if_fail(color, 0); >+ return color->color().alpha(); >+} >+ >+namespace WTF { >+ >+template <> WebKitColor* refGPtr(WebKitColor* ptr) >+{ >+ if (ptr) >+ webkitColorRef(ptr); >+ return ptr; >+} >+ >+template <> void derefGPtr(WebKitColor* ptr) >+{ >+ if (ptr) >+ webkitColorUnref(ptr); >+} >+ >+} >diff --git a/Source/WebKit/UIProcess/API/wpe/WebKitColor.h b/Source/WebKit/UIProcess/API/wpe/WebKitColor.h >new file mode 100644 >index 00000000000..5559d22fee5 >--- /dev/null >+++ b/Source/WebKit/UIProcess/API/wpe/WebKitColor.h >@@ -0,0 +1,56 @@ >+/* >+ * 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 >+ >+#define WEBKIT_TYPE_COLOR (webkit_color_get_type()) >+ >+typedef struct _WebKitColor WebKitColor; >+ >+WEBKIT_API GType >+webkit_color_get_type (void); >+ >+WEBKIT_API WebKitColor * >+webkit_color_new_from_string (const char* colorString); >+ >+WEBKIT_API gint >+webkit_color_get_red_channel (WebKitColor* color); >+ >+WEBKIT_API gint >+webkit_color_get_green_channel (WebKitColor* color); >+ >+WEBKIT_API gint >+webkit_color_get_blue_channel (WebKitColor* color); >+ >+WEBKIT_API gint >+webkit_color_get_alpha_channel (WebKitColor* color); >+ >+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 >index 00000000000..f0bb8656461 >--- /dev/null >+++ b/Source/WebKit/UIProcess/API/wpe/WebKitColorPrivate.h >@@ -0,0 +1,37 @@ >+/* >+ * 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" >+ >+#include <wtf/glib/GRefPtr.h> >+ >+namespace WTF { >+ >+template <> WebKitColor* refGPtr(WebKitColor* ptr); >+template <> void derefGPtr(WebKitColor* ptr); >+ >+} >+ >+void webkitColorUnref(WebKitColor*); >+ >+WebKitColor* webkitColorFromColor(const WebCore::Color&); >+const WebCore::Color& webkitColorGetColor(WebKitColor*); >diff --git a/Source/WebKit/UIProcess/API/wpe/WebKitWebView.h b/Source/WebKit/UIProcess/API/wpe/WebKitWebView.h >index 4102a7526d6..9df38839ee7 100644 >--- a/Source/WebKit/UIProcess/API/wpe/WebKitWebView.h >+++ b/Source/WebKit/UIProcess/API/wpe/WebKitWebView.h >@@ -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,12 @@ 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 WebKitColor * >+webkit_web_view_get_background_color (WebKitWebView *web_view); >+ > G_END_DECLS > > #endif >diff --git a/Source/WebKit/UIProcess/API/wpe/WebKitWebViewWPE.cpp b/Source/WebKit/UIProcess/API/wpe/WebKitWebViewWPE.cpp >index a3495e852e1..3527dc6d5c8 100644 >--- a/Source/WebKit/UIProcess/API/wpe/WebKitWebViewWPE.cpp >+++ b/Source/WebKit/UIProcess/API/wpe/WebKitWebViewWPE.cpp >@@ -20,6 +20,7 @@ > #include "config.h" > #include "WebKitWebView.h" > >+#include "WebKitColorPrivate.h" > #include "WebKitWebViewPrivate.h" > > gboolean webkitWebViewAuthenticate(WebKitWebView*, WebKitAuthenticationRequest*) >@@ -178,3 +179,48 @@ 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); >+ auto& color = webkitColorGetColor(backgroundColor); >+ if (!color.isOpaque()) >+ page.setDrawsBackground(false); >+ >+ page.setBackgroundColor(color); >+} >+ >+/** >+ * webkit_web_view_get_background_color: >+ * @web_view: a #WebKitWebView >+ * >+ * 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(). >+ * >+ * Returns: a #WebKitColor >+ * >+ * Since: 2.24 >+ */ >+WebKitColor* webkit_web_view_get_background_color(WebKitWebView* webView) >+{ >+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), nullptr); >+ auto& page = webkitWebViewGetPage(webView); >+ >+ return webkitColorFromColor(page.backgroundColor()); >+} >diff --git a/Source/WebKit/UIProcess/API/wpe/docs/wpe-0.1-sections.txt b/Source/WebKit/UIProcess/API/wpe/docs/wpe-0.1-sections.txt >index 628db4252a4..f7a6b44d96c 100644 >--- a/Source/WebKit/UIProcess/API/wpe/docs/wpe-0.1-sections.txt >+++ b/Source/WebKit/UIProcess/API/wpe/docs/wpe-0.1-sections.txt >@@ -206,6 +206,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 >@@ -266,6 +268,20 @@ webkit_web_view_backend_new > webkit_web_view_backend_get_type > </SECTION> > >+<SECTION> >+<FILE>WebKitColor</FILE> >+WEBKIT_TYPE_COLOR >+WebKitColor >+webkit_color_new_from_string >+webkit_color_get_red_channel >+webkit_color_get_green_channel >+webkit_color_get_blue_channel >+webkit_color_get_alpha_channel >+ >+<SUBSECTION Private> >+webkit_color_get_type >+</SECTION> >+ > <SECTION> > <FILE>WebKitAuthenticationRequest</FILE> > WebKitAuthenticationRequest >diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp >index 55e3a82681e..71a41169857 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.cpp >+++ b/Source/WebKit/UIProcess/WebPageProxy.cpp >@@ -1546,6 +1546,16 @@ void WebPageProxy::setDrawsBackground(bool drawsBackground) > m_process->send(Messages::WebPage::SetDrawsBackground(drawsBackground), m_pageID); > } > >+void WebPageProxy::setBackgroundColor(const WebCore::Color& color) >+{ >+ if (m_backgroundColor == color) >+ return; >+ >+ m_backgroundColor = color; >+ if (isValid()) >+ m_process->send(Messages::WebPage::SetBackgroundColor(color), m_pageID); >+} >+ > void WebPageProxy::setTopContentInset(float contentInset) > { > if (m_topContentInset == contentInset) >diff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h >index 78ea9500676..a87a5b62548 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.h >+++ b/Source/WebKit/UIProcess/WebPageProxy.h >@@ -751,8 +751,10 @@ public: > > #if PLATFORM(GTK) > PlatformWidget viewWidget(); >+#endif >+#if PLATFORM(GTK) || PLATFORM(WPE) > const WebCore::Color& backgroundColor() const { return m_backgroundColor; } >- void setBackgroundColor(const WebCore::Color& color) { m_backgroundColor = color; } >+ void setBackgroundColor(const WebCore::Color&); > #endif > > #if PLATFORM(WIN) >@@ -2159,6 +2161,8 @@ private: > > #if PLATFORM(GTK) > String m_accessibilityPlugID; >+#endif >+#if PLATFORM(GTK) || PLATFORM(WPE) > WebCore::Color m_backgroundColor { WebCore::Color::white }; > #endif > >diff --git a/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp b/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp >index aacb5b9ce61..70035ba3b8d 100644 >--- a/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp >+++ b/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp >@@ -1394,6 +1394,7 @@ void WebFrameLoaderClient::transitionToCommittedForNewPage() > > bool isMainFrame = m_frame->isMainFrame(); > bool isTransparent = !webPage->drawsBackground(); >+ Color backgroundColor = webPage->backgroundColor(); > bool shouldUseFixedLayout = isMainFrame && webPage->useFixedLayout(); > bool shouldDisableScrolling = isMainFrame && !webPage->mainFrameIsScrollable(); > bool shouldHideScrollbars = shouldDisableScrolling; >@@ -1418,7 +1419,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(), isTransparent, backgroundColor, > webPage->fixedLayoutSize(), fixedVisibleContentRect, shouldUseFixedLayout, > horizontalScrollbarMode, horizontalLock, verticalScrollbarMode, verticalLock); > >diff --git a/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.cpp b/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.cpp >index 9920465b173..f83ec064f4e 100644 >--- a/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.cpp >+++ b/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.cpp >@@ -101,6 +101,14 @@ void AcceleratedDrawingArea::pageBackgroundTransparencyChanged() > m_previousLayerTreeHost->pageBackgroundTransparencyChanged(); > } > >+void AcceleratedDrawingArea::pageBackgroundColorChanged() >+{ >+ if (m_layerTreeHost) >+ m_layerTreeHost->pageBackgroundColorChanged(); >+ else if (m_previousLayerTreeHost) >+ m_previousLayerTreeHost->pageBackgroundColorChanged(); >+} >+ > void AcceleratedDrawingArea::setLayerTreeStateIsFrozen(bool isFrozen) > { > if (m_layerTreeStateIsFrozen == isFrozen) >diff --git a/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.h b/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.h >index 70abe435925..c2bd5f76a96 100644 >--- a/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.h >+++ b/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.h >@@ -44,6 +44,7 @@ protected: > void setNeedsDisplayInRect(const WebCore::IntRect&) override; > void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta) override; > void pageBackgroundTransparencyChanged() override; >+ void pageBackgroundColorChanged() override; > void setLayerTreeStateIsFrozen(bool) override; > bool layerTreeStateIsFrozen() const override { return m_layerTreeStateIsFrozen; } > LayerTreeHost* layerTreeHost() const override { return m_layerTreeHost.get(); } >diff --git a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp >index 1520f520dac..aef4f015d6c 100644 >--- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp >+++ b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp >@@ -228,6 +228,11 @@ void CoordinatedLayerTreeHost::pageBackgroundTransparencyChanged() > { > } > >+void CoordinatedLayerTreeHost::pageBackgroundColorChanged() >+{ >+ >+} >+ > GraphicsLayerFactory* CoordinatedLayerTreeHost::graphicsLayerFactory() > { > return &m_coordinator; >diff --git a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h >index 0a8bec8a398..27cae004e42 100644 >--- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h >+++ b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h >@@ -56,6 +56,7 @@ protected: > > void deviceOrPageScaleFactorChanged() override; > void pageBackgroundTransparencyChanged() override; >+ void pageBackgroundColorChanged() override; > > void setVisibleContentsRect(const WebCore::FloatRect&); > void renderNextFrame(bool); >diff --git a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp >index 823b7fa2ac7..f8e2b5d0ece 100644 >--- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp >+++ b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp >@@ -195,6 +195,17 @@ void ThreadedCoordinatedLayerTreeHost::pageBackgroundTransparencyChanged() > m_compositor->setDrawsBackground(m_webPage.drawsBackground()); > } > >+void ThreadedCoordinatedLayerTreeHost::pageBackgroundColorChanged() >+{ >+ if (m_isDiscardable) { >+ m_discardableSyncActions.add(DiscardableSyncActions::UpdateBackground); >+ return; >+ } >+ >+ CoordinatedLayerTreeHost::pageBackgroundColorChanged(); >+ m_compositor->setBackgroundColor(m_webPage.backgroundColor()); >+} >+ > void ThreadedCoordinatedLayerTreeHost::sizeDidChange(const IntSize& size) > { > if (m_isDiscardable) { >diff --git a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h >index b784681679b..84b3f883283 100644 >--- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h >+++ b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h >@@ -58,6 +58,7 @@ private: > void sizeDidChange(const WebCore::IntSize&) override; > void deviceOrPageScaleFactorChanged() override; > void pageBackgroundTransparencyChanged() override; >+ void pageBackgroundColorChanged() override; > > void contentsSizeChanged(const WebCore::IntSize&) override; > void didChangeViewportAttributes(WebCore::ViewportAttributes&&) override; >diff --git a/Source/WebKit/WebProcess/WebPage/DrawingArea.h b/Source/WebKit/WebProcess/WebPage/DrawingArea.h >index f9c89174a4a..1b2bcbeab83 100644 >--- a/Source/WebKit/WebProcess/WebPage/DrawingArea.h >+++ b/Source/WebKit/WebProcess/WebPage/DrawingArea.h >@@ -80,6 +80,7 @@ public: > > // FIXME: These should be pure virtual. > virtual void pageBackgroundTransparencyChanged() { } >+ virtual void pageBackgroundColorChanged() { } > virtual void forceRepaint() { } > virtual bool forceRepaintAsync(CallbackID) { return false; } > virtual void setLayerTreeStateIsFrozen(bool) { } >diff --git a/Source/WebKit/WebProcess/WebPage/LayerTreeHost.h b/Source/WebKit/WebProcess/WebPage/LayerTreeHost.h >index 85dd458e018..1668bbb9d63 100644 >--- a/Source/WebKit/WebProcess/WebPage/LayerTreeHost.h >+++ b/Source/WebKit/WebProcess/WebPage/LayerTreeHost.h >@@ -75,6 +75,7 @@ public: > virtual bool forceRepaintAsync(CallbackID) { return false; } > virtual void sizeDidChange(const WebCore::IntSize& newSize) = 0; > virtual void pageBackgroundTransparencyChanged() = 0; >+ virtual void pageBackgroundColorChanged() = 0; > > virtual void pauseRendering(); > virtual void resumeRendering(); >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.cpp b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >index f6d4bea1d35..55387b0b79f 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >@@ -2884,6 +2884,20 @@ void WebPage::setDrawsBackground(bool drawsBackground) > m_drawingArea->setNeedsDisplay(); > } > >+void WebPage::setBackgroundColor(const WebCore::Color& backgroundColor) >+{ >+ if (m_backgroundColor == backgroundColor) >+ return; >+ >+ m_backgroundColor = backgroundColor; >+ >+ if (FrameView* frameView = mainFrameView()) >+ frameView->setBaseBackgroundColor(backgroundColor); >+ >+ m_drawingArea->pageBackgroundColorChanged(); >+ m_drawingArea->setNeedsDisplay(); >+} >+ > #if PLATFORM(COCOA) > void WebPage::setTopContentInsetFenced(float contentInset, IPC::Attachment fencePort) > { >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.h b/Source/WebKit/WebProcess/WebPage/WebPage.h >index 6e5c92e5848..37dcf3ac965 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.h >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.h >@@ -1136,6 +1136,8 @@ public: > > void didReceiveWebPageMessage(IPC::Connection&, IPC::Decoder&); > >+ const WebCore::Color& backgroundColor() const { return m_backgroundColor; } >+ > private: > WebPage(uint64_t pageID, WebPageCreationParameters&&); > >@@ -1263,6 +1265,7 @@ private: > #endif > > void setDrawsBackground(bool); >+ void setBackgroundColor(const WebCore::Color&); > > #if PLATFORM(COCOA) > void setTopContentInsetFenced(float, IPC::Attachment); >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >index 54abbaf8934..5fafff3d497 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >@@ -26,6 +26,7 @@ messages -> WebPage LegacyReceiver { > SetLayerHostingMode(enum:uint8_t WebKit::LayerHostingMode layerHostingMode) > > SetDrawsBackground(bool drawsBackground) >+ SetBackgroundColor(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) >diff --git a/Tools/MiniBrowser/wpe/main.cpp b/Tools/MiniBrowser/wpe/main.cpp >index e0c29b21299..1ce1278e35d 100644 >--- a/Tools/MiniBrowser/wpe/main.cpp >+++ b/Tools/MiniBrowser/wpe/main.cpp >@@ -42,6 +42,7 @@ static gboolean ignoreTLSErrors; > static const char* cookiesFile; > static const char* cookiesPolicy; > static const char* proxy; >+const char* bgColor; > > static const GOptionEntry commandLineOptions[] = > { >@@ -53,6 +54,7 @@ static const GOptionEntry commandLineOptions[] = > { "proxy", 0, 0, G_OPTION_ARG_STRING, &proxy, "Set proxy", "PROXY" }, > { "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 }, >+ { "bg-color", 0, 0, G_OPTION_ARG_STRING, &bgColor, "Window background color (white by default)", "white" }, > { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &uriArguments, nullptr, "[URL]" }, > { nullptr, 0, 0, G_OPTION_ARG_NONE, nullptr, nullptr, nullptr } > }; >@@ -194,6 +196,10 @@ int main(int argc, char *argv[]) > if (ignoreTLSErrors) > webkit_web_context_set_tls_errors_policy(webContext, WEBKIT_TLS_ERRORS_POLICY_IGNORE); > >+ auto* backgroundColor = webkit_color_new_from_string(bgColor); >+ webkit_web_view_set_background_color(webView, backgroundColor); >+ g_boxed_free(WEBKIT_TYPE_COLOR, backgroundColor); >+ > if (uriArguments) > webkit_web_view_load_uri(webView, uriArguments[0]); > else if (!automationMode) >@@ -202,7 +208,7 @@ int main(int argc, char *argv[]) > g_main_loop_run(loop); > > g_object_unref(webView); >- if (privateMode) >+ if (privateMode || automationMode) > g_object_unref(webContext); > g_main_loop_unref(loop); > >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp >index d757341b0fb..a5317811a4c 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp >+++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp >@@ -1133,9 +1133,9 @@ static void testWebViewIsPlayingAudio(IsPlayingAudioWebViewTest* test, gconstpoi > g_assert(!webkit_web_view_is_playing_audio(test->m_webView)); > } > >-#if PLATFORM(GTK) > static void testWebViewBackgroundColor(WebViewTest* test, gconstpointer) > { >+#if PLATFORM(GTK) > // White is the default background. > GdkRGBA rgba; > webkit_web_view_get_background_color(test->m_webView, &rgba); >@@ -1154,11 +1154,46 @@ static void testWebViewBackgroundColor(WebViewTest* test, gconstpointer) > g_assert_cmpfloat(rgba.green, ==, 0); > g_assert_cmpfloat(rgba.blue, ==, 0); > g_assert_cmpfloat(rgba.alpha, ==, 0.5); >+#endif >+#if PLATFORM(WPE) >+ // White is the default background. >+ WebKitColor* color = webkit_web_view_get_background_color(test->m_webView); >+ g_assert_cmpint(webkit_color_get_red_channel(color), ==, 255); >+ g_assert_cmpint(webkit_color_get_green_channel(color), ==, 255); >+ g_assert_cmpint(webkit_color_get_blue_channel(color), ==, 255); >+ g_assert_cmpint(webkit_color_get_alpha_channel(color), ==, 255); >+ g_boxed_free(WEBKIT_TYPE_COLOR, color); >+ >+ // Set to green. >+ WebKitColor* color2 = webkit_color_new_from_string("green"); >+ webkit_web_view_set_background_color(test->m_webView, color2); >+ g_boxed_free(WEBKIT_TYPE_COLOR, color2); >+ >+ color = webkit_web_view_get_background_color(test->m_webView); >+ g_assert_cmpint(webkit_color_get_red_channel(color), ==, 0); >+ g_assert_cmpint(webkit_color_get_green_channel(color), ==, 128); >+ g_assert_cmpint(webkit_color_get_blue_channel(color), ==, 0); >+ g_assert_cmpint(webkit_color_get_alpha_channel(color), ==, 255); >+ g_boxed_free(WEBKIT_TYPE_COLOR, color); >+ >+ // Fully transparent >+ color2 = webkit_color_new_from_string("transparent"); >+ webkit_web_view_set_background_color(test->m_webView, color2); >+ g_boxed_free(WEBKIT_TYPE_COLOR, color2); >+ >+ color = webkit_web_view_get_background_color(test->m_webView); >+ g_assert_cmpint(webkit_color_get_red_channel(color), ==, 0); >+ g_assert_cmpint(webkit_color_get_green_channel(color), ==, 0); >+ g_assert_cmpint(webkit_color_get_blue_channel(color), ==, 0); >+ g_assert_cmpint(webkit_color_get_alpha_channel(color), ==, 0); >+ g_boxed_free(WEBKIT_TYPE_COLOR, color); > >+#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 +1398,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); >-- >2.20.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 192305
:
356371
|
358458
|
358459
|
358597
|
358799
|
359005
|
359470
|
359477
|
360849
|
361048
|
361672
|
361676
|
361678