summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/win
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/platform/win')
-rw-r--r--Source/WebCore/platform/win/BString.cpp11
-rw-r--r--Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp277
-rw-r--r--Source/WebCore/platform/win/ClipboardUtilitiesWin.h11
-rw-r--r--Source/WebCore/platform/win/ClipboardWin.cpp128
-rw-r--r--Source/WebCore/platform/win/ClipboardWin.h7
-rw-r--r--Source/WebCore/platform/win/ContextMenuWin.cpp3
-rw-r--r--Source/WebCore/platform/win/CursorWin.cpp4
-rw-r--r--Source/WebCore/platform/win/DragDataWin.cpp145
-rw-r--r--Source/WebCore/platform/win/DragImageWin.cpp147
-rw-r--r--Source/WebCore/platform/win/FileChooserWin.cpp3
-rw-r--r--Source/WebCore/platform/win/LoggingWin.cpp2
-rw-r--r--Source/WebCore/platform/win/MIMETypeRegistryWin.cpp4
-rw-r--r--Source/WebCore/platform/win/PopupMenuWin.cpp19
-rw-r--r--Source/WebCore/platform/win/PopupMenuWin.h2
-rw-r--r--Source/WebCore/platform/win/SystemTimeWin.cpp11
-rw-r--r--Source/WebCore/platform/win/WCDataObject.cpp14
-rw-r--r--Source/WebCore/platform/win/WCDataObject.h6
17 files changed, 666 insertions, 128 deletions
diff --git a/Source/WebCore/platform/win/BString.cpp b/Source/WebCore/platform/win/BString.cpp
index 4d6d11e..6622f96 100644
--- a/Source/WebCore/platform/win/BString.cpp
+++ b/Source/WebCore/platform/win/BString.cpp
@@ -28,9 +28,8 @@
#include "KURL.h"
#include "PlatformString.h"
-#include <wtf/text/AtomicString.h>
-#include <tchar.h>
#include <windows.h>
+#include <wtf/text/AtomicString.h>
#if PLATFORM(CF)
#include <CoreFoundation/CoreFoundation.h>
@@ -102,7 +101,7 @@ BString::BString(CFStringRef cfstr)
const UniChar* uniChars = CFStringGetCharactersPtr(cfstr);
if (uniChars) {
- m_bstr = SysAllocStringLen((LPCTSTR)uniChars, CFStringGetLength(cfstr));
+ m_bstr = SysAllocStringLen((LPCWSTR)uniChars, CFStringGetLength(cfstr));
return;
}
@@ -158,7 +157,7 @@ bool operator ==(const BString& a, const BString& b)
return true;
if (!(BSTR)a || !(BSTR)b)
return false;
- return !_tcscmp((BSTR)a, (BSTR)b);
+ return !wcscmp((BSTR)a, (BSTR)b);
}
bool operator !=(const BString& a, const BString& b)
@@ -174,7 +173,7 @@ bool operator ==(const BString& a, BSTR b)
return true;
if (!(BSTR)a || !b)
return false;
- return !_tcscmp((BSTR)a, b);
+ return !wcscmp((BSTR)a, b);
}
bool operator !=(const BString& a, BSTR b)
@@ -190,7 +189,7 @@ bool operator ==(BSTR a, const BString& b)
return true;
if (!a || !(BSTR)b)
return false;
- return !_tcscmp(a, (BSTR)b);
+ return !wcscmp(a, (BSTR)b);
}
bool operator !=(BSTR a, const BString& b)
diff --git a/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp b/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp
index eb1e659..77b95ef 100644
--- a/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp
+++ b/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp
@@ -31,6 +31,7 @@
#include "PlatformString.h"
#include "TextEncoding.h"
#include "markup.h"
+#include <shlobj.h>
#include <shlwapi.h>
#include <wininet.h> // for INTERNET_MAX_URL_LENGTH
#include <wtf/StringExtras.h>
@@ -70,6 +71,15 @@ static bool urlFromPath(CFStringRef path, String& url)
}
#endif
+static bool getDataMapItem(const DragDataMap* dataObject, FORMATETC* format, String& item)
+{
+ DragDataMap::const_iterator found = dataObject->find(format->cfFormat);
+ if (found == dataObject->end())
+ return false;
+ item = found->second[0];
+ return true;
+}
+
static bool getWebLocData(IDataObject* dataObject, String& url, String* title)
{
bool succeeded = false;
@@ -111,6 +121,34 @@ exit:
return succeeded;
}
+static bool getWebLocData(const DragDataMap* dataObject, String& url, String* title)
+{
+#if PLATFORM(CF)
+ WCHAR filename[MAX_PATH];
+ WCHAR urlBuffer[INTERNET_MAX_URL_LENGTH];
+
+ if (!dataObject->contains(cfHDropFormat()->cfFormat))
+ return false;
+
+ wcscpy(filename, dataObject->get(cfHDropFormat()->cfFormat)[0].characters());
+ if (_wcsicmp(PathFindExtensionW(filename), L".url"))
+ return false;
+
+ if (!GetPrivateProfileStringW(L"InternetShortcut", L"url", 0, urlBuffer, WTF_ARRAY_LENGTH(urlBuffer), filename))
+ return false;
+
+ if (title) {
+ PathRemoveExtension(filename);
+ *title = filename;
+ }
+
+ url = urlBuffer;
+ return true;
+#else
+ return false;
+#endif
+}
+
static String extractURL(const String &inURL, String* title)
{
String url = inURL;
@@ -386,6 +424,33 @@ String getURL(IDataObject* dataObject, DragData::FilenameConversionPolicy filena
return url;
}
+String getURL(const DragDataMap* data, DragData::FilenameConversionPolicy filenamePolicy, String* title)
+{
+ String url;
+
+ if (getWebLocData(data, url, title))
+ return url;
+ if (getDataMapItem(data, urlWFormat(), url))
+ return extractURL(url, title);
+ if (getDataMapItem(data, urlFormat(), url))
+ return extractURL(url, title);
+#if PLATFORM(CF)
+ if (filenamePolicy != DragData::ConvertFilenames)
+ return url;
+
+ String stringData;
+ if (!getDataMapItem(data, filenameWFormat(), stringData))
+ getDataMapItem(data, filenameFormat(), stringData);
+
+ if (stringData.isEmpty() || (!PathFileExists(stringData.charactersWithNullTermination()) && !PathIsUNC(stringData.charactersWithNullTermination())))
+ return url;
+ RetainPtr<CFStringRef> pathAsCFString(AdoptCF, CFStringCreateWithCharacters(kCFAllocatorDefault, (const UniChar *)stringData.charactersWithNullTermination(), stringData.length()));
+ if (urlFromPath(pathAsCFString.get(), url) && title)
+ *title = url;
+#endif
+ return url;
+}
+
String getPlainText(IDataObject* dataObject, bool& success)
{
STGMEDIUM store;
@@ -415,6 +480,17 @@ String getPlainText(IDataObject* dataObject, bool& success)
return text;
}
+String getPlainText(const DragDataMap* data)
+{
+ String text;
+
+ if (getDataMapItem(data, plainTextWFormat(), text))
+ return text;
+ if (getDataMapItem(data, plainTextFormat(), text))
+ return text;
+ return getURL(data, DragData::DoNotConvertFilenames);
+}
+
String getTextHTML(IDataObject* data, bool& success)
{
STGMEDIUM store;
@@ -430,6 +506,13 @@ String getTextHTML(IDataObject* data, bool& success)
return html;
}
+String getTextHTML(const DragDataMap* data)
+{
+ String text;
+ getDataMapItem(data, texthtmlFormat(), text);
+ return text;
+}
+
String getCFHTML(IDataObject* data, bool& success)
{
String cfhtml = getFullCFHTML(data, success);
@@ -438,18 +521,37 @@ String getCFHTML(IDataObject* data, bool& success)
return String();
}
+String getCFHTML(const DragDataMap* dataMap)
+{
+ String cfhtml;
+ getDataMapItem(dataMap, htmlFormat(), cfhtml);
+ return extractMarkupFromCFHTML(cfhtml);
+}
+
PassRefPtr<DocumentFragment> fragmentFromFilenames(Document*, const IDataObject*)
{
// FIXME: We should be able to create fragments from files
return 0;
}
+PassRefPtr<DocumentFragment> fragmentFromFilenames(Document*, const DragDataMap*)
+{
+ // FIXME: We should be able to create fragments from files
+ return 0;
+}
+
bool containsFilenames(const IDataObject*)
{
// FIXME: We'll want to update this once we can produce fragments from files
return false;
}
+bool containsFilenames(const DragDataMap*)
+{
+ // FIXME: We'll want to update this once we can produce fragments from files
+ return false;
+}
+
// Convert a String containing CF_HTML formatted text to a DocumentFragment
PassRefPtr<DocumentFragment> fragmentFromCFHTML(Document* doc, const String& cfhtml)
{
@@ -477,8 +579,8 @@ PassRefPtr<DocumentFragment> fragmentFromHTML(Document* doc, IDataObject* data)
bool success = false;
String cfhtml = getFullCFHTML(data, success);
if (success) {
- if (PassRefPtr<DocumentFragment> fragment = fragmentFromCFHTML(doc, cfhtml))
- return fragment;
+ if (RefPtr<DocumentFragment> fragment = fragmentFromCFHTML(doc, cfhtml))
+ return fragment.release();
}
String html = getTextHTML(data, success);
@@ -489,9 +591,180 @@ PassRefPtr<DocumentFragment> fragmentFromHTML(Document* doc, IDataObject* data)
return 0;
}
+PassRefPtr<DocumentFragment> fragmentFromHTML(Document* document, const DragDataMap* data)
+{
+ if (!document || !data || data->isEmpty())
+ return 0;
+
+ String stringData;
+ if (getDataMapItem(data, htmlFormat(), stringData)) {
+ if (RefPtr<DocumentFragment> fragment = fragmentFromCFHTML(document, stringData))
+ return fragment.release();
+ }
+
+ String srcURL;
+ if (getDataMapItem(data, texthtmlFormat(), stringData))
+ return createFragmentFromMarkup(document, stringData, srcURL, FragmentScriptingNotAllowed);
+
+ return 0;
+}
+
bool containsHTML(IDataObject* data)
{
return SUCCEEDED(data->QueryGetData(texthtmlFormat())) || SUCCEEDED(data->QueryGetData(htmlFormat()));
}
+bool containsHTML(const DragDataMap* data)
+{
+ return data->contains(texthtmlFormat()->cfFormat) || data->contains(htmlFormat()->cfFormat);
+}
+
+typedef void (*GetStringFunction)(IDataObject*, FORMATETC*, Vector<String>&);
+typedef void (*SetStringFunction)(IDataObject*, FORMATETC*, const Vector<String>&);
+
+struct ClipboardDataItem {
+ GetStringFunction getString;
+ SetStringFunction setString;
+ FORMATETC* format;
+
+ ClipboardDataItem(FORMATETC* format, GetStringFunction getString, SetStringFunction setString): format(format), getString(getString), setString(setString) { }
+};
+
+typedef HashMap<UINT, ClipboardDataItem*> ClipboardFormatMap;
+
+// Getter functions.
+
+template<typename T> void getStringData(IDataObject* data, FORMATETC* format, Vector<String>& dataStrings)
+{
+ STGMEDIUM store;
+ if (FAILED(data->GetData(format, &store)))
+ return;
+ dataStrings.append(String(static_cast<T*>(GlobalLock(store.hGlobal)), ::GlobalSize(store.hGlobal) / sizeof(T)));
+ GlobalUnlock(store.hGlobal);
+ ReleaseStgMedium(&store);
+}
+
+void getUtf8Data(IDataObject* data, FORMATETC* format, Vector<String>& dataStrings)
+{
+ STGMEDIUM store;
+ if (FAILED(data->GetData(format, &store)))
+ return;
+ dataStrings.append(String(UTF8Encoding().decode(static_cast<char*>(GlobalLock(store.hGlobal)), GlobalSize(store.hGlobal))));
+ GlobalUnlock(store.hGlobal);
+ ReleaseStgMedium(&store);
+}
+
+#if PLATFORM(CF)
+void getCFData(IDataObject* data, FORMATETC* format, Vector<String>& dataStrings)
+{
+ STGMEDIUM store;
+ if (FAILED(data->GetData(format, &store)))
+ return;
+
+ HDROP hdrop = reinterpret_cast<HDROP>(GlobalLock(store.hGlobal));
+ if (!hdrop)
+ return;
+
+ WCHAR filename[MAX_PATH];
+ UINT fileCount = DragQueryFileW(hdrop, 0xFFFFFFFF, 0, 0);
+ for (UINT i = 0; i < fileCount; i++) {
+ if (!DragQueryFileW(hdrop, i, filename, WTF_ARRAY_LENGTH(filename)))
+ continue;
+ dataStrings.append(static_cast<UChar*>(filename));
+ }
+
+ GlobalUnlock(store.hGlobal);
+ ReleaseStgMedium(&store);
+}
+#endif
+
+// Setter functions.
+
+void setUCharData(IDataObject* data, FORMATETC* format, const Vector<String>& dataStrings)
+{
+ STGMEDIUM medium = {0};
+ medium.tymed = TYMED_HGLOBAL;
+
+ medium.hGlobal = createGlobalData(dataStrings.first());
+ if (!medium.hGlobal)
+ return;
+ data->SetData(format, &medium, FALSE);
+ ::GlobalFree(medium.hGlobal);
+}
+
+void setUtf8Data(IDataObject* data, FORMATETC* format, const Vector<String>& dataStrings)
+{
+ STGMEDIUM medium = {0};
+ medium.tymed = TYMED_HGLOBAL;
+
+ CString charString = dataStrings.first().utf8();
+ size_t stringLength = charString.length();
+ medium.hGlobal = ::GlobalAlloc(GPTR, stringLength + 1);
+ if (!medium.hGlobal)
+ return;
+ char* buffer = static_cast<char*>(GlobalLock(medium.hGlobal));
+ memcpy(buffer, charString.data(), stringLength);
+ buffer[stringLength] = 0;
+ GlobalUnlock(medium.hGlobal);
+ data->SetData(format, &medium, FALSE);
+ ::GlobalFree(medium.hGlobal);
+}
+
+#if PLATFORM(CF)
+void setCFData(IDataObject* data, FORMATETC* format, const Vector<String>& dataStrings)
+{
+ STGMEDIUM medium = {0};
+ SIZE_T dropFilesSize = sizeof(DROPFILES) + (sizeof(WCHAR) * (dataStrings.first().length() + 2));
+ medium.hGlobal = ::GlobalAlloc(GHND | GMEM_SHARE, dropFilesSize);
+ if (!medium.hGlobal)
+ return;
+
+ DROPFILES* dropFiles = reinterpret_cast<DROPFILES *>(GlobalLock(medium.hGlobal));
+ dropFiles->pFiles = sizeof(DROPFILES);
+ dropFiles->fWide = TRUE;
+ String filename = dataStrings.first();
+ wcscpy(reinterpret_cast<LPWSTR>(dropFiles + 1), filename.charactersWithNullTermination());
+ GlobalUnlock(medium.hGlobal);
+ data->SetData(format, &medium, FALSE);
+ ::GlobalFree(medium.hGlobal);
+}
+#endif
+
+static const ClipboardFormatMap& getClipboardMap()
+{
+ static ClipboardFormatMap formatMap;
+ if (formatMap.isEmpty()) {
+ formatMap.add(htmlFormat()->cfFormat, new ClipboardDataItem(htmlFormat(), getUtf8Data, setUtf8Data));
+ formatMap.add(texthtmlFormat()->cfFormat, new ClipboardDataItem(texthtmlFormat(), getStringData<UChar>, setUCharData));
+ formatMap.add(plainTextFormat()->cfFormat, new ClipboardDataItem(plainTextFormat(), getStringData<char>, setUtf8Data));
+ formatMap.add(plainTextWFormat()->cfFormat, new ClipboardDataItem(plainTextWFormat(), getStringData<UChar>, setUCharData));
+#if PLATFORM(CF)
+ formatMap.add(cfHDropFormat()->cfFormat, new ClipboardDataItem(cfHDropFormat(), getCFData, setCFData));
+#endif
+ formatMap.add(filenameFormat()->cfFormat, new ClipboardDataItem(filenameFormat(), getStringData<char>, setUtf8Data));
+ formatMap.add(filenameWFormat()->cfFormat, new ClipboardDataItem(filenameWFormat(), getStringData<UChar>, setUCharData));
+ formatMap.add(urlFormat()->cfFormat, new ClipboardDataItem(urlFormat(), getStringData<char>, setUtf8Data));
+ formatMap.add(urlWFormat()->cfFormat, new ClipboardDataItem(urlWFormat(), getStringData<UChar>, setUCharData));
+ }
+ return formatMap;
+}
+
+void getClipboardData(IDataObject* dataObject, FORMATETC* format, Vector<String>& dataStrings)
+{
+ const ClipboardFormatMap& formatMap = getClipboardMap();
+ ClipboardFormatMap::const_iterator found = formatMap.find(format->cfFormat);
+ if (found == formatMap.end())
+ return;
+ found->second->getString(dataObject, found->second->format, dataStrings);
+}
+
+void setClipboardData(IDataObject* dataObject, UINT format, const Vector<String>& dataStrings)
+{
+ const ClipboardFormatMap& formatMap = getClipboardMap();
+ ClipboardFormatMap::const_iterator found = formatMap.find(format);
+ if (found == formatMap.end())
+ return;
+ found->second->setString(dataObject, found->second->format, dataStrings);
+}
+
} // namespace WebCore
diff --git a/Source/WebCore/platform/win/ClipboardUtilitiesWin.h b/Source/WebCore/platform/win/ClipboardUtilitiesWin.h
index 1a29e7e..36508d4 100644
--- a/Source/WebCore/platform/win/ClipboardUtilitiesWin.h
+++ b/Source/WebCore/platform/win/ClipboardUtilitiesWin.h
@@ -55,16 +55,27 @@ void replaceNewlinesWithWindowsStyleNewlines(String&);
void replaceNBSPWithSpace(String&);
bool containsFilenames(const IDataObject*);
+bool containsFilenames(const DragDataMap*);
bool containsHTML(IDataObject*);
+bool containsHTML(const DragDataMap*);
PassRefPtr<DocumentFragment> fragmentFromFilenames(Document*, const IDataObject*);
+PassRefPtr<DocumentFragment> fragmentFromFilenames(Document*, const DragDataMap*);
PassRefPtr<DocumentFragment> fragmentFromHTML(Document*, IDataObject*);
+PassRefPtr<DocumentFragment> fragmentFromHTML(Document*, const DragDataMap*);
PassRefPtr<DocumentFragment> fragmentFromCFHTML(Document*, const String& cfhtml);
String getURL(IDataObject*, DragData::FilenameConversionPolicy, bool& success, String* title = 0);
+String getURL(const DragDataMap*, DragData::FilenameConversionPolicy, String* title = 0);
String getPlainText(IDataObject*, bool& success);
+String getPlainText(const DragDataMap*);
String getTextHTML(IDataObject*, bool& success);
+String getTextHTML(const DragDataMap*);
String getCFHTML(IDataObject*, bool& success);
+String getCFHTML(const DragDataMap*);
+
+void getClipboardData(IDataObject*, FORMATETC* fetc, Vector<String>& dataStrings);
+void setClipboardData(IDataObject*, UINT format, const Vector<String>& dataStrings);
} // namespace WebCore
diff --git a/Source/WebCore/platform/win/ClipboardWin.cpp b/Source/WebCore/platform/win/ClipboardWin.cpp
index 58cfe44..c0af712 100644
--- a/Source/WebCore/platform/win/ClipboardWin.cpp
+++ b/Source/WebCore/platform/win/ClipboardWin.cpp
@@ -115,7 +115,7 @@ static inline void pathRemoveBadFSCharacters(PWSTR psz, size_t length)
}
#endif
-static String filesystemPathFromUrlOrTitle(const String& url, const String& title, TCHAR* extension, bool isLink)
+static String filesystemPathFromUrlOrTitle(const String& url, const String& title, const UChar* extension, bool isLink)
{
#if OS(WINCE)
notImplemented();
@@ -163,7 +163,7 @@ static String filesystemPathFromUrlOrTitle(const String& url, const String& titl
}
String result(static_cast<UChar*>(fsPathBuffer));
- result += String(static_cast<UChar*>(extension));
+ result += String(extension);
return result;
#endif
}
@@ -195,7 +195,7 @@ static HGLOBAL createGlobalHDropContent(const KURL& url, String& fileName, Share
// windows does not enjoy a leading slash on paths
if (localPath[0] == '/')
localPath = localPath.substring(1);
- LPCTSTR localPathStr = localPath.charactersWithNullTermination();
+ LPCWSTR localPathStr = localPath.charactersWithNullTermination();
if (wcslen(localPathStr) + 1 < MAX_PATH)
wcscpy_s(filePath, MAX_PATH, localPathStr);
else
@@ -277,7 +277,7 @@ static HGLOBAL createGlobalImageFileDescriptor(const String& url, const String&
return 0;
}
extension.insert(".", 0);
- fsPath = filesystemPathFromUrlOrTitle(url, preferredTitle, (TCHAR*)extension.charactersWithNullTermination(), false);
+ fsPath = filesystemPathFromUrlOrTitle(url, preferredTitle, extension.charactersWithNullTermination(), false);
if (fsPath.length() <= 0) {
GlobalUnlock(memObj);
@@ -340,7 +340,9 @@ exit:
PassRefPtr<Clipboard> Clipboard::create(ClipboardAccessPolicy policy, DragData* dragData, Frame* frame)
{
- return ClipboardWin::create(DragAndDrop, dragData->platformData(), policy, frame);
+ if (dragData->platformData())
+ return ClipboardWin::create(DragAndDrop, dragData->platformData(), policy, frame);
+ return ClipboardWin::create(DragAndDrop, dragData->dragDataMap(), policy, frame);
}
ClipboardWin::ClipboardWin(ClipboardType clipboardType, IDataObject* dataObject, ClipboardAccessPolicy policy, Frame* frame)
@@ -359,6 +361,15 @@ ClipboardWin::ClipboardWin(ClipboardType clipboardType, WCDataObject* dataObject
{
}
+ClipboardWin::ClipboardWin(ClipboardType clipboardType, const DragDataMap& dataMap, ClipboardAccessPolicy policy, Frame* frame)
+ : Clipboard(policy, clipboardType)
+ , m_dataObject(0)
+ , m_writableDataObject(0)
+ , m_frame(frame)
+ , m_dragDataMap(dataMap)
+{
+}
+
ClipboardWin::~ClipboardWin()
{
}
@@ -442,19 +453,19 @@ void ClipboardWin::clearAllData()
String ClipboardWin::getData(const String& type, bool& success) const
{
success = false;
- if (policy() != ClipboardReadable || !m_dataObject)
+ if (policy() != ClipboardReadable || (!m_dataObject && m_dragDataMap.isEmpty()))
return "";
ClipboardDataType dataType = clipboardTypeFromMIMEType(type);
if (dataType == ClipboardDataTypeText)
- return getPlainText(m_dataObject.get(), success);
+ return m_dataObject ? getPlainText(m_dataObject.get(), success) : getPlainText(&m_dragDataMap);
if (dataType == ClipboardDataTypeURL)
- return getURL(m_dataObject.get(), DragData::DoNotConvertFilenames, success);
+ return m_dataObject ? getURL(m_dataObject.get(), DragData::DoNotConvertFilenames, success) : getURL(&m_dragDataMap, DragData::DoNotConvertFilenames);
else if (dataType == ClipboardDataTypeTextHTML) {
- String data = getTextHTML(m_dataObject.get(), success);
+ String data = m_dataObject ? getTextHTML(m_dataObject.get(), success) : getTextHTML(&m_dragDataMap);
if (success)
return data;
- return getCFHTML(m_dataObject.get(), success);
+ return m_dataObject ? getCFHTML(m_dataObject.get(), success) : getCFHTML(&m_dragDataMap);
}
return "";
@@ -510,22 +521,30 @@ HashSet<String> ClipboardWin::types() const
if (policy() != ClipboardReadable && policy() != ClipboardTypesReadable)
return results;
- if (!m_dataObject)
+ if (!m_dataObject && m_dragDataMap.isEmpty())
return results;
- COMPtr<IEnumFORMATETC> itr;
+ if (m_dataObject) {
+ COMPtr<IEnumFORMATETC> itr;
- if (FAILED(m_dataObject->EnumFormatEtc(DATADIR_GET, &itr)))
- return results;
+ if (FAILED(m_dataObject->EnumFormatEtc(DATADIR_GET, &itr)))
+ return results;
- if (!itr)
- return results;
+ if (!itr)
+ return results;
- FORMATETC data;
+ FORMATETC data;
- // IEnumFORMATETC::Next returns S_FALSE if there are no more items.
- while (itr->Next(1, &data, 0) == S_OK)
- addMimeTypesForFormat(results, data);
+ // IEnumFORMATETC::Next returns S_FALSE if there are no more items.
+ while (itr->Next(1, &data, 0) == S_OK)
+ addMimeTypesForFormat(results, data);
+ } else {
+ for (DragDataMap::const_iterator it = m_dragDataMap.begin(); it != m_dragDataMap.end(); ++it) {
+ FORMATETC data;
+ data.cfFormat = (*it).first;
+ addMimeTypesForFormat(results, data);
+ }
+ }
return results;
}
@@ -540,27 +559,35 @@ PassRefPtr<FileList> ClipboardWin::files() const
if (policy() != ClipboardReadable && policy() != ClipboardTypesReadable)
return files.release();
- if (!m_dataObject)
+ if (!m_dataObject && m_dragDataMap.isEmpty())
return files.release();
- STGMEDIUM medium;
- if (FAILED(m_dataObject->GetData(cfHDropFormat(), &medium)))
- return files.release();
+ if (m_dataObject) {
+ STGMEDIUM medium;
+ if (FAILED(m_dataObject->GetData(cfHDropFormat(), &medium)))
+ return files.release();
+
+ HDROP hdrop = reinterpret_cast<HDROP>(GlobalLock(medium.hGlobal));
+ if (!hdrop)
+ return files.release();
+
+ WCHAR filename[MAX_PATH];
+ UINT fileCount = DragQueryFileW(hdrop, 0xFFFFFFFF, 0, 0);
+ for (UINT i = 0; i < fileCount; i++) {
+ if (!DragQueryFileW(hdrop, i, filename, WTF_ARRAY_LENGTH(filename)))
+ continue;
+ files->append(File::create(reinterpret_cast<UChar*>(filename)));
+ }
- HDROP hdrop = reinterpret_cast<HDROP>(GlobalLock(medium.hGlobal));
- if (!hdrop)
+ GlobalUnlock(medium.hGlobal);
+ ReleaseStgMedium(&medium);
return files.release();
-
- WCHAR filename[MAX_PATH];
- UINT fileCount = DragQueryFileW(hdrop, 0xFFFFFFFF, 0, 0);
- for (UINT i = 0; i < fileCount; i++) {
- if (!DragQueryFileW(hdrop, i, filename, WTF_ARRAY_LENGTH(filename)))
- continue;
- files->append(File::create(reinterpret_cast<UChar*>(filename)));
}
-
- GlobalUnlock(medium.hGlobal);
- ReleaseStgMedium(&medium);
+ if (!m_dragDataMap.contains(cfHDropFormat()->cfFormat))
+ return files.release();
+ Vector<String> filesVector = m_dragDataMap.get(cfHDropFormat()->cfFormat);
+ for (Vector<String>::iterator it = filesVector.begin(); it != filesVector.end(); ++it)
+ files->append(File::create((*it).characters()));
return files.release();
#endif
}
@@ -778,25 +805,28 @@ void ClipboardWin::writePlainText(const String& text)
bool ClipboardWin::hasData()
{
- if (!m_dataObject)
+ if (!m_dataObject && m_dragDataMap.isEmpty())
return false;
- COMPtr<IEnumFORMATETC> itr;
- if (FAILED(m_dataObject->EnumFormatEtc(DATADIR_GET, &itr)))
- return false;
+ if (m_dataObject) {
+ COMPtr<IEnumFORMATETC> itr;
+ if (FAILED(m_dataObject->EnumFormatEtc(DATADIR_GET, &itr)))
+ return false;
- if (!itr)
- return false;
+ if (!itr)
+ return false;
- FORMATETC data;
+ FORMATETC data;
- // IEnumFORMATETC::Next returns S_FALSE if there are no more items.
- if (itr->Next(1, &data, 0) == S_OK) {
- // There is at least one item in the IDataObject
- return true;
- }
+ // IEnumFORMATETC::Next returns S_FALSE if there are no more items.
+ if (itr->Next(1, &data, 0) == S_OK) {
+ // There is at least one item in the IDataObject
+ return true;
+ }
- return false;
+ return false;
+ }
+ return !m_dragDataMap.isEmpty();
}
void ClipboardWin::setExternalDataObject(IDataObject *dataObject)
diff --git a/Source/WebCore/platform/win/ClipboardWin.h b/Source/WebCore/platform/win/ClipboardWin.h
index 779da26..7530eeb 100644
--- a/Source/WebCore/platform/win/ClipboardWin.h
+++ b/Source/WebCore/platform/win/ClipboardWin.h
@@ -29,6 +29,7 @@
#include "COMPtr.h"
#include "CachedResourceClient.h"
#include "Clipboard.h"
+#include "DragData.h"
struct IDataObject;
@@ -51,6 +52,10 @@ public:
{
return adoptRef(new ClipboardWin(clipboardType, dataObject, policy, frame));
}
+ static PassRefPtr<ClipboardWin> create(ClipboardType clipboardType, const DragDataMap& dataMap, ClipboardAccessPolicy policy, Frame* frame)
+ {
+ return adoptRef(new ClipboardWin(clipboardType, dataMap, policy, frame));
+ }
~ClipboardWin();
void clearData(const String& type);
@@ -80,12 +85,14 @@ public:
private:
ClipboardWin(ClipboardType, IDataObject*, ClipboardAccessPolicy, Frame*);
ClipboardWin(ClipboardType, WCDataObject*, ClipboardAccessPolicy, Frame*);
+ ClipboardWin(ClipboardType, const DragDataMap&, ClipboardAccessPolicy, Frame*);
void resetFromClipboard();
void setDragImage(CachedImage*, Node*, const IntPoint&);
COMPtr<IDataObject> m_dataObject;
COMPtr<WCDataObject> m_writableDataObject;
+ DragDataMap m_dragDataMap;
Frame* m_frame;
};
diff --git a/Source/WebCore/platform/win/ContextMenuWin.cpp b/Source/WebCore/platform/win/ContextMenuWin.cpp
index ed1b895..dad0f2e 100644
--- a/Source/WebCore/platform/win/ContextMenuWin.cpp
+++ b/Source/WebCore/platform/win/ContextMenuWin.cpp
@@ -31,7 +31,6 @@
#include "FrameView.h"
#include "Node.h"
#include "NotImplemented.h"
-#include <tchar.h>
#include <windows.h>
#include <wtf/Vector.h>
#include <wtf/text/CString.h>
@@ -73,7 +72,7 @@ void ContextMenu::getContextMenuItems(HMENU menu, Vector<ContextMenuItem>& items
}
int menuStringLength = info.cch + 1;
- OwnArrayPtr<WCHAR> menuString(new WCHAR[menuStringLength]);
+ OwnArrayPtr<WCHAR> menuString = adoptArrayPtr(new WCHAR[menuStringLength]);
info.dwTypeData = menuString.get();
info.cch = menuStringLength;
diff --git a/Source/WebCore/platform/win/CursorWin.cpp b/Source/WebCore/platform/win/CursorWin.cpp
index 2dd1452..0036388 100644
--- a/Source/WebCore/platform/win/CursorWin.cpp
+++ b/Source/WebCore/platform/win/CursorWin.cpp
@@ -123,9 +123,9 @@ static PassRefPtr<SharedCursor> createSharedCursor(Image* img, const IntPoint& h
return impl.release();
}
-static PassRefPtr<SharedCursor> loadSharedCursor(HINSTANCE hInstance, LPCTSTR lpCursorName)
+static PassRefPtr<SharedCursor> loadSharedCursor(HINSTANCE hInstance, LPCWSTR lpCursorName)
{
- return SharedCursor::create(::LoadCursor(hInstance, lpCursorName));
+ return SharedCursor::create(::LoadCursorW(hInstance, lpCursorName));
}
static PassRefPtr<SharedCursor> loadCursorByName(char* name, int x, int y)
diff --git a/Source/WebCore/platform/win/DragDataWin.cpp b/Source/WebCore/platform/win/DragDataWin.cpp
index 906119d..c5b99ea 100644
--- a/Source/WebCore/platform/win/DragDataWin.cpp
+++ b/Source/WebCore/platform/win/DragDataWin.cpp
@@ -26,6 +26,7 @@
#include "config.h"
#include "DragData.h"
+#include "COMPtr.h"
#include "ClipboardUtilitiesWin.h"
#include "Frame.h"
#include "DocumentFragment.h"
@@ -35,65 +36,109 @@
#include <objidl.h>
#include <shlwapi.h>
#include <wininet.h>
+#include <wtf/Forward.h>
+#include <wtf/Hashmap.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
namespace WebCore {
+DragData::DragData(const DragDataMap& data, const IntPoint& clientPosition, const IntPoint& globalPosition,
+ DragOperation sourceOperationMask, DragApplicationFlags flags)
+ : m_clientPosition(clientPosition)
+ , m_globalPosition(globalPosition)
+ , m_platformDragData(0)
+ , m_draggingSourceOperationMask(sourceOperationMask)
+ , m_applicationFlags(flags)
+ , m_dragDataMap(data)
+{
+}
+
bool DragData::containsURL(Frame*, FilenameConversionPolicy filenamePolicy) const
{
- return SUCCEEDED(m_platformDragData->QueryGetData(urlWFormat()))
- || SUCCEEDED(m_platformDragData->QueryGetData(urlFormat()))
- || (filenamePolicy == ConvertFilenames
- && (SUCCEEDED(m_platformDragData->QueryGetData(filenameWFormat()))
- || SUCCEEDED(m_platformDragData->QueryGetData(filenameFormat()))));
+ if (m_platformDragData)
+ return SUCCEEDED(m_platformDragData->QueryGetData(urlWFormat()))
+ || SUCCEEDED(m_platformDragData->QueryGetData(urlFormat()))
+ || (filenamePolicy == ConvertFilenames
+ && (SUCCEEDED(m_platformDragData->QueryGetData(filenameWFormat()))
+ || SUCCEEDED(m_platformDragData->QueryGetData(filenameFormat()))));
+ return m_dragDataMap.contains(urlWFormat()->cfFormat) || m_dragDataMap.contains(urlFormat()->cfFormat)
+ || (filenamePolicy == ConvertFilenames && (m_dragDataMap.contains(filenameWFormat()->cfFormat) || m_dragDataMap.contains(filenameFormat()->cfFormat)));
+}
+
+const DragDataMap& DragData::dragDataMap()
+{
+ if (!m_dragDataMap.isEmpty() || !m_platformDragData)
+ return m_dragDataMap;
+ // Enumerate clipboard content and load it in the map.
+ COMPtr<IEnumFORMATETC> itr;
+
+ if (FAILED(m_platformDragData->EnumFormatEtc(DATADIR_GET, &itr)) || !itr)
+ return m_dragDataMap;
+
+ FORMATETC dataFormat;
+ while (itr->Next(1, &dataFormat, 0) == S_OK) {
+ Vector<String> dataStrings;
+ getClipboardData(m_platformDragData, &dataFormat, dataStrings);
+ if (!dataStrings.isEmpty())
+ m_dragDataMap.set(dataFormat.cfFormat, dataStrings);
+ }
+ return m_dragDataMap;
}
String DragData::asURL(Frame*, FilenameConversionPolicy filenamePolicy, String* title) const
{
bool success;
- return getURL(m_platformDragData, filenamePolicy, success, title);
+ return (m_platformDragData) ? getURL(m_platformDragData, filenamePolicy, success, title) : getURL(&m_dragDataMap, filenamePolicy, title);
}
bool DragData::containsFiles() const
{
- return SUCCEEDED(m_platformDragData->QueryGetData(cfHDropFormat()));
+ return (m_platformDragData) ? SUCCEEDED(m_platformDragData->QueryGetData(cfHDropFormat())) : m_dragDataMap.contains(cfHDropFormat()->cfFormat);
}
void DragData::asFilenames(Vector<String>& result) const
{
- WCHAR filename[MAX_PATH];
-
- STGMEDIUM medium;
- if (FAILED(m_platformDragData->GetData(cfHDropFormat(), &medium)))
- return;
-
- HDROP hdrop = (HDROP)GlobalLock(medium.hGlobal);
-
- if (!hdrop)
- return;
+ if (m_platformDragData) {
+ WCHAR filename[MAX_PATH];
+
+ STGMEDIUM medium;
+ if (FAILED(m_platformDragData->GetData(cfHDropFormat(), &medium)))
+ return;
+
+ HDROP hdrop = (HDROP)GlobalLock(medium.hGlobal);
+
+ if (!hdrop)
+ return;
- const unsigned numFiles = DragQueryFileW(hdrop, 0xFFFFFFFF, 0, 0);
- for (unsigned i = 0; i < numFiles; i++) {
- if (!DragQueryFileW(hdrop, 0, filename, WTF_ARRAY_LENGTH(filename)))
- continue;
- result.append((UChar*)filename);
- }
+ const unsigned numFiles = DragQueryFileW(hdrop, 0xFFFFFFFF, 0, 0);
+ for (unsigned i = 0; i < numFiles; i++) {
+ if (!DragQueryFileW(hdrop, 0, filename, WTF_ARRAY_LENGTH(filename)))
+ continue;
+ result.append((UChar*)filename);
+ }
- // Free up memory from drag
- DragFinish(hdrop);
+ // Free up memory from drag
+ DragFinish(hdrop);
- GlobalUnlock(medium.hGlobal);
+ GlobalUnlock(medium.hGlobal);
+ return;
+ }
+ result = m_dragDataMap.get(cfHDropFormat()->cfFormat);
}
bool DragData::containsPlainText() const
{
- return SUCCEEDED(m_platformDragData->QueryGetData(plainTextWFormat()))
- || SUCCEEDED(m_platformDragData->QueryGetData(plainTextFormat()));
+ if (m_platformDragData)
+ return SUCCEEDED(m_platformDragData->QueryGetData(plainTextWFormat()))
+ || SUCCEEDED(m_platformDragData->QueryGetData(plainTextFormat()));
+ return m_dragDataMap.contains(plainTextWFormat()->cfFormat) || m_dragDataMap.contains(plainTextFormat()->cfFormat);
}
String DragData::asPlainText(Frame*) const
{
bool success;
- return getPlainText(m_platformDragData, success);
+ return (m_platformDragData) ? getPlainText(m_platformDragData, success) : getPlainText(&m_dragDataMap);
}
bool DragData::containsColor() const
@@ -103,14 +148,16 @@ bool DragData::containsColor() const
bool DragData::canSmartReplace() const
{
- return SUCCEEDED(m_platformDragData->QueryGetData(smartPasteFormat()));
+ if (m_platformDragData)
+ return SUCCEEDED(m_platformDragData->QueryGetData(smartPasteFormat()));
+ return m_dragDataMap.contains(smartPasteFormat()->cfFormat);
}
bool DragData::containsCompatibleContent() const
{
return containsPlainText() || containsURL(0)
- || containsHTML(m_platformDragData)
- || containsFilenames(m_platformDragData)
+ || ((m_platformDragData) ? (containsHTML(m_platformDragData) || containsFilenames(m_platformDragData))
+ : (containsHTML(&m_dragDataMap) || containsFilenames(&m_dragDataMap)))
|| containsColor();
}
@@ -125,16 +172,29 @@ PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, PassRefPtr<Range
* * TIFF
* * PICT
*/
-
- if (containsFilenames(m_platformDragData))
- if (PassRefPtr<DocumentFragment> fragment = fragmentFromFilenames(frame->document(), m_platformDragData))
- return fragment;
-
- if (containsHTML(m_platformDragData))
- if (PassRefPtr<DocumentFragment> fragment = fragmentFromHTML(frame->document(), m_platformDragData))
- return fragment;
-
- return 0;
+
+ if (m_platformDragData) {
+ if (containsFilenames(m_platformDragData)) {
+ if (PassRefPtr<DocumentFragment> fragment = fragmentFromFilenames(frame->document(), m_platformDragData))
+ return fragment;
+ }
+
+ if (containsHTML(m_platformDragData)) {
+ if (PassRefPtr<DocumentFragment> fragment = fragmentFromHTML(frame->document(), m_platformDragData))
+ return fragment;
+ }
+ } else {
+ if (containsFilenames(&m_dragDataMap)) {
+ if (PassRefPtr<DocumentFragment> fragment = fragmentFromFilenames(frame->document(), &m_dragDataMap))
+ return fragment;
+ }
+
+ if (containsHTML(&m_dragDataMap)) {
+ if (PassRefPtr<DocumentFragment> fragment = fragmentFromHTML(frame->document(), &m_dragDataMap))
+ return fragment;
+ }
+ }
+ return 0;
}
Color DragData::asColor() const
@@ -143,4 +203,3 @@ Color DragData::asColor() const
}
}
-
diff --git a/Source/WebCore/platform/win/DragImageWin.cpp b/Source/WebCore/platform/win/DragImageWin.cpp
index 135e9d0..4e5d168 100644
--- a/Source/WebCore/platform/win/DragImageWin.cpp
+++ b/Source/WebCore/platform/win/DragImageWin.cpp
@@ -27,14 +27,25 @@
#include "DragImage.h"
#include "CachedImage.h"
+#include "Font.h"
+#include "FontDescription.h"
+#include "FontSelector.h"
+#include "Frame.h"
#include "GraphicsContext.h"
#include "Image.h"
#include "RetainPtr.h"
+#include "Settings.h"
+#include "StringTruncator.h"
+#include "TextRun.h"
+#include "WebCoreTextRenderer.h"
#include <windows.h>
namespace WebCore {
+HBITMAP allocImage(HDC, IntSize, PlatformGraphicsContext** targetRef);
+void deallocContext(PlatformGraphicsContext* target);
+
IntSize dragImageSize(DragImageRef image)
{
if (!image)
@@ -79,5 +90,141 @@ DragImageRef createDragImageIconForCachedImage(CachedImage* image)
return iconInfo.hbmColor;
}
+
+const float DragLabelBorderX = 4;
+// Keep border_y in synch with DragController::LinkDragBorderInset.
+const float DragLabelBorderY = 2;
+const float DragLabelRadius = 5;
+const float LabelBorderYOffset = 2;
+
+const float MinDragLabelWidthBeforeClip = 120;
+const float MaxDragLabelWidth = 200;
+const float MaxDragLabelStringWidth = (MaxDragLabelWidth - 2 * DragLabelBorderX);
+
+const float DragLinkLabelFontsize = 11;
+const float DragLinkUrlFontSize = 10;
+
+static Font dragLabelFont(int size, bool bold, FontRenderingMode renderingMode)
+{
+ NONCLIENTMETRICS metrics;
+ metrics.cbSize = sizeof(metrics);
+ SystemParametersInfo(SPI_GETNONCLIENTMETRICS, metrics.cbSize, &metrics, 0);
+
+ FontDescription description;
+ description.setWeight(bold ? FontWeightBold : FontWeightNormal);
+
+ FontFamily family;
+ family.setFamily(metrics.lfSmCaptionFont.lfFaceName);
+ description.setFamily(family);
+ description.setSpecifiedSize((float)size);
+ description.setComputedSize((float)size);
+ description.setRenderingMode(renderingMode);
+ Font result = Font(description, 0, 0);
+ result.update(0);
+ return result;
+}
+
+DragImageRef createDragImageForLink(KURL& url, const String& inLabel, Frame* frame)
+{
+ // This is more or less an exact match for the Mac OS X code.
+
+ const Font* labelFont;
+ const Font* urlFont;
+
+ if (frame->settings() && frame->settings()->fontRenderingMode() == AlternateRenderingMode) {
+ static const Font alternateRenderingModeLabelFont = dragLabelFont(DragLinkLabelFontsize, true, AlternateRenderingMode);
+ static const Font alternateRenderingModeURLFont = dragLabelFont(DragLinkUrlFontSize, false, AlternateRenderingMode);
+ labelFont = &alternateRenderingModeLabelFont;
+ urlFont = &alternateRenderingModeURLFont;
+ } else {
+ static const Font normalRenderingModeLabelFont = dragLabelFont(DragLinkLabelFontsize, true, NormalRenderingMode);
+ static const Font normalRenderingModeURLFont = dragLabelFont(DragLinkUrlFontSize, false, NormalRenderingMode);
+ labelFont = &normalRenderingModeLabelFont;
+ urlFont = &normalRenderingModeURLFont;
+ }
+
+ bool drawURLString = true;
+ bool clipURLString = false;
+ bool clipLabelString = false;
+
+ String urlString = url.string();
+ String label = inLabel;
+ if (label.isEmpty()) {
+ drawURLString = false;
+ label = urlString;
+ }
+
+ // First step in drawing the link drag image width.
+ TextRun labelRun(label.impl());
+ TextRun urlRun(urlString.impl());
+ IntSize labelSize(labelFont->width(labelRun), labelFont->fontMetrics().ascent() + labelFont->fontMetrics().descent());
+
+ if (labelSize.width() > MaxDragLabelStringWidth) {
+ labelSize.setWidth(MaxDragLabelStringWidth);
+ clipLabelString = true;
+ }
+
+ IntSize urlStringSize;
+ IntSize imageSize(labelSize.width() + DragLabelBorderX * 2, labelSize.height() + DragLabelBorderY * 2);
+
+ if (drawURLString) {
+ urlStringSize.setWidth(urlFont->width(urlRun));
+ urlStringSize.setHeight(urlFont->fontMetrics().ascent() + urlFont->fontMetrics().descent());
+ imageSize.setHeight(imageSize.height() + urlStringSize.height());
+ if (urlStringSize.width() > MaxDragLabelStringWidth) {
+ imageSize.setWidth(MaxDragLabelWidth);
+ clipURLString = true;
+ } else
+ imageSize.setWidth(std::max(labelSize.width(), urlStringSize.width()) + DragLabelBorderX * 2);
+ }
+
+ // We now know how big the image needs to be, so we create and
+ // fill the background
+ HBITMAP image = 0;
+ HDC dc = GetDC(0);
+ HDC workingDC = CreateCompatibleDC(dc);
+ if (!workingDC) {
+ ReleaseDC(0, dc);
+ return 0;
+ }
+
+ PlatformGraphicsContext* contextRef;
+ image = allocImage(workingDC, imageSize, &contextRef);
+ if (!image) {
+ DeleteDC(workingDC);
+ ReleaseDC(0, dc);
+ return 0;
+ }
+
+ SelectObject(workingDC, image);
+ GraphicsContext context(contextRef);
+ // On Mac alpha is {0.7, 0.7, 0.7, 0.8}, however we can't control alpha
+ // for drag images on win, so we use 1
+ static const Color backgroundColor(140, 140, 140);
+ static const IntSize radii(DragLabelRadius, DragLabelRadius);
+ IntRect rect(0, 0, imageSize.width(), imageSize.height());
+ context.fillRoundedRect(rect, radii, radii, radii, radii, backgroundColor, ColorSpaceDeviceRGB);
+
+ // Draw the text
+ static const Color topColor(0, 0, 0, 255); // original alpha = 0.75
+ static const Color bottomColor(255, 255, 255, 127); // original alpha = 0.5
+ if (drawURLString) {
+ if (clipURLString)
+ urlString = StringTruncator::rightTruncate(urlString, imageSize.width() - (DragLabelBorderX * 2.0f), *urlFont, false);
+ IntPoint textPos(DragLabelBorderX, imageSize.height() - (LabelBorderYOffset + urlFont->fontMetrics().descent()));
+ WebCoreDrawDoubledTextAtPoint(context, urlString, textPos, *urlFont, topColor, bottomColor);
+ }
+ if (clipLabelString)
+ label = StringTruncator::rightTruncate(label, imageSize.width() - (DragLabelBorderX * 2.0f), *labelFont, false);
+
+ IntPoint textPos(DragLabelBorderX, DragLabelBorderY + labelFont->pixelSize());
+ WebCoreDrawDoubledTextAtPoint(context, label, textPos, *labelFont, topColor, bottomColor);
+
+ deallocContext(contextRef);
+ DeleteDC(workingDC);
+ ReleaseDC(0, dc);
+ return image;
+}
+
}
diff --git a/Source/WebCore/platform/win/FileChooserWin.cpp b/Source/WebCore/platform/win/FileChooserWin.cpp
index 7d07b5d..195b8eb 100644
--- a/Source/WebCore/platform/win/FileChooserWin.cpp
+++ b/Source/WebCore/platform/win/FileChooserWin.cpp
@@ -29,7 +29,6 @@
#include "LocalizedStrings.h"
#include "StringTruncator.h"
#include <shlwapi.h>
-#include <tchar.h>
#include <windows.h>
namespace WebCore {
@@ -44,7 +43,7 @@ String FileChooser::basenameForWidth(const Font& font, int width) const
string = fileButtonNoFileSelectedLabel();
else if (m_filenames.size() == 1) {
String tmpFilename = m_filenames[0];
- LPTSTR basename = PathFindFileName(tmpFilename.charactersWithNullTermination());
+ LPWSTR basename = PathFindFileNameW(tmpFilename.charactersWithNullTermination());
string = String(basename);
} else
return StringTruncator::rightTruncate(String::number(m_filenames.size()) + " files", width, font, false);
diff --git a/Source/WebCore/platform/win/LoggingWin.cpp b/Source/WebCore/platform/win/LoggingWin.cpp
index fe237e5..1d051ae 100644
--- a/Source/WebCore/platform/win/LoggingWin.cpp
+++ b/Source/WebCore/platform/win/LoggingWin.cpp
@@ -37,7 +37,7 @@ static inline void initializeWithUserDefault(WTFLogChannel& channel)
if (!length)
return;
- OwnArrayPtr<char> buffer(new char[length]);
+ OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
if (!GetEnvironmentVariableA(channel.defaultName, buffer.get(), length))
return;
diff --git a/Source/WebCore/platform/win/MIMETypeRegistryWin.cpp b/Source/WebCore/platform/win/MIMETypeRegistryWin.cpp
index 980742a..56ddab1 100644
--- a/Source/WebCore/platform/win/MIMETypeRegistryWin.cpp
+++ b/Source/WebCore/platform/win/MIMETypeRegistryWin.cpp
@@ -27,7 +27,9 @@
#include "MIMETypeRegistry.h"
#include <shlwapi.h>
+#include <wtf/Assertions.h>
#include <wtf/HashMap.h>
+#include <wtf/MainThread.h>
namespace WebCore
{
@@ -64,6 +66,8 @@ String MIMETypeRegistry::getPreferredExtensionForMIMEType(const String& type)
String MIMETypeRegistry::getMIMETypeForExtension(const String &ext)
{
+ ASSERT(isMainThread());
+
if (ext.isEmpty())
return String();
diff --git a/Source/WebCore/platform/win/PopupMenuWin.cpp b/Source/WebCore/platform/win/PopupMenuWin.cpp
index 15871e6..3f3afa2 100644
--- a/Source/WebCore/platform/win/PopupMenuWin.cpp
+++ b/Source/WebCore/platform/win/PopupMenuWin.cpp
@@ -42,7 +42,6 @@
#include "SimpleFontData.h"
#include "TextRun.h"
#include "WebCoreInstanceHandle.h"
-#include <tchar.h>
#include <windows.h>
#include <windowsx.h>
#if OS(WINCE)
@@ -64,7 +63,7 @@ static const int maxPopupHeight = 320;
const int optionSpacingMiddle = 1;
const int popupWindowBorderWidth = 1;
-static LPCTSTR kPopupWindowClassName = _T("PopupWindowClass");
+static LPCWSTR kPopupWindowClassName = L"PopupWindowClass";
// This is used from within our custom message pump when we want to send a
// message to the web view and not have our message stolen and sent to
@@ -121,7 +120,7 @@ void PopupMenuWin::disconnectClient()
m_popupClient = 0;
}
-LPCTSTR PopupMenuWin::popupClassName()
+LPCWSTR PopupMenuWin::popupClassName()
{
return kPopupWindowClassName;
}
@@ -145,7 +144,7 @@ void PopupMenuWin::show(const IntRect& r, FrameView* view, int index)
DWORD exStyle = WS_EX_LTRREADING;
- m_popup = ::CreateWindowEx(exStyle, kPopupWindowClassName, _T("PopupMenu"),
+ m_popup = ::CreateWindowExW(exStyle, kPopupWindowClassName, L"PopupMenu",
WS_POPUP | WS_BORDER,
m_windowRect.x(), m_windowRect.y(), m_windowRect.width(), m_windowRect.height(),
hostWindow, 0, WebCore::instanceHandle(), this);
@@ -306,7 +305,7 @@ void PopupMenuWin::calculatePositionAndSize(const IntRect& r, FrameView* v)
// First, determine the popup's height
int itemCount = client()->listSize();
- m_itemHeight = client()->menuStyle().font().height() + optionSpacingMiddle;
+ m_itemHeight = client()->menuStyle().font().fontMetrics().height() + optionSpacingMiddle;
int naturalHeight = m_itemHeight * itemCount;
int popupHeight = min(maxPopupHeight, naturalHeight);
// The popup should show an integral number of items (i.e. no partial items should be visible)
@@ -347,13 +346,13 @@ void PopupMenuWin::calculatePositionAndSize(const IntRect& r, FrameView* v)
// Always left-align items in the popup. This matches popup menus on the mac.
int popupX = rScreenCoords.x() + client()->clientInsetLeft();
- IntRect popupRect(popupX, rScreenCoords.bottom(), popupWidth, popupHeight);
+ IntRect popupRect(popupX, rScreenCoords.maxY(), popupWidth, popupHeight);
// The popup needs to stay within the bounds of the screen and not overlap any toolbars
FloatRect screen = screenAvailableRect(v);
// Check that we don't go off the screen vertically
- if (popupRect.bottom() > screen.height()) {
+ if (popupRect.maxY() > screen.height()) {
// The popup will go off the screen, so try placing it above the client
if (rScreenCoords.y() - popupRect.height() < 0) {
// The popup won't fit above, either, so place it whereever's bigger and resize it to fit
@@ -602,7 +601,7 @@ void PopupMenuWin::paint(const IntRect& damageRect, HDC hdc)
IntRect listRect = damageRect;
listRect.move(IntSize(0, m_scrollOffset * m_itemHeight));
- for (int y = listRect.y(); y < listRect.bottom(); y += m_itemHeight) {
+ for (int y = listRect.y(); y < listRect.maxY(); y += m_itemHeight) {
int index = y / m_itemHeight;
Color optionBackgroundColor, optionTextColor;
@@ -632,7 +631,7 @@ void PopupMenuWin::paint(const IntRect& damageRect, HDC hdc)
unsigned length = itemText.length();
const UChar* string = itemText.characters();
- TextRun textRun(string, length, false, 0, 0, itemText.defaultWritingDirection() == WTF::Unicode::RightToLeft);
+ TextRun textRun(string, length, false, 0, 0, TextRun::AllowTrailingExpansion, itemText.defaultWritingDirection() == WTF::Unicode::RightToLeft);
context.setFillColor(optionTextColor, ColorSpaceDeviceRGB);
@@ -649,7 +648,7 @@ void PopupMenuWin::paint(const IntRect& damageRect, HDC hdc)
int textX = max(0, client()->clientPaddingLeft() - client()->clientInsetLeft());
if (RenderTheme::defaultTheme()->popupOptionSupportsTextIndent() && itemStyle.textDirection() == LTR)
textX += itemStyle.textIndent().calcMinValue(itemRect.width());
- int textY = itemRect.y() + itemFont.ascent() + (itemRect.height() - itemFont.height()) / 2;
+ int textY = itemRect.y() + itemFont.fontMetrics().ascent() + (itemRect.height() - itemFont.fontMetrics().height()) / 2;
context.drawBidiText(itemFont, textRun, IntPoint(textX, textY));
}
}
diff --git a/Source/WebCore/platform/win/PopupMenuWin.h b/Source/WebCore/platform/win/PopupMenuWin.h
index 0d7630c..05edb07 100644
--- a/Source/WebCore/platform/win/PopupMenuWin.h
+++ b/Source/WebCore/platform/win/PopupMenuWin.h
@@ -49,7 +49,7 @@ public:
virtual void updateFromElement();
virtual void disconnectClient();
- static LPCTSTR popupClassName();
+ static LPCWSTR popupClassName();
private:
PopupMenuClient* client() const { return m_popupClient; }
diff --git a/Source/WebCore/platform/win/SystemTimeWin.cpp b/Source/WebCore/platform/win/SystemTimeWin.cpp
index 451262d..547decc 100644
--- a/Source/WebCore/platform/win/SystemTimeWin.cpp
+++ b/Source/WebCore/platform/win/SystemTimeWin.cpp
@@ -26,13 +26,9 @@
#include "config.h"
#include "SystemTime.h"
+#include <limits>
#include <windows.h>
-#if COMPILER(MINGW) || (PLATFORM(QT) && COMPILER(MSVC))
-#include <float.h>
-#define FLOAT_MAX FLT_MAX
-#endif
-
namespace WebCore {
float userIdleTime()
@@ -43,7 +39,8 @@ float userIdleTime()
if (::GetLastInputInfo(&lastInputInfo))
return (GetTickCount() - lastInputInfo.dwTime) * 0.001; // ::GetTickCount returns ms of uptime valid for up to 49.7 days.
#endif
- return FLT_MAX; // return an arbitrarily high userIdleTime so that releasing pages from the page cache isn't postponed.
+ // Return an arbitrarily high userIdleTime so that releasing pages from the page cache isn't postponed.
+ return std::numeric_limits<float>::max();
}
-}
+} // namespace WebCore
diff --git a/Source/WebCore/platform/win/WCDataObject.cpp b/Source/WebCore/platform/win/WCDataObject.cpp
index 6b4c859..0c03ce0 100644
--- a/Source/WebCore/platform/win/WCDataObject.cpp
+++ b/Source/WebCore/platform/win/WCDataObject.cpp
@@ -26,6 +26,8 @@
#include "config.h"
#include "WCDataObject.h"
+#include "ClipboardUtilitiesWin.h"
+#include "DragData.h"
#include "PlatformString.h"
namespace WebCore {
@@ -160,6 +162,17 @@ HRESULT WCDataObject::createInstance(WCDataObject** result)
return S_OK;
}
+HRESULT WCDataObject::createInstance(WCDataObject** result, const DragDataMap& dataMap)
+{
+ if (!result)
+ return E_POINTER;
+ *result = new WCDataObject;
+
+ for (DragDataMap::const_iterator it = dataMap.begin(); it != dataMap.end(); ++it)
+ setClipboardData(*result, it->first, it->second);
+ return S_OK;
+}
+
WCDataObject::WCDataObject()
: m_ref(1)
{
@@ -380,5 +393,4 @@ void WCDataObject::clearData(CLIPFORMAT format)
}
}
-
}
diff --git a/Source/WebCore/platform/win/WCDataObject.h b/Source/WebCore/platform/win/WCDataObject.h
index 133115d..e5fa298 100644
--- a/Source/WebCore/platform/win/WCDataObject.h
+++ b/Source/WebCore/platform/win/WCDataObject.h
@@ -26,10 +26,11 @@
#ifndef WCDataObject_h
#define WCDataObject_h
-#include <wtf/Forward.h>
-#include <wtf/Vector.h>
+#include "DragData.h"
#include <ShlObj.h>
#include <objidl.h>
+#include <wtf/Forward.h>
+#include <wtf/Vector.h>
namespace WebCore {
@@ -56,6 +57,7 @@ public:
void clearData(CLIPFORMAT);
static HRESULT createInstance(WCDataObject**);
+ static HRESULT createInstance(WCDataObject**, const DragDataMap&);
private:
WCDataObject();
virtual ~WCDataObject();