Changeset 108206 in webkit


Ignore:
Timestamp:
Feb 19, 2012 9:24:14 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[GTK] Can't find webinspector and error page redirection on Windows
https://bugs.webkit.org/show_bug.cgi?id=51616

Source/WebCore:

Create and use an abstraction for finding shared resources on Windows.

Patch by Paweł Forysiuk <tuxator@o2.pl> on 2012-02-19
Reviewed by Martin Robinson.

  • platform/FileSystem.h:

(WebCore):

  • platform/audio/gtk/AudioBusGtk.cpp:

(WebCore::AudioBus::loadPlatformResource):

  • platform/graphics/gtk/ImageGtk.cpp:

(WebCore::getPathToImageResource):

  • platform/gtk/FileSystemGtk.cpp:

(WebCore::sharedResourcesPath):
(WebCore):

Source/WebKit/gtk:

Use an abstraction for finding shared resources on Windows.

Patch by Paweł Forysiuk <tuxator@o2.pl> on 2012-02-19
Reviewed by Martin Robinson.

  • WebCoreSupport/FrameLoaderClientGtk.cpp:

(WebKit::FrameLoaderClient::dispatchDidFailLoad):

  • WebCoreSupport/InspectorClientGtk.cpp:

(WebKit::InspectorClient::inspectorFilesPath):

Location:
trunk/Source
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r108202 r108206  
     12012-02-19  Paweł Forysiuk  <tuxator@o2.pl>
     2
     3        [GTK] Can't find webinspector and error page redirection on Windows
     4        https://bugs.webkit.org/show_bug.cgi?id=51616
     5
     6        Create and use an abstraction for finding shared resources on Windows.
     7
     8        Reviewed by Martin Robinson.
     9
     10        * platform/FileSystem.h:
     11        (WebCore):
     12        * platform/audio/gtk/AudioBusGtk.cpp:
     13        (WebCore::AudioBus::loadPlatformResource):
     14        * platform/graphics/gtk/ImageGtk.cpp:
     15        (WebCore::getPathToImageResource):
     16        * platform/gtk/FileSystemGtk.cpp:
     17        (WebCore::sharedResourcesPath):
     18        (WebCore):
     19
    1202012-02-19  James Robinson  <jamesr@chromium.org>
    221
  • trunk/Source/WebCore/platform/FileSystem.h

    r107101 r108206  
    199199String filenameForDisplay(const String&);
    200200CString applicationDirectoryPath();
     201CString sharedResourcesPath();
    201202uint64_t getVolumeFreeSizeForPath(const char*);
    202203#endif
  • trunk/Source/WebCore/platform/audio/gtk/AudioBusGtk.cpp

    r101644 r108206  
    2424
    2525#include "AudioFileReader.h"
     26#include "FileSystem.h"
    2627#include "GOwnPtr.h"
    2728
     
    3435{
    3536    GOwnPtr<gchar> filename(g_strdup_printf("%s.wav", name));
    36     GOwnPtr<gchar> absoluteFilename(g_build_filename(DATA_DIR, "webkitgtk-"WEBKITGTK_API_VERSION_STRING, "resources", "audio", filename.get(), NULL));
     37    GOwnPtr<gchar> absoluteFilename(g_build_filename(sharedResourcesPath().data(), "resources", "audio", filename.get(), NULL));
    3738
    3839    GFile* file = g_file_new_for_path(filename.get());
  • trunk/Source/WebCore/platform/graphics/gtk/ImageGtk.cpp

    r105686 r108206  
    2727
    2828#include "BitmapImage.h"
     29#include "FileSystem.h"
    2930#include "GdkCairoUtilities.h"
    3031#include "GOwnPtrGtk.h"
     
    3435#include <gtk/gtk.h>
    3536
    36 #if PLATFORM(WIN)
    37 #include <mbstring.h>
    38 #include <shlobj.h>
    39 
    40 static HMODULE hmodule;
    41 
    42 extern "C" {
    43 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
    44 {
    45     if (fdwReason == DLL_PROCESS_ATTACH)
    46         hmodule = hinstDLL;
    47     return TRUE;
    48 }
    49 }
    50 
    51 static char* getPathToImageResource(char* resource)
    52 {
    53     static char* dataDirectory = 0;
    54     if (!dataDirectory) {
    55         dataDirectory = new char[PATH_MAX];
    56         if (!GetModuleFileName(hmodule, static_cast<CHAR*>(dataDirectory), sizeof(dataDirectory) - 10))
    57             dataDirectory = DATA_DIR;
    58 
    59         // FIXME: This is pretty ugly. Ideally we should be using Windows API
    60         // functions or GLib methods to calculate paths.
    61         unsigned char *p;
    62         p = _mbsrchr(static_cast<const unsigned char *>(dataDirectory), '\\');
    63         *p = '\0';
    64         p = _mbsrchr(static_cast<const unsigned char *>(dataDirectory), '\\');
    65         if (p) {
    66             if (!stricmp((const char *) (p+1), "bin"))
    67                 *p = '\0';
    68         }
    69         strcat(dataDirectory, "\\share\\webkitgtk-"WEBKITGTK_API_VERSION_STRING"\\images\\");
    70     }
    71 
    72     char* imageResourcePath = new char[PATH_MAX];
    73     strcat(imageResourcePath, dataDirectory);
    74     strcat(imageResourcePath, resource);
    75 
    76     return imageResourcePath;
    77 }
    78 
    79 #else
     37namespace WebCore {
    8038
    8139static char* getPathToImageResource(char* resource)
     
    8442        return g_build_filename(g_getenv("WEBKIT_TOP_LEVEL"), "Source", "WebCore", "Resources", resource, NULL);
    8543
    86     return g_build_filename(DATA_DIR, "webkitgtk-"WEBKITGTK_API_VERSION_STRING, "images", resource, NULL);
     44    return g_build_filename(sharedResourcesPath().data(), "images", resource, NULL);
    8745}
    88 
    89 #endif
    90 
    91 namespace WebCore {
    9246
    9347static CString getThemeIconFileName(const char* name, int size)
  • trunk/Source/WebCore/platform/gtk/FileSystemGtk.cpp

    r101710 r108206  
    191191}
    192192
     193CString sharedResourcesPath()
     194{
     195    static CString cachedPath;
     196    if (!cachedPath.isNull())
     197        return cachedPath;
     198
     199#if OS(WINDOWS)
     200    HMODULE hmodule = 0;
     201    GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, reinterpret_cast<char*>(sharedResourcesPath), &hmodule);
     202
     203    GOwnPtr<gchar> runtimeDir(g_win32_get_package_installation_directory_of_module(hmodule));
     204    GOwnPtr<gchar> dataPath(g_build_filename(runtimeDir.get(), "share", "webkitgtk-"WEBKITGTK_API_VERSION_STRING, NULL));
     205#else
     206    GOwnPtr<gchar> dataPath(g_build_filename(DATA_DIR, "webkitgtk-"WEBKITGTK_API_VERSION_STRING, NULL));
     207#endif
     208
     209    cachedPath = dataPath.get();
     210    return cachedPath;
     211}
     212
    193213uint64_t getVolumeFreeSizeForPath(const char* path)
    194214{
  • trunk/Source/WebKit/gtk/ChangeLog

    r108193 r108206  
     12012-02-19  Paweł Forysiuk  <tuxator@o2.pl>
     2        [GTK] Can't find webinspector and error page redirection on Windows
     3        https://bugs.webkit.org/show_bug.cgi?id=51616
     4
     5        Use an abstraction for finding shared resources on Windows.
     6
     7        Reviewed by Martin Robinson.
     8
     9        * WebCoreSupport/FrameLoaderClientGtk.cpp:
     10        (WebKit::FrameLoaderClient::dispatchDidFailLoad):
     11        * WebCoreSupport/InspectorClientGtk.cpp:
     12        (WebKit::InspectorClient::inspectorFilesPath):
     13
    1142012-02-19  Gustavo Noronha Silva  <gns@gnome.org>
    215
  • trunk/Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp

    r107249 r108206  
    3434#include "DocumentLoaderGtk.h"
    3535#include "ErrorsGtk.h"
     36#include "FileSystem.h"
    3637#include "FormState.h"
    3738#include "FrameLoader.h"
     
    11061107    String content;
    11071108    gchar* fileContent = 0;
    1108     gchar* errorURI = g_filename_to_uri(DATA_DIR"/webkit-1.0/resources/error.html", NULL, NULL);
     1109    GOwnPtr<gchar> errorPath(g_build_filename(sharedResourcesPath().data(), "resources", "error.html", NULL));
     1110    gchar* errorURI = g_filename_to_uri(errorPath.get(), 0, 0);
     1111
    11091112    GFile* errorFile = g_file_new_for_uri(errorURI);
    11101113    g_free(errorURI);
  • trunk/Source/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp

    r108190 r108206  
    2121#include "InspectorClientGtk.h"
    2222
     23#include "FileSystem.h"
    2324#include "Frame.h"
    2425#include "InspectorController.h"
     
    164165        m_inspectorFilesPath.set(g_strdup(environmentPath));
    165166    else
    166         m_inspectorFilesPath.set(g_build_filename(DATA_DIR, "webkitgtk-"WEBKITGTK_API_VERSION_STRING, "webinspector", NULL));
     167        m_inspectorFilesPath.set(g_build_filename(sharedResourcesPath().data(), "webinspector", NULL));
    167168
    168169    return m_inspectorFilesPath.get();
Note: See TracChangeset for help on using the changeset viewer.