WebKit Bugzilla
Attachment 359005 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]
Patch
bug-192305-20190113160143.patch (text/plain), 55.64 KB, created by
Philippe Normand
on 2019-01-13 08:01:45 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Philippe Normand
Created:
2019-01-13 08:01:45 PST
Size:
55.64 KB
patch
obsolete
>Subversion Revision: 239904 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 4c2344246c0c54dcdb051976de53f8c76c6c0caa..236b38cd4e2269ed5d2cd43aec2c7987444a72a1 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,22 @@ >+2019-01-10 Philippe Normand <pnormand@igalia.com> >+ >+ [WPE] Add API to allow application to disable background rendering >+ https://bugs.webkit.org/show_bug.cgi?id=192305 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Adapt the FrameView API to allow a default non-white background color. >+ >+ * page/Frame.cpp: >+ (WebCore::Frame::createView): A new argument is now expected, to >+ configure the background color of the view. >+ * page/Frame.h: >+ * page/FrameView.cpp: >+ (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: >+ > 2019-01-12 Timothy Hatcher <timothy@apple.com> > > Have prefers-color-scheme: light always match on macOS versions before Mojave. >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 9cf5967e741feb5a23496d1dfa680cab917c6f15..143340152b80eb953cae5abcd70c7b230655b2cc 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,84 @@ >+2019-01-10 Philippe Normand <pnormand@igalia.com> >+ >+ [WPE] Add API to allow application to disable background rendering >+ https://bugs.webkit.org/show_bug.cgi?id=192305 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * PlatformWPE.cmake: Add new WPE API for WebKitColor boxed type. >+ * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp: >+ (WebKit::CoordinatedGraphicsScene::paintToCurrentGLContext): >+ Simplified method signature and implementation. >+ * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h: >+ * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp: >+ (WebKit::ThreadedCompositor::setBackgroundColor): The webview >+ background color is now carried on through the compositor >+ attributes. >+ (WebKit::ThreadedCompositor::renderLayerTree): Ditto. >+ * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h: >+ * SourcesWPE.txt: Add new WPE API for WebKitColor boxed type. >+ * UIProcess/API/glib/WebKitWebView.cpp: Move GTK implementation of >+ webkit_web_view_set_background_color to the GTK implementation >+ file. >+ * UIProcess/API/gtk/WebKitWebViewGtk.cpp: Ditto. >+ (webkit_web_view_set_background_color): >+ (webkit_web_view_get_background_color): >+ * UIProcess/API/wpe/WebKitColor.cpp: Added. Very simple wrapper around WebCore::Color, basically. >+ (_WebKitColor::_WebKitColor): >+ (_WebKitColor::~_WebKitColor): >+ (_WebKitColor::color const): >+ (webkitColorRef): >+ (webkitColorUnref): >+ (webkitColorFromColor): >+ (webkitColorGetColor): >+ (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): >+ (WTF::refGPtr): >+ (WTF::derefGPtr): >+ * 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::setBackgroundColor): Send background color >+ change notification to the WebProcess. >+ * UIProcess/WebPageProxy.h: Enable background color configuration API for WPE. >+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: >+ (WebKit::WebFrameLoaderClient::transitionToCommittedForNewPage): >+ Use background color as provided by the UIProcess when creating >+ the FrameView. >+ * WebProcess/WebPage/AcceleratedDrawingArea.cpp: >+ (WebKit::AcceleratedDrawingArea::pageBackgroundColorChanged): >+ Propagate background color notification to the LayerTreeHost. It >+ will end up in the ThreadedCompositor for WPE. >+ * WebProcess/WebPage/AcceleratedDrawingArea.h: >+ * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp: >+ Empty implementation of background color notification API. >+ (WebKit::CoordinatedLayerTreeHost::pageBackgroundColorChanged): >+ * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h: >+ * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp: >+ (WebKit::ThreadedCoordinatedLayerTreeHost::pageBackgroundColorChanged): >+ Propagate background color notification to the ThreadedCompositor. >+ * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h: >+ * WebProcess/WebPage/DrawingArea.h: >+ (WebKit::DrawingArea::pageBackgroundColorChanged): new virtual >+ method for background color notifications. >+ * 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: New message for >+ background color configuration support from the UIProcess to the >+ WebProcess. >+ > 2019-01-12 Timothy Hatcher <timothy@apple.com> > > Have prefers-color-scheme: light always match on macOS versions before Mojave. >diff --git a/Source/WebKitLegacy/win/ChangeLog b/Source/WebKitLegacy/win/ChangeLog >index 2670497541605c6a27842f87060f0c481ce8ef66..d36ce86cdfa3d5ffcda275e67f4d3df6fb2b2fc8 100644 >--- a/Source/WebKitLegacy/win/ChangeLog >+++ b/Source/WebKitLegacy/win/ChangeLog >@@ -1,3 +1,15 @@ >+2019-01-10 Philippe Normand <pnormand@igalia.com> >+ >+ [WPE] Add API to allow application to disable background rendering >+ https://bugs.webkit.org/show_bug.cgi?id=192305 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WebCoreSupport/WebFrameLoaderClient.cpp: >+ (WebFrameLoaderClient::transitionToCommittedForNewPage): Create >+ FrameView with explicit default white background. This used to be >+ implicit. Hence no behavior change expected. >+ > 2019-01-08 Alex Christensen <achristensen@webkit.org> > > Stop using NetworkStorageSession in WebProcess >diff --git a/Source/WebCore/page/Frame.cpp b/Source/WebCore/page/Frame.cpp >index 73bafdb46602785ff41415fe2699a0ab710a19ca..b4e0a3508976a0814da473a675293f6df70013c6 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 8ad13d6e1ccc27a638157d811ab1cf48ce2e2069..d117083412b257c0d048ced60f9e47ae3cd31579 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 d25a7e61a7ae34cb257e14f0e525c73982282de9..fc761049c60057b294458b5e9eb16344e66506fd 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 2976b567dbf0a19789b76e609a117e62b511825b..876ef3ca3f45ba3a49778f4a2e1f2488baae2bd3 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 1f675c44e4c7459c005dd6781adb762a56a7ac37..3cdefd2bed21705e4323b6537fdd6dcfea97248e 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 1b2ed1b0275e65bbe191955998c293a83ba64608..0ae692a0eaa10de73874714aac6d0d93279511f5 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 d4bb58268fe752216138d564117b4b76ec8a9f93..d68f4f9902bcfdba88aeb9454aa54ae4818b77be 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 7522f84ea8f8a6823bb921ffc3f05cfbd87eb581..ddbef56f756875a46c786c2d508be217fda86b47 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 6d7053850dad57a164f19e9186f4fa2a6a866aff..bc9ac616e3812780407b7c96c21e2d9f7da7cc57 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/Shared/WebPageCreationParameters.cpp b/Source/WebKit/Shared/WebPageCreationParameters.cpp >index ca2df40ee1dd2ca36f3a48a04757f97bdbb63647..5ebb0a9ad3a07c050a68d82a7ba435103e9281a4 100644 >--- a/Source/WebKit/Shared/WebPageCreationParameters.cpp >+++ b/Source/WebKit/Shared/WebPageCreationParameters.cpp >@@ -120,6 +120,9 @@ void WebPageCreationParameters::encode(IPC::Encoder& encoder) const > #if ENABLE(CONTENT_EXTENSIONS) > encoder << contentRuleLists; > #endif >+#if PLATFORM(GTK) || PLATFORM(WPE) >+ encoder << backgroundColor; >+#endif > } > > Optional<WebPageCreationParameters> WebPageCreationParameters::decode(IPC::Decoder& decoder) >@@ -347,6 +350,10 @@ Optional<WebPageCreationParameters> WebPageCreationParameters::decode(IPC::Decod > return WTF::nullopt; > parameters.contentRuleLists = WTFMove(*contentRuleLists); > #endif >+#if PLATFORM(GTK) || PLATFORM(WPE) >+ if (!decoder.decode(parameters.backgroundColor)) >+ return WTF::nullopt; >+#endif > > return WTFMove(parameters); > } >diff --git a/Source/WebKit/Shared/WebPageCreationParameters.h b/Source/WebKit/Shared/WebPageCreationParameters.h >index ae4325cbd5f1e567616586f5e9fa73ee5b35b937..c435bd5a244d64a1a0ca6240ec017fb304d4ad76 100644 >--- a/Source/WebKit/Shared/WebPageCreationParameters.h >+++ b/Source/WebKit/Shared/WebPageCreationParameters.h >@@ -186,6 +186,10 @@ struct WebPageCreationParameters { > #if ENABLE(CONTENT_EXTENSIONS) > Vector<std::pair<String, WebCompiledContentRuleListData>> contentRuleLists; > #endif >+ >+#if PLATFORM(GTK) || PLATFORM(WPE) >+ WebCore::Color backgroundColor; >+#endif > }; > > } // namespace WebKit >diff --git a/Source/WebKit/SourcesWPE.txt b/Source/WebKit/SourcesWPE.txt >index 5119cae56bc06f22973f6733c08437ab2e3e3e12..1a820a85b51a5507d8d6b309f90f58341e680252 100644 >--- a/Source/WebKit/SourcesWPE.txt >+++ b/Source/WebKit/SourcesWPE.txt >@@ -168,6 +168,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 67201d89eaa1f3f20df8b91f1da15d9c258b638f..7a8a10f5c1c80159a28a761364a262059eec7c8a 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 bc82179912826ab47af7c96575e1ba8ba426e881..ed569e62dc0b549b31a7cdd74073b264cb84bf57 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 0000000000000000000000000000000000000000..742d32cb76f1da03f895b78b69d9e53b802af0ef >--- /dev/null >+++ b/Source/WebKit/UIProcess/API/wpe/WebKitColor.cpp >@@ -0,0 +1,115 @@ >+/* >+ * 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) >+{ >+ auto webCoreColor = WebCore::Color(colorString); >+ if (!webCoreColor.isValid()) >+ return FALSE; >+ >+ if (color) { >+ webkitColorFillFromWebCoreColor(webCoreColor, color); >+ return TRUE; >+ } >+ return FALSE; >+} >diff --git a/Source/WebKit/UIProcess/API/wpe/WebKitColor.h b/Source/WebKit/UIProcess/API/wpe/WebKitColor.h >new file mode 100644 >index 0000000000000000000000000000000000000000..d4ed178c418c01994167eabe11bdcc256c9b0c24 >--- /dev/null >+++ b/Source/WebKit/UIProcess/API/wpe/WebKitColor.h >@@ -0,0 +1,58 @@ >+/* >+ * 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 and 1 >+ * @green: Green channel, between 0 and 1 >+ * @blue: Blue channel, between 0 and 1 >+ * @alpha: Alpha channel, between 0 and 1 >+ */ >+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 >index 0000000000000000000000000000000000000000..239a11603417771af43ccfb4ee97ee7cb1c22c73 >--- /dev/null >+++ b/Source/WebKit/UIProcess/API/wpe/WebKitColorPrivate.h >@@ -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*); >diff --git a/Source/WebKit/UIProcess/API/wpe/WebKitWebView.h b/Source/WebKit/UIProcess/API/wpe/WebKitWebView.h >index 4102a7526d6bdf013cbb904a52425d61d12e3cd9..2a4a6204235533e0c7780bf396696be979a14148 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,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 >diff --git a/Source/WebKit/UIProcess/API/wpe/WebKitWebViewWPE.cpp b/Source/WebKit/UIProcess/API/wpe/WebKitWebViewWPE.cpp >index a3495e852e19f92d1c4f0e937b4b9f11832eada4..4e2012f2821dda88905dd80e1370dc0ef4ada559 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,45 @@ 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(); >+ g_return_if_fail(webCoreColor.isValid()); >+ webkitColorFillFromWebCoreColor(webCoreColor, color); >+} >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 628db4252a4d2bf48f490da54087ac4c2c95bc91..5e238c8ffafec2f296477b0e50c1c210a674e89f 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,16 @@ webkit_web_view_backend_new > 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 >diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp >index c8ab70333b4039a8779c4ca3f31e1907563a3369..4f9d73e219efc811ff76a7fd4c9ee0a01405dd17 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.cpp >+++ b/Source/WebKit/UIProcess/WebPageProxy.cpp >@@ -1538,6 +1538,18 @@ void WebPageProxy::setDrawsBackground(bool drawsBackground) > m_process->send(Messages::WebPage::SetDrawsBackground(drawsBackground), m_pageID); > } > >+#if PLATFORM(GTK) || PLATFORM(WPE) >+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); >+} >+#endif >+ > void WebPageProxy::setTopContentInset(float contentInset) > { > if (m_topContentInset == contentInset) >@@ -6781,6 +6793,10 @@ WebPageCreationParameters WebPageProxy::creationParameters() > > parameters.needsFontAttributes = m_needsFontAttributes; > >+#if PLATFORM(GTK) || PLATFORM(WPE) >+ parameters.backgroundColor = m_backgroundColor; >+#endif >+ > m_process->addWebUserContentControllerProxy(m_userContentController, parameters); > > return parameters; >diff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h >index de98694aa37db3c7f2ce27cc829a9200211de10d..126de45a356f12810983d9008a81b52b4b752c78 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.h >+++ b/Source/WebKit/UIProcess/WebPageProxy.h >@@ -752,8 +752,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) >@@ -2165,6 +2167,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 aacb5b9ce61b81657146a4bca653834ba0d400b0..70035ba3b8db30a462e197d12326f100032f6478 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 9920465b17392a8314cf2d05c31533f5606d2011..f83ec064f4e1b6d82e4ef25653f28877ac76fc2d 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 70abe435925cbf37dbc3d2d874dbf483f4c8f19e..c2bd5f76a965f5dbb2521596783d5b8b68ae62f4 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 1520f520dac98e43e45b7e0637571b930258ccac..aef4f015d6cad1de2e05766ce1a5bcb2febda367 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 0a8bec8a3986cea2a80da50992aba2a831c3536a..27cae004e4247562327d5f966a3d07dc7be80807 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 823b7fa2ac7597a3aeab274431bc0cc9b92908c9..f8e2b5d0ece256da7548531c0bd7a56b00ad8cec 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 b784681679b227bb81227745e1b768e1a3b063cd..84b3f8832838c37e7129067aeb918c3fc29978ec 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 f9c89174a4a37bf4db22c1d2c42624cf9df2a742..1b2bcbeab83568f5d88c84eb08d25bbdf3ec1257 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 85dd458e01800311c38b56da00fd2019090d207a..1668bbb9d6373aef245839d29952a34dce809462 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 803ba8b995ed3ec831ab46b5397c7662e6a81c65..f84165c7a4c63e70cc4c63ea06956f94a0b4814f 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >@@ -637,6 +637,10 @@ WebPage::WebPage(uint64_t pageID, WebPageCreationParameters&& parameters) > #if USE(AUDIO_SESSION) > PlatformMediaSessionManager::setShouldDeactivateAudioSession(true); > #endif >+ >+#if PLATFORM(GTK) || PLATFORM(WPE) >+ setBackgroundColor(parameters.backgroundColor); >+#endif > } > > #if ENABLE(WEB_RTC) >@@ -2891,6 +2895,22 @@ void WebPage::setDrawsBackground(bool drawsBackground) > m_drawingArea->setNeedsDisplay(); > } > >+#if PLATFORM(GTK) || PLATFORM(WPE) >+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(); >+} >+#endif >+ > #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 715e124520ff076b960aed70e9b92075a6552aef..b968ed527b2ddbb2d297d8ac8be264678a0a6bff 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.h >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.h >@@ -1137,6 +1137,8 @@ public: > > void didReceiveWebPageMessage(IPC::Connection&, IPC::Decoder&); > >+ const WebCore::Color& backgroundColor() const { return m_backgroundColor; } >+ > private: > WebPage(uint64_t pageID, WebPageCreationParameters&&); > >@@ -1265,6 +1267,10 @@ private: > > void setDrawsBackground(bool); > >+#if PLATFORM(GTK) || PLATFORM(WPE) >+ void setBackgroundColor(const WebCore::Color&); >+#endif >+ > #if PLATFORM(COCOA) > void setTopContentInsetFenced(float, IPC::Attachment); > #endif >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >index 54abbaf8934ccdcf8e4f20f783fcb6b9f03040eb..776654690906227d6dffac0025f7996d5437e27d 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >@@ -27,6 +27,10 @@ messages -> WebPage LegacyReceiver { > > SetDrawsBackground(bool drawsBackground) > >+#if PLATFORM(GTK) || PLATFORM(WPE) >+ SetBackgroundColor(WebCore::Color color) >+#endif >+ > 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) > EnqueueSecurityPolicyViolationEvent(uint64_t frameID, WebCore::SecurityPolicyViolationEvent::Init eventInit) >diff --git a/Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.cpp b/Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.cpp >index ee8198a88271681e51bc1cec21755e1f574ddfa9..05e3d7341f71b796082dd710c9ce92693084c4a2 100644 >--- a/Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.cpp >+++ b/Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.cpp >@@ -987,7 +987,7 @@ void WebFrameLoaderClient::transitionToCommittedForNewPage() > bool transparent = view->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(), transparent, Color::white, /* fixedLayoutSize */ { }, /* fixedVisibleContentRect */ { }); > } > > void WebFrameLoaderClient::didSaveToPageCache() >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 73a2cca089a3dc2cedf1362c2f70e29d2d9bcc73..1e9c77944e69728e665df28305d8e5a7b7a6bb8a 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,17 @@ >+2019-01-10 Philippe Normand <pnormand@igalia.com> >+ >+ [WPE] Add API to allow application to disable background rendering >+ https://bugs.webkit.org/show_bug.cgi?id=192305 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * 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-01-12 Timothy Hatcher <timothy@apple.com> > > Have prefers-color-scheme: light always match on macOS versions before Mojave. >diff --git a/Tools/MiniBrowser/wpe/main.cpp b/Tools/MiniBrowser/wpe/main.cpp >index e0c29b2129934371274a6f25451eae9821c4689f..ee65058805e3d02722dd098d558159a95fe01cc7 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. 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 } > }; >@@ -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); > >+ WebKitColor color; >+ if (bgColor && webkit_color_parse(&color, bgColor)) >+ webkit_web_view_set_background_color(webView, &color); >+ > if (uriArguments) > webkit_web_view_load_uri(webView, uriArguments[0]); > else if (!automationMode) >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp >index 54f197b883367abb250260e402ebf5b9fda6c4f3..d0531b49f0fc36012ae3aa26d2973b54e54c4259 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp >+++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp >@@ -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);
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