diff options
Diffstat (limited to 'WebCore/platform/win')
-rw-r--r-- | WebCore/platform/win/BitmapInfo.cpp | 21 | ||||
-rw-r--r-- | WebCore/platform/win/BitmapInfo.h | 20 | ||||
-rw-r--r-- | WebCore/platform/win/ClipboardUtilitiesWin.cpp | 154 | ||||
-rw-r--r-- | WebCore/platform/win/ClipboardUtilitiesWin.h | 1 | ||||
-rw-r--r-- | WebCore/platform/win/ClipboardWin.cpp | 24 | ||||
-rw-r--r-- | WebCore/platform/win/ClipboardWin.h | 13 | ||||
-rw-r--r-- | WebCore/platform/win/DragDataWin.cpp | 7 | ||||
-rw-r--r-- | WebCore/platform/win/EditorWin.cpp | 5 | ||||
-rw-r--r-- | WebCore/platform/win/PasteboardWin.cpp | 72 | ||||
-rw-r--r-- | WebCore/platform/win/PlatformScrollBar.h | 50 | ||||
-rw-r--r-- | WebCore/platform/win/PlatformScrollBarWin.cpp | 43 | ||||
-rw-r--r-- | WebCore/platform/win/PopupMenuWin.cpp | 7 |
12 files changed, 197 insertions, 220 deletions
diff --git a/WebCore/platform/win/BitmapInfo.cpp b/WebCore/platform/win/BitmapInfo.cpp index 9a2312c..514f722 100644 --- a/WebCore/platform/win/BitmapInfo.cpp +++ b/WebCore/platform/win/BitmapInfo.cpp @@ -1,6 +1,8 @@ /* * Copyright (C) 2009 Apple Inc. All Rights Reserved. * Copyright (C) 2009 Brent Fulgham + * Copyright (C) 2007-2009 Torch Mobile, Inc. All Rights Reserved. + * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,16 +29,19 @@ #include "config.h" #include "BitmapInfo.h" +#include <wtf/Assertions.h> + namespace WebCore { -BitmapInfo bitmapInfoForSize(int width, int height) +BitmapInfo bitmapInfoForSize(int width, int height, WORD bitCount) { + ASSERT_ARG(bitCount, bitCount == 16 || bitCount == 32); + BitmapInfo bitmapInfo; - bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bitmapInfo.bmiHeader.biWidth = width; + bitmapInfo.bmiHeader.biWidth = width; bitmapInfo.bmiHeader.biHeight = height; bitmapInfo.bmiHeader.biPlanes = 1; - bitmapInfo.bmiHeader.biBitCount = 32; + bitmapInfo.bmiHeader.biBitCount = bitCount; bitmapInfo.bmiHeader.biCompression = BI_RGB; bitmapInfo.bmiHeader.biSizeImage = 0; bitmapInfo.bmiHeader.biXPelsPerMeter = 0; @@ -53,14 +58,14 @@ BitmapInfo::BitmapInfo() bmiHeader.biSize = sizeof(BITMAPINFOHEADER); } -BitmapInfo BitmapInfo::create(const IntSize& size) +BitmapInfo BitmapInfo::create(const IntSize& size, WORD bitCount) { - return bitmapInfoForSize(size.width(), size.height()); + return bitmapInfoForSize(size.width(), size.height(), bitCount); } -BitmapInfo BitmapInfo::createBottomUp(const IntSize& size) +BitmapInfo BitmapInfo::createBottomUp(const IntSize& size, WORD bitCount) { - return bitmapInfoForSize(size.width(), -size.height()); + return bitmapInfoForSize(size.width(), -size.height(), bitCount); } } // namespace WebCore diff --git a/WebCore/platform/win/BitmapInfo.h b/WebCore/platform/win/BitmapInfo.h index 0127fdb..d1c3319 100644 --- a/WebCore/platform/win/BitmapInfo.h +++ b/WebCore/platform/win/BitmapInfo.h @@ -1,6 +1,8 @@ /* * Copyright (C) 2009 Apple Inc. All Rights Reserved. * Copyright (C) 2009 Brent Fulgham + * Copyright (C) 2007-2009 Torch Mobile, Inc. All Rights Reserved. + * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,17 +29,25 @@ #ifndef BitmapInfo_h #define BitmapInfo_h -#include <windows.h> #include "IntSize.h" +#include <windows.h> namespace WebCore { struct BitmapInfo : public BITMAPINFO { - BitmapInfo (); - static BitmapInfo create(const IntSize&); - static BitmapInfo createBottomUp(const IntSize&); -}; + BitmapInfo(); + static BitmapInfo create(const IntSize&, WORD bitCount = 32); + static BitmapInfo createBottomUp(const IntSize&, WORD bitCount = 32); + bool is16bit() const { return bmiHeader.biBitCount == 16; } + bool is32bit() const { return bmiHeader.biBitCount == 32; } + unsigned width() const { return abs(bmiHeader.biWidth); } + unsigned height() const { return abs(bmiHeader.biHeight); } + IntSize size() const { return IntSize(width(), height()); } + unsigned paddedWidth() const { return is16bit() ? (width() + 1) & ~0x1 : width(); } + unsigned numPixels() const { return paddedWidth() * height(); } + unsigned paddedBytesPerLine() const { return is16bit() ? paddedWidth() * 2 : width() * 4; } + unsigned bytesPerLine() const { return width() * bmiHeader.biBitCount / 8; }}; } // namespace WebCore #endif // BitmapInfo_h diff --git a/WebCore/platform/win/ClipboardUtilitiesWin.cpp b/WebCore/platform/win/ClipboardUtilitiesWin.cpp index e6af7ef..0130a70 100644 --- a/WebCore/platform/win/ClipboardUtilitiesWin.cpp +++ b/WebCore/platform/win/ClipboardUtilitiesWin.cpp @@ -31,23 +31,47 @@ #include "PlatformString.h" #include "TextEncoding.h" #include "markup.h" -#include <CoreFoundation/CoreFoundation.h> #include <shlwapi.h> #include <wininet.h> // for INTERNET_MAX_URL_LENGTH -#include <wtf/RetainPtr.h> #include <wtf/text/CString.h> +#if PLATFORM(CF) +#include <CoreFoundation/CoreFoundation.h> +#include <wtf/RetainPtr.h> +#endif + namespace WebCore { +#if PLATFORM(CF) FORMATETC* cfHDropFormat() { static FORMATETC urlFormat = {CF_HDROP, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL}; return &urlFormat; } +static bool urlFromPath(CFStringRef path, String& url) +{ + if (!path) + return false; + + RetainPtr<CFURLRef> cfURL(AdoptCF, CFURLCreateWithFileSystemPath(0, path, kCFURLWindowsPathStyle, false)); + if (!cfURL) + return false; + + url = CFURLGetString(cfURL.get()); + + // Work around <rdar://problem/6708300>, where CFURLCreateWithFileSystemPath makes URLs with "localhost". + if (url.startsWith("file://localhost/")) + url.remove(7, 9); + + return true; +} +#endif + static bool getWebLocData(IDataObject* dataObject, String& url, String* title) { bool succeeded = false; +#if PLATFORM(CF) WCHAR filename[MAX_PATH]; WCHAR urlBuffer[INTERNET_MAX_URL_LENGTH]; @@ -55,8 +79,8 @@ static bool getWebLocData(IDataObject* dataObject, String& url, String* title) if (FAILED(dataObject->GetData(cfHDropFormat(), &medium))) return false; - HDROP hdrop = (HDROP)GlobalLock(medium.hGlobal); - + HDROP hdrop = static_cast<HDROP>(GlobalLock(medium.hGlobal)); + if (!hdrop) return false; @@ -81,6 +105,7 @@ exit: // Free up memory. DragFinish(hdrop); GlobalUnlock(medium.hGlobal); +#endif return succeeded; } @@ -113,9 +138,9 @@ HGLOBAL createGlobalData(const KURL& url, const String& title) HGLOBAL cbData = ::GlobalAlloc(GPTR, size * sizeof(UChar)); if (cbData) { - PWSTR buffer = (PWSTR)::GlobalLock(cbData); - swprintf_s(buffer, size, L"%s\n%s", mutableURL.charactersWithNullTermination(), mutableTitle.charactersWithNullTermination()); - ::GlobalUnlock(cbData); + PWSTR buffer = static_cast<PWSTR>(GlobalLock(cbData)); + _snwprintf(buffer, size, L"%s\n%s", mutableURL.charactersWithNullTermination(), mutableTitle.charactersWithNullTermination()); + GlobalUnlock(cbData); } return cbData; } @@ -125,10 +150,10 @@ HGLOBAL createGlobalData(const String& str) HGLOBAL globalData = ::GlobalAlloc(GPTR, (str.length() + 1) * sizeof(UChar)); if (!globalData) return 0; - UChar* buffer = static_cast<UChar*>(::GlobalLock(globalData)); + UChar* buffer = static_cast<UChar*>(GlobalLock(globalData)); memcpy(buffer, str.characters(), str.length() * sizeof(UChar)); buffer[str.length()] = 0; - ::GlobalUnlock(globalData); + GlobalUnlock(globalData); return globalData; } @@ -137,13 +162,30 @@ HGLOBAL createGlobalData(const Vector<char>& vector) HGLOBAL globalData = ::GlobalAlloc(GPTR, vector.size() + 1); if (!globalData) return 0; - char* buffer = static_cast<char*>(::GlobalLock(globalData)); + char* buffer = static_cast<char*>(GlobalLock(globalData)); memcpy(buffer, vector.data(), vector.size()); buffer[vector.size()] = 0; - ::GlobalUnlock(globalData); + GlobalUnlock(globalData); return globalData; } +static String getFullCFHTML(IDataObject* data, bool& success) +{ + STGMEDIUM store; + if (SUCCEEDED(data->GetData(htmlFormat(), &store))) { + // MS HTML Format parsing + char* data = static_cast<char*>(GlobalLock(store.hGlobal)); + SIZE_T dataSize = ::GlobalSize(store.hGlobal); + String cfhtml(UTF8Encoding().decode(data, dataSize)); + GlobalUnlock(store.hGlobal); + ReleaseStgMedium(&store); + success = true; + return cfhtml; + } + success = false; + return String(); +} + static void append(Vector<char>& vector, const char* string) { vector.append(string, strlen(string)); @@ -154,6 +196,17 @@ static void append(Vector<char>& vector, const CString& string) vector.append(string.data(), string.length()); } +// Find the markup between "<!--StartFragment -->" and "<!--EndFragment -->", accounting for browser quirks. +static String extractMarkupFromCFHTML(const String& cfhtml) +{ + unsigned markupStart = cfhtml.find("<html", 0, false); + unsigned tagStart = cfhtml.find("startfragment", markupStart, false); + unsigned fragmentStart = cfhtml.find('>', tagStart) + 1; + unsigned tagEnd = cfhtml.find("endfragment", fragmentStart, false); + unsigned fragmentEnd = cfhtml.reverseFind('<', tagEnd); + return cfhtml.substring(fragmentStart, fragmentEnd - fragmentStart).stripWhiteSpace(); +} + // Documentation for the CF_HTML format is available at http://msdn.microsoft.com/workshop/networking/clipboard/htmlclipboard.asp void markupToCFHTML(const String& markup, const String& srcURL, Vector<char>& result) { @@ -271,24 +324,6 @@ FORMATETC* smartPasteFormat() return &htmlFormat; } -static bool urlFromPath(CFStringRef path, String& url) -{ - if (!path) - return false; - - RetainPtr<CFURLRef> cfURL(AdoptCF, CFURLCreateWithFileSystemPath(0, path, kCFURLWindowsPathStyle, false)); - if (!cfURL) - return false; - - url = CFURLGetString(cfURL.get()); - - // Work around <rdar://problem/6708300>, where CFURLCreateWithFileSystemPath makes URLs with "localhost". - if (url.startsWith("file://localhost/")) - url.remove(7, 9); - - return true; -} - String getURL(IDataObject* dataObject, DragData::FilenameConversionPolicy filenamePolicy, bool& success, String* title) { STGMEDIUM store; @@ -298,22 +333,24 @@ String getURL(IDataObject* dataObject, DragData::FilenameConversionPolicy filena success = true; else if (SUCCEEDED(dataObject->GetData(urlWFormat(), &store))) { // URL using Unicode - UChar* data = (UChar*)GlobalLock(store.hGlobal); + UChar* data = static_cast<UChar*>(GlobalLock(store.hGlobal)); url = extractURL(String(data), title); - GlobalUnlock(store.hGlobal); + GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); success = true; } else if (SUCCEEDED(dataObject->GetData(urlFormat(), &store))) { // URL using ASCII - char* data = (char*)GlobalLock(store.hGlobal); + char* data = static_cast<char*>(GlobalLock(store.hGlobal)); url = extractURL(String(data), title); - GlobalUnlock(store.hGlobal); + GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); success = true; - } else if (filenamePolicy == DragData::ConvertFilenames) { + } +#if PLATFORM(CF) + else if (filenamePolicy == DragData::ConvertFilenames) { if (SUCCEEDED(dataObject->GetData(filenameWFormat(), &store))) { // file using unicode - wchar_t* data = (wchar_t*)GlobalLock(store.hGlobal); + wchar_t* data = static_cast<wchar_t*>(GlobalLock(store.hGlobal)); if (data && data[0] && (PathFileExists(data) || PathIsUNC(data))) { RetainPtr<CFStringRef> pathAsCFString(AdoptCF, CFStringCreateWithCharacters(kCFAllocatorDefault, (const UniChar*)data, wcslen(data))); if (urlFromPath(pathAsCFString.get(), url)) { @@ -326,7 +363,7 @@ String getURL(IDataObject* dataObject, DragData::FilenameConversionPolicy filena ReleaseStgMedium(&store); } else if (SUCCEEDED(dataObject->GetData(filenameFormat(), &store))) { // filename using ascii - char* data = (char*)GlobalLock(store.hGlobal); + char* data = static_cast<char*>(GlobalLock(store.hGlobal)); if (data && data[0] && (PathFileExistsA(data) || PathIsUNCA(data))) { RetainPtr<CFStringRef> pathAsCFString(AdoptCF, CFStringCreateWithCString(kCFAllocatorDefault, data, kCFStringEncodingASCII)); if (urlFromPath(pathAsCFString.get(), url)) { @@ -339,6 +376,7 @@ String getURL(IDataObject* dataObject, DragData::FilenameConversionPolicy filena ReleaseStgMedium(&store); } } +#endif return url; } @@ -349,14 +387,14 @@ String getPlainText(IDataObject* dataObject, bool& success) success = false; if (SUCCEEDED(dataObject->GetData(plainTextWFormat(), &store))) { // Unicode text - UChar* data = (UChar*)GlobalLock(store.hGlobal); + UChar* data = static_cast<UChar*>(GlobalLock(store.hGlobal)); text = String(data); GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); success = true; } else if (SUCCEEDED(dataObject->GetData(plainTextFormat(), &store))) { // ASCII text - char* data = (char*)GlobalLock(store.hGlobal); + char* data = static_cast<char*>(GlobalLock(store.hGlobal)); text = String(data); GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); @@ -386,6 +424,14 @@ String getTextHTML(IDataObject* data, bool& success) return html; } +String getCFHTML(IDataObject* data, bool& success) +{ + String cfhtml = getFullCFHTML(data, success); + if (success) + return extractMarkupFromCFHTML(cfhtml); + return String(); +} + PassRefPtr<DocumentFragment> fragmentFromFilenames(Document*, const IDataObject*) { // FIXME: We should be able to create fragments from files @@ -400,7 +446,7 @@ bool containsFilenames(const IDataObject*) // Convert a String containing CF_HTML formatted text to a DocumentFragment PassRefPtr<DocumentFragment> fragmentFromCFHTML(Document* doc, const String& cfhtml) -{ +{ // obtain baseURL if present String srcURLStr("sourceURL:"); String srcURL; @@ -413,38 +459,24 @@ PassRefPtr<DocumentFragment> fragmentFromCFHTML(Document* doc, const String& cfh srcURL = rawSrcURL.stripWhiteSpace(); } - // find the markup between "<!--StartFragment -->" and "<!--EndFragment -->", accounting for browser quirks - unsigned markupStart = cfhtml.find("<html", 0, false); - unsigned tagStart = cfhtml.find("startfragment", markupStart, false); - unsigned fragmentStart = cfhtml.find('>', tagStart) + 1; - unsigned tagEnd = cfhtml.find("endfragment", fragmentStart, false); - unsigned fragmentEnd = cfhtml.reverseFind('<', tagEnd); - String markup = cfhtml.substring(fragmentStart, fragmentEnd - fragmentStart).stripWhiteSpace(); - + String markup = extractMarkupFromCFHTML(cfhtml); return createFragmentFromMarkup(doc, markup, srcURL, FragmentScriptingNotAllowed); } - PassRefPtr<DocumentFragment> fragmentFromHTML(Document* doc, IDataObject* data) { if (!doc || !data) return 0; - STGMEDIUM store; - String html; - String srcURL; - if (SUCCEEDED(data->GetData(htmlFormat(), &store))) { - // MS HTML Format parsing - char* data = (char*)GlobalLock(store.hGlobal); - SIZE_T dataSize = ::GlobalSize(store.hGlobal); - String cfhtml(UTF8Encoding().decode(data, dataSize)); - GlobalUnlock(store.hGlobal); - ReleaseStgMedium(&store); + bool success = false; + String cfhtml = getFullCFHTML(data, success); + if (success) { if (PassRefPtr<DocumentFragment> fragment = fragmentFromCFHTML(doc, cfhtml)) return fragment; - } - bool success = false; - html = getTextHTML(data, success); + } + + String html = getTextHTML(data, success); + String srcURL; if (success) return createFragmentFromMarkup(doc, html, srcURL, FragmentScriptingNotAllowed); diff --git a/WebCore/platform/win/ClipboardUtilitiesWin.h b/WebCore/platform/win/ClipboardUtilitiesWin.h index 4ca46f9..fe01499 100644 --- a/WebCore/platform/win/ClipboardUtilitiesWin.h +++ b/WebCore/platform/win/ClipboardUtilitiesWin.h @@ -64,6 +64,7 @@ PassRefPtr<DocumentFragment> fragmentFromCFHTML(Document*, const String& cfhtml) String getURL(IDataObject*, DragData::FilenameConversionPolicy, bool& success, String* title = 0); String getPlainText(IDataObject*, bool& success); String getTextHTML(IDataObject*, bool& success); +String getCFHTML(IDataObject*, bool& success); } // namespace WebCore diff --git a/WebCore/platform/win/ClipboardWin.cpp b/WebCore/platform/win/ClipboardWin.cpp index 2cd6feb..6e026d6 100644 --- a/WebCore/platform/win/ClipboardWin.cpp +++ b/WebCore/platform/win/ClipboardWin.cpp @@ -70,7 +70,7 @@ static const char szShellDotUrlTemplate[] = "[InternetShortcut]\r\nURL=%s\r\n"; // We provide the IE clipboard types (URL and Text), and the clipboard types specified in the WHATWG Web Applications 1.0 draft // see http://www.whatwg.org/specs/web-apps/current-work/ Section 6.3.5.3 -enum ClipboardDataType { ClipboardDataTypeNone, ClipboardDataTypeURL, ClipboardDataTypeText }; +enum ClipboardDataType { ClipboardDataTypeNone, ClipboardDataTypeURL, ClipboardDataTypeText, ClipboardDataTypeTextHTML }; static ClipboardDataType clipboardTypeFromMIMEType(const String& type) { @@ -81,6 +81,8 @@ static ClipboardDataType clipboardTypeFromMIMEType(const String& type) return ClipboardDataTypeText; if (qType == "url" || qType == "text/uri-list") return ClipboardDataTypeURL; + if (qType == "text/html") + return ClipboardDataTypeTextHTML; return ClipboardDataTypeNone; } @@ -393,17 +395,24 @@ exit: return hr; } -ClipboardWin::ClipboardWin(bool isForDragging, IDataObject* dataObject, ClipboardAccessPolicy policy) +PassRefPtr<Clipboard> Clipboard::create(ClipboardAccessPolicy policy, DragData* dragData, Frame* frame) +{ + return ClipboardWin::create(true, dragData->platformData(), policy, frame); +} + +ClipboardWin::ClipboardWin(bool isForDragging, IDataObject* dataObject, ClipboardAccessPolicy policy, Frame* frame) : Clipboard(policy, isForDragging) , m_dataObject(dataObject) , m_writableDataObject(0) + , m_frame(frame) { } -ClipboardWin::ClipboardWin(bool isForDragging, WCDataObject* dataObject, ClipboardAccessPolicy policy) +ClipboardWin::ClipboardWin(bool isForDragging, WCDataObject* dataObject, ClipboardAccessPolicy policy, Frame* frame) : Clipboard(policy, isForDragging) , m_dataObject(dataObject) , m_writableDataObject(dataObject) + , m_frame(frame) { } @@ -498,6 +507,12 @@ String ClipboardWin::getData(const String& type, bool& success) const return getPlainText(m_dataObject.get(), success); if (dataType == ClipboardDataTypeURL) return getURL(m_dataObject.get(), DragData::DoNotConvertFilenames, success); + else if (dataType == ClipboardDataTypeTextHTML) { + String data = getTextHTML(m_dataObject.get(), success); + if (success) + return data; + return getCFHTML(m_dataObject.get(), success); + } return ""; } @@ -589,12 +604,13 @@ PassRefPtr<FileList> ClipboardWin::files() const if (!hdrop) return files.release(); + ScriptExecutionContext* scriptExecutionContext = m_frame->document()->scriptExecutionContext(); WCHAR filename[MAX_PATH]; UINT fileCount = DragQueryFileW(hdrop, 0xFFFFFFFF, 0, 0); for (UINT i = 0; i < fileCount; i++) { if (!DragQueryFileW(hdrop, i, filename, ARRAYSIZE(filename))) continue; - files->append(File::create(reinterpret_cast<UChar*>(filename))); + files->append(File::create(scriptExecutionContext, reinterpret_cast<UChar*>(filename))); } GlobalUnlock(medium.hGlobal); diff --git a/WebCore/platform/win/ClipboardWin.h b/WebCore/platform/win/ClipboardWin.h index 1b139ed..6a08087 100644 --- a/WebCore/platform/win/ClipboardWin.h +++ b/WebCore/platform/win/ClipboardWin.h @@ -35,19 +35,20 @@ struct IDataObject; namespace WebCore { class CachedImage; +class Frame; class IntPoint; class WCDataObject; // State available during IE's events for drag and drop and copy/paste class ClipboardWin : public Clipboard, public CachedResourceClient { public: - static PassRefPtr<ClipboardWin> create(bool isForDragging, IDataObject* dataObject, ClipboardAccessPolicy policy) + static PassRefPtr<ClipboardWin> create(bool isForDragging, IDataObject* dataObject, ClipboardAccessPolicy policy, Frame* frame) { - return adoptRef(new ClipboardWin(isForDragging, dataObject, policy)); + return adoptRef(new ClipboardWin(isForDragging, dataObject, policy, frame)); } - static PassRefPtr<ClipboardWin> create(bool isForDragging, WCDataObject* dataObject, ClipboardAccessPolicy policy) + static PassRefPtr<ClipboardWin> create(bool isForDragging, WCDataObject* dataObject, ClipboardAccessPolicy policy, Frame* frame) { - return adoptRef(new ClipboardWin(isForDragging, dataObject, policy)); + return adoptRef(new ClipboardWin(isForDragging, dataObject, policy, frame)); } ~ClipboardWin(); @@ -76,8 +77,8 @@ public: void setExternalDataObject(IDataObject *dataObject); private: - ClipboardWin(bool isForDragging, IDataObject*, ClipboardAccessPolicy); - ClipboardWin(bool isForDragging, WCDataObject*, ClipboardAccessPolicy); + ClipboardWin(bool isForDragging, IDataObject*, ClipboardAccessPolicy, Frame*); + ClipboardWin(bool isForDragging, WCDataObject*, ClipboardAccessPolicy, Frame*); void resetFromClipboard(); void setDragImage(CachedImage*, Node*, const IntPoint&); diff --git a/WebCore/platform/win/DragDataWin.cpp b/WebCore/platform/win/DragDataWin.cpp index 82e537e..05f9103 100644 --- a/WebCore/platform/win/DragDataWin.cpp +++ b/WebCore/platform/win/DragDataWin.cpp @@ -26,9 +26,7 @@ #include "config.h" #include "DragData.h" -#include "ClipboardWin.h" #include "ClipboardUtilitiesWin.h" -#include "ClipboardAccessPolicy.h" #include "DocumentFragment.h" #include "PlatformString.h" #include "Markup.h" @@ -39,11 +37,6 @@ namespace WebCore { -PassRefPtr<Clipboard> DragData::createClipboard(ClipboardAccessPolicy policy) const -{ - return ClipboardWin::create(true, m_platformDragData, policy); -} - bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const { return SUCCEEDED(m_platformDragData->QueryGetData(urlWFormat())) diff --git a/WebCore/platform/win/EditorWin.cpp b/WebCore/platform/win/EditorWin.cpp index 09abdbd..075827d 100644 --- a/WebCore/platform/win/EditorWin.cpp +++ b/WebCore/platform/win/EditorWin.cpp @@ -30,6 +30,7 @@ #include "ClipboardWin.h" #include "Document.h" #include "Element.h" +#include "Frame.h" #include "htmlediting.h" #include "TextIterator.h" #include "visible_units.h" @@ -38,13 +39,13 @@ namespace WebCore { -PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy) +PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy, Frame* frame) { COMPtr<IDataObject> clipboardData; if (!SUCCEEDED(OleGetClipboard(&clipboardData))) clipboardData = 0; - return ClipboardWin::create(false, clipboardData.get(), policy); + return ClipboardWin::create(false, clipboardData.get(), policy, frame); } } // namespace WebCore diff --git a/WebCore/platform/win/PasteboardWin.cpp b/WebCore/platform/win/PasteboardWin.cpp index 808c863..03ecd36 100644 --- a/WebCore/platform/win/PasteboardWin.cpp +++ b/WebCore/platform/win/PasteboardWin.cpp @@ -52,7 +52,6 @@ static UINT WebSmartPasteFormat = 0; static LRESULT CALLBACK PasteboardOwnerWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { LRESULT lresult = 0; - LONG_PTR longPtr = GetWindowLongPtr(hWnd, 0); switch (message) { case WM_RENDERFORMAT: @@ -64,12 +63,14 @@ static LRESULT CALLBACK PasteboardOwnerWndProc(HWND hWnd, UINT message, WPARAM w // and now this application is about to quit, so it must put data on // the clipboard before it exits. break; - case WM_DRAWCLIPBOARD: - break; case WM_DESTROY: break; +#if !OS(WINCE) + case WM_DRAWCLIPBOARD: + break; case WM_CHANGECBCHAIN: break; +#endif default: lresult = DefWindowProc(hWnd, message, wParam, lParam); break; @@ -84,17 +85,21 @@ Pasteboard* Pasteboard::generalPasteboard() } Pasteboard::Pasteboard() -{ - // make a dummy HWND to be the Windows clipboard's owner - WNDCLASSEX wcex = {0}; - wcex.cbSize = sizeof(WNDCLASSEX); - wcex.lpfnWndProc = PasteboardOwnerWndProc; - wcex.hInstance = WebCore::instanceHandle(); - wcex.lpszClassName = L"PasteboardOwnerWindowClass"; - ::RegisterClassEx(&wcex); +{ + HWND hWndParent = 0; +#if !OS(WINCE) + hWndParent = HWND_MESSAGE; +#endif + + WNDCLASS wc; + memset(&wc, 0, sizeof(WNDCLASS)); + wc.lpfnWndProc = PasteboardOwnerWndProc; + wc.hInstance = WebCore::instanceHandle(); + wc.lpszClassName = L"PasteboardOwnerWindowClass"; + RegisterClass(&wc); m_owner = ::CreateWindow(L"PasteboardOwnerWindowClass", L"PasteboardOwnerWindow", 0, 0, 0, 0, 0, - HWND_MESSAGE, 0, 0, 0); + hWndParent, 0, 0, 0); HTMLClipboardFormat = ::RegisterClipboardFormat(L"HTML Format"); BookmarkClipboardFormat = ::RegisterClipboardFormat(L"UniformResourceLocatorW"); @@ -216,31 +221,34 @@ void Pasteboard::writeImage(Node* node, const KURL&, const String&) HDC dc = GetDC(0); HDC compatibleDC = CreateCompatibleDC(0); HDC sourceDC = CreateCompatibleDC(0); - HBITMAP resultBitmap = CreateCompatibleBitmap(dc, image->width(), image->height()); - HBITMAP oldBitmap = (HBITMAP)SelectObject(compatibleDC, resultBitmap); + OwnPtr<HBITMAP> resultBitmap(CreateCompatibleBitmap(dc, image->width(), image->height())); + HGDIOBJ oldBitmap = SelectObject(compatibleDC, resultBitmap.get()); BitmapInfo bmInfo = BitmapInfo::create(image->size()); HBITMAP coreBitmap = CreateDIBSection(dc, &bmInfo, DIB_RGB_COLORS, 0, 0, 0); - HBITMAP oldSource = (HBITMAP)SelectObject(sourceDC, coreBitmap); + HGDIOBJ oldSource = SelectObject(sourceDC, coreBitmap); image->getHBITMAP(coreBitmap); +#if !defined(NO_ALPHABLEND) BLENDFUNCTION bf = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA}; AlphaBlend(compatibleDC, 0, 0, image->width(), image->height(), sourceDC, 0, 0, image->width(), image->height(), bf); +#else + StretchBlt(compatibleDC, 0, 0, image->width(), image->height(), + sourceDC, 0, 0, image->width(), image->height(), SRCCOPY); +#endif - SelectObject(compatibleDC, oldBitmap); SelectObject(sourceDC, oldSource); - - DeleteObject(oldBitmap); - DeleteObject(oldSource); DeleteObject(coreBitmap); - ReleaseDC(0, dc); - DeleteDC(compatibleDC); + + SelectObject(compatibleDC, oldBitmap); DeleteDC(sourceDC); + DeleteDC(compatibleDC); + ReleaseDC(0, dc); if (::OpenClipboard(m_owner)) { - ::SetClipboardData(CF_BITMAP, resultBitmap); + ::SetClipboardData(CF_BITMAP, resultBitmap.leakPtr()); ::CloseClipboard(); } } @@ -255,9 +263,9 @@ String Pasteboard::plainText(Frame* frame) if (::IsClipboardFormatAvailable(CF_UNICODETEXT) && ::OpenClipboard(m_owner)) { HANDLE cbData = ::GetClipboardData(CF_UNICODETEXT); if (cbData) { - UChar* buffer = (UChar*)::GlobalLock(cbData); + UChar* buffer = static_cast<UChar*>(GlobalLock(cbData)); String fromClipboard(buffer); - ::GlobalUnlock(cbData); + GlobalUnlock(cbData); ::CloseClipboard(); return fromClipboard; } @@ -267,9 +275,9 @@ String Pasteboard::plainText(Frame* frame) if (::IsClipboardFormatAvailable(CF_TEXT) && ::OpenClipboard(m_owner)) { HANDLE cbData = ::GetClipboardData(CF_TEXT); if (cbData) { - char* buffer = (char*)::GlobalLock(cbData); + char* buffer = static_cast<char*>(GlobalLock(cbData)); String fromClipboard(buffer); - ::GlobalUnlock(cbData); + GlobalUnlock(cbData); ::CloseClipboard(); return fromClipboard; } @@ -288,8 +296,8 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefP HANDLE cbData = ::GetClipboardData(HTMLClipboardFormat); if (cbData) { SIZE_T dataSize = ::GlobalSize(cbData); - String cfhtml(UTF8Encoding().decode((char*)::GlobalLock(cbData), dataSize)); - ::GlobalUnlock(cbData); + String cfhtml(UTF8Encoding().decode(static_cast<char*>(GlobalLock(cbData)), dataSize)); + GlobalUnlock(cbData); ::CloseClipboard(); PassRefPtr<DocumentFragment> fragment = fragmentFromCFHTML(frame->document(), cfhtml); @@ -304,9 +312,9 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefP if (::OpenClipboard(m_owner)) { HANDLE cbData = ::GetClipboardData(CF_UNICODETEXT); if (cbData) { - UChar* buffer = (UChar*)GlobalLock(cbData); + UChar* buffer = static_cast<UChar*>(GlobalLock(cbData)); String str(buffer); - ::GlobalUnlock(cbData); + GlobalUnlock(cbData); ::CloseClipboard(); RefPtr<DocumentFragment> fragment = createFragmentFromText(context.get(), str); if (fragment) @@ -321,9 +329,9 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefP if (::OpenClipboard(m_owner)) { HANDLE cbData = ::GetClipboardData(CF_TEXT); if (cbData) { - char* buffer = (char*)GlobalLock(cbData); + char* buffer = static_cast<char*>(GlobalLock(cbData)); String str(buffer); - ::GlobalUnlock(cbData); + GlobalUnlock(cbData); ::CloseClipboard(); RefPtr<DocumentFragment> fragment = createFragmentFromText(context.get(), str); if (fragment) diff --git a/WebCore/platform/win/PlatformScrollBar.h b/WebCore/platform/win/PlatformScrollBar.h deleted file mode 100644 index 89c6e4a..0000000 --- a/WebCore/platform/win/PlatformScrollBar.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef PlatformScrollBar_h -#define PlatformScrollBar_h - -#include "Scrollbar.h" -#include "Timer.h" -#include <wtf/PassRefPtr.h> - -typedef struct HDC__* HDC; - -namespace WebCore { - -class PlatformScrollbar : public Scrollbar { -public: - static PassRefPtr<PlatformScrollbar> create(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize size) - { - return adoptRef(new PlatformScrollbar(client, orientation, size)); - } - - PlatformScrollbar(ScrollbarClient*, ScrollbarOrientation, ScrollbarControlSize, ScrollbarTheme* = 0); -}; - -} - -#endif // PlatformScrollBar_h - diff --git a/WebCore/platform/win/PlatformScrollBarWin.cpp b/WebCore/platform/win/PlatformScrollBarWin.cpp deleted file mode 100644 index aa5333b..0000000 --- a/WebCore/platform/win/PlatformScrollBarWin.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. - * Copyright (C) 2008 Brent Fulgham - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "PlatformScrollBar.h" - -#include "FrameView.h" -#include "ScrollbarClient.h" -#include "ScrollbarTheme.h" - -namespace WebCore { - -PlatformScrollbar::PlatformScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize size, - ScrollbarTheme* theme) - : Scrollbar(client, orientation, size, theme) -{ -} - -} - diff --git a/WebCore/platform/win/PopupMenuWin.cpp b/WebCore/platform/win/PopupMenuWin.cpp index 44141f2..4bc6dc7 100644 --- a/WebCore/platform/win/PopupMenuWin.cpp +++ b/WebCore/platform/win/PopupMenuWin.cpp @@ -199,6 +199,7 @@ void PopupMenu::show(const IntRect& r, FrameView* view, int index) break; // Steal mouse messages. +#if !OS(WINCE) case WM_NCMOUSEMOVE: case WM_NCLBUTTONDOWN: case WM_NCLBUTTONUP: @@ -209,6 +210,7 @@ void PopupMenu::show(const IntRect& r, FrameView* view, int index) case WM_NCMBUTTONDOWN: case WM_NCMBUTTONUP: case WM_NCMBUTTONDBLCLK: +#endif case WM_MOUSEWHEEL: msg.hwnd = m_popup; break; @@ -578,7 +580,7 @@ void PopupMenu::paint(const IntRect& damageRect, HDC hdc) } if (!m_bmp) { #if OS(WINCE) - BitmapInfo bitmapInfo(true, clientRect().width(), clientRect().height()); + BitmapInfo bitmapInfo = BitmapInfo::createBottomUp(clientRect().size(), 16); #else BitmapInfo bitmapInfo = BitmapInfo::createBottomUp(clientRect().size()); #endif @@ -774,9 +776,10 @@ LRESULT PopupMenu::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam LRESULT lResult = 0; switch (message) { +#if !OS(WINCE) case WM_MOUSEACTIVATE: return MA_NOACTIVATE; - +#endif case WM_SIZE: { if (!scrollbar()) break; |