Changeset 70914 in webkit
- Timestamp:
- Oct 29, 2010 12:13:22 PM (13 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r70912 r70914 1 2010-10-29 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::createGlobalURLContent): 10 (WebCore::createGlobalUrlFileDescriptor): 11 (WebCore::ClipboardWin::writeURL): 12 1 13 2010-10-29 Dmitry Titov <dimich@chromium.org> 2 14 -
trunk/WebCore/platform/win/ClipboardWin.cpp
r68854 r70914 57 57 #include <wtf/RefPtr.h> 58 58 #include <wtf/text/CString.h> 59 #include <wtf/text/StringConcatenate.h> 59 60 #include <wtf/text/StringHash.h> 60 61 … … 64 65 65 66 using namespace HTMLNames; 66 67 // format string for68 static const char szShellDotUrlTemplate[] = "[InternetShortcut]\r\nURL=%s\r\n";69 67 70 68 // We provide the IE clipboard types (URL and Text), and the clipboard types specified in the WHATWG Web Applications 1.0 draft … … 164 162 } 165 163 166 static HGLOBAL createGlobalURLContent(const String& url, int estimatedFileSize)164 static HGLOBAL createGlobalURLContent(const CString& content) 167 165 { 168 166 HRESULT hr = S_OK; … … 170 168 171 169 char* fileContents; 172 char ansiUrl[INTERNET_MAX_URL_LENGTH + 1]; 173 // Used to generate the buffer. This is null terminated whereas the fileContents won't be. 174 char contentGenerationBuffer[INTERNET_MAX_URL_LENGTH + ARRAYSIZE(szShellDotUrlTemplate) + 1]; 175 176 if (estimatedFileSize > 0 && estimatedFileSize > ARRAYSIZE(contentGenerationBuffer)) 177 return 0; 178 179 int ansiUrlSize = ::WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)url.characters(), url.length(), ansiUrl, ARRAYSIZE(ansiUrl) - 1, 0, 0); 180 if (!ansiUrlSize) 181 return 0; 182 183 ansiUrl[ansiUrlSize] = 0; 184 185 int fileSize = (int) (ansiUrlSize+strlen(szShellDotUrlTemplate)-2); // -2 to remove the %s 186 ASSERT(estimatedFileSize < 0 || fileSize == estimatedFileSize); 187 188 memObj = GlobalAlloc(GPTR, fileSize); 170 171 memObj = GlobalAlloc(GPTR, content.length()); 189 172 if (!memObj) 190 173 return 0; 191 174 192 175 fileContents = (PSTR)GlobalLock(memObj); 193 194 sprintf_s(contentGenerationBuffer, ARRAYSIZE(contentGenerationBuffer), szShellDotUrlTemplate, ansiUrl); 195 CopyMemory(fileContents, contentGenerationBuffer, fileSize); 176 CopyMemory(fileContents, content.data(), content.length()); 196 177 197 178 GlobalUnlock(memObj); … … 278 259 } 279 260 280 static HGLOBAL createGlobalUrlFileDescriptor(const String& url, const String& title, int& /*out*/ estimatedSize)261 static HGLOBAL createGlobalUrlFileDescriptor(const String& url, const String& title, const CString& content) 281 262 { 282 263 HRESULT hr = S_OK; … … 291 272 fgd->cItems = 1; 292 273 fgd->fgd[0].dwFlags = FD_FILESIZE; 293 int fileSize = ::WideCharToMultiByte(CP_ACP, 0, url.characters(), url.length(), 0, 0, 0, 0); 294 fileSize += strlen(szShellDotUrlTemplate) - 2; // -2 is for getting rid of %s in the template string 295 fgd->fgd[0].nFileSizeLow = fileSize; 296 estimatedSize = fileSize; 274 fgd->fgd[0].nFileSizeLow = content.length(); 297 275 fsPath = filesystemPathFromUrlOrTitle(url, title, L".URL", true); 298 276 … … 745 723 WebCore::writeURL(m_writableDataObject.get(), kurl, titleStr, true, true); 746 724 747 int estimatedSize = 0;748 725 String url = kurl.string(); 749 750 HGLOBAL urlFileDescriptor = createGlobalUrlFileDescriptor(url, titleStr, estimatedSize); 726 ASSERT(url.containsOnlyASCII()); // KURL::string() is URL encoded. 727 728 CString content = makeString("[InternetShortcut]\r\nURL=", url, "\r\n").ascii(); 729 730 HGLOBAL urlFileDescriptor = createGlobalUrlFileDescriptor(url, titleStr, content); 751 731 if (!urlFileDescriptor) 752 732 return; 753 HGLOBAL urlFileContent = createGlobalURLContent( url, estimatedSize);733 HGLOBAL urlFileContent = createGlobalURLContent(content); 754 734 if (!urlFileContent) { 755 735 GlobalFree(urlFileDescriptor);
Note: See TracChangeset
for help on using the changeset viewer.