Diff
Modified: trunk/Source/WebCore/ChangeLog (278656 => 278657)
--- trunk/Source/WebCore/ChangeLog 2021-06-09 11:17:36 UTC (rev 278656)
+++ trunk/Source/WebCore/ChangeLog 2021-06-09 12:36:07 UTC (rev 278657)
@@ -1,3 +1,17 @@
+2021-06-09 Alexander Mikhaylenko <[email protected]>
+
+ [GTK4] Add support for navigation gestures
+ https://bugs.webkit.org/show_bug.cgi?id=212327
+
+ Reviewed by Michael Catanzaro.
+
+ Support GskRenderNode for GRefPtr.
+
+ * platform/gtk/GRefPtrGtk.cpp:
+ (WTF::refGPtr):
+ (WTF::derefGPtr):
+ * platform/gtk/GRefPtrGtk.h:
+
2021-06-09 Alicia Boya GarcĂa <[email protected]>
[WTF][GStreamer] Add RAII lockers for 3rd party locks
Modified: trunk/Source/WebCore/platform/gtk/GRefPtrGtk.cpp (278656 => 278657)
--- trunk/Source/WebCore/platform/gtk/GRefPtrGtk.cpp 2021-06-09 11:17:36 UTC (rev 278656)
+++ trunk/Source/WebCore/platform/gtk/GRefPtrGtk.cpp 2021-06-09 12:36:07 UTC (rev 278657)
@@ -76,4 +76,19 @@
}
#endif
+#if USE(GTK4)
+template <> GskRenderNode* refGPtr(GskRenderNode* ptr)
+{
+ if (ptr)
+ gsk_render_node_ref(ptr);
+ return ptr;
}
+
+template <> void derefGPtr(GskRenderNode* ptr)
+{
+ if (ptr)
+ gsk_render_node_unref(ptr);
+}
+#endif
+
+}
Modified: trunk/Source/WebCore/platform/gtk/GRefPtrGtk.h (278656 => 278657)
--- trunk/Source/WebCore/platform/gtk/GRefPtrGtk.h 2021-06-09 11:17:36 UTC (rev 278656)
+++ trunk/Source/WebCore/platform/gtk/GRefPtrGtk.h 2021-06-09 12:36:07 UTC (rev 278657)
@@ -24,6 +24,7 @@
typedef struct _GtkWidgetPath GtkWidgetPath;
typedef struct _SecretValue SecretValue;
+typedef struct _GskRenderNode GskRenderNode;
namespace WTF {
@@ -42,5 +43,10 @@
template <> void derefGPtr(GtkWidgetPath* ptr);
#endif
+#if USE(GTK4)
+template <> GskRenderNode* refGPtr(GskRenderNode* ptr);
+template <> void derefGPtr(GskRenderNode* ptr);
+#endif
+
}
Modified: trunk/Source/WebKit/ChangeLog (278656 => 278657)
--- trunk/Source/WebKit/ChangeLog 2021-06-09 11:17:36 UTC (rev 278656)
+++ trunk/Source/WebKit/ChangeLog 2021-06-09 12:36:07 UTC (rev 278657)
@@ -1,3 +1,57 @@
+2021-06-09 Alexander Mikhaylenko <[email protected]>
+
+ [GTK4] Add support for navigation gestures
+ https://bugs.webkit.org/show_bug.cgi?id=212327
+
+ Reviewed by Michael Catanzaro.
+
+ Make ViewSnapshotStore store GdkTexture instead of Cairo surfaces
+ for GTK4. Split ViewSnapshotStoreGtk.cpp into GTK3 and GTK4 versions
+ since they don't have much in common.
+
+ When taking a view snapshot, render the web view into a texture.
+
+ When starting a navigation gesture, create a render node from
+ either the texture, or a fallback color, then render that instead
+ of using Cairo.
+
+ Implement the same dimming+shadow as in GTK3. This time don't bother
+ with CSS, the approach we used in GTK3 doesn't work anymore, and since
+ elements like scrollbars aren't themeable anyway it's not very important
+ to preserve that.
+
+ * SourcesGTK.txt:
+ * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+ (webkitWebViewBaseTakeViewSnapshot):
+ * UIProcess/Automation/cairo/WebAutomationSessionCairo.cpp:
+ (WebKit::WebAutomationSession::platformGetBase64EncodedPNGData):
+ * UIProcess/ViewGestureController.h:
+ * UIProcess/ViewSnapshotStore.cpp:
+ (WebKit::ViewSnapshotStore::didAddImageToSnapshot):
+ (WebKit::ViewSnapshotStore::willRemoveImageFromSnapshot):
+ * UIProcess/ViewSnapshotStore.h:
+ (WebKit::ViewSnapshot::estimatedImageSizeInBytes const):
+ (WebKit::ViewSnapshot::texture const):
+ (WebKit::ViewSnapshot::imageSizeInBytes const): Renamed to estimatedImageSizeInBytes().
+ * UIProcess/gtk/ViewGestureControllerGtk.cpp:
+ (WebKit::ViewGestureController::beginSwipeGesture):
+ (WebKit::ViewGestureController::snapshot):
+ (WebKit::ViewGestureController::removeSwipeSnapshot):
+ * UIProcess/gtk/ViewSnapshotStoreGtk3.cpp: Copied from Source/WebKit/UIProcess/gtk/ViewSnapshotStoreGtk.cpp.
+ (WebKit::ViewSnapshot::create):
+ (WebKit::ViewSnapshot::ViewSnapshot):
+ (WebKit::ViewSnapshot::hasImage const):
+ (WebKit::ViewSnapshot::clearImage):
+ (WebKit::ViewSnapshot::estimatedImageSizeInBytes const):
+ (WebKit::ViewSnapshot::size const):
+ * UIProcess/gtk/ViewSnapshotStoreGtk4.cpp: Renamed from Source/WebKit/UIProcess/gtk/ViewSnapshotStoreGtk.cpp.
+ (WebKit::ViewSnapshot::create):
+ (WebKit::ViewSnapshot::ViewSnapshot):
+ (WebKit::ViewSnapshot::hasImage const):
+ (WebKit::ViewSnapshot::clearImage):
+ (WebKit::ViewSnapshot::estimatedImageSizeInBytes const):
+ (WebKit::ViewSnapshot::size const):
+
2021-06-09 Chris Dumez <[email protected]>
Rely on SQLiteDatabase::setMaximumSize() for quota management in LocalStorageDatabase
Modified: trunk/Source/WebKit/SourcesGTK.txt (278656 => 278657)
--- trunk/Source/WebKit/SourcesGTK.txt 2021-06-09 11:17:36 UTC (rev 278656)
+++ trunk/Source/WebKit/SourcesGTK.txt 2021-06-09 12:36:07 UTC (rev 278657)
@@ -259,7 +259,8 @@
UIProcess/gtk/PointerLockManagerWayland.cpp @no-unify
UIProcess/gtk/PointerLockManagerX11.cpp @no-unify
UIProcess/gtk/TextCheckerGtk.cpp @no-unify
-UIProcess/gtk/ViewSnapshotStoreGtk.cpp
+UIProcess/gtk/ViewSnapshotStoreGtk3.cpp @no-unify
+UIProcess/gtk/ViewSnapshotStoreGtk4.cpp @no-unify
UIProcess/gtk/ViewGestureControllerGtk.cpp
UIProcess/gtk/WaylandCompositor.cpp @no-unify
UIProcess/gtk/WebColorPickerGtk.cpp
Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp (278656 => 278657)
--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp 2021-06-09 11:17:36 UTC (rev 278656)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp 2021-06-09 12:36:07 UTC (rev 278657)
@@ -2528,6 +2528,7 @@
float deviceScale = page->deviceScaleFactor();
size.scale(deviceScale);
+#if !USE(GTK4)
RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_RGB24, size.width(), size.height()));
cairo_surface_set_device_scale(surface.get(), deviceScale, deviceScale);
@@ -2537,11 +2538,39 @@
cairo_rectangle(cr.get(), clipRect->x(), clipRect->y(), clipRect->width(), clipRect->height());
cairo_clip(cr.get());
}
-#if !USE(GTK4)
webkitWebViewBaseDraw(GTK_WIDGET(webkitWebViewBase), cr.get());
-#endif
return ViewSnapshot::create(WTFMove(surface));
+#else
+ WebKitWebViewBasePrivate* priv = webkitWebViewBase->priv;
+ auto* renderer = gtk_native_get_renderer(GTK_NATIVE(priv->toplevelOnScreenWindow));
+
+ GRefPtr<GtkSnapshot> snapshot = adoptGRef(gtk_snapshot_new());
+
+ if (clipRect) {
+ graphene_point_t point = { -static_cast<float>(clipRect->x()), -static_cast<float>(clipRect->y()) };
+ graphene_rect_t rect = {
+ { static_cast<float>(clipRect->x()), static_cast<float>(clipRect->y()) },
+ { static_cast<float>(clipRect->width()), static_cast<float>(clipRect->height()) }
+ };
+
+ gtk_snapshot_translate(snapshot.get(), &point);
+ gtk_snapshot_push_clip(snapshot.get(), &rect);
+ }
+
+ gtk_snapshot_scale(snapshot.get(), deviceScale, deviceScale);
+ webkitWebViewBaseSnapshot(GTK_WIDGET(webkitWebViewBase), snapshot.get());
+
+ if (clipRect)
+ gtk_snapshot_pop(snapshot.get());
+
+ GRefPtr<GskRenderNode> renderNode = adoptGRef(gtk_snapshot_to_node(snapshot.get()));
+
+ graphene_rect_t viewport = { 0, 0, static_cast<float>(size.width()), static_cast<float>(size.height()) };
+ GdkTexture* texture = gsk_renderer_render_texture(renderer, renderNode.get(), &viewport);
+
+ return ViewSnapshot::create(WTFMove(texture));
+#endif
}
void webkitWebViewBaseDidStartProvisionalLoadForMainFrame(WebKitWebViewBase* webkitWebViewBase)
Modified: trunk/Source/WebKit/UIProcess/Automation/cairo/WebAutomationSessionCairo.cpp (278656 => 278657)
--- trunk/Source/WebKit/UIProcess/Automation/cairo/WebAutomationSessionCairo.cpp 2021-06-09 11:17:36 UTC (rev 278656)
+++ trunk/Source/WebKit/UIProcess/Automation/cairo/WebAutomationSessionCairo.cpp 2021-06-09 12:36:07 UTC (rev 278657)
@@ -64,7 +64,7 @@
std::optional<String> WebAutomationSession::platformGetBase64EncodedPNGData(const ViewSnapshot& snapshot)
{
-#if PLATFORM(GTK)
+#if PLATFORM(GTK) && !USE(GTK4)
return base64EncodedPNGData(snapshot.surface());
#else
return std::nullopt;
Modified: trunk/Source/WebKit/UIProcess/ViewGestureController.h (278656 => 278657)
--- trunk/Source/WebKit/UIProcess/ViewGestureController.h 2021-06-09 11:17:36 UTC (rev 278656)
+++ trunk/Source/WebKit/UIProcess/ViewGestureController.h 2021-06-09 12:36:07 UTC (rev 278657)
@@ -40,10 +40,15 @@
#endif
#if PLATFORM(GTK)
-#include <WebCore/CairoUtilities.h>
#include <gtk/gtk.h>
#include <wtf/glib/GRefPtr.h>
+
+#if USE(GTK4)
+#include <WebCore/GRefPtrGtk.h>
+#else
+#include <WebCore/CairoUtilities.h>
#endif
+#endif
#if PLATFORM(COCOA)
OBJC_CLASS CALayer;
@@ -436,15 +441,20 @@
SwipeProgressTracker m_swipeProgressTracker;
+#if USE(GTK4)
+ GRefPtr<GskRenderNode> m_currentSwipeSnapshotPattern;
+#else
RefPtr<cairo_pattern_t> m_currentSwipeSnapshotPattern;
RefPtr<cairo_pattern_t> m_swipeDimmingPattern;
RefPtr<cairo_pattern_t> m_swipeShadowPattern;
RefPtr<cairo_pattern_t> m_swipeBorderPattern;
RefPtr<cairo_pattern_t> m_swipeOutlinePattern;
+
int m_swipeShadowSize;
int m_swipeBorderSize;
int m_swipeOutlineSize;
GRefPtr<GtkCssProvider> m_cssProvider;
+#endif
bool m_isSimulatedSwipe { false };
#endif
Modified: trunk/Source/WebKit/UIProcess/ViewSnapshotStore.cpp (278656 => 278657)
--- trunk/Source/WebKit/UIProcess/ViewSnapshotStore.cpp 2021-06-09 11:17:36 UTC (rev 278656)
+++ trunk/Source/WebKit/UIProcess/ViewSnapshotStore.cpp 2021-06-09 12:36:07 UTC (rev 278657)
@@ -58,7 +58,7 @@
{
bool isNewEntry = m_snapshotsWithImages.add(&snapshot).isNewEntry;
ASSERT_UNUSED(isNewEntry, isNewEntry);
- m_snapshotCacheSize += snapshot.imageSizeInBytes();
+ m_snapshotCacheSize += snapshot.estimatedImageSizeInBytes();
}
void ViewSnapshotStore::willRemoveImageFromSnapshot(ViewSnapshot& snapshot)
@@ -65,7 +65,7 @@
{
bool removed = m_snapshotsWithImages.remove(&snapshot);
ASSERT_UNUSED(removed, removed);
- m_snapshotCacheSize -= snapshot.imageSizeInBytes();
+ m_snapshotCacheSize -= snapshot.estimatedImageSizeInBytes();
}
void ViewSnapshotStore::pruneSnapshots(WebPageProxy& webPageProxy)
Modified: trunk/Source/WebKit/UIProcess/ViewSnapshotStore.h (278656 => 278657)
--- trunk/Source/WebKit/UIProcess/ViewSnapshotStore.h 2021-06-09 11:17:36 UTC (rev 278656)
+++ trunk/Source/WebKit/UIProcess/ViewSnapshotStore.h 2021-06-09 12:36:07 UTC (rev 278657)
@@ -36,8 +36,12 @@
#endif
#if PLATFORM(GTK)
+#if USE(GTK4)
+#include <gtk/gtk.h>
+#else
#include <WebCore/RefPtrCairo.h>
#endif
+#endif
namespace WebKit {
@@ -50,8 +54,12 @@
static Ref<ViewSnapshot> create(std::unique_ptr<WebCore::IOSurface>);
#endif
#if PLATFORM(GTK)
+#if USE(GTK4)
+ static Ref<ViewSnapshot> create(GRefPtr<GdkTexture>&&);
+#else
static Ref<ViewSnapshot> create(RefPtr<cairo_surface_t>&&);
#endif
+#endif
~ViewSnapshot();
@@ -78,7 +86,7 @@
#if HAVE(IOSURFACE)
WebCore::IOSurface* surface() const { return m_surface.get(); }
- size_t imageSizeInBytes() const { return m_surface ? m_surface->totalBytes() : 0; }
+ size_t estimatedImageSizeInBytes() const { return m_surface ? m_surface->totalBytes() : 0; }
WebCore::IntSize size() const { return m_surface ? m_surface->size() : WebCore::IntSize(); }
void setSurface(std::unique_ptr<WebCore::IOSurface>);
@@ -87,9 +95,13 @@
#endif
#if PLATFORM(GTK)
+#if USE(GTK4)
+ GdkTexture* texture() const { return m_texture.get(); }
+#else
cairo_surface_t* surface() const { return m_surface.get(); }
+#endif
- size_t imageSizeInBytes() const;
+ size_t estimatedImageSizeInBytes() const;
WebCore::IntSize size() const;
#endif
@@ -101,10 +113,16 @@
#endif
#if PLATFORM(GTK)
+#if USE(GTK4)
+ explicit ViewSnapshot(GRefPtr<GdkTexture>&&);
+
+ GRefPtr<GdkTexture> m_texture;
+#else
explicit ViewSnapshot(RefPtr<cairo_surface_t>&&);
RefPtr<cairo_surface_t> m_surface;
#endif
+#endif
uint64_t m_renderTreeSize;
float m_deviceScaleFactor;
Modified: trunk/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp (278656 => 278657)
--- trunk/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp 2021-06-09 11:17:36 UTC (rev 278656)
+++ trunk/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp 2021-06-09 12:36:07 UTC (rev 278657)
@@ -48,6 +48,21 @@
static const double swipeCancelArea = 0.5;
static const double swipeCancelVelocityThreshold = 0.4;
+#if USE(GTK4)
+static const float swipeOverlayShadowOpacity = 0.06;
+static const float swipeOverlayBorderOpacity = 0.05;
+static const float swipeOverlayOutlineOpacity = 0.05;
+static const float swipeOverlayDimmingOpacity = 0.12;
+static const float swipeOverlayShadowWidth = 57;
+static const GskColorStop swipeOverlayShadowStops[] = {
+ { 0, { 0, 0, 0, 0.08 } },
+ { 0.125, { 0, 0, 0, 0.053 } },
+ { 0.428, { 0, 0, 0, 0.026 } },
+ { 0.714, { 0, 0, 0, 0.01 } },
+ { 1, { 0, 0, 0, 0 } }
+};
+#endif
+
static bool isEventStop(PlatformGtkScrollData* event)
{
return event->isEnd;
@@ -309,6 +324,7 @@
return width;
}
+
#endif
void ViewGestureController::beginSwipeGesture(WebBackForwardListItem* targetItem, SwipeDirection direction)
@@ -319,12 +335,21 @@
willBeginGesture(ViewGestureType::Swipe);
+ FloatSize viewSize(m_webPageProxy.viewSize());
+
+#if USE(GTK4)
+ graphene_rect_t bounds = { 0, 0, viewSize.width(), viewSize.height() };
+#endif
+
if (auto* snapshot = targetItem->snapshot()) {
m_currentSwipeSnapshot = snapshot;
- FloatSize viewSize(m_webPageProxy.viewSize());
if (snapshot->hasImage() && shouldUseSnapshotForSize(*snapshot, viewSize, 0))
+#if USE(GTK4)
+ m_currentSwipeSnapshotPattern = gsk_texture_node_new(snapshot->texture(), &bounds);
+#else
m_currentSwipeSnapshotPattern = adoptRef(cairo_pattern_create_for_surface(snapshot->surface()));
+#endif
Color color = snapshot->backgroundColor();
if (color.isValid()) {
@@ -331,22 +356,37 @@
m_backgroundColorForCurrentSnapshot = color;
if (!m_currentSwipeSnapshotPattern) {
auto [red, green, blue, alpha] = color.toSRGBALossy<float>();
+#if USE(GTK4)
+ GdkRGBA rgba = { red, green, blue, alpha };
+ m_currentSwipeSnapshotPattern = adoptGRef(gsk_color_node_new(&rgba, &bounds));
+#else
m_currentSwipeSnapshotPattern = adoptRef(cairo_pattern_create_rgba(red, green, blue, alpha));
+#endif
}
}
}
-#if !USE(GTK4)
if (!m_currentSwipeSnapshotPattern) {
GdkRGBA color;
auto* context = gtk_widget_get_style_context(m_webPageProxy.viewWidget());
if (gtk_style_context_lookup_color(context, "theme_base_color", &color))
+#if USE(GTK4)
+ m_currentSwipeSnapshotPattern = adoptGRef(gsk_color_node_new(&color, &bounds));
+#else
m_currentSwipeSnapshotPattern = adoptRef(cairo_pattern_create_rgba(color.red, color.green, color.blue, color.alpha));
+#endif
}
- if (!m_currentSwipeSnapshotPattern)
+ if (!m_currentSwipeSnapshotPattern) {
+#if USE(GTK4)
+ GdkRGBA color = { 1, 1, 1, 1 };
+ m_currentSwipeSnapshotPattern = adoptGRef(gsk_color_node_new(&color, &bounds));
+#else
m_currentSwipeSnapshotPattern = adoptRef(cairo_pattern_create_rgb(1, 1, 1));
+#endif
+ }
+#if !USE(GTK4)
auto size = m_webPageProxy.drawingArea()->size();
if (!m_cssProvider) {
@@ -404,27 +444,32 @@
int height = size.height();
double scale = m_webPageProxy.deviceScaleFactor();
- double swipingLayerOffset = (swipingLeft ? 0 : width) + floor(width * progress * scale) / scale;
+ float swipingLayerOffset = (swipingLeft ? 0 : width) + floor(width * progress * scale) / scale;
- double dimmingProgress = swipingLeft ? 1 - progress : -progress;
+ float dimmingProgress = swipingLeft ? 1 - progress : -progress;
if (isRTL) {
dimmingProgress = 1 - dimmingProgress;
swipingLayerOffset = -(width - swipingLayerOffset);
}
+ float remainingSwipeDistance = dimmingProgress * width;
+
+ float shadowOpacity = 1;
+ if (remainingSwipeDistance < swipeOverlayShadowWidth)
+ shadowOpacity = remainingSwipeDistance / swipeOverlayShadowWidth;
+
gtk_snapshot_save(snapshot);
- graphene_point_t translation = { static_cast<float>(swipingLayerOffset), 0 };
+ graphene_rect_t clip = { 0, 0, static_cast<float>(size.width()), static_cast<float>(size.height()) };
+ gtk_snapshot_push_clip(snapshot, &clip);
+
+ graphene_point_t translation = { swipingLayerOffset, 0 };
if (!swipingBack) {
gtk_snapshot_append_node(snapshot, pageRenderNode);
gtk_snapshot_translate(snapshot, &translation);
}
- graphene_rect_t rect = { 0, 0, (float)width, (float)height };
- auto* cr = gtk_snapshot_append_cairo(snapshot, &rect);
- cairo_set_source(cr, m_currentSwipeSnapshotPattern.get());
- cairo_rectangle(cr, 0, 0, width, height);
- cairo_fill(cr);
+ gtk_snapshot_append_node(snapshot, m_currentSwipeSnapshotPattern.get());
if (swipingBack) {
gtk_snapshot_translate(snapshot, &translation);
@@ -431,6 +476,38 @@
gtk_snapshot_append_node(snapshot, pageRenderNode);
}
+ if (!progress) {
+ gtk_snapshot_pop(snapshot);
+ gtk_snapshot_restore(snapshot);
+ return;
+ }
+
+ if (isRTL) {
+ translation = { static_cast<float>(width), 0 };
+ gtk_snapshot_translate(snapshot, &translation);
+ } else
+ gtk_snapshot_scale(snapshot, -1, 1);
+
+ GdkRGBA dimming = { 0, 0, 0, swipeOverlayDimmingOpacity * dimmingProgress };
+ GdkRGBA border = { 0, 0, 0, swipeOverlayBorderOpacity };
+ GdkRGBA outline = { 1, 1, 1, swipeOverlayOutlineOpacity };
+
+ graphene_rect_t dimmingRect = { 0, 0, static_cast<float>(width), static_cast<float>(height) };
+ graphene_rect_t borderRect = { 0, 0, 1, static_cast<float>(height) };
+ graphene_rect_t outlineRect = { -1, 0, 1, static_cast<float>(height) };
+ graphene_rect_t shadowRect = { 0, 0, swipeOverlayShadowWidth, static_cast<float>(height) };
+ graphene_point_t shadowStart = { 0, 0 };
+ graphene_point_t shadowEnd = { swipeOverlayShadowWidth, 0 };
+
+ gtk_snapshot_append_color(snapshot, &dimming, &dimmingRect);
+ gtk_snapshot_append_color(snapshot, &border, &borderRect);
+ gtk_snapshot_append_color(snapshot, &outline, &outlineRect);
+ gtk_snapshot_push_opacity(snapshot, shadowOpacity);
+ gtk_snapshot_append_linear_gradient(snapshot, &shadowRect, &shadowStart, &shadowEnd,
+ swipeOverlayShadowStops, G_N_ELEMENTS(swipeOverlayShadowStops));
+ gtk_snapshot_pop(snapshot);
+
+ gtk_snapshot_pop(snapshot);
gtk_snapshot_restore(snapshot);
}
#else
@@ -536,10 +613,12 @@
return;
m_currentSwipeSnapshotPattern = nullptr;
+#if !USE(GTK4)
m_swipeDimmingPattern = nullptr;
m_swipeShadowPattern = nullptr;
m_swipeBorderPattern = nullptr;
m_swipeOutlinePattern = nullptr;
+#endif
m_currentSwipeSnapshot = nullptr;
Deleted: trunk/Source/WebKit/UIProcess/gtk/ViewSnapshotStoreGtk.cpp (278656 => 278657)
--- trunk/Source/WebKit/UIProcess/gtk/ViewSnapshotStoreGtk.cpp 2021-06-09 11:17:36 UTC (rev 278656)
+++ trunk/Source/WebKit/UIProcess/gtk/ViewSnapshotStoreGtk.cpp 2021-06-09 12:36:07 UTC (rev 278657)
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ViewSnapshotStore.h"
-
-#include <WebCore/CairoUtilities.h>
-
-namespace WebKit {
-using namespace WebCore;
-
-Ref<ViewSnapshot> ViewSnapshot::create(RefPtr<cairo_surface_t>&& surface)
-{
- return adoptRef(*new ViewSnapshot(WTFMove(surface)));
-}
-
-ViewSnapshot::ViewSnapshot(RefPtr<cairo_surface_t>&& surface)
- : m_surface(WTFMove(surface))
-{
- if (hasImage())
- ViewSnapshotStore::singleton().didAddImageToSnapshot(*this);
-}
-
-bool ViewSnapshot::hasImage() const
-{
- return !!m_surface;
-}
-
-void ViewSnapshot::clearImage()
-{
- if (!hasImage())
- return;
-
- ViewSnapshotStore::singleton().willRemoveImageFromSnapshot(*this);
-
- m_surface = nullptr;
-}
-
-size_t ViewSnapshot::imageSizeInBytes() const
-{
- if (!m_surface)
- return 0;
-
- cairo_surface_t* surface = m_surface.get();
- int stride = cairo_image_surface_get_stride(surface);
- int height = cairo_image_surface_get_width(surface);
-
- return stride * height;
-}
-
-WebCore::IntSize ViewSnapshot::size() const
-{
- if (!m_surface)
- return { };
-
- cairo_surface_t* surface = m_surface.get();
- int width = cairo_image_surface_get_width(surface);
- int height = cairo_image_surface_get_height(surface);
-
- return { width, height };
-}
-
-} // namespace WebKit
Copied: trunk/Source/WebKit/UIProcess/gtk/ViewSnapshotStoreGtk3.cpp (from rev 278656, trunk/Source/WebKit/UIProcess/gtk/ViewSnapshotStoreGtk.cpp) (0 => 278657)
--- trunk/Source/WebKit/UIProcess/gtk/ViewSnapshotStoreGtk3.cpp (rev 0)
+++ trunk/Source/WebKit/UIProcess/gtk/ViewSnapshotStoreGtk3.cpp 2021-06-09 12:36:07 UTC (rev 278657)
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ViewSnapshotStore.h"
+
+#if !USE(GTK4)
+
+#include <WebCore/CairoUtilities.h>
+
+namespace WebKit {
+using namespace WebCore;
+
+Ref<ViewSnapshot> ViewSnapshot::create(RefPtr<cairo_surface_t>&& surface)
+{
+ return adoptRef(*new ViewSnapshot(WTFMove(surface)));
+}
+
+ViewSnapshot::ViewSnapshot(RefPtr<cairo_surface_t>&& surface)
+ : m_surface(WTFMove(surface))
+{
+ if (hasImage())
+ ViewSnapshotStore::singleton().didAddImageToSnapshot(*this);
+}
+
+bool ViewSnapshot::hasImage() const
+{
+ return !!m_surface;
+}
+
+void ViewSnapshot::clearImage()
+{
+ if (!hasImage())
+ return;
+
+ ViewSnapshotStore::singleton().willRemoveImageFromSnapshot(*this);
+
+ m_surface = nullptr;
+}
+
+size_t ViewSnapshot::estimatedImageSizeInBytes() const
+{
+ if (!m_surface)
+ return 0;
+
+ cairo_surface_t* surface = m_surface.get();
+ int stride = cairo_image_surface_get_stride(surface);
+ int height = cairo_image_surface_get_width(surface);
+
+ return stride * height;
+}
+
+WebCore::IntSize ViewSnapshot::size() const
+{
+ if (!m_surface)
+ return { };
+
+ cairo_surface_t* surface = m_surface.get();
+ int width = cairo_image_surface_get_width(surface);
+ int height = cairo_image_surface_get_height(surface);
+
+ return { width, height };
+}
+
+} // namespace WebKit
+
+#endif
Copied: trunk/Source/WebKit/UIProcess/gtk/ViewSnapshotStoreGtk4.cpp (from rev 278656, trunk/Source/WebKit/UIProcess/gtk/ViewSnapshotStoreGtk.cpp) (0 => 278657)
--- trunk/Source/WebKit/UIProcess/gtk/ViewSnapshotStoreGtk4.cpp (rev 0)
+++ trunk/Source/WebKit/UIProcess/gtk/ViewSnapshotStoreGtk4.cpp 2021-06-09 12:36:07 UTC (rev 278657)
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,dd
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ViewSnapshotStore.h"
+
+#if USE(GTK4)
+
+namespace WebKit {
+using namespace WebCore;
+
+Ref<ViewSnapshot> ViewSnapshot::create(GRefPtr<GdkTexture>&& texture)
+{
+ return adoptRef(*new ViewSnapshot(WTFMove(texture)));
+}
+
+ViewSnapshot::ViewSnapshot(GRefPtr<GdkTexture>&& texture)
+ : m_texture(WTFMove(texture))
+{
+ if (hasImage())
+ ViewSnapshotStore::singleton().didAddImageToSnapshot(*this);
+}
+
+bool ViewSnapshot::hasImage() const
+{
+ return m_texture;
+}
+
+void ViewSnapshot::clearImage()
+{
+ if (!hasImage())
+ return;
+
+ ViewSnapshotStore::singleton().willRemoveImageFromSnapshot(*this);
+
+ m_texture = nullptr;
+}
+
+size_t ViewSnapshot::estimatedImageSizeInBytes() const
+{
+ if (!m_texture)
+ return 0;
+
+ int width = gdk_texture_get_width(m_texture.get());
+ int height = gdk_texture_get_height(m_texture.get());
+
+ // Unfortunately we don't have a way to get size of a texture in
+ // bytes, so we'll have to make something up. Let's assume that
+ // pixel == 4 bytes.
+ return width * height * 4;
+}
+
+WebCore::IntSize ViewSnapshot::size() const
+{
+ if (!m_texture)
+ return { };
+
+ int width = gdk_texture_get_width(m_texture.get());
+ int height = gdk_texture_get_height(m_texture.get());
+
+ return { width, height };
+}
+
+} // namespace WebKit
+
+#endif