Modified: trunk/Source/WebCore/ChangeLog (212286 => 212287)
--- trunk/Source/WebCore/ChangeLog 2017-02-14 11:54:59 UTC (rev 212286)
+++ trunk/Source/WebCore/ChangeLog 2017-02-14 11:58:13 UTC (rev 212287)
@@ -1,3 +1,21 @@
+2017-02-14 Carlos Garcia Campos <[email protected]>
+
+ [GTK] Make DragImageRef a RefPtr instead of a plain pointer
+ https://bugs.webkit.org/show_bug.cgi?id=168296
+
+ Reviewed by Sergio Villar Senin.
+
+ Use RefPtr<cairo_surface_t> as DragImageRef for GTK+ port to avoid memory leaks.
+
+ * platform/DragImage.h:
+ * platform/gtk/DragImageGtk.cpp:
+ (WebCore::dragImageSize):
+ (WebCore::deleteDragImage):
+ (WebCore::scaleDragImage):
+ (WebCore::dissolveDragImageToFraction):
+ (WebCore::createDragImageFromImage):
+ (WebCore::createDragImageIconForCachedImageFilename):
+
2017-02-14 Vanessa Chipirrás Navalón <[email protected]>
[GStreamer][MSE] Some GStreamer log messages are generated with the 'default' category
Modified: trunk/Source/WebCore/platform/DragImage.h (212286 => 212287)
--- trunk/Source/WebCore/platform/DragImage.h 2017-02-14 11:54:59 UTC (rev 212286)
+++ trunk/Source/WebCore/platform/DragImage.h 2017-02-14 11:58:13 UTC (rev 212287)
@@ -40,7 +40,7 @@
#elif PLATFORM(WIN)
typedef struct HBITMAP__* HBITMAP;
#elif PLATFORM(GTK)
-typedef struct _cairo_surface cairo_surface_t;
+#include "RefPtrCairo.h"
#endif
// We need to #define YOffset as it needs to be shared with WebKit
@@ -62,7 +62,7 @@
#elif PLATFORM(WIN)
typedef HBITMAP DragImageRef;
#elif PLATFORM(GTK)
-typedef cairo_surface_t* DragImageRef;
+typedef RefPtr<cairo_surface_t> DragImageRef;
#elif PLATFORM(EFL)
typedef void* DragImageRef;
#endif
Modified: trunk/Source/WebCore/platform/gtk/DragImageGtk.cpp (212286 => 212287)
--- trunk/Source/WebCore/platform/gtk/DragImageGtk.cpp 2017-02-14 11:54:59 UTC (rev 212286)
+++ trunk/Source/WebCore/platform/gtk/DragImageGtk.cpp 2017-02-14 11:58:13 UTC (rev 212287)
@@ -1,5 +1,5 @@
/*
- * 2010 Igalia S.L
+ * Copyright (C) 2010,2017 Igalia S.L.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,7 +20,6 @@
#include "DragImage.h"
#include "Image.h"
-#include "RefPtrCairo.h"
#include <cairo.h>
#include <gdk/gdk.h>
@@ -29,35 +28,38 @@
IntSize dragImageSize(DragImageRef image)
{
if (image)
- return IntSize(cairo_image_surface_get_width(image), cairo_image_surface_get_height(image));
+ return { cairo_image_surface_get_width(image.get()), cairo_image_surface_get_height(image.get()) };
- return IntSize(0, 0);
+ return { 0, 0 };
}
-void deleteDragImage(DragImageRef image)
+void deleteDragImage(DragImageRef)
{
- if (image)
- cairo_surface_destroy(image);
+ // Since this is a RefPtr, there's nothing additional we need to do to
+ // delete it. It will be released when it falls out of scope.
}
DragImageRef scaleDragImage(DragImageRef image, FloatSize scale)
{
if (!image)
- return 0;
+ return nullptr;
- int newWidth = scale.width() * cairo_image_surface_get_width(image);
- int newHeight = scale.height() * cairo_image_surface_get_height(image);
- cairo_surface_t* scaledSurface = cairo_surface_create_similar(image, CAIRO_CONTENT_COLOR_ALPHA, newWidth, newHeight);
+ IntSize imageSize = dragImageSize(image);
+ IntSize scaledSize(imageSize);
+ scaledSize.scale(scale.width(), scale.height());
+ if (imageSize == scaledSize)
+ return image;
- RefPtr<cairo_t> context = adoptRef(cairo_create(scaledSurface));
+ RefPtr<cairo_surface_t> scaledSurface = adoptRef(cairo_surface_create_similar(image.get(), CAIRO_CONTENT_COLOR_ALPHA, scaledSize.width(), scaledSize.height()));
+
+ RefPtr<cairo_t> context = adoptRef(cairo_create(scaledSurface.get()));
cairo_scale(context.get(), scale.width(), scale.height());
cairo_pattern_set_extend(cairo_get_source(context.get()), CAIRO_EXTEND_PAD);
cairo_pattern_set_filter(cairo_get_source(context.get()), CAIRO_FILTER_BEST);
cairo_set_operator(context.get(), CAIRO_OPERATOR_SOURCE);
- cairo_set_source_surface(context.get(), image, 0, 0);
+ cairo_set_source_surface(context.get(), image.get(), 0, 0);
cairo_paint(context.get());
- deleteDragImage(image);
return scaledSurface;
}
@@ -64,12 +66,12 @@
DragImageRef dissolveDragImageToFraction(DragImageRef image, float fraction)
{
if (!image)
- return 0;
+ return nullptr;
if (!gdk_screen_is_composited(gdk_screen_get_default()))
return image;
- RefPtr<cairo_t> context = adoptRef(cairo_create(image));
+ RefPtr<cairo_t> context = adoptRef(cairo_create(image.get()));
cairo_set_operator(context.get(), CAIRO_OPERATOR_DEST_IN);
cairo_set_source_rgba(context.get(), 0, 0, 0, fraction);
cairo_paint(context.get());
@@ -78,12 +80,12 @@
DragImageRef createDragImageFromImage(Image* image, ImageOrientationDescription)
{
- return image->nativeImageForCurrentFrame().leakRef();
+ return image->nativeImageForCurrentFrame();
}
DragImageRef createDragImageIconForCachedImageFilename(const String&)
{
- return 0;
+ return nullptr;
}
}
Modified: trunk/Source/WebKit2/ChangeLog (212286 => 212287)
--- trunk/Source/WebKit2/ChangeLog 2017-02-14 11:54:59 UTC (rev 212286)
+++ trunk/Source/WebKit2/ChangeLog 2017-02-14 11:58:13 UTC (rev 212287)
@@ -1,5 +1,15 @@
2017-02-14 Carlos Garcia Campos <[email protected]>
+ [GTK] Make DragImageRef a RefPtr instead of a plain pointer
+ https://bugs.webkit.org/show_bug.cgi?id=168296
+
+ Reviewed by Sergio Villar Senin.
+
+ * WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp:
+ (WebKit::WebDragClient::startDrag):
+
+2017-02-14 Carlos Garcia Campos <[email protected]>
+
[SOUP] Ensure a response MIME type when Content-Type is missing and sniffing not allowed
https://bugs.webkit.org/show_bug.cgi?id=168299
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp (212286 => 212287)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp 2017-02-14 11:54:59 UTC (rev 212286)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp 2017-02-14 11:58:13 UTC (rev 212287)
@@ -58,7 +58,7 @@
void WebDragClient::startDrag(DragImageRef dragImage, const IntPoint& clientPosition, const IntPoint& globalPosition, const FloatPoint&, DataTransfer& dataTransfer, Frame&, bool)
{
- RefPtr<ShareableBitmap> bitmap = convertCairoSurfaceToShareableBitmap(dragImage);
+ RefPtr<ShareableBitmap> bitmap = convertCairoSurfaceToShareableBitmap(dragImage.get());
ShareableBitmap::Handle handle;
// If we have a bitmap, but cannot create a handle to it, we fail early.