diff options
author | Ben Murdoch <benm@google.com> | 2009-08-11 17:01:47 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2009-08-11 18:21:02 +0100 |
commit | 0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5 (patch) | |
tree | 2943df35f62d885c89d01063cc528dd73b480fea /WebCore/platform/win | |
parent | 7e7a70bfa49a1122b2597a1e6367d89eb4035eca (diff) | |
download | external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.zip external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.tar.gz external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.tar.bz2 |
Merge in WebKit r47029.
Diffstat (limited to 'WebCore/platform/win')
-rw-r--r-- | WebCore/platform/win/BitmapInfo.cpp | 66 | ||||
-rw-r--r-- | WebCore/platform/win/BitmapInfo.h | 43 | ||||
-rw-r--r-- | WebCore/platform/win/ClipboardWin.cpp | 25 | ||||
-rw-r--r-- | WebCore/platform/win/ClipboardWin.h | 5 | ||||
-rw-r--r-- | WebCore/platform/win/CursorWin.cpp | 10 | ||||
-rw-r--r-- | WebCore/platform/win/DragImageCGWin.cpp | 13 | ||||
-rw-r--r-- | WebCore/platform/win/DragImageCairoWin.cpp | 11 | ||||
-rw-r--r-- | WebCore/platform/win/DragImageWin.cpp | 24 | ||||
-rw-r--r-- | WebCore/platform/win/FileSystemWin.cpp | 6 | ||||
-rw-r--r-- | WebCore/platform/win/LoggingWin.cpp | 2 | ||||
-rw-r--r-- | WebCore/platform/win/PasteboardWin.cpp | 14 | ||||
-rw-r--r-- | WebCore/platform/win/PlatformMouseEventWin.cpp | 5 | ||||
-rw-r--r-- | WebCore/platform/win/PlatformScreenWin.cpp | 14 | ||||
-rw-r--r-- | WebCore/platform/win/PopupMenuWin.cpp | 67 | ||||
-rw-r--r-- | WebCore/platform/win/SoftLinking.h | 17 | ||||
-rw-r--r-- | WebCore/platform/win/SystemTimeWin.cpp | 2 | ||||
-rw-r--r-- | WebCore/platform/win/WCDataObject.cpp | 7 | ||||
-rw-r--r-- | WebCore/platform/win/WheelEventWin.cpp | 25 | ||||
-rw-r--r-- | WebCore/platform/win/WindowMessageBroadcaster.h | 2 |
19 files changed, 283 insertions, 75 deletions
diff --git a/WebCore/platform/win/BitmapInfo.cpp b/WebCore/platform/win/BitmapInfo.cpp new file mode 100644 index 0000000..9a2312c --- /dev/null +++ b/WebCore/platform/win/BitmapInfo.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2009 Apple Inc. All Rights Reserved. + * Copyright (C) 2009 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 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 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 "BitmapInfo.h" + +namespace WebCore { + +BitmapInfo bitmapInfoForSize(int width, int height) +{ + BitmapInfo bitmapInfo; + bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bitmapInfo.bmiHeader.biWidth = width; + bitmapInfo.bmiHeader.biHeight = height; + bitmapInfo.bmiHeader.biPlanes = 1; + bitmapInfo.bmiHeader.biBitCount = 32; + bitmapInfo.bmiHeader.biCompression = BI_RGB; + bitmapInfo.bmiHeader.biSizeImage = 0; + bitmapInfo.bmiHeader.biXPelsPerMeter = 0; + bitmapInfo.bmiHeader.biYPelsPerMeter = 0; + bitmapInfo.bmiHeader.biClrUsed = 0; + bitmapInfo.bmiHeader.biClrImportant = 0; + + return bitmapInfo; +} + +BitmapInfo::BitmapInfo() +{ + memset(&bmiHeader, 0, sizeof(bmiHeader)); + bmiHeader.biSize = sizeof(BITMAPINFOHEADER); +} + +BitmapInfo BitmapInfo::create(const IntSize& size) +{ + return bitmapInfoForSize(size.width(), size.height()); +} + +BitmapInfo BitmapInfo::createBottomUp(const IntSize& size) +{ + return bitmapInfoForSize(size.width(), -size.height()); +} + +} // namespace WebCore diff --git a/WebCore/platform/win/BitmapInfo.h b/WebCore/platform/win/BitmapInfo.h new file mode 100644 index 0000000..0127fdb --- /dev/null +++ b/WebCore/platform/win/BitmapInfo.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2009 Apple Inc. All Rights Reserved. + * Copyright (C) 2009 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 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 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 BitmapInfo_h +#define BitmapInfo_h + +#include <windows.h> +#include "IntSize.h" + +namespace WebCore { + +struct BitmapInfo : public BITMAPINFO { + BitmapInfo (); + static BitmapInfo create(const IntSize&); + static BitmapInfo createBottomUp(const IntSize&); +}; + +} // namespace WebCore + +#endif // BitmapInfo_h diff --git a/WebCore/platform/win/ClipboardWin.cpp b/WebCore/platform/win/ClipboardWin.cpp index 7a88c3a..65741e4 100644 --- a/WebCore/platform/win/ClipboardWin.cpp +++ b/WebCore/platform/win/ClipboardWin.cpp @@ -34,12 +34,14 @@ #include "Editor.h" #include "Element.h" #include "EventHandler.h" +#include "FileList.h" #include "Frame.h" #include "FrameLoader.h" #include "FrameView.h" #include "HTMLNames.h" #include "Image.h" #include "MIMETypeRegistry.h" +#include "NotImplemented.h" #include "Page.h" #include "Pasteboard.h" #include "PlatformMouseEvent.h" @@ -580,6 +582,12 @@ HashSet<String> ClipboardWin::types() const return results; } +PassRefPtr<FileList> ClipboardWin::files() const +{ + notImplemented(); + return 0; +} + void ClipboardWin::setDragImage(CachedImage* image, Node *node, const IntPoint &loc) { if (policy() != ClipboardImageWritable && policy() != ClipboardWritable) @@ -608,10 +616,13 @@ void ClipboardWin::setDragImageElement(Node *node, const IntPoint &loc) DragImageRef ClipboardWin::createDragImage(IntPoint& loc) const { HBITMAP result = 0; - //FIXME: Need to be able to draw element <rdar://problem/5015942> if (m_dragImage) { result = createDragImageFromImage(m_dragImage->image()); loc = m_dragLoc; + } else if (m_dragImageElement) { + Node* node = m_dragImageElement.get(); + result = node->document()->frame()->nodeImage(node); + loc = m_dragLoc; } return result; } @@ -632,7 +643,7 @@ static CachedImage* getCachedImage(Element* element) if (!renderer || !renderer->isImage()) return 0; - RenderImage* image = static_cast<RenderImage*>(renderer); + RenderImage* image = toRenderImage(renderer); if (image->cachedImage() && !image->cachedImage()->errorOccurred()) return image->cachedImage(); @@ -683,7 +694,7 @@ void ClipboardWin::declareAndWriteDragImage(Element* element, const KURL& url, c if (imageURL.isEmpty()) return; - String fullURL = frame->document()->completeURL(parseURL(imageURL)).string(); + String fullURL = frame->document()->completeURL(deprecatedParseURL(imageURL)).string(); if (fullURL.isEmpty()) return; STGMEDIUM medium = {0}; @@ -769,4 +780,12 @@ bool ClipboardWin::hasData() return false; } +void ClipboardWin::setExternalDataObject(IDataObject *dataObject) +{ + ASSERT(isForDragging()); + + m_writableDataObject = 0; + m_dataObject = dataObject; +} + } // namespace WebCore diff --git a/WebCore/platform/win/ClipboardWin.h b/WebCore/platform/win/ClipboardWin.h index 01f7332..6e60254 100644 --- a/WebCore/platform/win/ClipboardWin.h +++ b/WebCore/platform/win/ClipboardWin.h @@ -57,7 +57,8 @@ namespace WebCore { bool setData(const String& type, const String& data); // extensions beyond IE's API - HashSet<String> types() const; + virtual HashSet<String> types() const; + virtual PassRefPtr<FileList> files() const; void setDragImage(CachedImage*, const IntPoint&); void setDragImageElement(Node*, const IntPoint&); @@ -71,6 +72,8 @@ namespace WebCore { COMPtr<IDataObject> dataObject() { return m_dataObject; } + void setExternalDataObject(IDataObject *dataObject); + private: ClipboardWin(bool isForDragging, IDataObject*, ClipboardAccessPolicy); ClipboardWin(bool isForDragging, WCDataObject*, ClipboardAccessPolicy); diff --git a/WebCore/platform/win/CursorWin.cpp b/WebCore/platform/win/CursorWin.cpp index e91e86b..2bfe7a8 100644 --- a/WebCore/platform/win/CursorWin.cpp +++ b/WebCore/platform/win/CursorWin.cpp @@ -27,6 +27,7 @@ #include "config.h" #include "Cursor.h" +#include "BitmapInfo.h" #include "Image.h" #include "IntPoint.h" @@ -54,13 +55,8 @@ static inline bool supportsAlphaCursors() Cursor::Cursor(Image* img, const IntPoint& hotspot) { static bool doAlpha = supportsAlphaCursors(); - BITMAPINFO cursorImage = {0}; - cursorImage.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - cursorImage.bmiHeader.biWidth = img->width(); - cursorImage.bmiHeader.biHeight = img->height(); - cursorImage.bmiHeader.biPlanes = 1; - cursorImage.bmiHeader.biBitCount = 32; - cursorImage.bmiHeader.biCompression = BI_RGB; + BitmapInfo cursorImage = BitmapInfo::create(IntSize(img->width(), img->height())); + HDC dc = GetDC(0); HDC workingDC = CreateCompatibleDC(dc); if (doAlpha) { diff --git a/WebCore/platform/win/DragImageCGWin.cpp b/WebCore/platform/win/DragImageCGWin.cpp index 77b358b..ffd2162 100644 --- a/WebCore/platform/win/DragImageCGWin.cpp +++ b/WebCore/platform/win/DragImageCGWin.cpp @@ -26,6 +26,7 @@ #include "config.h" #include "DragImage.h" +#include "BitmapInfo.h" #include "CachedImage.h" #include "GraphicsContext.h" #include "Image.h" @@ -44,16 +45,10 @@ void deallocContext(CGContextRef target) HBITMAP allocImage(HDC dc, IntSize size, CGContextRef *targetRef) { - HBITMAP hbmp; - BITMAPINFO bmpInfo = {0}; - bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bmpInfo.bmiHeader.biWidth = size.width(); - bmpInfo.bmiHeader.biHeight = size.height(); - bmpInfo.bmiHeader.biPlanes = 1; - bmpInfo.bmiHeader.biBitCount = 32; - bmpInfo.bmiHeader.biCompression = BI_RGB; + BitmapInfo bmpInfo = BitmapInfo::create(size); + LPVOID bits; - hbmp = CreateDIBSection(dc, &bmpInfo, DIB_RGB_COLORS, &bits, 0, 0); + HBITMAP hbmp = CreateDIBSection(dc, &bmpInfo, DIB_RGB_COLORS, &bits, 0, 0); if (!targetRef) return hbmp; diff --git a/WebCore/platform/win/DragImageCairoWin.cpp b/WebCore/platform/win/DragImageCairoWin.cpp index 1b8fb06..e356575 100644 --- a/WebCore/platform/win/DragImageCairoWin.cpp +++ b/WebCore/platform/win/DragImageCairoWin.cpp @@ -26,6 +26,7 @@ #include "config.h" #include "DragImage.h" +#include "BitmapInfo.h" #include "CachedImage.h" #include "GraphicsContext.h" #include "Image.h" @@ -49,15 +50,7 @@ void deallocContext(CairoContextRef target) HBITMAP allocImage(HDC dc, IntSize size, CairoContextRef* targetRef) { - BITMAPINFO bmpInfo = {0}; - bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bmpInfo.bmiHeader.biWidth = size.width(); - bmpInfo.bmiHeader.biHeight = size.height(); // Must be positive! - bmpInfo.bmiHeader.biPlanes = 1; - bmpInfo.bmiHeader.biBitCount = 32; - bmpInfo.bmiHeader.biCompression = BI_RGB; - bmpInfo.bmiHeader.biClrUsed = 0; // unused - bmpInfo.bmiHeader.biClrImportant = 0; + BitmapInfo bmpInfo = BitmapInfo::create(size); LPVOID bits; HBITMAP hbmp = CreateDIBSection(dc, &bmpInfo, DIB_RGB_COLORS, &bits, 0, 0); diff --git a/WebCore/platform/win/DragImageWin.cpp b/WebCore/platform/win/DragImageWin.cpp index 46146b3..135e9d0 100644 --- a/WebCore/platform/win/DragImageWin.cpp +++ b/WebCore/platform/win/DragImageWin.cpp @@ -56,10 +56,28 @@ DragImageRef dissolveDragImageToFraction(DragImageRef image, float) return image; } -DragImageRef createDragImageIconForCachedImage(CachedImage*) +DragImageRef createDragImageIconForCachedImage(CachedImage* image) { - //FIXME: Provide icon for image type <rdar://problem/5015949> - return 0; + if (!image) + return 0; + + String filename = image->response().suggestedFilename(); + + SHFILEINFO shfi = {0}; + if (FAILED(SHGetFileInfo(static_cast<LPCWSTR>(filename.charactersWithNullTermination()), FILE_ATTRIBUTE_NORMAL, + &shfi, sizeof(shfi), SHGFI_ICON | SHGFI_USEFILEATTRIBUTES))) + return 0; + + ICONINFO iconInfo; + if (!GetIconInfo(shfi.hIcon, &iconInfo)) { + DestroyIcon(shfi.hIcon); + return 0; + } + + DestroyIcon(shfi.hIcon); + DeleteObject(iconInfo.hbmMask); + + return iconInfo.hbmColor; } } diff --git a/WebCore/platform/win/FileSystemWin.cpp b/WebCore/platform/win/FileSystemWin.cpp index 746fceb..a676f87 100644 --- a/WebCore/platform/win/FileSystemWin.cpp +++ b/WebCore/platform/win/FileSystemWin.cpp @@ -133,8 +133,10 @@ String pathGetFileName(const String& path) String directoryName(const String& path) { - notImplemented(); - return String(); + String fileName = pathGetFileName(path); + String dirName = String(path); + dirName.truncate(dirName.length() - pathGetFileName(path).length()); + return dirName; } static String bundleName() diff --git a/WebCore/platform/win/LoggingWin.cpp b/WebCore/platform/win/LoggingWin.cpp index bb0e4f4..bdf9e1f 100644 --- a/WebCore/platform/win/LoggingWin.cpp +++ b/WebCore/platform/win/LoggingWin.cpp @@ -93,7 +93,7 @@ void InitializeLoggingChannelsIfNecessary() initializeWithUserDefault(LogThreading); initializeWithUserDefault(LogStorageAPI); initializeWithUserDefault(LogMedia); - initializeWithUserDefault(LogPlugin); + initializeWithUserDefault(LogPlugins); initializeWithUserDefault(LogArchives); } diff --git a/WebCore/platform/win/PasteboardWin.cpp b/WebCore/platform/win/PasteboardWin.cpp index 8cf9bf2..188630f 100644 --- a/WebCore/platform/win/PasteboardWin.cpp +++ b/WebCore/platform/win/PasteboardWin.cpp @@ -26,6 +26,7 @@ #include "config.h" #include "Pasteboard.h" +#include "BitmapInfo.h" #include "CString.h" #include "ClipboardUtilitiesWin.h" #include "Document.h" @@ -187,8 +188,8 @@ void Pasteboard::writeURL(const KURL& url, const String& titleStr, Frame* frame) void Pasteboard::writeImage(Node* node, const KURL&, const String&) { ASSERT(node && node->renderer() && node->renderer()->isImage()); - RenderImage* renderer = static_cast<RenderImage*>(node->renderer()); - CachedImage* cachedImage = static_cast<CachedImage*>(renderer->cachedImage()); + RenderImage* renderer = toRenderImage(node->renderer()); + CachedImage* cachedImage = renderer->cachedImage(); ASSERT(cachedImage); Image* image = cachedImage->image(); ASSERT(image); @@ -201,13 +202,8 @@ void Pasteboard::writeImage(Node* node, const KURL&, const String&) HBITMAP resultBitmap = CreateCompatibleBitmap(dc, image->width(), image->height()); HBITMAP oldBitmap = (HBITMAP)SelectObject(compatibleDC, resultBitmap); - BITMAPINFO bmInfo = {0}; - bmInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bmInfo.bmiHeader.biWidth = image->width(); - bmInfo.bmiHeader.biHeight = image->height(); - bmInfo.bmiHeader.biPlanes = 1; - bmInfo.bmiHeader.biBitCount = 32; - bmInfo.bmiHeader.biCompression = BI_RGB; + BitmapInfo bmInfo = BitmapInfo::create(image->size()); + HBITMAP coreBitmap = CreateDIBSection(dc, &bmInfo, DIB_RGB_COLORS, 0, 0, 0); HBITMAP oldSource = (HBITMAP)SelectObject(sourceDC, coreBitmap); image->getHBITMAP(coreBitmap); diff --git a/WebCore/platform/win/PlatformMouseEventWin.cpp b/WebCore/platform/win/PlatformMouseEventWin.cpp index 7110b39..e9c0e3e 100644 --- a/WebCore/platform/win/PlatformMouseEventWin.cpp +++ b/WebCore/platform/win/PlatformMouseEventWin.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007-2008 Torch Mobile Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -63,7 +64,9 @@ static MouseEventType messageToEventType(UINT message) case WM_MBUTTONUP: return MouseEventReleased; +#if !PLATFORM(WINCE) case WM_MOUSELEAVE: +#endif case WM_MOUSEMOVE: return MouseEventMoved; @@ -104,7 +107,9 @@ PlatformMouseEvent::PlatformMouseEvent(HWND hWnd, UINT message, WPARAM wParam, L m_button = MiddleButton; break; case WM_MOUSEMOVE: +#if !PLATFORM(WINCE) case WM_MOUSELEAVE: +#endif if (wParam & MK_LBUTTON) m_button = LeftButton; else if (wParam & MK_MBUTTON) diff --git a/WebCore/platform/win/PlatformScreenWin.cpp b/WebCore/platform/win/PlatformScreenWin.cpp index 56c8139..7ac4706 100644 --- a/WebCore/platform/win/PlatformScreenWin.cpp +++ b/WebCore/platform/win/PlatformScreenWin.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2009 Torch Mobile, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -49,12 +50,16 @@ static MONITORINFOEX monitorInfoForWidget(Widget* widget) static DEVMODE deviceInfoForWidget(Widget* widget) { - MONITORINFOEX monitorInfo = monitorInfoForWidget(widget); - DEVMODE deviceInfo; deviceInfo.dmSize = sizeof(DEVMODE); deviceInfo.dmDriverExtra = 0; +#if PLATFORM(WINCE) + if (!EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &deviceInfo)) + deviceInfo.dmBitsPerPel = 16; +#else + MONITORINFOEX monitorInfo = monitorInfoForWidget(widget); EnumDisplaySettings(monitorInfo.szDevice, ENUM_CURRENT_SETTINGS, &deviceInfo); +#endif return deviceInfo; } @@ -74,8 +79,13 @@ int screenDepthPerComponent(Widget* widget) bool screenIsMonochrome(Widget* widget) { +#if PLATFORM(WINCE) + // EnumDisplaySettings doesn't set dmColor in DEVMODE. + return false; +#else DEVMODE deviceInfo = deviceInfoForWidget(widget); return deviceInfo.dmColor == DMCOLOR_MONOCHROME; +#endif } FloatRect screenRect(Widget* widget) diff --git a/WebCore/platform/win/PopupMenuWin.cpp b/WebCore/platform/win/PopupMenuWin.cpp index 2b4749a..e53053f 100644 --- a/WebCore/platform/win/PopupMenuWin.cpp +++ b/WebCore/platform/win/PopupMenuWin.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2007-2009 Torch Mobile Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -21,6 +22,7 @@ #include "config.h" #include "PopupMenu.h" +#include "BitmapInfo.h" #include "Document.h" #include "FloatRect.h" #include "FontSelector.h" @@ -38,6 +40,10 @@ #include "SimpleFontData.h" #include <tchar.h> #include <windows.h> +#if PLATFORM(WINCE) +#include <ResDefCE.h> +#define MAKEPOINTS(l) (*((POINTS FAR *)&(l))) +#endif using std::min; @@ -83,7 +89,7 @@ PopupMenu::~PopupMenu() if (m_bmp) ::DeleteObject(m_bmp); if (m_DC) - ::DeleteObject(m_DC); + ::DeleteDC(m_DC); if (m_popup) ::DestroyWindow(m_popup); } @@ -109,7 +115,11 @@ void PopupMenu::show(const IntRect& r, FrameView* v, int index) if (!m_popup) return; +#if PLATFORM(WINCE) + ::SetWindowLong(m_popup, 0, (LONG)this); +#else ::SetWindowLongPtr(m_popup, 0, (LONG_PTR)this); +#endif } if (!m_scrollbar) @@ -123,6 +133,7 @@ void PopupMenu::show(const IntRect& r, FrameView* v, int index) // Determine whether we should animate our popups // Note: Must use 'BOOL' and 'FALSE' instead of 'bool' and 'false' to avoid stack corruption with SystemParametersInfo BOOL shouldAnimate = FALSE; +#if !PLATFORM(WINCE) ::SystemParametersInfo(SPI_GETCOMBOBOXANIMATION, 0, &shouldAnimate, 0); if (shouldAnimate) { @@ -137,6 +148,7 @@ void PopupMenu::show(const IntRect& r, FrameView* v, int index) ::AnimateWindow(m_popup, defaultAnimationDuration, AW_SLIDE | slideDirection | AW_ACTIVATE); } } else +#endif ::ShowWindow(m_popup, SW_SHOWNORMAL); ::SetCapture(m_popup); @@ -451,19 +463,11 @@ void PopupMenu::paint(const IntRect& damageRect, HDC hdc) } } if (!m_bmp) { - BITMAPINFO bitmapInfo; - bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bitmapInfo.bmiHeader.biWidth = clientRect().width(); - bitmapInfo.bmiHeader.biHeight = -clientRect().height(); - bitmapInfo.bmiHeader.biPlanes = 1; - bitmapInfo.bmiHeader.biBitCount = 32; - bitmapInfo.bmiHeader.biCompression = BI_RGB; - bitmapInfo.bmiHeader.biSizeImage = 0; - bitmapInfo.bmiHeader.biXPelsPerMeter = 0; - bitmapInfo.bmiHeader.biYPelsPerMeter = 0; - bitmapInfo.bmiHeader.biClrUsed = 0; - bitmapInfo.bmiHeader.biClrImportant = 0; - +#if PLATFORM(WINCE) + BitmapInfo bitmapInfo(true, clientRect().width(), clientRect().height()); +#else + BitmapInfo bitmapInfo = BitmapInfo::createBottomUp(clientRect().size()); +#endif void* pixels = 0; m_bmp = ::CreateDIBSection(m_DC, &bitmapInfo, DIB_RGB_COLORS, &pixels, 0, 0); if (!m_bmp) @@ -486,8 +490,8 @@ void PopupMenu::paint(const IntRect& damageRect, HDC hdc) Color optionBackgroundColor, optionTextColor; PopupMenuStyle itemStyle = client()->itemStyle(index); if (index == focusedIndex()) { - optionBackgroundColor = theme()->activeListBoxSelectionBackgroundColor(); - optionTextColor = theme()->activeListBoxSelectionForegroundColor(); + optionBackgroundColor = RenderTheme::defaultTheme()->activeListBoxSelectionBackgroundColor(); + optionTextColor = RenderTheme::defaultTheme()->activeListBoxSelectionForegroundColor(); } else { optionBackgroundColor = itemStyle.backgroundColor(); optionTextColor = itemStyle.foregroundColor(); @@ -525,7 +529,7 @@ void PopupMenu::paint(const IntRect& damageRect, HDC hdc) // Draw the item text if (itemStyle.isVisible()) { int textX = max(0, client()->clientPaddingLeft() - client()->clientInsetLeft()); - if (theme()->popupOptionSupportsTextIndent() && itemStyle.textDirection() == LTR) + if (RenderTheme::defaultTheme()->popupOptionSupportsTextIndent() && itemStyle.textDirection() == LTR) textX += itemStyle.textIndent().calcMinValue(itemRect.width()); int textY = itemRect.y() + itemFont.ascent() + (itemRect.height() - itemFont.height()) / 2; context.drawBidiText(itemFont, textRun, IntPoint(textX, textY)); @@ -535,10 +539,12 @@ void PopupMenu::paint(const IntRect& damageRect, HDC hdc) if (m_scrollbar) m_scrollbar->paint(&context, damageRect); - if (!hdc) - hdc = ::GetDC(m_popup); + HDC localDC = hdc ? hdc : ::GetDC(m_popup); + + ::BitBlt(localDC, damageRect.x(), damageRect.y(), damageRect.width(), damageRect.height(), m_DC, damageRect.x(), damageRect.y(), SRCCOPY); - ::BitBlt(hdc, damageRect.x(), damageRect.y(), damageRect.width(), damageRect.height(), m_DC, damageRect.x(), damageRect.y(), SRCCOPY); + if (!hdc) + ::ReleaseDC(m_popup, localDC); } void PopupMenu::valueChanged(Scrollbar* scrollBar) @@ -592,11 +598,15 @@ static ATOM registerPopup() if (haveRegisteredWindowClass) return true; +#if PLATFORM(WINCE) + WNDCLASS wcex; +#else WNDCLASSEX wcex; - wcex.cbSize = sizeof(WNDCLASSEX); - + wcex.hIconSm = 0; wcex.style = CS_DROPSHADOW; +#endif + wcex.lpfnWndProc = PopupWndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = sizeof(PopupMenu*); // For the PopupMenu pointer @@ -606,18 +616,25 @@ static ATOM registerPopup() wcex.hbrBackground = 0; wcex.lpszMenuName = 0; wcex.lpszClassName = kPopupWindowClassName; - wcex.hIconSm = 0; haveRegisteredWindowClass = true; +#if PLATFORM(WINCE) + return ::RegisterClass(&wcex); +#else return ::RegisterClassEx(&wcex); +#endif } const int smoothScrollAnimationDuration = 5000; static LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { LRESULT lResult = 0; +#if PLATFORM(WINCE) + LONG longPtr = GetWindowLong(hWnd, 0); +#else LONG_PTR longPtr = GetWindowLongPtr(hWnd, 0); +#endif PopupMenu* popup = reinterpret_cast<PopupMenu*>(longPtr); switch (message) { @@ -734,7 +751,9 @@ static LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT message, WPARAM wParam, LPA } BOOL shouldHotTrack = FALSE; +#if !PLATFORM(WINCE) ::SystemParametersInfo(SPI_GETHOTTRACKING, 0, &shouldHotTrack, 0); +#endif RECT bounds; GetClientRect(popup->popupHandle(), &bounds); @@ -819,10 +838,12 @@ static LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT message, WPARAM wParam, LPA lResult = 0; } break; +#if !PLATFORM(WINCE) case WM_PRINTCLIENT: if (popup) popup->paint(popup->clientRect(), (HDC)wParam); break; +#endif default: lResult = DefWindowProc(hWnd, message, wParam, lParam); } diff --git a/WebCore/platform/win/SoftLinking.h b/WebCore/platform/win/SoftLinking.h index 761cb7a..bb06672 100644 --- a/WebCore/platform/win/SoftLinking.h +++ b/WebCore/platform/win/SoftLinking.h @@ -49,7 +49,7 @@ \ static resultType callingConvention init##functionName parameterDeclarations \ { \ - softLink##functionName = (resultType (callingConvention*) parameterDeclarations) GetProcAddress(library##Library(), #functionName); \ + softLink##functionName = reinterpret_cast<resultType (callingConvention*) parameterDeclarations>(GetProcAddress(library##Library(), #functionName)); \ ASSERT(softLink##functionName); \ return softLink##functionName parameterNames; \ }\ @@ -59,4 +59,19 @@ return softLink##functionName parameterNames; \ } +#define SOFT_LINK_OPTIONAL(library, functionName, resultType, callingConvention, parameterDeclarations) \ + typedef resultType (callingConvention *functionName##PtrType) parameterDeclarations; \ + static functionName##PtrType functionName##Ptr() \ + { \ + static functionName##PtrType ptr; \ + static bool initialized; \ + \ + if (initialized) \ + return ptr; \ + initialized = true; \ + \ + ptr = reinterpret_cast<functionName##PtrType>(GetProcAddress(library##Library(), #functionName)); \ + return ptr; \ + }\ + #endif // SoftLinking_h diff --git a/WebCore/platform/win/SystemTimeWin.cpp b/WebCore/platform/win/SystemTimeWin.cpp index 88ea145..6ab4c27 100644 --- a/WebCore/platform/win/SystemTimeWin.cpp +++ b/WebCore/platform/win/SystemTimeWin.cpp @@ -37,7 +37,7 @@ namespace WebCore { float userIdleTime() { -#if !PLATFORM(WIN_CE) +#if !PLATFORM(WINCE) LASTINPUTINFO lastInputInfo = {0}; lastInputInfo.cbSize = sizeof(LASTINPUTINFO); if (::GetLastInputInfo(&lastInputInfo)) diff --git a/WebCore/platform/win/WCDataObject.cpp b/WebCore/platform/win/WCDataObject.cpp index 5201bfa..aaa41cf 100644 --- a/WebCore/platform/win/WCDataObject.cpp +++ b/WebCore/platform/win/WCDataObject.cpp @@ -74,8 +74,7 @@ WCEnumFormatEtc::WCEnumFormatEtc(const Vector<FORMATETC*>& formats) STDMETHODIMP WCEnumFormatEtc::QueryInterface(REFIID riid, void** ppvObject) { *ppvObject = 0; - if (IsEqualIID(riid, IID_IUnknown) || - IsEqualIID(riid, IID_IEnumFORMATETC)) { + if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IEnumFORMATETC)) { *ppvObject = this; AddRef(); return S_OK; @@ -178,8 +177,10 @@ WCDataObject::~WCDataObject() STDMETHODIMP WCDataObject::QueryInterface(REFIID riid,void** ppvObject) { *ppvObject = 0; - if (IID_IUnknown==riid || IID_IDataObject==riid) + if (IsEqualIID(riid, IID_IUnknown) || + IsEqualIID(riid, IID_IDataObject)) { *ppvObject=this; + } if (*ppvObject) { AddRef(); return S_OK; diff --git a/WebCore/platform/win/WheelEventWin.cpp b/WebCore/platform/win/WheelEventWin.cpp index e6670a4..3fb8118 100644 --- a/WebCore/platform/win/WheelEventWin.cpp +++ b/WebCore/platform/win/WheelEventWin.cpp @@ -23,8 +23,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" #include "PlatformWheelEvent.h" +#include "FloatPoint.h" +#include "FloatSize.h" #include <windows.h> #include <windowsx.h> @@ -62,6 +65,28 @@ static int verticalScrollLines() return scrollLines; } +PlatformWheelEvent::PlatformWheelEvent(HWND hWnd, const FloatSize& delta, const FloatPoint& location) + : m_isAccepted(false) + , m_shiftKey(false) + , m_ctrlKey(false) + , m_altKey(false) + , m_metaKey(false) +{ + m_deltaX = delta.width(); + m_deltaY = delta.height(); + + m_wheelTicksX = m_deltaX; + m_wheelTicksY = m_deltaY; + + // Global Position is just x, y location of event + POINT point = {location.x(), location.y()}; + m_globalPosition = point; + + // Position needs to be translated to our client + ScreenToClient(hWnd, &point); + m_position = point; +} + PlatformWheelEvent::PlatformWheelEvent(HWND hWnd, WPARAM wParam, LPARAM lParam, bool isMouseHWheel) : m_position(positionForEvent(hWnd, lParam)) , m_globalPosition(globalPositionForEvent(hWnd, lParam)) diff --git a/WebCore/platform/win/WindowMessageBroadcaster.h b/WebCore/platform/win/WindowMessageBroadcaster.h index 734f4b1..e7856e7 100644 --- a/WebCore/platform/win/WindowMessageBroadcaster.h +++ b/WebCore/platform/win/WindowMessageBroadcaster.h @@ -37,7 +37,7 @@ namespace WebCore { class WindowMessageListener; - class WindowMessageBroadcaster : Noncopyable { + class WindowMessageBroadcaster : public Noncopyable { public: static void addListener(HWND, WindowMessageListener*); static void removeListener(HWND, WindowMessageListener*); |