⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 286752 in webkit


Ignore:
Timestamp:
Dec 8, 2021, 4:32:05 PM (5 years ago)
Author:
don.olmstead@sony.com
Message:

[Win] Remove CF when using Windows clipboard
https://bugs.webkit.org/show_bug.cgi?id=194876

Reviewed by Brent Fulgham.

Remove any CF code from ClipboardUtilitiesWin and replace it with WTF code. The
urlFromPath function is deleted since it is no longer relevant.

  • platform/win/ClipboardUtilitiesWin.cpp:

(WebCore::getURL):
(WebCore::urlFromPath): Deleted.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r286743 r286752  
     12021-12-08  Don Olmstead  <don.olmstead@sony.com>
     2
     3        [Win] Remove CF when using Windows clipboard
     4        https://bugs.webkit.org/show_bug.cgi?id=194876
     5
     6        Reviewed by Brent Fulgham.
     7
     8        Remove any CF code from ClipboardUtilitiesWin and replace it with WTF code. The
     9        urlFromPath function is deleted since it is no longer relevant.
     10
     11        * platform/win/ClipboardUtilitiesWin.cpp:
     12        (WebCore::getURL):
     13        (WebCore::urlFromPath): Deleted.
     14
    1152021-12-08  Jer Noble  <jer.noble@apple.com>
    216
  • trunk/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp

    r286708 r286752  
    4040#include <wtf/text/win/WCharStringExtras.h>
    4141
    42 #if USE(CF)
    43 #include <CoreFoundation/CoreFoundation.h>
    44 #include <wtf/RetainPtr.h>
    45 #endif
    46 
    4742namespace WebCore {
    4843
     
    5247    return &urlFormat;
    5348}
    54 
    55 #if USE(CF)
    56 
    57 static bool urlFromPath(CFStringRef path, String& url)
    58 {
    59     if (!path)
    60         return false;
    61 
    62     RetainPtr<CFURLRef> cfURL = adoptCF(CFURLCreateWithFileSystemPath(0, path, kCFURLWindowsPathStyle, false));
    63     if (!cfURL)
    64         return false;
    65 
    66     url = CFURLGetString(cfURL.get());
    67 
    68     // Work around <rdar://problem/6708300>, where CFURLCreateWithFileSystemPath makes URLs with "localhost".
    69     if (url.startsWith("file://localhost/"))
    70         url.remove(7, 9);
    71 
    72     return true;
    73 }
    74 #endif
    7549
    7650static bool getDataMapItem(const DragDataMap* dataObject, FORMATETC* format, String& item)
     
    487461        ReleaseStgMedium(&store);
    488462    }
    489 #if USE(CF)
    490463    else if (filenamePolicy == DragData::ConvertFilenames) {
    491464        if (SUCCEEDED(dataObject->GetData(filenameWFormat(), &store))) {
     
    493466            wchar_t* data = static_cast<wchar_t*>(GlobalLock(store.hGlobal));
    494467            if (data && data[0] && (PathFileExists(data) || PathIsUNC(data))) {
    495                 RetainPtr<CFStringRef> pathAsCFString = adoptCF(CFStringCreateWithCharacters(kCFAllocatorDefault, (const UniChar*)data, wcslen(data)));
    496                 if (urlFromPath(pathAsCFString.get(), url) && title)
     468                url = URL::fileURLWithFileSystemPath(String(data)).fileSystemPath();
     469                if (title)
    497470                    *title = url;
    498471            }
     
    503476            char* data = static_cast<char*>(GlobalLock(store.hGlobal));
    504477            if (data && data[0] && (PathFileExistsA(data) || PathIsUNCA(data))) {
    505                 RetainPtr<CFStringRef> pathAsCFString = adoptCF(CFStringCreateWithCString(kCFAllocatorDefault, data, kCFStringEncodingASCII));
    506                 if (urlFromPath(pathAsCFString.get(), url) && title)
     478                url = URL::fileURLWithFileSystemPath(String(data)).fileSystemPath();
     479                if (title)
    507480                    *title = url;
    508481            }
     
    511484        }
    512485    }
    513 #endif
    514486    return url;
    515487}
     
    525497    if (getDataMapItem(data, urlFormat(), url))
    526498        return extractURL(url, title);
    527 #if USE(CF)
    528499    if (filenamePolicy != DragData::ConvertFilenames)
    529500        return url;
     
    536507    if (stringData.isEmpty() || (!PathFileExists(wcharData) && !PathIsUNC(wcharData)))
    537508        return url;
    538     RetainPtr<CFStringRef> pathAsCFString = adoptCF(CFStringCreateWithCharacters(kCFAllocatorDefault, (const UniChar *)wcharData, wcslen(wcharData)));
    539     if (urlFromPath(pathAsCFString.get(), url) && title)
     509
     510    url = URL::fileURLWithFileSystemPath(stringData).fileSystemPath();
     511    if (title)
    540512        *title = url;
    541 #endif
     513
    542514    return url;
    543515}
Note: See TracChangeset for help on using the changeset viewer.