https://bugs.webkit.org/show_bug.cgi?id=192305
Source/WebCore:
Reviewed by Michael Catanzaro.
Adapt the FrameView API to allow a default non-white background color.
* page/Frame.cpp:
(WebCore::Frame::createView): Replace isTransparent argument with a background color one.
* page/Frame.h:
* page/FrameView.cpp:
(WebCore::FrameView::recalculateBaseBackgroundColor): Use Color::transparent if m_isTransparent is true.
(WebCore::FrameView::updateBackgroundRecursively): Allow the fallback background color to be non-white, this is
used only in non-dark-mode-css build configurations.
* page/FrameView.h:
* testing/Internals.cpp:
(WebCore::Internals::setViewIsTransparent): Use Color::transparent if transparent is true.
Source/WebKit:
Reviewed by Michael Catanzaro.
In the case of WPE we need to send the background color to the web process to be used as the background color of
the page. This patch adapts the GTK+ implementation to do the same, since it's a lot simpler. The patch also
removes the SetDrawsBackground message in favor of the new SetBackgroundColor message that receives an optional
color.
* PlatformWPE.cmake: Add new WPE API for WebKitColor boxed type.
* Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
(WebKit::CoordinatedGraphicsScene::paintToCurrentGLContext): Remove background rendering and opacity handling.
* Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h:
* Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
(WebKit::ThreadedCompositor::renderLayerTree): Remove drawsBakground and always clear the context with
transparent color.
* Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode const): Replace drawsBackground with backgroundColor.
(WebKit::WebPageCreationParameters::decode): Ditto.
* Shared/WebPageCreationParameters.h:
* SourcesWPE.txt:
* UIProcess/API/glib/WebKitWebView.cpp:
* UIProcess/API/gtk/WebKitWebViewGtk.cpp:
(webkit_web_view_set_background_color):
(webkit_web_view_get_background_color):
* UIProcess/API/wpe/WebKitColor.cpp: Added.
(webkit_color_copy):
(webkit_color_free):
(webkitColorToWebCoreColor):
(webkitColorFillFromWebCoreColor):
(webkit_color_parse):
* UIProcess/API/wpe/WebKitColor.h: Added.
* UIProcess/API/wpe/WebKitColorPrivate.h: Added.
* UIProcess/API/wpe/WebKitWebView.h: Implement webkit_web_view_set_background_color API.
* UIProcess/API/wpe/WebKitWebViewWPE.cpp: Ditto.
(webkit_web_view_set_background_color):
(webkit_web_view_get_background_color):
* UIProcess/API/wpe/docs/wpe-0.1-sections.txt: Add new symbols.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::setDrawsBackground): Set a transparent background color when false is passed.
(WebKit::WebPageProxy::setBackgroundColor): Send background color to the WebProcess.
(WebKit::WebPageProxy::creationParameters): Replace drawsBackground with backgroundColor.
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::drawsBackground const):
(WebKit::WebPageProxy::backgroundColor const):
* UIProcess/cairo/BackingStoreCairo.cpp:
(WebKit::BackingStore::incorporateUpdate): Remove GTK+ code to handle background color.
* UIProcess/gtk/AcceleratedBackingStore.cpp:
* UIProcess/gtk/AcceleratedBackingStore.h: Make paint() pure virtual and remove the implementation.
* UIProcess/gtk/AcceleratedBackingStoreWayland.cpp:
(WebKit::AcceleratedBackingStoreWayland::paint): Dot not call AcceleratedBackingStore::paint() now that is pure virtual.
* UIProcess/gtk/AcceleratedBackingStoreX11.cpp:
(WebKit::AcceleratedBackingStoreX11::paint): Ditto.
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::transitionToCommittedForNewPage): Use background color as provided by the
UIProcess when creating the FrameView.
* WebProcess/WebPage/AcceleratedDrawingArea.cpp:
* WebProcess/WebPage/AcceleratedDrawingArea.h:
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
* WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
(WebKit::ThreadedCoordinatedLayerTreeHost::setIsDiscardable):
* WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h:
* WebProcess/WebPage/DrawingArea.h:
* WebProcess/WebPage/DrawingAreaImpl.cpp:
(WebKit::DrawingAreaImpl::display): Remove special case for transparent background.
* WebProcess/WebPage/LayerTreeHost.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setBackgroundColor): New API for background color configuration. Proxies to FrameView and DrawingArea.
* WebProcess/WebPage/WebPage.h:
(WebKit::WebPage::backgroundColor const): Read-only access to the current background color.
* WebProcess/WebPage/WebPage.messages.in: Replace SetDrawsBackground message with SetBackgroundColor.
Source/WebKitLegacy/win:
Patch by Philippe Normand <pnormand@igalia.com> on 2019-02-26
Reviewed by Michael Catanzaro.
* WebCoreSupport/WebFrameLoaderClient.cpp:
(WebFrameLoaderClient::transitionToCommittedForNewPage): Create
FrameView with background color.
Tools:
Patch by Philippe Normand <pnormand@igalia.com> on 2019-02-26
Reviewed by Michael Catanzaro.
* MiniBrowser/wpe/main.cpp:
(main): Add a new option to configure the webview background
color. Example: --bg-color=transparent.
* TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp:
(testWebViewBackgroundColor): Enable background color API tests for WPE.
(beforeAll): Ditto.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242082
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2019-02-26 Philippe Normand <pnormand@igalia.com> and Carlos Garcia Campos <cgarcia@igalia.com>
+
+ [WPE] Add API for webview background color configuration
+ https://bugs.webkit.org/show_bug.cgi?id=192305
+
+ Reviewed by Michael Catanzaro.
+
+ Adapt the FrameView API to allow a default non-white background color.
+
+ * page/Frame.cpp:
+ (WebCore::Frame::createView): Replace isTransparent argument with a background color one.
+ * page/Frame.h:
+ * page/FrameView.cpp:
+ (WebCore::FrameView::recalculateBaseBackgroundColor): Use Color::transparent if m_isTransparent is true.
+ (WebCore::FrameView::updateBackgroundRecursively): Allow the fallback background color to be non-white, this is
+ used only in non-dark-mode-css build configurations.
+ * page/FrameView.h:
+ * testing/Internals.cpp:
+ (WebCore::Internals::setViewIsTransparent): Use Color::transparent if transparent is true.
+
2019-02-25 Yongjun Zhang <yongjun_zhang@apple.com>
scalableNativeWebpageParameters() is not preserved on new page navigation.
return nullptr;
}
-void Frame::createView(const IntSize& viewportSize, bool transparent,
+void Frame::createView(const IntSize& viewportSize, const Optional<Color>& backgroundColor,
const IntSize& fixedLayoutSize, const IntRect& fixedVisibleContentRect,
bool useFixedLayout, ScrollbarMode horizontalScrollbarMode, bool horizontalLock,
ScrollbarMode verticalScrollbarMode, bool verticalLock)
setView(frameView.copyRef());
- frameView->updateBackgroundRecursively(transparent);
+ frameView->updateBackgroundRecursively(backgroundColor);
if (isMainFrame)
frameView->setParentVisible(true);
WEBCORE_EXPORT void initWithSimpleHTMLDocument(const String& style, const URL&);
#endif
WEBCORE_EXPORT void setView(RefPtr<FrameView>&&);
- WEBCORE_EXPORT void createView(const IntSize&, bool transparent,
+ WEBCORE_EXPORT void createView(const IntSize&, const Optional<Color>& backgroundColor,
const IntSize& fixedLayoutSize, const IntRect& fixedVisibleContentRect,
bool useFixedLayout = false, ScrollbarMode = ScrollbarAuto, bool horizontalLock = false,
ScrollbarMode = ScrollbarAuto, bool verticalLock = false);
return;
m_usesDarkAppearance = usingDarkAppearance;
- updateBackgroundRecursively(m_isTransparent);
+ Optional<Color> backgroundColor;
+ if (m_isTransparent)
+ backgroundColor = Color(Color::transparent);
+ updateBackgroundRecursively(backgroundColor);
}
#endif
setNeedsCompositingConfigurationUpdate();
}
-void FrameView::updateBackgroundRecursively(bool transparent)
+void FrameView::updateBackgroundRecursively(const Optional<Color>& backgroundColor)
{
#if ENABLE(DARK_MODE_CSS) && PLATFORM(MAC)
- Color backgroundColor = transparent ? Color::transparent : RenderTheme::singleton().systemColor(CSSValueAppleSystemControlBackground, styleColorOptions());
+ Color baseBackgroundColor = backgroundColor.valueOr(RenderTheme::singleton().systemColor(CSSValueAppleSystemControlBackground, styleColorOptions()));
#else
- Color backgroundColor = transparent ? Color::transparent : Color::white;
+ Color baseBackgroundColor = backgroundColor.valueOr(Color::white);
#endif
for (auto* frame = m_frame.ptr(); frame; frame = frame->tree().traverseNext(m_frame.ptr())) {
if (FrameView* view = frame->view()) {
- view->setTransparent(transparent);
- view->setBaseBackgroundColor(backgroundColor);
+ view->setTransparent(!baseBackgroundColor.isVisible());
+ view->setBaseBackgroundColor(baseBackgroundColor);
if (view->needsLayout())
view->layoutContext().scheduleLayout();
}
WEBCORE_EXPORT Color baseBackgroundColor() const;
WEBCORE_EXPORT void setBaseBackgroundColor(const Color&);
- WEBCORE_EXPORT void updateBackgroundRecursively(bool);
+ WEBCORE_EXPORT void updateBackgroundRecursively(const Optional<Color>& backgroundColor);
enum ExtendedBackgroundModeFlags {
ExtendedBackgroundModeNone = 0,
Document* document = contextDocument();
if (!document || !document->view())
return Exception { InvalidAccessError };
- document->view()->updateBackgroundRecursively(transparent);
+ Optional<Color> backgroundColor;
+ if (transparent)
+ backgroundColor = Color(Color::transparent);
+ document->view()->updateBackgroundRecursively(backgroundColor);
return { };
}
+2019-02-26 Philippe Normand <pnormand@igalia.com> and Carlos Garcia Campos <cgarcia@igalia.com>
+
+ [WPE] Add API for webview background color configuration
+ https://bugs.webkit.org/show_bug.cgi?id=192305
+
+ Reviewed by Michael Catanzaro.
+
+ In the case of WPE we need to send the background color to the web process to be used as the background color of
+ the page. This patch adapts the GTK+ implementation to do the same, since it's a lot simpler. The patch also
+ removes the SetDrawsBackground message in favor of the new SetBackgroundColor message that receives an optional
+ color.
+
+ * PlatformWPE.cmake: Add new WPE API for WebKitColor boxed type.
+ * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
+ (WebKit::CoordinatedGraphicsScene::paintToCurrentGLContext): Remove background rendering and opacity handling.
+ * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h:
+ * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
+ (WebKit::ThreadedCompositor::renderLayerTree): Remove drawsBakground and always clear the context with
+ transparent color.
+ * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h:
+ * Shared/WebPageCreationParameters.cpp:
+ (WebKit::WebPageCreationParameters::encode const): Replace drawsBackground with backgroundColor.
+ (WebKit::WebPageCreationParameters::decode): Ditto.
+ * Shared/WebPageCreationParameters.h:
+ * SourcesWPE.txt:
+ * UIProcess/API/glib/WebKitWebView.cpp:
+ * UIProcess/API/gtk/WebKitWebViewGtk.cpp:
+ (webkit_web_view_set_background_color):
+ (webkit_web_view_get_background_color):
+ * UIProcess/API/wpe/WebKitColor.cpp: Added.
+ (webkit_color_copy):
+ (webkit_color_free):
+ (webkitColorToWebCoreColor):
+ (webkitColorFillFromWebCoreColor):
+ (webkit_color_parse):
+ * UIProcess/API/wpe/WebKitColor.h: Added.
+ * UIProcess/API/wpe/WebKitColorPrivate.h: Added.
+ * UIProcess/API/wpe/WebKitWebView.h: Implement webkit_web_view_set_background_color API.
+ * UIProcess/API/wpe/WebKitWebViewWPE.cpp: Ditto.
+ (webkit_web_view_set_background_color):
+ (webkit_web_view_get_background_color):
+ * UIProcess/API/wpe/docs/wpe-0.1-sections.txt: Add new symbols.
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::setDrawsBackground): Set a transparent background color when false is passed.
+ (WebKit::WebPageProxy::setBackgroundColor): Send background color to the WebProcess.
+ (WebKit::WebPageProxy::creationParameters): Replace drawsBackground with backgroundColor.
+ * UIProcess/WebPageProxy.h:
+ (WebKit::WebPageProxy::drawsBackground const):
+ (WebKit::WebPageProxy::backgroundColor const):
+ * UIProcess/cairo/BackingStoreCairo.cpp:
+ (WebKit::BackingStore::incorporateUpdate): Remove GTK+ code to handle background color.
+ * UIProcess/gtk/AcceleratedBackingStore.cpp:
+ * UIProcess/gtk/AcceleratedBackingStore.h: Make paint() pure virtual and remove the implementation.
+ * UIProcess/gtk/AcceleratedBackingStoreWayland.cpp:
+ (WebKit::AcceleratedBackingStoreWayland::paint): Dot not call AcceleratedBackingStore::paint() now that is pure virtual.
+ * UIProcess/gtk/AcceleratedBackingStoreX11.cpp:
+ (WebKit::AcceleratedBackingStoreX11::paint): Ditto.
+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+ (WebKit::WebFrameLoaderClient::transitionToCommittedForNewPage): Use background color as provided by the
+ UIProcess when creating the FrameView.
+ * WebProcess/WebPage/AcceleratedDrawingArea.cpp:
+ * WebProcess/WebPage/AcceleratedDrawingArea.h:
+ * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
+ * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
+ * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp:
+ (WebKit::ThreadedCoordinatedLayerTreeHost::setIsDiscardable):
+ * WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h:
+ * WebProcess/WebPage/DrawingArea.h:
+ * WebProcess/WebPage/DrawingAreaImpl.cpp:
+ (WebKit::DrawingAreaImpl::display): Remove special case for transparent background.
+ * WebProcess/WebPage/LayerTreeHost.h:
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::setBackgroundColor): New API for background color configuration. Proxies to FrameView and DrawingArea.
+ * WebProcess/WebPage/WebPage.h:
+ (WebKit::WebPage::backgroundColor const): Read-only access to the current background color.
+ * WebProcess/WebPage/WebPage.messages.in: Replace SetDrawsBackground message with SetBackgroundColor.
+
2019-02-25 Yongjun Zhang <yongjun_zhang@apple.com>
scalableNativeWebpageParameters() is not preserved on new page navigation.
${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
commitSceneState(state.nicosia);
}
-void CoordinatedGraphicsScene::paintToCurrentGLContext(const TransformationMatrix& matrix, float opacity, const FloatRect& clipRect, const Color& backgroundColor, bool drawsBackground, TextureMapper::PaintFlags PaintFlags)
+void CoordinatedGraphicsScene::paintToCurrentGLContext(const TransformationMatrix& matrix, const FloatRect& clipRect, TextureMapper::PaintFlags PaintFlags)
{
updateSceneState();
m_textureMapper->beginPainting(PaintFlags);
m_textureMapper->beginClip(TransformationMatrix(), clipRect);
- if (drawsBackground) {
- RGBA32 rgba = makeRGBA32FromFloats(backgroundColor.red(),
- backgroundColor.green(), backgroundColor.blue(),
- backgroundColor.alpha() * opacity);
- m_textureMapper->drawSolidColor(clipRect, TransformationMatrix(), Color(rgba), true);
- } else
- m_textureMapper->clearColor(m_viewBackgroundColor);
-
- if (currentRootLayer->opacity() != opacity || currentRootLayer->transform() != matrix) {
- currentRootLayer->setOpacity(opacity);
+ if (currentRootLayer->transform() != matrix)
currentRootLayer->setTransform(matrix);
- }
currentRootLayer->paint();
m_fpsCounter.updateFPSAndDisplay(*m_textureMapper, clipRect.location(), matrix);
virtual ~CoordinatedGraphicsScene();
void applyStateChanges(const Vector<WebCore::CoordinatedGraphicsState>&);
- void paintToCurrentGLContext(const WebCore::TransformationMatrix&, float, const WebCore::FloatRect&, const WebCore::Color& backgroundColor, bool drawsBackground, WebCore::TextureMapper::PaintFlags = 0);
+ void paintToCurrentGLContext(const WebCore::TransformationMatrix&, const WebCore::FloatRect&, WebCore::TextureMapper::PaintFlags = 0);
void detach();
// The painting thread must lock the main thread to use below two methods, because two methods access members that the main thread manages. See m_client.
bool isActive() const { return m_isActive; }
void setActive(bool active) { m_isActive = active; }
- void setViewBackgroundColor(const WebCore::Color& color) { m_viewBackgroundColor = color; }
- WebCore::Color viewBackgroundColor() const { return m_viewBackgroundColor; }
-
private:
void commitSceneState(const WebCore::CoordinatedGraphicsState::NicosiaState&);
void updateSceneState();
std::unique_ptr<WebCore::TextureMapperLayer> m_rootLayer;
Nicosia::PlatformLayer::LayerID m_rootLayerID { 0 };
- WebCore::Color m_viewBackgroundColor { WebCore::Color::white };
WebCore::TextureMapperFPSCounter m_fpsCounter;
};
m_compositingRunLoop->scheduleUpdate();
}
-void ThreadedCompositor::setDrawsBackground(bool drawsBackground)
-{
- LockHolder locker(m_attributes.lock);
- m_attributes.drawsBackground = drawsBackground;
- m_compositingRunLoop->scheduleUpdate();
-}
-
void ThreadedCompositor::updateViewport()
{
m_compositingRunLoop->scheduleUpdate();
WebCore::IntSize viewportSize;
WebCore::IntPoint scrollPosition;
float scaleFactor;
- bool drawsBackground;
bool needsResize;
+
Vector<WebCore::CoordinatedGraphicsState> states;
{
viewportSize = m_attributes.viewportSize;
scrollPosition = m_attributes.scrollPosition;
scaleFactor = m_attributes.scaleFactor;
- drawsBackground = m_attributes.drawsBackground;
needsResize = m_attributes.needsResize;
states = WTFMove(m_attributes.states);
viewportTransform.scale(scaleFactor);
viewportTransform.translate(-scrollPosition.x(), -scrollPosition.y());
- if (!drawsBackground) {
- glClearColor(0, 0, 0, 0);
- glClear(GL_COLOR_BUFFER_BIT);
- }
+ glClearColor(0, 0, 0, 0);
+ glClear(GL_COLOR_BUFFER_BIT);
m_scene->applyStateChanges(states);
- m_scene->paintToCurrentGLContext(viewportTransform, 1, FloatRect { FloatPoint { }, viewportSize },
- Color::transparent, !drawsBackground, m_paintFlags);
+ m_scene->paintToCurrentGLContext(viewportTransform, FloatRect { FloatPoint { }, viewportSize }, m_paintFlags);
m_context->swapBuffers();
void setScaleFactor(float);
void setScrollPosition(const WebCore::IntPoint&, float scale);
void setViewportSize(const WebCore::IntSize&, float scale);
- void setDrawsBackground(bool);
void updateSceneState(const WebCore::CoordinatedGraphicsState&);
WebCore::IntSize viewportSize;
WebCore::IntPoint scrollPosition;
float scaleFactor { 1 };
- bool drawsBackground { true };
bool needsResize { false };
-
Vector<WebCore::CoordinatedGraphicsState> states;
bool clientRendersNextFrame { false };
encoder.encodeEnum(drawingAreaType);
encoder << drawingAreaIdentifier;
encoder << pageGroupData;
- encoder << drawsBackground;
encoder << isEditable;
encoder << underlayColor;
encoder << useFixedLayout;
#if ENABLE(CONTENT_EXTENSIONS)
encoder << contentRuleLists;
#endif
+ encoder << backgroundColor;
}
Optional<WebPageCreationParameters> WebPageCreationParameters::decode(IPC::Decoder& decoder)
if (!pageGroupData)
return WTF::nullopt;
parameters.pageGroupData = WTFMove(*pageGroupData);
- if (!decoder.decode(parameters.drawsBackground))
- return WTF::nullopt;
if (!decoder.decode(parameters.isEditable))
return WTF::nullopt;
if (!decoder.decode(parameters.underlayColor))
parameters.contentRuleLists = WTFMove(*contentRuleLists);
#endif
+ Optional<Optional<WebCore::Color>> backgroundColor;
+ decoder >> backgroundColor;
+ if (!backgroundColor)
+ return WTF::nullopt;
+ parameters.backgroundColor = WTFMove(*backgroundColor);
+
return WTFMove(parameters);
}
DrawingAreaIdentifier drawingAreaIdentifier;
WebPageGroupData pageGroupData;
- bool drawsBackground;
bool isEditable;
WebCore::Color underlayColor;
#if ENABLE(CONTENT_EXTENSIONS)
Vector<std::pair<String, WebCompiledContentRuleListData>> contentRuleLists;
#endif
+
+ Optional<WebCore::Color> backgroundColor;
};
} // namespace WebKit
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
_page = [_contentView page];
[self _dispatchSetDeviceOrientation:deviceOrientation()];
- _page->setDrawsBackground(self.opaque);
+ if (!self.opaque)
+ _page->setBackgroundColor(WebCore::Color(WebCore::Color::transparent));
[_contentView layer].anchorPoint = CGPointZero;
[_contentView setFrame:bounds];
if (!_page)
return;
- _page->setDrawsBackground(opaque);
+ Optional<WebCore::Color> backgroundColor;
+ if (!opaque)
+ backgroundColor = WebCore::Color(WebCore::Color::transparent);
+ _page->setBackgroundColor(backgroundColor);
[self _updateScrollViewBackground];
}
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
#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>
return GTK_WIDGET(g_object_new(WEBKIT_TYPE_WEB_VIEW, "user-content-manager", userContentManager, nullptr));
}
+
+/**
+ * webkit_web_view_set_background_color:
+ * @web_view: a #WebKitWebView
+ * @rgba: a #GdkRGBA
+ *
+ * Sets the color that will be used to draw the @web_view background before
+ * the actual contents are rendered. Note that if the web page loaded in @web_view
+ * specifies a background color, it will take precedence over the @rgba color.
+ * By default the @web_view background color is opaque white.
+ * Note that the parent window must have a RGBA visual and
+ * #GtkWidget:app-paintable property set to %TRUE for backgrounds colors to work.
+ *
+ * <informalexample><programlisting>
+ * static void browser_window_set_background_color (BrowserWindow *window,
+ * const GdkRGBA *rgba)
+ * {
+ * WebKitWebView *web_view;
+ * GdkScreen *screen = gtk_window_get_screen (GTK_WINDOW (window));
+ * GdkVisual *rgba_visual = gdk_screen_get_rgba_visual (screen);
+ *
+ * if (!rgba_visual)
+ * return;
+ *
+ * gtk_widget_set_visual (GTK_WIDGET (window), rgba_visual);
+ * gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
+ *
+ * web_view = browser_window_get_web_view (window);
+ * webkit_web_view_set_background_color (web_view, rgba);
+ * }
+ * </programlisting></informalexample>
+ *
+ * Since: 2.8
+ */
+void webkit_web_view_set_background_color(WebKitWebView* webView, const GdkRGBA* rgba)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+ g_return_if_fail(rgba);
+
+ auto& page = *webkitWebViewBaseGetPage(reinterpret_cast<WebKitWebViewBase*>(webView));
+ page.setBackgroundColor(WebCore::Color(*rgba));
+}
+
+/**
+ * webkit_web_view_get_background_color:
+ * @web_view: a #WebKitWebView
+ * @rgba: (out): a #GdkRGBA to fill in with the background color
+ *
+ * Gets the color that is used to draw the @web_view background before
+ * the actual contents are rendered.
+ * For more information see also webkit_web_view_set_background_color()
+ *
+ * Since: 2.8
+ */
+void webkit_web_view_get_background_color(WebKitWebView* webView, GdkRGBA* rgba)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+ g_return_if_fail(rgba);
+
+ auto& page = *webkitWebViewBaseGetPage(reinterpret_cast<WebKitWebViewBase*>(webView));
+ *rgba = page.backgroundColor().valueOr(WebCore::Color::white);
+}
--- /dev/null
+/*
+ * Copyright (C) 2019 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebKitColor.h"
+
+#include "WebKitColorPrivate.h"
+
+/**
+ * SECTION: WebKitColor
+ * @Short_description: A boxed type representing a RGBA color
+ * @Title: WebKitColor
+ * @See_also: #WebKitWebView.
+ *
+ * A WebKitColor is a boxed type representing a RGBA color.
+ *
+ * Since: 2.24
+ */
+
+/**
+ * webkit_color_copy:
+ * @color: a #WebKitColor
+ *
+ * Make a copy of @color.
+ *
+ * Returns: (transfer full): A copy of passed in #WebKitColor.
+ *
+ * Since: 2.24
+ */
+WebKitColor* webkit_color_copy(WebKitColor* color)
+{
+ g_return_val_if_fail(color, nullptr);
+
+ WebKitColor* copy = static_cast<WebKitColor*>(fastZeroedMalloc(sizeof(WebKitColor)));
+ copy->red = color->red;
+ copy->green = color->green;
+ copy->blue = color->blue;
+ copy->alpha = color->alpha;
+ return copy;
+}
+
+/**
+ * webkit_color_free:
+ * @color: a #WebKitColor
+ *
+ * Free the #WebKitColor.
+ *
+ * Since: 2.24
+ */
+void webkit_color_free(WebKitColor* color)
+{
+ g_return_if_fail(color);
+
+ fastFree(color);
+}
+
+G_DEFINE_BOXED_TYPE(WebKitColor, webkit_color, webkit_color_copy, webkit_color_free);
+
+const WebCore::Color webkitColorToWebCoreColor(WebKitColor* color)
+{
+ return WebCore::Color(static_cast<float>(color->red), static_cast<float>(color->green),
+ static_cast<float>(color->blue), static_cast<float>(color->alpha));
+}
+
+void webkitColorFillFromWebCoreColor(const WebCore::Color& webCoreColor, WebKitColor* color)
+{
+ RELEASE_ASSERT(webCoreColor.isValid());
+
+ double r, g, b, a;
+ webCoreColor.getRGBA(r, g, b, a);
+ color->red = r;
+ color->green = g;
+ color->blue = b;
+ color->alpha = a;
+}
+
+/**
+ * webkit_color_parse:
+ * @color: a #WebKitColor to fill in
+ * @color_string: color representation as color nickname or HEX string
+ *
+ * Create a new #WebKitColor for the given @color_string
+ * representation. There are two valid representation types: standard color
+ * names (see https://htmlcolorcodes.com/color-names/ for instance) or HEX
+ * values.
+ *
+ * Returns: a #gboolean indicating if the @color was correctly filled in or not.
+ *
+ * Since: 2.24
+ */
+gboolean webkit_color_parse(WebKitColor* color, const gchar* colorString)
+{
+ g_return_val_if_fail(color, FALSE);
+ g_return_val_if_fail(colorString, FALSE);
+
+ auto webCoreColor = WebCore::Color(colorString);
+ if (!webCoreColor.isValid())
+ return FALSE;
+
+ webkitColorFillFromWebCoreColor(webCoreColor, color);
+ return TRUE;
+}
--- /dev/null
+/*
+ * Copyright (C) 2019 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#if !defined(__WEBKIT_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <wpe/webkit.h> can be included directly."
+#endif
+
+#ifndef WebKitColor_h
+#define WebKitColor_h
+
+#include <glib-object.h>
+#include <wpe/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+/**
+ * WebKitColor:
+ * @red: Red channel, between 0.0 and 1.0 inclusive
+ * @green: Green channel, between 0.0 and 1.0 inclusive
+ * @blue: Blue channel, between 0.0 and 1.0 inclusive
+ * @alpha: Alpha channel, between 0.0 and 1.0 inclusive
+ *
+ * A WebKitColor is a boxed type representing a RGBA color.
+ *
+ * Since: 2.24
+ */
+struct _WebKitColor {
+ gdouble red;
+ gdouble green;
+ gdouble blue;
+ gdouble alpha;
+};
+
+typedef struct _WebKitColor WebKitColor;
+
+#define WEBKIT_TYPE_COLOR (webkit_color_get_type())
+
+WEBKIT_API GType
+webkit_color_get_type (void);
+
+WEBKIT_API gboolean
+webkit_color_parse (WebKitColor *color, const gchar *color_string);
+
+G_END_DECLS
+
+#endif /* WebKitColor_h */
--- /dev/null
+/*
+ * 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*);
#include <wpe/WebKitWebContext.h>
#include <wpe/WebKitWebResource.h>
#include <wpe/WebKitWebViewBackend.h>
+#include <wpe/WebKitColor.h>
#include <wpe/WebKitWebViewSessionState.h>
#include <wpe/WebKitWindowProperties.h>
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
#include "config.h"
#include "WebKitWebView.h"
+#include "WebKitColorPrivate.h"
#include "WebKitWebViewPrivate.h"
gboolean webkitWebViewAuthenticate(WebKitWebView*, WebKitAuthenticationRequest*)
"user-content-manager", userContentManager,
nullptr));
}
+
+/**
+ * webkit_web_view_set_background_color:
+ * @web_view: a #WebKitWebView
+ * @backgroundColor: a #WebKitColor
+ *
+ * Sets the color that will be used to draw the @web_view background before
+ * the actual contents are rendered. Note that if the web page loaded in @web_view
+ * specifies a background color, it will take precedence over the background color.
+ * By default the @web_view background color is opaque white.
+ *
+ * Since: 2.24
+ */
+void webkit_web_view_set_background_color(WebKitWebView* webView, WebKitColor* backgroundColor)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+ g_return_if_fail(backgroundColor);
+
+ auto& page = webkitWebViewGetPage(webView);
+ page.setBackgroundColor(webkitColorToWebCoreColor(backgroundColor));
+}
+
+/**
+ * webkit_web_view_get_background_color:
+ * @web_view: a #WebKitWebView
+ * @rgba: (out): a #WebKitColor to fill in with the background color
+ *
+ * Gets the color that is used to draw the @web_view background before the
+ * actual contents are rendered. For more information see also
+ * webkit_web_view_set_background_color().
+ *
+ * Since: 2.24
+ */
+void webkit_web_view_get_background_color(WebKitWebView* webView, WebKitColor* color)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+ auto& page = webkitWebViewGetPage(webView);
+
+ auto& webCoreColor = page.backgroundColor();
+ webkitColorFillFromWebCoreColor(webCoreColor.valueOr(WebCore::Color::white), color);
+}
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
</SECTION>
<SECTION>
+<FILE>WebKitColor</FILE>
+WEBKIT_TYPE_COLOR
+WebKitColor
+webkit_color_parse
+
+<SUBSECTION Private>
+webkit_color_get_type
+</SECTION>
+
+<SECTION>
<FILE>WebKitAuthenticationRequest</FILE>
WebKitAuthenticationRequest
WebKitAuthenticationScheme
<xi:include href="xml/WebKitNetworkProxySettings.xml"/>
<xi:include href="xml/WebKitAutomationSession.xml"/>
<xi:include href="xml/WebKitApplicationInfo.xml"/>
+ <xi:include href="xml/WebKitColor.xml"/>
</chapter>
<chapter>
void WebViewImpl::setDrawsBackground(bool drawsBackground)
{
- m_page->setDrawsBackground(drawsBackground);
+ Optional<WebCore::Color> backgroundColor;
+ if (!drawsBackground)
+ backgroundColor = WebCore::Color(WebCore::Color::transparent);
+ m_page->setBackgroundColor(backgroundColor);
// Make sure updateLayer gets called on the web view.
[m_view setNeedsDisplay:YES];
bool WebViewImpl::drawsBackground() const
{
- return m_page->drawsBackground();
+ auto& backgroundColor = m_page->backgroundColor();
+ return !backgroundColor || backgroundColor.value().isVisible();
}
void WebViewImpl::setBackgroundColor(NSColor *backgroundColor)
bool WebViewImpl::isOpaque() const
{
- return m_page->drawsBackground();
+ return drawsBackground();
}
void WebViewImpl::setShouldSuppressFirstResponderChanges(bool shouldSuppress)
, m_cpuLimit(m_configuration->cpuLimit())
, m_backForwardList(WebBackForwardList::create(*this))
, m_waitsForPaintAfterViewDidMoveToWindow(m_configuration->waitsForPaintAfterViewDidMoveToWindow())
- , m_drawsBackground(m_configuration->drawsBackground())
, m_pageID(pageID)
, m_controlledByAutomation(m_configuration->isControlledByAutomation())
#if PLATFORM(COCOA)
{
RELEASE_LOG_IF_ALLOWED(Loading, "constructor: webPID = %i, pageID = %" PRIu64, m_process->processIdentifier(), m_pageID);
+ if (!m_configuration->drawsBackground())
+ m_backgroundColor = Color(Color::transparent);
+
m_webProcessLifetimeTracker.addObserver(m_visitedLinkStore);
m_webProcessLifetimeTracker.addObserver(m_websiteDataStore);
m_inspectorController->createInspectorTarget(pageTargetId, Inspector::InspectorTargetType::Page);
}
-void WebPageProxy::setDrawsBackground(bool drawsBackground)
+void WebPageProxy::setBackgroundColor(const Optional<Color>& color)
{
- if (m_drawsBackground == drawsBackground)
+ if (m_backgroundColor == color)
return;
- m_drawsBackground = drawsBackground;
-
+ m_backgroundColor = color;
if (isValid())
- m_process->send(Messages::WebPage::SetDrawsBackground(drawsBackground), m_pageID);
+ m_process->send(Messages::WebPage::SetBackgroundColor(color), m_pageID);
}
void WebPageProxy::setTopContentInset(float contentInset)
parameters.drawingAreaIdentifier = drawingArea.identifier();
parameters.store = preferencesStore();
parameters.pageGroupData = m_pageGroup->data();
- parameters.drawsBackground = m_drawsBackground;
parameters.isEditable = m_isEditable;
parameters.underlayColor = m_underlayColor;
parameters.useFixedLayout = m_useFixedLayout;
#endif
parameters.needsFontAttributes = m_needsFontAttributes;
+ parameters.backgroundColor = m_backgroundColor;
process.addWebUserContentControllerProxy(m_userContentController, parameters);
bool canShowMIMEType(const String& mimeType);
- bool drawsBackground() const { return m_drawsBackground; }
- void setDrawsBackground(bool);
-
String currentURL() const;
float topContentInset() const { return m_topContentInset; }
#if PLATFORM(GTK)
PlatformWidget viewWidget();
- const WebCore::Color& backgroundColor() const { return m_backgroundColor; }
- void setBackgroundColor(const WebCore::Color& color) { m_backgroundColor = color; }
bool makeGLContextCurrent();
#endif
+ const Optional<WebCore::Color>& backgroundColor() const { return m_backgroundColor; }
+ void setBackgroundColor(const Optional<WebCore::Color>&);
+
#if PLATFORM(WIN)
PlatformWidget viewWidget();
#endif
LayerHostingMode m_layerHostingMode { LayerHostingMode::InProcess };
- bool m_drawsBackground { true };
-
WebCore::Color m_underlayColor;
WebCore::Color m_pageExtendedBackgroundColor;
#if PLATFORM(GTK)
String m_accessibilityPlugID;
- WebCore::Color m_backgroundColor { WebCore::Color::white };
#endif
+ Optional<WebCore::Color> m_backgroundColor;
+
unsigned m_pendingLearnOrIgnoreWordMessageCount { 0 };
bool m_mainFrameHasCustomContentProvider { false };
#include <WebCore/RefPtrCairo.h>
#include <cairo.h>
-#if PLATFORM(GTK)
-#include <gtk/gtk.h>
-#endif
-
#if PLATFORM(GTK) && PLATFORM(X11) && defined(GDK_WINDOWING_X11)
#include <WebCore/BackingStoreBackendCairoX11.h>
#include <WebCore/PlatformDisplayX11.h>
for (const auto& updateRect : updateInfo.updateRects) {
IntRect srcRect = updateRect;
srcRect.move(-updateRectLocation.x(), -updateRectLocation.y());
-#if PLATFORM(GTK)
- if (!m_webPageProxy.drawsBackground()) {
- const WebCore::Color color = m_webPageProxy.backgroundColor();
- if (color.isVisible()) {
- // When the application sets the background color through m_webPageProxy.backgroundColor(), we update the surface in 2 steps.
- // 1. Fill the surface by m_webPageProxy.backgroundColor().
- // 2. Composite webpage's bitmap which has a transparent background.
- // In step 1, we use CompositeCopy as m_webPageProxy.backgroundColor() may not be opaque.
- // On the other hand, in step 2, bitmap should be composited by CompositeSourceOver
- // because it should be blended with m_webPageProxy.backgroundColor().
- graphicsContext.fillRect(srcRect, color);
- graphicsContext.setCompositeOperation(WebCore::CompositeSourceOver);
- bitmap->paint(graphicsContext, deviceScaleFactor(), updateRect.location(), srcRect);
- graphicsContext.setCompositeOperation(WebCore::CompositeCopy);
- continue;
- }
- }
-#endif
bitmap->paint(graphicsContext, deviceScaleFactor(), updateRect.location(), srcRect);
}
}
{
}
-bool AcceleratedBackingStore::paint(cairo_t* cr, const IntRect& clipRect)
-{
- if (m_webPage.drawsBackground())
- return true;
-
- const WebCore::Color& color = m_webPage.backgroundColor();
- if (!color.isOpaque()) {
- cairo_rectangle(cr, clipRect.x(), clipRect.y(), clipRect.width(), clipRect.height());
- cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
- cairo_fill(cr);
- }
-
- if (color.isVisible()) {
- setSourceRGBAFromColor(cr, color);
- cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
- cairo_rectangle(cr, clipRect.x(), clipRect.y(), clipRect.width(), clipRect.height());
- cairo_fill(cr);
- }
-
- return true;
-}
-
} // namespace WebKit
virtual ~AcceleratedBackingStore() = default;
virtual void update(const LayerTreeContext&) { }
- virtual bool paint(cairo_t*, const WebCore::IntRect&);
+ virtual bool paint(cairo_t*, const WebCore::IntRect&) = 0;
virtual bool makeContextCurrent() { return false; }
protected:
return false;
cairo_save(cr);
- AcceleratedBackingStore::paint(cr, clipRect);
#if GTK_CHECK_VERSION(3, 16, 0)
if (m_gdkGLContext) {
return false;
cairo_save(cr);
- AcceleratedBackingStore::paint(cr, clipRect);
// The surface can be modified by the web process at any time, so we mark it
// as dirty to ensure we always render the updated contents as soon as possible.
static void drawPageBackground(HDC dc, const WebPageProxy* page, const RECT& rect)
{
- if (!page->drawsBackground())
+ auto& backgroundColor = page->backgroundColor();
+ if (!backgroundColor || backgroundColor.value().isVisible())
return;
::FillRect(dc, &rect, reinterpret_cast<HBRUSH>(COLOR_WINDOW + 1));
WebPage* webPage = m_frame->page();
bool isMainFrame = m_frame->isMainFrame();
- bool isTransparent = !webPage->drawsBackground();
bool shouldUseFixedLayout = isMainFrame && webPage->useFixedLayout();
bool shouldDisableScrolling = isMainFrame && !webPage->mainFrameIsScrollable();
bool shouldHideScrollbars = shouldDisableScrolling;
bool horizontalLock = shouldHideScrollbars || webPage->alwaysShowsHorizontalScroller();
bool verticalLock = shouldHideScrollbars || webPage->alwaysShowsVerticalScroller();
- m_frame->coreFrame()->createView(webPage->size(), isTransparent,
+ m_frame->coreFrame()->createView(webPage->size(), webPage->backgroundColor(),
webPage->fixedLayoutSize(), fixedVisibleContentRect, shouldUseFixedLayout,
horizontalScrollbarMode, horizontalLock, verticalScrollbarMode, verticalLock);
m_layerTreeHost->scrollNonCompositedContents(scrollRect);
}
-void AcceleratedDrawingArea::pageBackgroundTransparencyChanged()
-{
- if (m_layerTreeHost)
- m_layerTreeHost->pageBackgroundTransparencyChanged();
- else if (m_previousLayerTreeHost)
- m_previousLayerTreeHost->pageBackgroundTransparencyChanged();
-}
-
void AcceleratedDrawingArea::setLayerTreeStateIsFrozen(bool isFrozen)
{
if (m_layerTreeStateIsFrozen == isFrozen)
void setNeedsDisplay() override;
void setNeedsDisplayInRect(const WebCore::IntRect&) override;
void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta) override;
- void pageBackgroundTransparencyChanged() override;
void setLayerTreeStateIsFrozen(bool) override;
bool layerTreeStateIsFrozen() const override { return m_layerTreeStateIsFrozen; }
LayerTreeHost* layerTreeHost() const override { return m_layerTreeHost.get(); }
m_webPage.corePage()->pageOverlayController().didChangeDeviceScaleFactor();
}
-void CoordinatedLayerTreeHost::pageBackgroundTransparencyChanged()
-{
-}
-
GraphicsLayerFactory* CoordinatedLayerTreeHost::graphicsLayerFactory()
{
return &m_coordinator;
void sizeDidChange(const WebCore::IntSize& newSize) override;
void deviceOrPageScaleFactorChanged() override;
- void pageBackgroundTransparencyChanged() override;
void setVisibleContentsRect(const WebCore::FloatRect&);
void renderNextFrame(bool);
m_compositor->setScaleFactor(m_webPage.deviceScaleFactor() * m_viewportController.pageScaleFactor());
}
-void ThreadedCoordinatedLayerTreeHost::pageBackgroundTransparencyChanged()
-{
- if (m_isDiscardable) {
- m_discardableSyncActions.add(DiscardableSyncActions::UpdateBackground);
- return;
- }
-
- CoordinatedLayerTreeHost::pageBackgroundTransparencyChanged();
- m_compositor->setDrawsBackground(m_webPage.drawsBackground());
-}
-
void ThreadedCoordinatedLayerTreeHost::sizeDidChange(const IntSize& size)
{
if (m_isDiscardable) {
if (m_discardableSyncActions.isEmpty())
return;
- if (m_discardableSyncActions.contains(DiscardableSyncActions::UpdateBackground))
- pageBackgroundTransparencyChanged();
-
if (m_discardableSyncActions.contains(DiscardableSyncActions::UpdateSize)) {
// Size changes already sets the scale factor and updates the viewport.
sizeDidChange(m_webPage.size());
void scrollNonCompositedContents(const WebCore::IntRect& scrollRect) override;
void sizeDidChange(const WebCore::IntSize&) override;
void deviceOrPageScaleFactorChanged() override;
- void pageBackgroundTransparencyChanged() override;
void contentsSizeChanged(const WebCore::IntSize&) override;
void didChangeViewportAttributes(WebCore::ViewportAttributes&&) override;
enum class DiscardableSyncActions {
UpdateSize = 1 << 1,
UpdateViewport = 1 << 2,
- UpdateScale = 1 << 3,
- UpdateBackground = 1 << 4
+ UpdateScale = 1 << 3
};
CompositorClient m_compositorClient;
virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta) = 0;
// FIXME: These should be pure virtual.
- virtual void pageBackgroundTransparencyChanged() { }
virtual void forceRepaint() { }
virtual bool forceRepaintAsync(CallbackID) { return false; }
virtual void setLayerTreeStateIsFrozen(bool) { }
updateInfo.viewSize = m_webPage.size();
updateInfo.deviceScaleFactor = m_webPage.corePage()->deviceScaleFactor();
- // Always render the whole page when we don't render the background.
- IntRect bounds = m_webPage.drawsBackground() ? m_dirtyRegion.bounds() : m_webPage.bounds();
+ IntRect bounds = m_dirtyRegion.bounds();
ASSERT(m_webPage.bounds().contains(bounds));
IntSize bitmapSize = bounds.size();
if (!bitmap->createHandle(updateInfo.bitmapHandle))
return;
- Vector<IntRect> rects;
- if (m_webPage.drawsBackground()) {
- rects = m_dirtyRegion.rects();
-
- if (shouldPaintBoundsRect(bounds, rects)) {
- rects.clear();
- rects.append(bounds);
- }
- } else
+ Vector<IntRect> rects = m_dirtyRegion.rects();
+ if (shouldPaintBoundsRect(bounds, rects)) {
+ rects.clear();
rects.append(bounds);
+ }
updateInfo.scrollRect = m_scrollRect;
updateInfo.scrollOffset = m_scrollOffset;
virtual void forceRepaint() = 0;
virtual bool forceRepaintAsync(CallbackID) { return false; }
virtual void sizeDidChange(const WebCore::IntSize& newSize) = 0;
- virtual void pageBackgroundTransparencyChanged() = 0;
virtual void pauseRendering();
virtual void resumeRendering();
setUseFixedLayout(parameters.useFixedLayout);
- setDrawsBackground(parameters.drawsBackground);
-
setUnderlayColor(parameters.underlayColor);
setPaginationMode(parameters.paginationMode);
#if USE(AUDIO_SESSION)
PlatformMediaSessionManager::setShouldDeactivateAudioSession(true);
#endif
+
+ setBackgroundColor(parameters.backgroundColor);
}
#if ENABLE(WEB_RTC)
}
#endif
-void WebPage::setDrawsBackground(bool drawsBackground)
+void WebPage::setBackgroundColor(const Optional<WebCore::Color>& backgroundColor)
{
- if (m_drawsBackground == drawsBackground)
+ if (m_backgroundColor == backgroundColor)
return;
- m_drawsBackground = drawsBackground;
+ m_backgroundColor = backgroundColor;
- if (FrameView* frameView = mainFrameView()) {
- bool isTransparent = !drawsBackground;
- frameView->updateBackgroundRecursively(isTransparent);
- }
+ if (FrameView* frameView = mainFrameView())
+ frameView->updateBackgroundRecursively(backgroundColor);
- m_drawingArea->pageBackgroundTransparencyChanged();
m_drawingArea->setNeedsDisplay();
}
void postInjectedBundleMessage(const String& messageName, const UserData&);
- bool drawsBackground() const { return m_drawsBackground; }
-
void setUnderlayColor(const WebCore::Color& color) { m_underlayColor = color; }
WebCore::Color underlayColor() const { return m_underlayColor; }
bool requestDOMPasteAccess();
WebCore::IntRect rectForElementAtInteractionLocation() const;
+ const Optional<WebCore::Color>& backgroundColor() const { return m_backgroundColor; }
+
private:
WebPage(uint64_t pageID, WebPageCreationParameters&&);
void setIndicating(bool);
#endif
- void setDrawsBackground(bool);
+ void setBackgroundColor(const Optional<WebCore::Color>&);
#if PLATFORM(COCOA)
void setTopContentInsetFenced(float, IPC::Attachment);
bool m_isSuspendedUnderLock { false };
HashSet<String, ASCIICaseInsensitiveHash> m_mimeTypesWithCustomContentProviders;
- WebCore::Color m_backgroundColor { WebCore::Color::white };
+ Optional<WebCore::Color> m_backgroundColor { WebCore::Color::white };
HashSet<unsigned> m_activeRenderingSuppressionTokens;
unsigned m_maximumRenderingSuppressionToken { 0 };
SetActivityState(OptionSet<WebCore::ActivityState::Flag> activityState, WebKit::ActivityStateChangeID activityStateChangeID, Vector<WebKit::CallbackID> callbackIDs)
SetLayerHostingMode(enum:uint8_t WebKit::LayerHostingMode layerHostingMode)
- SetDrawsBackground(bool drawsBackground)
+ SetBackgroundColor(Optional<WebCore::Color> color)
AddConsoleMessage(uint64_t frameID, enum:uint8_t JSC::MessageSource messageSource, enum:uint8_t JSC::MessageLevel messageLevel, String message, uint64_t requestID)
SendCSPViolationReport(uint64_t frameID, URL reportURL, IPC::FormDataReference reportData)
+2019-02-26 Philippe Normand <pnormand@igalia.com>
+
+ [WPE] Add API for webview background color configuration
+ https://bugs.webkit.org/show_bug.cgi?id=192305
+
+ Reviewed by Michael Catanzaro.
+
+ * WebCoreSupport/WebFrameLoaderClient.cpp:
+ (WebFrameLoaderClient::transitionToCommittedForNewPage): Create
+ FrameView with background color.
+
2019-02-20 Darin Adler <darin@apple.com>
Finish removing String::format
RECT pixelRect;
view->frameRect(&pixelRect);
- bool transparent = view->transparent();
+ Optional<Color> backgroundColor;
+ if (view->transparent())
+ backgroundColor = Color(Color::transparent);
FloatRect logicalFrame(pixelRect);
logicalFrame.scale(1.0f / view->deviceScaleFactor());
- core(m_webFrame)->createView(enclosingIntRect(logicalFrame).size(), transparent, /* fixedLayoutSize */ { }, /* fixedVisibleContentRect */ { });
+ core(m_webFrame)->createView(enclosingIntRect(logicalFrame).size(), backgroundColor, /* fixedLayoutSize */ { }, /* fixedVisibleContentRect */ { });
}
void WebFrameLoaderClient::didSaveToPageCache()
if (!coreFrame || !coreFrame->view())
return;
- coreFrame->view()->updateBackgroundRecursively(webView()->transparent());
+ Optional<Color> backgroundColor;
+ if (webView()->transparent())
+ backgroundColor = Color(Color::transparent);
+ coreFrame->view()->updateBackgroundRecursively(backgroundColor);
}
// IWebFrame2
+2019-02-26 Philippe Normand <pnormand@igalia.com>
+
+ [WPE] Add API for webview background color configuration
+ https://bugs.webkit.org/show_bug.cgi?id=192305
+
+ Reviewed by Michael Catanzaro.
+
+ * MiniBrowser/wpe/main.cpp:
+ (main): Add a new option to configure the webview background
+ color. Example: --bg-color=transparent.
+ * TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp:
+ (testWebViewBackgroundColor): Enable background color API tests for WPE.
+ (beforeAll): Ditto.
+
2019-02-25 Yongjun Zhang <yongjun_zhang@apple.com>
scalableNativeWebpageParameters() is not preserved on new page navigation.
static const char* cookiesFile;
static const char* cookiesPolicy;
static const char* proxy;
+const char* bgColor;
static const GOptionEntry commandLineOptions[] =
{
{ "ignore-host", 0, 0, G_OPTION_ARG_STRING_ARRAY, &ignoreHosts, "Set proxy ignore hosts", "HOSTS" },
{ "ignore-tls-errors", 0, 0, G_OPTION_ARG_NONE, &ignoreTLSErrors, "Ignore TLS errors", nullptr },
{ "content-filter", 0, 0, G_OPTION_ARG_FILENAME, &contentFilter, "JSON with content filtering rules", "FILE" },
+ { "bg-color", 0, 0, G_OPTION_ARG_STRING, &bgColor, "Window background color. Default: white", "COLOR" },
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &uriArguments, nullptr, "[URL]" },
{ nullptr, 0, 0, G_OPTION_ARG_NONE, nullptr, nullptr, nullptr }
};
if (ignoreTLSErrors)
webkit_web_context_set_tls_errors_policy(webContext, WEBKIT_TLS_ERRORS_POLICY_IGNORE);
+ WebKitColor color;
+ if (bgColor && webkit_color_parse(&color, bgColor))
+ webkit_web_view_set_background_color(webView, &color);
+
if (uriArguments) {
GFile* file = g_file_new_for_commandline_arg(uriArguments[0]);
char* url = g_file_get_uri(file);
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);
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);
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);