- a/Source/WebCore/ChangeLog +14 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2020-04-15  Carlos Garcia Campos  <cgarcia@igalia.com>
2
3
        [GTK] Remove IconGtk
4
        https://bugs.webkit.org/show_bug.cgi?id=210546
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        It's currently unused in GTK port since we never show an icon for file uploads.
9
10
        * SourcesGTK.txt:
11
        * platform/graphics/Icon.cpp:
12
        * platform/graphics/Icon.h:
13
        * platform/graphics/gtk/IconGtk.cpp: Removed.
14
1
2020-04-15  Adrian Perez de Castro  <aperez@igalia.com>
15
2020-04-15  Adrian Perez de Castro  <aperez@igalia.com>
2
16
3
        [GTK4] Adapt to cursor API changes
17
        [GTK4] Adapt to cursor API changes
- a/Source/WebCore/SourcesGTK.txt -1 lines
Lines 85-91 platform/graphics/glx/GLContextGLX.cpp a/Source/WebCore/SourcesGTK.txt_sec1
85
platform/graphics/gtk/ColorGtk.cpp
85
platform/graphics/gtk/ColorGtk.cpp
86
platform/graphics/gtk/DisplayRefreshMonitorGtk.cpp
86
platform/graphics/gtk/DisplayRefreshMonitorGtk.cpp
87
platform/graphics/gtk/GdkCairoUtilities.cpp
87
platform/graphics/gtk/GdkCairoUtilities.cpp
88
platform/graphics/gtk/IconGtk.cpp
89
platform/graphics/gtk/ImageGtk.cpp
88
platform/graphics/gtk/ImageGtk.cpp
90
89
91
platform/graphics/gstreamer/ImageGStreamerCairo.cpp
90
platform/graphics/gstreamer/ImageGStreamerCairo.cpp
- a/Source/WebCore/platform/graphics/Icon.cpp -1 / +1 lines
Lines 26-32 a/Source/WebCore/platform/graphics/Icon.cpp_sec1
26
#include "config.h"
26
#include "config.h"
27
#include "Icon.h"
27
#include "Icon.h"
28
28
29
#if !PLATFORM(GTK) && !PLATFORM(IOS_FAMILY) && !PLATFORM(MAC) && !PLATFORM(WIN)
29
#if !PLATFORM(IOS_FAMILY) && !PLATFORM(MAC) && !PLATFORM(WIN)
30
30
31
namespace WebCore {
31
namespace WebCore {
32
32
- a/Source/WebCore/platform/graphics/Icon.h -5 lines
Lines 33-40 a/Source/WebCore/platform/graphics/Icon.h_sec1
33
OBJC_CLASS NSImage;
33
OBJC_CLASS NSImage;
34
#elif PLATFORM(WIN)
34
#elif PLATFORM(WIN)
35
typedef struct HICON__* HICON;
35
typedef struct HICON__* HICON;
36
#elif PLATFORM(GTK)
37
typedef struct _GdkPixbuf GdkPixbuf;
38
#endif
36
#endif
39
37
40
namespace WebCore {
38
namespace WebCore {
Lines 74-82 private: a/Source/WebCore/platform/graphics/Icon.h_sec2
74
#elif PLATFORM(WIN)
72
#elif PLATFORM(WIN)
75
    Icon(HICON);
73
    Icon(HICON);
76
    HICON m_hIcon;
74
    HICON m_hIcon;
77
#elif PLATFORM(GTK)
78
    Icon();
79
    GdkPixbuf* m_icon;
80
#endif
75
#endif
81
};
76
};
82
77
- a/Source/WebCore/platform/graphics/gtk/IconGtk.cpp -129 lines
Lines 1-129 a/Source/WebCore/platform/graphics/gtk/IconGtk.cpp_sec1
1
/*
2
 * Copyright (C) 2006, 2007 Apple Inc.  All rights reserved.
3
 * Copyright (C) 2007 Holger Hans Peter Freyther
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 *
9
 * 1.  Redistributions of source code must retain the above copyright
10
 *     notice, this list of conditions and the following disclaimer.
11
 * 2.  Redistributions in binary form must reproduce the above copyright
12
 *     notice, this list of conditions and the following disclaimer in the
13
 *     documentation and/or other materials provided with the distribution.
14
 * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
15
 *     its contributors may be used to endorse or promote products derived
16
 *     from this software without specific prior written permission.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
 */
29
30
#include "config.h"
31
#include "Icon.h"
32
33
#include "GraphicsContext.h"
34
#include "MIMETypeRegistry.h"
35
#include "PlatformContextCairo.h"
36
37
#include <gtk/gtk.h>
38
39
#include <wtf/RefPtr.h>
40
#include <wtf/text/CString.h>
41
42
namespace WebCore {
43
44
Icon::Icon()
45
    : m_icon(0)
46
{
47
}
48
49
Icon::~Icon()
50
{
51
    if (m_icon)
52
        g_object_unref(m_icon);
53
}
54
55
static String lookupIconName(String MIMEType)
56
{
57
    /*
58
     Lookup an appropriate icon according to either the Icon Naming Spec
59
     or conventional Gnome icon names respectively.
60
61
     See http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
62
63
     The icon theme is probed for the following names:
64
     1. media-subtype
65
     2. gnome-mime-media-subtype
66
     3. media-x-generic
67
     4. gnome-mime-media
68
69
     In the worst case it falls back to the stock file icon.
70
    */
71
    int pos = MIMEType.find('/');
72
    if(pos >= 0) {
73
        String media = MIMEType.substring(0, pos);
74
        String subtype = MIMEType.substring(pos + 1);
75
        GtkIconTheme* iconTheme = gtk_icon_theme_get_default();
76
        String iconName = media + "-" + subtype;
77
        if(gtk_icon_theme_has_icon(iconTheme, iconName.utf8().data()))
78
            return iconName;
79
        iconName = "gnome-mime-" + media + "-" + subtype;
80
        if(gtk_icon_theme_has_icon(iconTheme, iconName.utf8().data()))
81
            return iconName;
82
        iconName = media + "-x-generic";
83
        if(gtk_icon_theme_has_icon(iconTheme, iconName.utf8().data()))
84
            return iconName;
85
        iconName = media + "gnome-mime-" + media;
86
        if(gtk_icon_theme_has_icon(iconTheme, iconName.utf8().data()))
87
            return iconName;
88
    }
89
    return "text-x-generic";
90
}
91
92
// FIXME: Move the code to ChromeClient::iconForFiles().
93
RefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames)
94
{
95
    if (filenames.isEmpty())
96
        return nullptr;
97
98
    if (filenames.size() == 1) {
99
        if (!g_path_skip_root(filenames[0].utf8().data()))
100
            return nullptr;
101
102
        String MIMEType = MIMETypeRegistry::getMIMETypeForPath(filenames[0]);
103
        String iconName = lookupIconName(MIMEType);
104
105
        RefPtr<Icon> icon = adoptRef(new Icon);
106
        icon->m_icon = gtk_icon_theme_load_icon(gtk_icon_theme_get_default(), iconName.utf8().data(), 16, GTK_ICON_LOOKUP_USE_BUILTIN, 0);
107
        if (!icon->m_icon)
108
            return nullptr;
109
        return icon;
110
    }
111
112
    //FIXME: Implement this
113
    return 0;
114
}
115
116
void Icon::paint(GraphicsContext& context, const FloatRect& rect)
117
{
118
    if (context.paintingDisabled())
119
        return;
120
121
    // TODO: Scale/clip the image if necessary.
122
    cairo_t* cr = context.platformContext()->cr();
123
    cairo_save(cr);
124
    gdk_cairo_set_source_pixbuf(cr, m_icon, rect.x(), rect.y());
125
    cairo_paint(cr);
126
    cairo_restore(cr);
127
}
128
129
}

Return to Bug 210546