Changeset 64062 in webkit


Ignore:
Timestamp:
Jul 26, 2010 12:30:38 PM (14 years ago)
Author:
commit-queue@webkit.org
Message:

2010-07-26 Patrick Gansterer <paroga@paroga.com>

Reviewed by Kent Tamura.

[WINCE] Port ClipboardUtilities to WinCE
https://bugs.webkit.org/show_bug.cgi?id=42929

Make ClipboardUtilitiesWin more portable and remove the global namespace prefix
from GlobalLock/GlobalUnlock, since they are only macros on WinCE.

  • platform/win/ClipboardUtilitiesWin.cpp: (WebCore::urlFromPath): (WebCore::getWebLocData): (WebCore::createGlobalData): (WebCore::getURL): (WebCore::getPlainText): (WebCore::fragmentFromHTML):
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r64060 r64062  
     12010-07-26  Patrick Gansterer  <paroga@paroga.com>
     2
     3        Reviewed by Kent Tamura.
     4
     5        [WINCE] Port ClipboardUtilities to WinCE
     6        https://bugs.webkit.org/show_bug.cgi?id=42929
     7
     8        Make ClipboardUtilitiesWin more portable and remove the global namespace prefix
     9        from GlobalLock/GlobalUnlock, since they are only macros on WinCE.
     10
     11        * platform/win/ClipboardUtilitiesWin.cpp:
     12        (WebCore::urlFromPath):
     13        (WebCore::getWebLocData):
     14        (WebCore::createGlobalData):
     15        (WebCore::getURL):
     16        (WebCore::getPlainText):
     17        (WebCore::fragmentFromHTML):
     18
    1192010-07-26  Patrick Gansterer  <paroga@paroga.com>
    220
  • trunk/WebCore/platform/win/ClipboardUtilitiesWin.cpp

    r63734 r64062  
    3232#include "TextEncoding.h"
    3333#include "markup.h"
    34 #include <CoreFoundation/CoreFoundation.h>
    3534#include <shlwapi.h>
    3635#include <wininet.h> // for INTERNET_MAX_URL_LENGTH
     36#include <wtf/text/CString.h>
     37
     38#if PLATFORM(CF)
     39#include <CoreFoundation/CoreFoundation.h>
    3740#include <wtf/RetainPtr.h>
    38 #include <wtf/text/CString.h>
     41#endif
    3942
    4043namespace WebCore {
    4144
     45#if PLATFORM(CF)
    4246FORMATETC* cfHDropFormat()
    4347{
     
    4650}
    4751
     52static bool urlFromPath(CFStringRef path, String& url)
     53{
     54    if (!path)
     55        return false;
     56
     57    RetainPtr<CFURLRef> cfURL(AdoptCF, CFURLCreateWithFileSystemPath(0, path, kCFURLWindowsPathStyle, false));
     58    if (!cfURL)
     59        return false;
     60
     61    url = CFURLGetString(cfURL.get());
     62
     63    // Work around <rdar://problem/6708300>, where CFURLCreateWithFileSystemPath makes URLs with "localhost".
     64    if (url.startsWith("file://localhost/"))
     65        url.remove(7, 9);
     66
     67    return true;
     68}
     69#endif
     70
    4871static bool getWebLocData(IDataObject* dataObject, String& url, String* title)
    4972{
    5073    bool succeeded = false;
     74#if PLATFORM(CF)
    5175    WCHAR filename[MAX_PATH];
    5276    WCHAR urlBuffer[INTERNET_MAX_URL_LENGTH];
     
    5680        return false;
    5781
    58     HDROP hdrop = (HDROP)GlobalLock(medium.hGlobal);
    59    
     82    HDROP hdrop = static_cast<HDROP>(GlobalLock(medium.hGlobal));
     83
    6084    if (!hdrop)
    6185        return false;
     
    82106    DragFinish(hdrop);
    83107    GlobalUnlock(medium.hGlobal);
     108#endif
    84109    return succeeded;
    85110}
     
    114139
    115140    if (cbData) {
    116         PWSTR buffer = (PWSTR)::GlobalLock(cbData);
    117         swprintf_s(buffer, size, L"%s\n%s", mutableURL.charactersWithNullTermination(), mutableTitle.charactersWithNullTermination());
    118         ::GlobalUnlock(cbData);
     141        PWSTR buffer = static_cast<PWSTR>(GlobalLock(cbData));
     142        _snwprintf(buffer, size, L"%s\n%s", mutableURL.charactersWithNullTermination(), mutableTitle.charactersWithNullTermination());
     143        GlobalUnlock(cbData);
    119144    }
    120145    return cbData;
     
    126151    if (!globalData)
    127152        return 0;
    128     UChar* buffer = static_cast<UChar*>(::GlobalLock(globalData));
     153    UChar* buffer = static_cast<UChar*>(GlobalLock(globalData));
    129154    memcpy(buffer, str.characters(), str.length() * sizeof(UChar));
    130155    buffer[str.length()] = 0;
    131     ::GlobalUnlock(globalData);
     156    GlobalUnlock(globalData);
    132157    return globalData;
    133158}
     
    138163    if (!globalData)
    139164        return 0;
    140     char* buffer = static_cast<char*>(::GlobalLock(globalData));
     165    char* buffer = static_cast<char*>(GlobalLock(globalData));
    141166    memcpy(buffer, vector.data(), vector.size());
    142167    buffer[vector.size()] = 0;
    143     ::GlobalUnlock(globalData);
     168    GlobalUnlock(globalData);
    144169    return globalData;
    145170}
     
    272297}
    273298
    274 static bool urlFromPath(CFStringRef path, String& url)
    275 {
    276     if (!path)
    277         return false;
    278 
    279     RetainPtr<CFURLRef> cfURL(AdoptCF, CFURLCreateWithFileSystemPath(0, path, kCFURLWindowsPathStyle, false));
    280     if (!cfURL)
    281         return false;
    282 
    283     url = CFURLGetString(cfURL.get());
    284 
    285     // Work around <rdar://problem/6708300>, where CFURLCreateWithFileSystemPath makes URLs with "localhost".
    286     if (url.startsWith("file://localhost/"))
    287         url.remove(7, 9);
    288 
    289     return true;
    290 }
    291 
    292299String getURL(IDataObject* dataObject, DragData::FilenameConversionPolicy filenamePolicy, bool& success, String* title)
    293300{
     
    299306    else if (SUCCEEDED(dataObject->GetData(urlWFormat(), &store))) {
    300307        // URL using Unicode
    301         UChar* data = (UChar*)GlobalLock(store.hGlobal);
     308        UChar* data = static_cast<UChar*>(GlobalLock(store.hGlobal));
    302309        url = extractURL(String(data), title);
    303         GlobalUnlock(store.hGlobal);     
     310        GlobalUnlock(store.hGlobal);
    304311        ReleaseStgMedium(&store);
    305312        success = true;
    306313    } else if (SUCCEEDED(dataObject->GetData(urlFormat(), &store))) {
    307314        // URL using ASCII
    308         char* data = (char*)GlobalLock(store.hGlobal);
     315        char* data = static_cast<char*>(GlobalLock(store.hGlobal));
    309316        url = extractURL(String(data), title);
    310         GlobalUnlock(store.hGlobal);     
     317        GlobalUnlock(store.hGlobal);
    311318        ReleaseStgMedium(&store);
    312319        success = true;
    313     } else if (filenamePolicy == DragData::ConvertFilenames) {
     320    }
     321#if PLATFORM(CF)
     322    else if (filenamePolicy == DragData::ConvertFilenames) {
    314323        if (SUCCEEDED(dataObject->GetData(filenameWFormat(), &store))) {
    315324            // file using unicode
    316             wchar_t* data = (wchar_t*)GlobalLock(store.hGlobal);
     325            wchar_t* data = static_cast<wchar_t*>(GlobalLock(store.hGlobal));
    317326            if (data && data[0] && (PathFileExists(data) || PathIsUNC(data))) {
    318327                RetainPtr<CFStringRef> pathAsCFString(AdoptCF, CFStringCreateWithCharacters(kCFAllocatorDefault, (const UniChar*)data, wcslen(data)));
     
    327336        } else if (SUCCEEDED(dataObject->GetData(filenameFormat(), &store))) {
    328337            // filename using ascii
    329             char* data = (char*)GlobalLock(store.hGlobal);
     338            char* data = static_cast<char*>(GlobalLock(store.hGlobal));
    330339            if (data && data[0] && (PathFileExistsA(data) || PathIsUNCA(data))) {
    331340                RetainPtr<CFStringRef> pathAsCFString(AdoptCF, CFStringCreateWithCString(kCFAllocatorDefault, data, kCFStringEncodingASCII));
     
    340349        }
    341350    }
     351#endif
    342352    return url;
    343353}
     
    350360    if (SUCCEEDED(dataObject->GetData(plainTextWFormat(), &store))) {
    351361        // Unicode text
    352         UChar* data = (UChar*)GlobalLock(store.hGlobal);
     362        UChar* data = static_cast<UChar*>(GlobalLock(store.hGlobal));
    353363        text = String(data);
    354364        GlobalUnlock(store.hGlobal);
     
    357367    } else if (SUCCEEDED(dataObject->GetData(plainTextFormat(), &store))) {
    358368        // ASCII text
    359         char* data = (char*)GlobalLock(store.hGlobal);
     369        char* data = static_cast<char*>(GlobalLock(store.hGlobal));
    360370        text = String(data);
    361371        GlobalUnlock(store.hGlobal);
     
    436446    if (SUCCEEDED(data->GetData(htmlFormat(), &store))) {
    437447        // MS HTML Format parsing
    438         char* data = (char*)GlobalLock(store.hGlobal);
     448        char* data = static_cast<char*>(GlobalLock(store.hGlobal));
    439449        SIZE_T dataSize = ::GlobalSize(store.hGlobal);
    440         String cfhtml(UTF8Encoding().decode(data, dataSize));         
     450        String cfhtml(UTF8Encoding().decode(data, dataSize));
    441451        GlobalUnlock(store.hGlobal);
    442452        ReleaseStgMedium(&store);
Note: See TracChangeset for help on using the changeset viewer.