Changeset 65529 in webkit


Ignore:
Timestamp:
Aug 17, 2010 12:00:10 PM (14 years ago)
Author:
Martin Robinson
Message:

2010-08-17 Martin Robinson <mrobinson@igalia.com>

[GTK] Clean up WebCore/platform/graphics/gtk/ImageGtk.cpp
https://bugs.webkit.org/show_bug.cgi?id=44069

No new tests as functionality has not changed.

  • GNUmakefile.am: Add WEBKITGTK_API_VERSION_STRING definition, which allows WebCore to use this as well.
  • platform/graphics/gtk/ImageGtk.cpp: (getWebKitDataDirectory): Added this helper. (WebCore::Image::loadPlatformResource): Use GOwnPtr for gchar pointers and use the new getWebKitDataDirectory helper.
  • platform/gtk/GOwnPtrGtk.cpp: Move the GtkIconInfo template specialization to this file. (WTF::GtkIconInfo): Added this forward declaration.
  • platform/gtk/GOwnPtrGtk.h: Declaration for new template specialization.

2010-08-17 Martin Robinson <mrobinson@igalia.com>

Reviewed by Gustavo Noronha Silva.

[GTK] Clean up WebCore/platform/graphics/gtk/ImageGtk.cpp
https://bugs.webkit.org/show_bug.cgi?id=44069

  • WebCoreSupport/InspectorClientGtk.cpp: (WebKit::InspectorClient::openInspectorFrontend): Switched to using the new WEBKITGTK_API_VERSION_STRING define.
  • webkit/webkitprivate.cpp: (inspectorGSettings): Ditto.
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r65528 r65529  
     12010-08-17  Martin Robinson  <mrobinson@igalia.com>
     2
     3        [GTK] Clean up WebCore/platform/graphics/gtk/ImageGtk.cpp
     4        https://bugs.webkit.org/show_bug.cgi?id=44069
     5
     6        No new tests as functionality has not changed.
     7
     8        * GNUmakefile.am: Add WEBKITGTK_API_VERSION_STRING definition, which
     9        allows WebCore to use this as well.
     10        * platform/graphics/gtk/ImageGtk.cpp:
     11        (getWebKitDataDirectory): Added this helper.
     12        (WebCore::Image::loadPlatformResource): Use GOwnPtr for gchar pointers and
     13        use the new getWebKitDataDirectory helper.
     14        * platform/gtk/GOwnPtrGtk.cpp: Move the GtkIconInfo template specialization to this file.
     15        (WTF::GtkIconInfo): Added this forward declaration.
     16        * platform/gtk/GOwnPtrGtk.h: Declaration for new template specialization.
     17
    1182010-08-17  Stephen White  <senorblanco@chromium.org>
    219
  • trunk/WebCore/GNUmakefile.am

    r65526 r65529  
    7070
    7171webcoregtk_cppflags += \
     72        -DWEBKITGTK_API_VERSION_STRING=\"@WEBKITGTK_API_VERSION@\" \
    7273        -DWTF_USE_SOUP=1 \
    7374        -DWTF_USE_GSTREAMER=1 \
     
    46234624        $(shell ls $(WebCore)/inspector/front-end/Images/*.png)
    46244625
    4625 webresourcesdir = ${datadir}/webkit-@WEBKITGTK_API_VERSION@/images
     4626webresourcesdir = ${datadir}/webkitgtk-@WEBKITGTK_API_VERSION@/images
    46264627dist_webresources_DATA = \
    46274628        $(WebCore)/Resources/textAreaResizeCorner.png \
  • trunk/WebCore/platform/graphics/gtk/ImageGtk.cpp

    r64506 r65529  
    2828#include "BitmapImage.h"
    2929#include "CairoUtilities.h"
    30 #include "GOwnPtr.h"
     30#include "GOwnPtrGtk.h"
    3131#include "SharedBuffer.h"
    3232#include <wtf/text/CString.h>
     
    3434#include <gtk/gtk.h>
    3535
    36 #ifdef _WIN32
    37 #  include <mbstring.h>
    38 #  include <shlobj.h>
    39 /* search for data relative to where we are installed */
     36#if PLATFORM(WIN)
     37#include <mbstring.h>
     38#include <shlobj.h>
    4039
    4140static HMODULE hmodule;
    4241
    43 #ifdef __cplusplus
    4442extern "C" {
    45 #endif
    46 BOOL WINAPI
    47 DllMain(HINSTANCE hinstDLL,
    48     DWORD     fdwReason,
    49     LPVOID    lpvReserved)
     43BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
    5044{
    51     switch (fdwReason) {
    52     case DLL_PROCESS_ATTACH:
     45    if (fdwReason == DLL_PROCESS_ATTACH)
    5346        hmodule = hinstDLL;
    54         break;
    55     }
    56 
    5747    return TRUE;
    5848}
    59 #ifdef __cplusplus
    6049}
    61 #endif
    6250
    63 static char *
    64 get_webkit_datadir(void)
     51static const char* getWebKitDataDirectory()
    6552{
    66     static char retval[1000];
    67     static int beenhere = 0;
     53    static char* dataDirectory = 0;
     54    if (dataDirectory)
     55        return dataDirectory;
    6856
    69     unsigned char *p;
    70 
    71     if (beenhere)
    72         return retval;
    73 
    74     if (!GetModuleFileName (hmodule, (CHAR *) retval, sizeof(retval) - 10))
     57    dataDirectory = new char[PATH_MAX];
     58    if (!GetModuleFileName(hmodule, static_cast<CHAR*>(dataDirectory), sizeof(dataDirectory) - 10))
    7559        return DATA_DIR;
    7660
    77     p = _mbsrchr((const unsigned char *) retval, '\\');
     61    // FIXME: This is pretty ugly. Ideally we should be using Windows API
     62    // functions or GLib methods to calculate paths.
     63    unsigned char *p;
     64    p = _mbsrchr(static_cast<const unsigned char *>(dataDirectory), '\\');
    7865    *p = '\0';
    79     p = _mbsrchr((const unsigned char *) retval, '\\');
     66    p = _mbsrchr(static_cast<const unsigned char *>(dataDirectory), '\\');
    8067    if (p) {
    8168        if (!stricmp((const char *) (p+1), "bin"))
    8269            *p = '\0';
    8370    }
    84     strcat(retval, "\\share");
     71    strcat(dataDirectory, "\\share");
    8572
    86     beenhere = 1;
    87 
    88     return retval;
     73    return dataDirectory;
    8974}
    9075
    91 #undef DATA_DIR
    92 #define DATA_DIR get_webkit_datadir ()
    93 #endif
     76#else
    9477
    95 
    96 namespace WTF {
    97 
    98 template <> void freeOwnedGPtr<GtkIconInfo>(GtkIconInfo* info)
     78static const char* getWebKitDataDirectory()
    9979{
    100     if (info)
    101         gtk_icon_info_free(info);
     80    return DATA_DIR;
    10281}
    10382
    104 }
     83#endif
    10584
    10685namespace WebCore {
     
    159138        fileName = getThemeIconFileName(GTK_STOCK_MISSING_IMAGE, 16);
    160139    if (fileName.isNull()) {
    161         gchar* imagename = g_strdup_printf("%s.png", name);
    162         gchar* glibFileName = g_build_filename(DATA_DIR, "webkit-1.0", "images", imagename, NULL);
    163         fileName = glibFileName;
    164         g_free(imagename);
    165         g_free(glibFileName);
     140        GOwnPtr<gchar> imageName(g_strdup_printf("%s.png", name));
     141        GOwnPtr<gchar> glibFileName(g_build_filename(getWebKitDataDirectory(), "webkitgtk-"WEBKITGTK_API_VERSION_STRING, "images", imageName.get(), NULL));
     142        fileName = glibFileName.get();
    166143    }
    167144
  • trunk/WebCore/platform/gtk/GOwnPtrGtk.cpp

    r60482 r65529  
    2020#include "GOwnPtrGtk.h"
    2121
    22 #include <gdk/gdk.h>
    23 #include <glib.h>
     22#include <gtk/gtk.h>
    2423
    2524namespace WTF {
     
    3130}
    3231
     32template <> void freeOwnedGPtr<GtkIconInfo>(GtkIconInfo* info)
     33{
     34    if (info)
     35        gtk_icon_info_free(info);
    3336}
     37
     38}
  • trunk/WebCore/platform/gtk/GOwnPtrGtk.h

    r60482 r65529  
    2424
    2525typedef union _GdkEvent GdkEvent;
     26typedef struct _GtkIconInfo GtkIconInfo;
    2627
    2728namespace WTF {
    2829
    29 template<> void freeOwnedGPtr<GdkEvent>(GdkEvent*);
     30template <> void freeOwnedGPtr<GdkEvent>(GdkEvent*);
     31template <> void freeOwnedGPtr<GtkIconInfo>(GtkIconInfo*);
    3032
    3133}
  • trunk/WebKit/gtk/ChangeLog

    r65501 r65529  
     12010-08-17  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Reviewed by Gustavo Noronha Silva.
     4
     5        [GTK] Clean up WebCore/platform/graphics/gtk/ImageGtk.cpp
     6        https://bugs.webkit.org/show_bug.cgi?id=44069
     7
     8        * WebCoreSupport/InspectorClientGtk.cpp:
     9        (WebKit::InspectorClient::openInspectorFrontend): Switched to using the new WEBKITGTK_API_VERSION_STRING define.
     10        * webkit/webkitprivate.cpp:
     11        (inspectorGSettings): Ditto.
     12
    1132010-08-17  Sheriff Bot  <webkit.review.bot@gmail.com>
    214
  • trunk/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp

    r65501 r65529  
    8888        inspectorURI.set(g_filename_to_uri(fullPath.get(), NULL, NULL));
    8989    } else {
    90         GOwnPtr<gchar> dataPath(g_strdup_printf(DATA_DIR"/webkitgtk-%.1f/webinspector/inspector.html", WEBKITGTK_API_VERSION));
    91         inspectorURI.set(g_filename_to_uri(dataPath.get(), NULL, NULL));
     90        inspectorURI.set(g_filename_to_uri(DATA_DIR"/webkitgtk-"WEBKITGTK_API_VERSION_STRING"/webinspector/inspector.html", NULL, NULL));
    9291    }
    9392
  • trunk/WebKit/gtk/webkit/webkitprivate.cpp

    r65498 r65529  
    238238        return settings;
    239239
    240     GOwnPtr<gchar> schemaID(g_strdup_printf("org.webkitgtk-%.1f.inspector", WEBKITGTK_API_VERSION));
     240    const gchar* schemaID = "org.webkitgtk-"WEBKITGTK_API_VERSION_STRING".inspector"
    241241
    242242    // Unfortunately GSettings will abort the process execution if the
     
    244244    // tests, or even the introspection dump at build time, so check
    245245    // if we have the schema before trying to initialize it.
    246     if (!isSchemaAvailable(schemaID.get())) {
     246    if (!isSchemaAvailable(schemaID)) {
    247247        g_warning("GSettings schema not found - settings will not be used or saved.");
    248248        return 0;
    249249    }
    250250
    251     settings = g_settings_new(schemaID.get());
     251    settings = g_settings_new(schemaID);
    252252
    253253    return settings;
Note: See TracChangeset for help on using the changeset viewer.