Changeset 71145 in webkit
- Timestamp:
- Nov 2, 2010 12:07:32 PM (13 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r71144 r71145 1 2010-11-02 Patrick Gansterer <paroga@webkit.org> 2 3 Reviewed by Adam Roben. 4 5 Cleanup createGlobalImageFileDescriptor in ClipboardWin 6 https://bugs.webkit.org/show_bug.cgi?id=48189 7 8 * platform/win/ClipboardWin.cpp: 9 (WebCore::ClipboardWin::writeURL): 10 1 11 2010-11-02 Pavel Feldman <pfeldman@chromium.org> 2 12 -
trunk/WebCore/platform/win/ClipboardWin.cpp
r70914 r71145 57 57 #include <wtf/RefPtr.h> 58 58 #include <wtf/text/CString.h> 59 #include <wtf/text/StringConcatenate.h> 59 #include <wtf/text/StringConcatenate.h> 60 60 #include <wtf/text/StringHash.h> 61 61 … … 160 160 result += String(static_cast<UChar*>(extension)); 161 161 return result; 162 }163 164 static HGLOBAL createGlobalURLContent(const CString& content)165 {166 HRESULT hr = S_OK;167 HGLOBAL memObj = 0;168 169 char* fileContents;170 171 memObj = GlobalAlloc(GPTR, content.length());172 if (!memObj)173 return 0;174 175 fileContents = (PSTR)GlobalLock(memObj);176 CopyMemory(fileContents, content.data(), content.length());177 178 GlobalUnlock(memObj);179 180 return memObj;181 162 } 182 163 … … 259 240 } 260 241 261 static HGLOBAL createGlobalUrlFileDescriptor(const String& url, const String& title, const CString& content)262 {263 HRESULT hr = S_OK;264 HGLOBAL memObj = 0;265 String fsPath;266 memObj = GlobalAlloc(GPTR, sizeof(FILEGROUPDESCRIPTOR));267 if (!memObj)268 return 0;269 270 FILEGROUPDESCRIPTOR* fgd = (FILEGROUPDESCRIPTOR*)GlobalLock(memObj);271 memset(fgd, 0, sizeof(FILEGROUPDESCRIPTOR));272 fgd->cItems = 1;273 fgd->fgd[0].dwFlags = FD_FILESIZE;274 fgd->fgd[0].nFileSizeLow = content.length();275 fsPath = filesystemPathFromUrlOrTitle(url, title, L".URL", true);276 277 if (fsPath.length() <= 0) {278 GlobalUnlock(memObj);279 GlobalFree(memObj);280 return 0;281 }282 283 int maxSize = min(fsPath.length(), ARRAYSIZE(fgd->fgd[0].cFileName));284 CopyMemory(fgd->fgd[0].cFileName, (LPCWSTR)fsPath.characters(), maxSize * sizeof(UChar));285 GlobalUnlock(memObj);286 287 return memObj;288 }289 290 291 242 static HGLOBAL createGlobalImageFileDescriptor(const String& url, const String& title, CachedImage* image) 292 243 { … … 726 677 ASSERT(url.containsOnlyASCII()); // KURL::string() is URL encoded. 727 678 679 String fsPath = filesystemPathFromUrlOrTitle(url, titleStr, L".URL", true); 728 680 CString content = makeString("[InternetShortcut]\r\nURL=", url, "\r\n").ascii(); 729 681 730 HGLOBAL urlFileDescriptor = createGlobalUrlFileDescriptor(url, titleStr, content); 682 if (fsPath.length() <= 0) 683 return; 684 685 HGLOBAL urlFileDescriptor = GlobalAlloc(GPTR, sizeof(FILEGROUPDESCRIPTOR)); 731 686 if (!urlFileDescriptor) 732 687 return; 733 HGLOBAL urlFileContent = createGlobalURLContent(content); 688 689 HGLOBAL urlFileContent = GlobalAlloc(GPTR, content.length()); 734 690 if (!urlFileContent) { 735 691 GlobalFree(urlFileDescriptor); 736 692 return; 737 693 } 694 695 FILEGROUPDESCRIPTOR* fgd = static_cast<FILEGROUPDESCRIPTOR*>(GlobalLock(urlFileDescriptor)); 696 ZeroMemory(fgd, sizeof(FILEGROUPDESCRIPTOR)); 697 fgd->cItems = 1; 698 fgd->fgd[0].dwFlags = FD_FILESIZE; 699 fgd->fgd[0].nFileSizeLow = content.length(); 700 701 unsigned maxSize = min(fsPath.length(), ARRAYSIZE(fgd->fgd[0].cFileName)); 702 CopyMemory(fgd->fgd[0].cFileName, fsPath.characters(), maxSize * sizeof(UChar)); 703 GlobalUnlock(urlFileDescriptor); 704 705 char* fileContents = static_cast<char*>(GlobalLock(urlFileContent)); 706 CopyMemory(fileContents, content.data(), content.length()); 707 GlobalUnlock(urlFileContent); 708 738 709 writeFileToDataObject(m_writableDataObject.get(), urlFileDescriptor, urlFileContent, 0); 739 710 }
Note: See TracChangeset
for help on using the changeset viewer.