diff options
author | Steve Block <steveblock@google.com> | 2010-08-24 07:50:47 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-08-24 07:50:47 -0700 |
commit | c570a147a94b126d4172c30914f53dea17b4c8f5 (patch) | |
tree | 99c11741887d21f65d67c5bbdab58b7ba2a5d4d5 /WebCore/platform/graphics/gtk/ImageGtk.cpp | |
parent | c952714bc6809a5ad081baaf9fcc04107b92ea3f (diff) | |
parent | 6c65f16005b91786c2b7c0791b9ea1dd684d57f4 (diff) | |
download | external_webkit-c570a147a94b126d4172c30914f53dea17b4c8f5.zip external_webkit-c570a147a94b126d4172c30914f53dea17b4c8f5.tar.gz external_webkit-c570a147a94b126d4172c30914f53dea17b4c8f5.tar.bz2 |
Merge changes I2e7e2317,Ie6ccde3a,I3e89f231,Id06ff339,I268dfe7d,Icaf70d9f,Ie234f1a0,Iff5c7aaa,I69b75bf0,Ifbf384f4
* changes:
Merge WebKit at r65615 : Update WebKit revision number
Merge WebKit at r65615 : Ignore http/tests/appcache/origin-quota.html
Merge WebKit at r65615 : Android-specific results for Geolocation tests.
Merge WebKit at r65615 : Fix GraphicsContext and ImageBuffer.
Merge WebKit at r65615 : processingUserGesture() is now static.
Merge WebKit at r65615 : UTF8String() becomes utf8().
Merge WebKit at r65615 : Fix include paths for string headers.
Merge WebKit at r65615 : Fix Makefiles.
Merge WebKit at r65615 : Fix conflicts.
Merge WebKit at r65615 : Initial merge by git.
Diffstat (limited to 'WebCore/platform/graphics/gtk/ImageGtk.cpp')
-rw-r--r-- | WebCore/platform/graphics/gtk/ImageGtk.cpp | 75 |
1 files changed, 26 insertions, 49 deletions
diff --git a/WebCore/platform/graphics/gtk/ImageGtk.cpp b/WebCore/platform/graphics/gtk/ImageGtk.cpp index 30db6d7..5272243 100644 --- a/WebCore/platform/graphics/gtk/ImageGtk.cpp +++ b/WebCore/platform/graphics/gtk/ImageGtk.cpp @@ -27,81 +27,60 @@ #include "BitmapImage.h" #include "CairoUtilities.h" -#include "GOwnPtr.h" +#include "GOwnPtrGtk.h" #include "SharedBuffer.h" #include <wtf/text/CString.h> #include <cairo.h> #include <gtk/gtk.h> -#ifdef _WIN32 -# include <mbstring.h> -# include <shlobj.h> -/* search for data relative to where we are installed */ +#if PLATFORM(WIN) +#include <mbstring.h> +#include <shlobj.h> static HMODULE hmodule; -#ifdef __cplusplus extern "C" { -#endif -BOOL WINAPI -DllMain(HINSTANCE hinstDLL, - DWORD fdwReason, - LPVOID lpvReserved) +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { - switch (fdwReason) { - case DLL_PROCESS_ATTACH: + if (fdwReason == DLL_PROCESS_ATTACH) hmodule = hinstDLL; - break; - } - return TRUE; } -#ifdef __cplusplus } -#endif -static char * -get_webkit_datadir(void) +static const char* getWebKitDataDirectory() { - static char retval[1000]; - static int beenhere = 0; - - unsigned char *p; - - if (beenhere) - return retval; + static char* dataDirectory = 0; + if (dataDirectory) + return dataDirectory; - if (!GetModuleFileName (hmodule, (CHAR *) retval, sizeof(retval) - 10)) + dataDirectory = new char[PATH_MAX]; + if (!GetModuleFileName(hmodule, static_cast<CHAR*>(dataDirectory), sizeof(dataDirectory) - 10)) return DATA_DIR; - p = _mbsrchr((const unsigned char *) retval, '\\'); + // FIXME: This is pretty ugly. Ideally we should be using Windows API + // functions or GLib methods to calculate paths. + unsigned char *p; + p = _mbsrchr(static_cast<const unsigned char *>(dataDirectory), '\\'); *p = '\0'; - p = _mbsrchr((const unsigned char *) retval, '\\'); + p = _mbsrchr(static_cast<const unsigned char *>(dataDirectory), '\\'); if (p) { if (!stricmp((const char *) (p+1), "bin")) *p = '\0'; } - strcat(retval, "\\share"); - - beenhere = 1; + strcat(dataDirectory, "\\share"); - return retval; + return dataDirectory; } -#undef DATA_DIR -#define DATA_DIR get_webkit_datadir () -#endif - +#else -namespace WTF { - -template <> void freeOwnedGPtr<GtkIconInfo>(GtkIconInfo* info) +static const char* getWebKitDataDirectory() { - if (info) - gtk_icon_info_free(info); + return DATA_DIR; } -} +#endif namespace WebCore { @@ -158,11 +137,9 @@ PassRefPtr<Image> Image::loadPlatformResource(const char* name) if (!strcmp("missingImage", name)) fileName = getThemeIconFileName(GTK_STOCK_MISSING_IMAGE, 16); if (fileName.isNull()) { - gchar* imagename = g_strdup_printf("%s.png", name); - gchar* glibFileName = g_build_filename(DATA_DIR, "webkit-1.0", "images", imagename, NULL); - fileName = glibFileName; - g_free(imagename); - g_free(glibFileName); + GOwnPtr<gchar> imageName(g_strdup_printf("%s.png", name)); + GOwnPtr<gchar> glibFileName(g_build_filename(getWebKitDataDirectory(), "webkitgtk-"WEBKITGTK_API_VERSION_STRING, "images", imageName.get(), NULL)); + fileName = glibFileName.get(); } return loadImageFromFile(fileName); |