diff options
author | Ben Murdoch <benm@google.com> | 2011-06-02 12:07:03 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-06-10 10:47:21 +0100 |
commit | 2daae5fd11344eaa88a0d92b0f6d65f8d2255c00 (patch) | |
tree | e4964fbd1cb70599f7718ff03e50ea1dab33890b /Source/WebCore/platform/win | |
parent | 87bdf0060a247bfbe668342b87e0874182e0ffa9 (diff) | |
download | external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.zip external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.gz external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.bz2 |
Merge WebKit at r84325: Initial merge by git.
Change-Id: Ic1a909300ecc0a13ddc6b4e784371d2ac6e3d59b
Diffstat (limited to 'Source/WebCore/platform/win')
-rw-r--r-- | Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp | 2 | ||||
-rw-r--r-- | Source/WebCore/platform/win/ClipboardWin.cpp | 2 | ||||
-rw-r--r-- | Source/WebCore/platform/win/DragImageCairoWin.cpp | 51 | ||||
-rw-r--r-- | Source/WebCore/platform/win/FileSystemWin.cpp | 9 | ||||
-rw-r--r-- | Source/WebCore/platform/win/LocalizedStringsWin.cpp | 54 | ||||
-rw-r--r-- | Source/WebCore/platform/win/LoggingWin.cpp | 3 | ||||
-rw-r--r-- | Source/WebCore/platform/win/PopupMenuWin.h | 4 | ||||
-rw-r--r-- | Source/WebCore/platform/win/WindowsTouch.h | 112 |
8 files changed, 205 insertions, 32 deletions
diff --git a/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp b/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp index 33d8ccd..7bd97d6 100644 --- a/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp +++ b/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp @@ -444,7 +444,7 @@ String getURL(const DragDataMap* data, DragData::FilenameConversionPolicy filena if (stringData.isEmpty() || (!PathFileExists(stringData.charactersWithNullTermination()) && !PathIsUNC(stringData.charactersWithNullTermination()))) return url; - RetainPtr<CFStringRef> pathAsCFString(AdoptCF, CFStringCreateWithCharacters(kCFAllocatorDefault, (const UniChar *)stringData.charactersWithNullTermination(), stringData.length())); + RetainPtr<CFStringRef> pathAsCFString(AdoptCF, CFStringCreateWithCharacters(kCFAllocatorDefault, (const UniChar *)stringData.charactersWithNullTermination(), wcslen(stringData.charactersWithNullTermination()))); if (urlFromPath(pathAsCFString.get(), url) && title) *title = url; #endif diff --git a/Source/WebCore/platform/win/ClipboardWin.cpp b/Source/WebCore/platform/win/ClipboardWin.cpp index 791ec86..0b5a3d3 100644 --- a/Source/WebCore/platform/win/ClipboardWin.cpp +++ b/Source/WebCore/platform/win/ClipboardWin.cpp @@ -703,7 +703,6 @@ void ClipboardWin::declareAndWriteDragImage(Element* element, const KURL& url, c return; STGMEDIUM medium = {0}; medium.tymed = TYMED_HGLOBAL; - ExceptionCode ec = 0; // Put img tag on the clipboard referencing the image Vector<char> data; @@ -791,7 +790,6 @@ void ClipboardWin::writePlainText(const String& text) STGMEDIUM medium = {0}; medium.tymed = TYMED_HGLOBAL; - ExceptionCode ec = 0; String str = text; replaceNewlinesWithWindowsStyleNewlines(str); diff --git a/Source/WebCore/platform/win/DragImageCairoWin.cpp b/Source/WebCore/platform/win/DragImageCairoWin.cpp index e356575..a67a82c 100644 --- a/Source/WebCore/platform/win/DragImageCairoWin.cpp +++ b/Source/WebCore/platform/win/DragImageCairoWin.cpp @@ -29,26 +29,20 @@ #include "BitmapInfo.h" #include "CachedImage.h" #include "GraphicsContext.h" +#include "GraphicsContextPlatformPrivateCairo.h" #include "Image.h" #include "RetainPtr.h" - #include <cairo-win32.h> -#include "GraphicsContextPlatformPrivateCairo.h" - #include <windows.h> -extern "C" { -typedef struct _cairo* CairoContextRef; -} - namespace WebCore { -void deallocContext(CairoContextRef target) +void deallocContext(PlatformContextCairo* target) { - cairo_destroy(target); + delete target; } -HBITMAP allocImage(HDC dc, IntSize size, CairoContextRef* targetRef) +HBITMAP allocImage(HDC dc, IntSize size, PlatformContextCairo** targetRef) { BitmapInfo bmpInfo = BitmapInfo::create(size); @@ -72,8 +66,8 @@ HBITMAP allocImage(HDC dc, IntSize size, CairoContextRef* targetRef) return 0; } - *targetRef = cairo_create (bitmapContext); - cairo_surface_destroy (bitmapContext); + cairo_t* cr = cairo_create(bitmapContext); + cairo_surface_destroy(bitmapContext); // At this point, we have a Cairo surface that points to a Windows DIB. The DIB interprets // with the opposite meaning of positive Y axis, so everything we draw into this cairo @@ -83,7 +77,10 @@ HBITMAP allocImage(HDC dc, IntSize size, CairoContextRef* targetRef) // before they get written to the internal buffer. cairo_matrix_t matrix; cairo_matrix_init(&matrix, 1.0, 0.0, 0.0, -1.0, 0.0, size.height()); - cairo_set_matrix(*targetRef, &matrix); + cairo_set_matrix(cr, &matrix); + + *targetRef = new PlatformGraphicsContext(cr); + cairo_destroy(cr); return hbmp; } @@ -121,7 +118,7 @@ DragImageRef scaleDragImage(DragImageRef image, FloatSize scale) if (!dstDC) goto exit; - CairoContextRef targetContext; + PlatformContextCairo* targetContext; hbmp = allocImage(dstDC, dstSize, &targetContext); if (!hbmp) goto exit; @@ -131,15 +128,16 @@ DragImageRef scaleDragImage(DragImageRef image, FloatSize scale) // Scale the target surface to the new image size, and flip it // so that when we set the srcImage as the surface it will draw // right-side-up. - cairo_translate(targetContext, 0, dstSize.height()); - cairo_scale(targetContext, scale.width(), -scale.height()); - cairo_set_source_surface (targetContext, srcImage, 0.0, 0.0); + cairo_t* cr = targetContext->cr(); + cairo_translate(cr, 0, dstSize.height()); + cairo_scale(cr, scale.width(), -scale.height()); + cairo_set_source_surface(cr, srcImage, 0.0, 0.0); // Now we can paint and get the correct result - cairo_paint(targetContext); + cairo_paint(cr); - cairo_surface_destroy (srcImage); - cairo_destroy(targetContext); + cairo_surface_destroy(srcImage); + deallocContext(targetContext); ::DeleteObject(image); image = 0; @@ -160,7 +158,7 @@ DragImageRef createDragImageFromImage(Image* img) if (!workingDC) goto exit; - CairoContextRef drawContext = 0; + PlatformContextCairo* drawContext = 0; hbmp = allocImage(workingDC, img->size(), &drawContext); if (!hbmp) goto exit; @@ -170,16 +168,17 @@ DragImageRef createDragImageFromImage(Image* img) hbmp = 0; } - cairo_set_source_rgb (drawContext, 1.0, 0.0, 1.0); - cairo_fill_preserve (drawContext); + cairo_t* cr = drawContext->cr(); + cairo_set_source_rgb(cr, 1.0, 0.0, 1.0); + cairo_fill_preserve(cr); cairo_surface_t* srcImage = img->nativeImageForCurrentFrame(); // Draw the image. - cairo_set_source_surface(drawContext, srcImage, 0.0, 0.0); - cairo_paint(drawContext); + cairo_set_source_surface(cr, srcImage, 0.0, 0.0); + cairo_paint(cr); - cairo_destroy (drawContext); + deallocContext(drawContext); exit: if (workingDC) diff --git a/Source/WebCore/platform/win/FileSystemWin.cpp b/Source/WebCore/platform/win/FileSystemWin.cpp index 03a2eaf..7d1c8f2 100644 --- a/Source/WebCore/platform/win/FileSystemWin.cpp +++ b/Source/WebCore/platform/win/FileSystemWin.cpp @@ -136,7 +136,12 @@ String pathGetFileName(const String& path) String directoryName(const String& path) { - return path.left(path.length() - pathGetFileName(path).length()); + String name = path.left(path.length() - pathGetFileName(path).length()); + if (name.characterStartingAt(name.length() - 1) == '\\') { + // Remove any trailing "\". + name.truncate(name.length() - 1); + } + return name; } static String bundleName() @@ -241,9 +246,11 @@ PlatformFileHandle openFile(const String& path, FileOpenMode mode) case OpenForRead: desiredAccess = GENERIC_READ; creationDisposition = OPEN_EXISTING; + break; case OpenForWrite: desiredAccess = GENERIC_WRITE; creationDisposition = CREATE_ALWAYS; + break; default: ASSERT_NOT_REACHED(); } diff --git a/Source/WebCore/platform/win/LocalizedStringsWin.cpp b/Source/WebCore/platform/win/LocalizedStringsWin.cpp index 67de0fc..c079441 100644 --- a/Source/WebCore/platform/win/LocalizedStringsWin.cpp +++ b/Source/WebCore/platform/win/LocalizedStringsWin.cpp @@ -26,14 +26,66 @@ #include "config.h" #include "LocalizedStrings.h" +#include "WebCoreInstanceHandle.h" +#include <wtf/Assertions.h> +#include <wtf/StdLibExtras.h> +#include <wtf/Threading.h> #include <wtf/text/WTFString.h> +#if USE(CF) +#include <CoreFoundation/CFBundle.h> +#include <wtf/RetainPtr.h> +#endif + namespace WebCore { +#if USE(CF) + +static CFBundleRef createWebKitBundle() +{ + if (CFBundleRef existingBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.WebKit"))) { + CFRetain(existingBundle); + return existingBundle; + } + + wchar_t dllPathBuffer[MAX_PATH]; + DWORD length = ::GetModuleFileNameW(instanceHandle(), dllPathBuffer, WTF_ARRAY_LENGTH(dllPathBuffer)); + ASSERT(length); + ASSERT(length < WTF_ARRAY_LENGTH(dllPathBuffer)); + + RetainPtr<CFStringRef> dllPath(AdoptCF, CFStringCreateWithCharactersNoCopy(0, reinterpret_cast<const UniChar*>(dllPathBuffer), length, kCFAllocatorNull)); + RetainPtr<CFURLRef> dllURL(AdoptCF, CFURLCreateWithFileSystemPath(0, dllPath.get(), kCFURLWindowsPathStyle, false)); + RetainPtr<CFURLRef> dllDirectoryURL(AdoptCF, CFURLCreateCopyDeletingLastPathComponent(0, dllURL.get())); + RetainPtr<CFURLRef> resourcesDirectoryURL(AdoptCF, CFURLCreateCopyAppendingPathComponent(0, dllDirectoryURL.get(), CFSTR("WebKit.resources"), true)); + + return CFBundleCreate(0, resourcesDirectoryURL.get()); +} + +static CFBundleRef webKitBundle() +{ + static CFBundleRef bundle = createWebKitBundle(); + ASSERT(bundle); + return bundle; +} + +#endif // USE(CF) + String localizedString(const char* key) { - // FIXME: <rdar://problem/9119405> Win: WebKit2 needs to be made localizable + ASSERT(isMainThread()); + +#if USE(CF) + static CFStringRef notFound = CFSTR("localized string not found"); + + RetainPtr<CFStringRef> keyString(AdoptCF, CFStringCreateWithCStringNoCopy(NULL, key, kCFStringEncodingUTF8, kCFAllocatorNull)); + RetainPtr<CFStringRef> result(AdoptCF, CFCopyLocalizedStringWithDefaultValue(keyString.get(), 0, webKitBundle(), notFound, 0)); + ASSERT_WITH_MESSAGE(result.get() != notFound, "could not find localizable string %s in bundle", key); + + return result.get(); +#else + // FIXME: Implement localizedString() for !USE(CF). return String::fromUTF8(key, strlen(key)); +#endif } } // namespace WebCore diff --git a/Source/WebCore/platform/win/LoggingWin.cpp b/Source/WebCore/platform/win/LoggingWin.cpp index 1d051ae..5e9fbda 100644 --- a/Source/WebCore/platform/win/LoggingWin.cpp +++ b/Source/WebCore/platform/win/LoggingWin.cpp @@ -88,6 +88,7 @@ void InitializeLoggingChannelsIfNecessary() initializeWithUserDefault(LogHistory); initializeWithUserDefault(LogPageCache); initializeWithUserDefault(LogPlatformLeaks); + initializeWithUserDefault(LogResourceLoading); initializeWithUserDefault(LogNetwork); initializeWithUserDefault(LogFTP); initializeWithUserDefault(LogThreading); @@ -95,6 +96,8 @@ void InitializeLoggingChannelsIfNecessary() initializeWithUserDefault(LogMedia); initializeWithUserDefault(LogPlugins); initializeWithUserDefault(LogArchives); + initializeWithUserDefault(LogProgress); + initializeWithUserDefault(LogFileAPI); } } // namespace WebCore diff --git a/Source/WebCore/platform/win/PopupMenuWin.h b/Source/WebCore/platform/win/PopupMenuWin.h index 05edb07..0684424 100644 --- a/Source/WebCore/platform/win/PopupMenuWin.h +++ b/Source/WebCore/platform/win/PopupMenuWin.h @@ -95,8 +95,10 @@ private: virtual int scrollPosition(Scrollbar*) const; virtual void setScrollOffset(const IntPoint&); virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&); + virtual void invalidateScrollCornerRect(const WebCore::IntRect&) { } virtual bool isActive() const { return true; } - virtual bool scrollbarCornerPresent() const { return false; } + virtual bool isScrollCornerVisible() const { return false; } + virtual WebCore::IntRect scrollCornerRect() const { return WebCore::IntRect(); } virtual Scrollbar* verticalScrollbar() const { return m_scrollbar.get(); } // NOTE: This should only be called by the overriden setScrollOffset from ScrollableArea. diff --git a/Source/WebCore/platform/win/WindowsTouch.h b/Source/WebCore/platform/win/WindowsTouch.h new file mode 100644 index 0000000..9048103 --- /dev/null +++ b/Source/WebCore/platform/win/WindowsTouch.h @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2009 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 WindowsTouch_h +#define WindowsTouch_h + +/* + * The following constants are used to determine multitouch and gesture behavior + * for Windows 7. For more information, see: + * http://msdn.microsoft.com/en-us/library/dd562197(VS.85).aspx + */ + +// Value used in WebViewWndProc for Gestures +#define WM_GESTURE 0x0119 +#define WM_GESTURENOTIFY 0x011A + +// Gesture Information Flags +#define GF_BEGIN 0x00000001 +#define GF_INERTIA 0x00000002 +#define GF_END 0x00000004 + +// Gesture IDs +#define GID_BEGIN 1 +#define GID_END 2 +#define GID_ZOOM 3 +#define GID_PAN 4 +#define GID_ROTATE 5 +#define GID_TWOFINGERTAP 6 +#define GID_PRESSANDTAP 7 +#define GID_ROLLOVER GID_PRESSANDTAP + +// Zoom Gesture Confiration Flags +#define GC_ZOOM 0x00000001 + +// Pan Gesture Configuration Flags +#define GC_PAN 0x00000001 +#define GC_PAN_WITH_SINGLE_FINGER_VERTICALLY 0x00000002 +#define GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY 0x00000004 +#define GC_PAN_WITH_GUTTER 0x00000008 +#define GC_PAN_WITH_INERTIA 0x00000010 + +// Rotate Gesture Configuration Flags +#define GC_ROTATE 0x00000001 + +// Two finger tap configuration flags +#define GC_TWOFINGERTAP 0x00000001 + +// Press and tap Configuration Flags +#define GC_PRESSANDTAP 0x00000001 +#define GC_ROLLOVER GC_PRESSANDTAP + +// GESTUREINFO struct definition +typedef struct tagGESTUREINFO { + UINT cbSize; // size, in bytes, of this structure (including variable length Args field) + DWORD dwFlags; // see GF_* flags + DWORD dwID; // gesture ID, see GID_* defines + HWND hwndTarget; // handle to window targeted by this gesture + POINTS ptsLocation; // current location of this gesture + DWORD dwInstanceID; // internally used + DWORD dwSequenceID; // internally used + ULONGLONG ullArguments; // arguments for gestures whose arguments fit in 8 BYTES + UINT cbExtraArgs; // size, in bytes, of extra arguments, if any, that accompany this gesture +} GESTUREINFO, *PGESTUREINFO; +typedef GESTUREINFO const * PCGESTUREINFO; + +// GESTURECONFIG struct defintion +typedef struct tagGESTURECONFIG { + DWORD dwID; // gesture ID + DWORD dwWant; // settings related to gesture ID that are to be turned on + DWORD dwBlock; // settings related to gesture ID that are to be turned off +} GESTURECONFIG, *PGESTURECONFIG; + +/* + * Gesture notification structure + * - The WM_GESTURENOTIFY message lParam contains a pointer to this structure. + * - The WM_GESTURENOTIFY message notifies a window that gesture recognition is + * in progress and a gesture will be generated if one is recognized under the + * current gesture settings. + */ +typedef struct tagGESTURENOTIFYSTRUCT { + UINT cbSize; // size, in bytes, of this structure + DWORD dwFlags; // unused + HWND hwndTarget; // handle to window targeted by the gesture + POINTS ptsLocation; // starting location + DWORD dwInstanceID; // internally used +} GESTURENOTIFYSTRUCT, *PGESTURENOTIFYSTRUCT; + +DECLARE_HANDLE(HGESTUREINFO); + +#endif |