Changeset 55531 in webkit


Ignore:
Timestamp:
Mar 4, 2010 10:00:12 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-03-04 Fridrich Strba <fridrich.strba@bluewin.ch>

Reviewed by Holger Freyther.

Make paths relocatable on runtime on Windows
https://bugs.webkit.org/show_bug.cgi?id=32711

  • platform/graphics/gtk/ImageGtk.cpp: (get_webkit_datadir): (WebCore::Image::loadPlatformResource):
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r55530 r55531  
     12010-03-04  Fridrich Strba  <fridrich.strba@bluewin.ch>
     2
     3        Reviewed by Holger Freyther.
     4
     5        Make paths relocatable on runtime on Windows
     6        https://bugs.webkit.org/show_bug.cgi?id=32711
     7
     8        * platform/graphics/gtk/ImageGtk.cpp:
     9        (get_webkit_datadir):
     10        (WebCore::Image::loadPlatformResource):
     11
    1122010-03-04  Pavel Feldman  <pfeldman@chromium.org>
    213
  • trunk/WebCore/platform/graphics/gtk/ImageGtk.cpp

    r55420 r55531  
    3333#include <gtk/gtk.h>
    3434
     35#ifdef _WIN32
     36#  include <mbstring.h>
     37#  include <shlobj.h>
     38/* search for data relative to where we are installed */
     39
     40static HMODULE hmodule;
     41
     42#ifdef __cplusplus
     43extern "C" {
     44#endif
     45BOOL WINAPI
     46DllMain(HINSTANCE hinstDLL,
     47    DWORD     fdwReason,
     48    LPVOID    lpvReserved)
     49{
     50    switch (fdwReason) {
     51    case DLL_PROCESS_ATTACH:
     52        hmodule = hinstDLL;
     53        break;
     54    }
     55
     56    return TRUE;
     57}
     58#ifdef __cplusplus
     59}
     60#endif
     61
     62static char *
     63get_webkit_datadir(void)
     64{
     65    static char retval[1000];
     66    static int beenhere = 0;
     67
     68    unsigned char *p;
     69
     70    if (beenhere)
     71        return retval;
     72
     73    if (!GetModuleFileName (hmodule, (CHAR *) retval, sizeof(retval) - 10))
     74        return DATA_DIR;
     75
     76    p = _mbsrchr((const unsigned char *) retval, '\\');
     77    *p = '\0';
     78    p = _mbsrchr((const unsigned char *) retval, '\\');
     79    if (p) {
     80        if (!stricmp((const char *) (p+1), "bin"))
     81            *p = '\0';
     82    }
     83    strcat(retval, "\\share");
     84
     85    beenhere = 1;
     86
     87    return retval;
     88}
     89
     90#undef DATA_DIR
     91#define DATA_DIR get_webkit_datadir ()
     92#endif
     93
     94
    3595namespace WTF {
    3696
     
    97157    if (!strcmp("missingImage", name))
    98158        fileName = getThemeIconFileName(GTK_STOCK_MISSING_IMAGE, 16);
    99     if (fileName.isNull())
    100         fileName = String::format("%s/webkit-1.0/images/%s.png", DATA_DIR, name).utf8();
     159    if (fileName.isNull()) {
     160        gchar* imagename = g_strdup_printf("%s.png", name);
     161        gchar* glibFileName = g_build_filename(DATA_DIR, "webkit-1.0", "images", imagename, 0);
     162        fileName = glib_file_name;
     163        g_free(imagename);
     164        g_free(glibFileName);
     165    }
    101166
    102167    return loadImageFromFile(fileName);
Note: See TracChangeset for help on using the changeset viewer.