summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/win
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2011-05-25 19:08:45 +0100
committerSteve Block <steveblock@google.com>2011-06-08 13:51:31 +0100
commit2bde8e466a4451c7319e3a072d118917957d6554 (patch)
tree28f4a1b869a513e565c7760d0e6a06e7cf1fe95a /Source/WebCore/platform/win
parent6939c99b71d9372d14a0c74a772108052e8c48c8 (diff)
downloadexternal_webkit-2bde8e466a4451c7319e3a072d118917957d6554.zip
external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.gz
external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.bz2
Merge WebKit at r82507: Initial merge by git
Change-Id: I60ce9d780725b58b45e54165733a8ffee23b683e
Diffstat (limited to 'Source/WebCore/platform/win')
-rw-r--r--Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp2
-rw-r--r--Source/WebCore/platform/win/CursorWin.cpp11
-rw-r--r--Source/WebCore/platform/win/FileSystemWin.cpp46
-rw-r--r--Source/WebCore/platform/win/LocalizedStringsWin.cpp39
-rw-r--r--Source/WebCore/platform/win/PathWalker.cpp51
-rw-r--r--Source/WebCore/platform/win/PathWalker.h51
-rw-r--r--Source/WebCore/platform/win/SSLKeyGeneratorWin.cpp1
-rw-r--r--Source/WebCore/platform/win/ScrollbarThemeWin.cpp2
-rw-r--r--Source/WebCore/platform/win/SystemInfo.cpp149
-rw-r--r--Source/WebCore/platform/win/SystemInfo.h37
10 files changed, 358 insertions, 31 deletions
diff --git a/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp b/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp
index 513992d..33d8ccd 100644
--- a/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp
+++ b/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp
@@ -130,7 +130,7 @@ static bool getWebLocData(const DragDataMap* dataObject, String& url, String* ti
if (!dataObject->contains(cfHDropFormat()->cfFormat))
return false;
- wcscpy(filename, dataObject->get(cfHDropFormat()->cfFormat)[0].characters());
+ wcscpy(filename, dataObject->get(cfHDropFormat()->cfFormat)[0].charactersWithNullTermination());
if (_wcsicmp(PathFindExtensionW(filename), L".url"))
return false;
diff --git a/Source/WebCore/platform/win/CursorWin.cpp b/Source/WebCore/platform/win/CursorWin.cpp
index 0036388..3a8cc09 100644
--- a/Source/WebCore/platform/win/CursorWin.cpp
+++ b/Source/WebCore/platform/win/CursorWin.cpp
@@ -30,6 +30,7 @@
#include "BitmapInfo.h"
#include "Image.h"
#include "IntPoint.h"
+#include "SystemInfo.h"
#include <wtf/OwnPtr.h>
@@ -39,20 +40,12 @@
namespace WebCore {
-static inline bool supportsAlphaCursors()
-{
- OSVERSIONINFO osinfo = {0};
- osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- GetVersionEx(&osinfo);
- return osinfo.dwMajorVersion > 5 || (osinfo.dwMajorVersion == 5 && osinfo.dwMinorVersion > 0);
-}
-
static PassRefPtr<SharedCursor> createSharedCursor(Image* img, const IntPoint& hotSpot)
{
RefPtr<SharedCursor> impl;
IntPoint effectiveHotSpot = determineHotSpot(img, hotSpot);
- static bool doAlpha = supportsAlphaCursors();
+ static bool doAlpha = windowsVersion() >= WindowsXP;
BitmapInfo cursorImage = BitmapInfo::create(IntSize(img->width(), img->height()));
HDC dc = GetDC(0);
diff --git a/Source/WebCore/platform/win/FileSystemWin.cpp b/Source/WebCore/platform/win/FileSystemWin.cpp
index 5ee3b8e..03a2eaf 100644
--- a/Source/WebCore/platform/win/FileSystemWin.cpp
+++ b/Source/WebCore/platform/win/FileSystemWin.cpp
@@ -31,9 +31,11 @@
#include "FileSystem.h"
#include "NotImplemented.h"
+#include "PathWalker.h"
#include "PlatformString.h"
#include <wtf/HashMap.h>
#include <wtf/text/CString.h>
+#include <wtf/text/StringConcatenate.h>
#include <windows.h>
#include <winbase.h>
@@ -184,18 +186,18 @@ static String cachedStorageDirectory(DWORD pathIdentifier)
return directory;
}
-CString openTemporaryFile(const char*, PlatformFileHandle& handle)
+String openTemporaryFile(const String&, PlatformFileHandle& handle)
{
handle = INVALID_HANDLE_VALUE;
char tempPath[MAX_PATH];
int tempPathLength = ::GetTempPathA(WTF_ARRAY_LENGTH(tempPath), tempPath);
if (tempPathLength <= 0 || tempPathLength > WTF_ARRAY_LENGTH(tempPath))
- return CString();
+ return String();
HCRYPTPROV hCryptProv = 0;
if (!CryptAcquireContext(&hCryptProv, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
- return CString();
+ return String();
char proposedPath[MAX_PATH];
while (1) {
@@ -226,9 +228,28 @@ CString openTemporaryFile(const char*, PlatformFileHandle& handle)
CryptReleaseContext(hCryptProv, 0);
if (!isHandleValid(handle))
- return CString();
+ return String();
- return proposedPath;
+ return String::fromUTF8(proposedPath);
+}
+
+PlatformFileHandle openFile(const String& path, FileOpenMode mode)
+{
+ DWORD desiredAccess = 0;
+ DWORD creationDisposition = 0;
+ switch (mode) {
+ case OpenForRead:
+ desiredAccess = GENERIC_READ;
+ creationDisposition = OPEN_EXISTING;
+ case OpenForWrite:
+ desiredAccess = GENERIC_WRITE;
+ creationDisposition = CREATE_ALWAYS;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+
+ String destination = path;
+ return CreateFile(destination.charactersWithNullTermination(), desiredAccess, 0, 0, creationDisposition, FILE_ATTRIBUTE_NORMAL, 0);
}
void closeFile(PlatformFileHandle& handle)
@@ -297,10 +318,21 @@ bool safeCreateFile(const String& path, CFDataRef data)
return true;
}
-Vector<String> listDirectory(const String& path, const String& filter)
+Vector<String> listDirectory(const String& directory, const String& filter)
{
Vector<String> entries;
- notImplemented();
+
+ PathWalker walker(directory, filter);
+ if (!walker.isValid())
+ return entries;
+
+ do {
+ if (walker.data().dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ continue;
+
+ entries.append(makeString(directory, "\\", reinterpret_cast<const UChar*>(walker.data().cFileName)));
+ } while (walker.step());
+
return entries;
}
diff --git a/Source/WebCore/platform/win/LocalizedStringsWin.cpp b/Source/WebCore/platform/win/LocalizedStringsWin.cpp
new file mode 100644
index 0000000..67de0fc
--- /dev/null
+++ b/Source/WebCore/platform/win/LocalizedStringsWin.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2011 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 INC. AND ITS CONTRIBUTORS ``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 ITS 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 "LocalizedStrings.h"
+
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+String localizedString(const char* key)
+{
+ // FIXME: <rdar://problem/9119405> Win: WebKit2 needs to be made localizable
+ return String::fromUTF8(key, strlen(key));
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/platform/win/PathWalker.cpp b/Source/WebCore/platform/win/PathWalker.cpp
new file mode 100644
index 0000000..cb4fccb
--- /dev/null
+++ b/Source/WebCore/platform/win/PathWalker.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2011 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 INC. AND ITS CONTRIBUTORS ``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 ITS 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 "PathWalker.h"
+
+#include <wtf/text/StringConcatenate.h>
+
+namespace WebCore {
+
+PathWalker::PathWalker(const String& directory, const String& pattern)
+{
+ String path = makeString(directory, "\\", pattern);
+ m_handle = ::FindFirstFileW(path.charactersWithNullTermination(), &m_data);
+}
+
+PathWalker::~PathWalker()
+{
+ if (!isValid())
+ return;
+ ::FindClose(m_handle);
+}
+
+bool PathWalker::step()
+{
+ return ::FindNextFileW(m_handle, &m_data);
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/platform/win/PathWalker.h b/Source/WebCore/platform/win/PathWalker.h
new file mode 100644
index 0000000..219c837
--- /dev/null
+++ b/Source/WebCore/platform/win/PathWalker.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2011 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 INC. AND ITS CONTRIBUTORS ``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 ITS 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 <Windows.h>
+#include <wtf/Noncopyable.h>
+
+namespace WTF {
+ class String;
+}
+
+namespace WebCore {
+
+class PathWalker {
+ WTF_MAKE_NONCOPYABLE(PathWalker);
+public:
+ PathWalker(const WTF::String& directory, const WTF::String& pattern);
+ ~PathWalker();
+
+ bool isValid() const { return m_handle != INVALID_HANDLE_VALUE; }
+ const WIN32_FIND_DATAW& data() const { return m_data; }
+
+ bool step();
+
+private:
+ HANDLE m_handle;
+ WIN32_FIND_DATAW m_data;
+};
+
+} // namespace WebCore
diff --git a/Source/WebCore/platform/win/SSLKeyGeneratorWin.cpp b/Source/WebCore/platform/win/SSLKeyGeneratorWin.cpp
index 50aee8e..b10961b 100644
--- a/Source/WebCore/platform/win/SSLKeyGeneratorWin.cpp
+++ b/Source/WebCore/platform/win/SSLKeyGeneratorWin.cpp
@@ -30,6 +30,7 @@ namespace WebCore {
void WebCore::getSupportedKeySizes(Vector<String>& v)
{
+ // FIXME: Strings should be localizable.
v.append("High Grade");
v.append("Medium Grade");
}
diff --git a/Source/WebCore/platform/win/ScrollbarThemeWin.cpp b/Source/WebCore/platform/win/ScrollbarThemeWin.cpp
index ff3aaa4..576cd92 100644
--- a/Source/WebCore/platform/win/ScrollbarThemeWin.cpp
+++ b/Source/WebCore/platform/win/ScrollbarThemeWin.cpp
@@ -100,7 +100,7 @@ ScrollbarThemeWin::ScrollbarThemeWin()
if (!initialized) {
initialized = true;
checkAndInitScrollbarTheme();
- runningVista = isRunningOnVistaOrLater();
+ runningVista = (windowsVersion() >= WindowsVista);
}
}
diff --git a/Source/WebCore/platform/win/SystemInfo.cpp b/Source/WebCore/platform/win/SystemInfo.cpp
index f2fe62b..878a6cc 100644
--- a/Source/WebCore/platform/win/SystemInfo.cpp
+++ b/Source/WebCore/platform/win/SystemInfo.cpp
@@ -27,30 +27,155 @@
#include "SystemInfo.h"
#include <windows.h>
+#include <wtf/text/StringConcatenate.h>
namespace WebCore {
-bool isRunningOnVistaOrLater()
+WindowsVersion windowsVersion(int* major, int* minor)
{
+ static bool initialized = false;
+ static WindowsVersion version;
+ static int majorVersion, minorVersion;
+
+ if (!initialized) {
+ initialized = true;
+#if OS(WINCE)
+ OSVERSIONINFO versionInfo;
+#else
+ OSVERSIONINFOEX versionInfo;
+#endif
+ ZeroMemory(&versionInfo, sizeof(versionInfo));
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&versionInfo));
+ majorVersion = versionInfo.dwMajorVersion;
+ minorVersion = versionInfo.dwMinorVersion;
+
#if OS(WINCE)
- return false;
+ if (majorVersion >= 1 && majorVersion <= 7)
+ version = static_cast<WindowsVersion>(WindowsCE1 + (majorVersion - 1));
+ else
+ version = (majorVersion < 1) ? WindowsCE1 : WindowsCE7;
#else
- static bool isVistaOrLater;
- static bool initialized;
+ if (versionInfo.dwPlatformId == VER_PLATFORM_WIN32s)
+ version = Windows3_1;
+ else if (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
+ if (!minorVersion)
+ version = Windows95;
+ else
+ version = (minorVersion == 10) ? Windows98 : WindowsME;
+ } else {
+ if (majorVersion == 5) {
+ if (!minorVersion)
+ version = Windows2000;
+ else
+ version = (minorVersion == 1) ? WindowsXP : WindowsServer2003;
+ } else if (majorVersion >= 6) {
+ if (versionInfo.wProductType == VER_NT_WORKSTATION)
+ version = (majorVersion == 6 && !minorVersion) ? WindowsVista : Windows7;
+ else
+ version = WindowsServer2008;
+ } else
+ version = (majorVersion == 4) ? WindowsNT4 : WindowsNT3;
+ }
+#endif
+ }
- if (initialized)
- return isVistaOrLater;
+ if (major)
+ *major = majorVersion;
+ if (minor)
+ *minor = minorVersion;
+ return version;
+}
+
+static String osVersionForUAString()
+{
+ int major, minor;
+ WindowsVersion version = windowsVersion(&major, &minor);
+ switch (version) {
+ case WindowsCE1:
+ case WindowsCE2:
+ case WindowsCE3:
+ return "Windows CE";
+ case WindowsCE4:
+ return "Windows CE .NET";
+ case Windows3_1:
+ return "Windows 3.1";
+ case Windows95:
+ return "Windows 95";
+ case Windows98:
+ return "Windows 98";
+ case WindowsME:
+ return "Windows 98; Win 9x 4.90";
+ case WindowsNT4:
+ return "WinNT4.0";
+ }
- initialized = true;
+ const char* familyName = (version >= WindowsNT3) ? "Windows NT " : "Windows CE ";
+ return makeString(familyName, String::number(major), '.', String::number(minor));
+}
- OSVERSIONINFOEX vi = {0};
- vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
- GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&vi));
+#if !OS(WINCE)
+static bool isWOW64()
+{
+ static bool initialized = false;
+ static bool wow64 = false;
- isVistaOrLater = vi.dwMajorVersion >= 6;
+ if (!initialized) {
+ initialized = true;
+ HMODULE kernel32Module = GetModuleHandleA("kernel32.dll");
+ if (!kernel32Module)
+ return wow64;
+ typedef BOOL (WINAPI* IsWow64ProcessFunc)(HANDLE, PBOOL);
+ IsWow64ProcessFunc isWOW64Process = reinterpret_cast<IsWow64ProcessFunc>(GetProcAddress(kernel32Module, "IsWow64Process"));
+ if (isWOW64Process) {
+ BOOL result = FALSE;
+ wow64 = isWOW64Process(GetCurrentProcess(), &result) && result;
+ }
+ }
- return isVistaOrLater;
+ return wow64;
+}
+
+static WORD processorArchitecture()
+{
+ static bool initialized = false;
+ static WORD architecture = PROCESSOR_ARCHITECTURE_INTEL;
+
+ if (!initialized) {
+ initialized = true;
+ HMODULE kernel32Module = GetModuleHandleA("kernel32.dll");
+ if (!kernel32Module)
+ return architecture;
+ typedef VOID (WINAPI* GetNativeSystemInfoFunc)(LPSYSTEM_INFO);
+ GetNativeSystemInfoFunc getNativeSystemInfo = reinterpret_cast<GetNativeSystemInfoFunc>(GetProcAddress(kernel32Module, "GetNativeSystemInfo"));
+ if (getNativeSystemInfo) {
+ SYSTEM_INFO systemInfo;
+ ZeroMemory(&systemInfo, sizeof(systemInfo));
+ getNativeSystemInfo(&systemInfo);
+ architecture = systemInfo.wProcessorArchitecture;
+ }
+ }
+
+ return architecture;
+}
#endif
+
+static String architectureTokenForUAString()
+{
+#if !OS(WINCE)
+ if (isWOW64())
+ return "; WOW64";
+ if (processorArchitecture() == PROCESSOR_ARCHITECTURE_AMD64)
+ return "; Win64; x64";
+ if (processorArchitecture() == PROCESSOR_ARCHITECTURE_IA64)
+ return "; Win64; IA64";
+#endif
+ return String();
+}
+
+String windowsVersionForUAString()
+{
+ return makeString(osVersionForUAString(), architectureTokenForUAString());
}
} // namespace WebCore
diff --git a/Source/WebCore/platform/win/SystemInfo.h b/Source/WebCore/platform/win/SystemInfo.h
index 9f2c2a0..2631ace 100644
--- a/Source/WebCore/platform/win/SystemInfo.h
+++ b/Source/WebCore/platform/win/SystemInfo.h
@@ -26,9 +26,44 @@
#ifndef SystemInfo_h
#define SystemInfo_h
+#include <wtf/text/WTFString.h>
+
namespace WebCore {
-bool isRunningOnVistaOrLater();
+// NOTE: Keep these in order so callers can do things like
+// "if (windowsVersion() >= WindowsVista) ...". It's OK to change or add values,
+// though.
+enum WindowsVersion {
+ // CE-based versions
+ WindowsCE1 = 0,
+ WindowsCE2,
+ WindowsCE3,
+ WindowsCE4,
+ WindowsCE5,
+ WindowsCE6,
+ WindowsCE7,
+ // 3.x-based versions
+ Windows3_1,
+ // 9x-based versions
+ Windows95,
+ Windows98,
+ WindowsME,
+ // NT-based versions
+ WindowsNT3,
+ WindowsNT4,
+ Windows2000,
+ WindowsXP,
+ WindowsServer2003,
+ WindowsVista,
+ WindowsServer2008,
+ Windows7,
+};
+
+// If supplied, |major| and |minor| are set to the OSVERSIONINFO::dwMajorVersion
+// and dwMinorVersion field values, respectively.
+WindowsVersion windowsVersion(int* major = 0, int* minor = 0);
+
+String windowsVersionForUAString();
} // namespace WebCore