aboutsummaryrefslogtreecommitdiffstats
path: root/win32/patches/webkitgtk.patch
diff options
context:
space:
mode:
Diffstat (limited to 'win32/patches/webkitgtk.patch')
-rw-r--r--win32/patches/webkitgtk.patch727
1 files changed, 727 insertions, 0 deletions
diff --git a/win32/patches/webkitgtk.patch b/win32/patches/webkitgtk.patch
new file mode 100644
index 0000000000..7cc42fc0f3
--- /dev/null
+++ b/win32/patches/webkitgtk.patch
@@ -0,0 +1,727 @@
+diff -upr -x .deps -x .libs -x '*.la' webkitgtk-2.4.1.old/Source/JavaScriptCore/jit/JITStubsX86.h webkitgtk-2.4.1/Source/JavaScriptCore/jit/JITStubsX86.h
+--- webkitgtk-2.4.1.old/Source/JavaScriptCore/jit/JITStubsX86.h 2014-06-20 20:05:59 +0000
++++ webkitgtk-2.4.1/Source/JavaScriptCore/jit/JITStubsX86.h 2014-06-20 19:42:30 +0000
+@@ -32,6 +32,7 @@
+ #define JITStubsX86_h
+
+ #include "JITStubsX86Common.h"
++#include <wtf/InlineASM.h>
+
+ #if !CPU(X86)
+ #error "JITStubsX86.h should only be #included if CPU(X86)"
+@@ -198,6 +199,225 @@ SYMBOL_STRING(ctiMasmProbeTrampolineEnd)
+ );
+ #endif // USE(MASM_PROBE)
+
++#if OS(WINDOWS) && ENABLE(JIT)
++extern "C" {
++
++ // FIXME: Since Windows doesn't use the LLInt, we have inline stubs here.
++ // Until the LLInt is changed to support Windows, these stub needs to be updated.
++ asm (
++ ".globl " SYMBOL_STRING(callToJavaScript) "\n"
++ HIDE_SYMBOL(callToJavaScript) "\n"
++ SYMBOL_STRING(callToJavaScript) ":" "\n"
++ "mov (%esp),%edx" "\n"
++ "push %ebp" "\n"
++ "mov %ebp,%eax" "\n"
++ "mov %esp,%ebp" "\n"
++ "push %esi" "\n"
++ "push %edi" "\n"
++ "push %ebx" "\n"
++ "sub $0x1c,%esp" "\n"
++ "mov 0x34(%esp),%ecx" "\n"
++ "mov 0x38(%esp),%esi" "\n"
++ "mov 0x3c(%esp),%ebp" "\n"
++ "sub $0x20,%ebp" "\n"
++ "movl $0x0,0x24(%ebp)" "\n"
++ "movl $0x0,0x20(%ebp)" "\n"
++ "movl $0x0,0x1c(%ebp)" "\n"
++ "mov %ecx,0x18(%ebp)" "\n"
++ "mov (%ecx),%ebx" "\n"
++ "movl $0x0,0x14(%ebp)" "\n"
++ "mov %ebx,0x10(%ebp)" "\n"
++ "movl $0x0,0xc(%ebp)" "\n"
++ "movl $0x1,0x8(%ebp)" "\n"
++ "mov %edx,0x4(%ebp)" "\n"
++ "mov %eax,0x0(%ebp)" "\n"
++ "mov %ebp,%eax" "\n"
++
++ "mov 0x28(%esi),%edx" "\n"
++ "add $0x5,%edx" "\n"
++ "shl $0x3,%edx" "\n"
++ "sub %edx,%ebp" "\n"
++ "mov %eax,0x0(%ebp)" "\n"
++
++ "mov $0x5,%eax" "\n"
++
++ ".copyHeaderLoop:" "\n"
++ "sub $0x1,%eax" "\n"
++ "mov (%esi,%eax,8),%ecx" "\n"
++ "mov %ecx,0x8(%ebp,%eax,8)" "\n"
++ "mov 0x4(%esi,%eax,8),%ecx" "\n"
++ "mov %ecx,0xc(%ebp,%eax,8)" "\n"
++ "test %eax,%eax" "\n"
++ "jne .copyHeaderLoop" "\n"
++
++ "mov 0x18(%esi),%edx" "\n"
++ "sub $0x1,%edx" "\n"
++ "mov 0x28(%esi),%ecx" "\n"
++ "sub $0x1,%ecx" "\n"
++
++ "cmp %ecx,%edx" "\n"
++ "je .copyArgs" "\n"
++
++ "xor %eax,%eax" "\n"
++ "mov $0xfffffffc,%ebx" "\n"
++
++ ".fillExtraArgsLoop:" "\n"
++ "sub $0x1,%ecx" "\n"
++ "mov %eax,0x30(%ebp,%ecx,8)" "\n"
++ "mov %ebx,0x34(%ebp,%ecx,8)" "\n"
++ "cmp %ecx,%edx" "\n"
++ "jne .fillExtraArgsLoop" "\n"
++
++ ".copyArgs:" "\n"
++ "mov 0x2c(%esi),%eax" "\n"
++
++ ".copyArgsLoop:" "\n"
++ "test %edx,%edx" "\n"
++ "je .copyArgsDone" "\n"
++ "sub $0x1,%edx" "\n"
++ "mov (%eax,%edx,8),%ecx" "\n"
++ "mov 0x4(%eax,%edx,8),%ebx" "\n"
++ "mov %ecx,0x30(%ebp,%edx,8)" "\n"
++ "mov %ebx,0x34(%ebp,%edx,8)" "\n"
++ "jmp .copyArgsLoop" "\n"
++
++ ".copyArgsDone:" "\n"
++ "mov 0x34(%esp),%ecx" "\n"
++ "mov %ebp,(%ecx)" "\n"
++
++ "call *0x30(%esp)" "\n"
++
++ "cmpl $0x1,0x8(%ebp)" "\n"
++ "je .calleeFramePopped" "\n"
++ "mov 0x0(%ebp),%ebp" "\n"
++
++ ".calleeFramePopped:" "\n"
++ "mov 0x18(%ebp),%ecx" "\n"
++ "mov 0x10(%ebp),%ebx" "\n"
++ "mov %ebx,(%ecx)" "\n"
++
++ "add $0x1c,%esp" "\n"
++ "pop %ebx" "\n"
++ "pop %edi" "\n"
++ "pop %esi" "\n"
++ "pop %ebp" "\n"
++ "ret" "\n"
++
++ ".globl " SYMBOL_STRING(returnFromJavaScript) "\n"
++ HIDE_SYMBOL(returnFromJavaScript) "\n"
++ SYMBOL_STRING(returnFromJavaScript) ":" "\n"
++ "add $0x1c,%esp" "\n"
++ "pop %ebx" "\n"
++ "pop %edi" "\n"
++ "pop %esi" "\n"
++ "pop %ebp" "\n"
++ "ret" "\n"
++
++ ".globl " SYMBOL_STRING(callToNativeFunction) "\n"
++ HIDE_SYMBOL(callToNativeFunction) "\n"
++ SYMBOL_STRING(callToNativeFunction) ":" "\n"
++ "mov (%esp),%edx" "\n"
++ "push %ebp" "\n"
++ "mov %ebp,%eax" "\n"
++ "mov %esp,%ebp" "\n"
++ "push %esi" "\n"
++ "push %edi" "\n"
++ "push %ebx" "\n"
++ "sub $0x1c,%esp" "\n"
++ "mov 0x34(%esp),%ecx" "\n"
++ "mov 0x38(%esp),%esi" "\n"
++ "mov 0x3c(%esp),%ebp" "\n"
++ "sub $0x20,%ebp" "\n"
++ "movl $0x0,0x24(%ebp)" "\n"
++ "movl $0x0,0x20(%ebp)" "\n"
++ "movl $0x0,0x1c(%ebp)" "\n"
++ "mov %ecx,0x18(%ebp)" "\n"
++ "mov (%ecx),%ebx" "\n"
++ "movl $0x0,0x14(%ebp)" "\n"
++ "mov %ebx,0x10(%ebp)" "\n"
++ "movl $0x0,0xc(%ebp)" "\n"
++ "movl $0x1,0x8(%ebp)" "\n"
++ "mov %edx,0x4(%ebp)" "\n"
++ "mov %eax,0x0(%ebp)" "\n"
++ "mov %ebp,%eax" "\n"
++
++ "mov 0x28(%esi),%edx" "\n"
++ "add $0x5,%edx" "\n"
++ "shl $0x3,%edx" "\n"
++ "sub %edx,%ebp" "\n"
++ "mov %eax,0x0(%ebp)" "\n"
++
++ "mov $0x5,%eax" "\n"
++
++ "copyHeaderLoop:" "\n"
++ "sub $0x1,%eax" "\n"
++ "mov (%esi,%eax,8),%ecx" "\n"
++ "mov %ecx,0x8(%ebp,%eax,8)" "\n"
++ "mov 0x4(%esi,%eax,8),%ecx" "\n"
++ "mov %ecx,0xc(%ebp,%eax,8)" "\n"
++ "test %eax,%eax" "\n"
++ "jne copyHeaderLoop" "\n"
++
++ "mov 0x18(%esi),%edx" "\n"
++ "sub $0x1,%edx" "\n"
++ "mov 0x28(%esi),%ecx" "\n"
++ "sub $0x1,%ecx" "\n"
++
++ "cmp %ecx,%edx" "\n"
++ "je copyArgs" "\n"
++
++ "xor %eax,%eax" "\n"
++ "mov $0xfffffffc,%ebx" "\n"
++
++ "fillExtraArgsLoop:" "\n"
++ "sub $0x1,%ecx" "\n"
++ "mov %eax,0x30(%ebp,%ecx,8)" "\n"
++ "mov %ebx,0x34(%ebp,%ecx,8)" "\n"
++ "cmp %ecx,%edx" "\n"
++ "jne fillExtraArgsLoop" "\n"
++
++ "copyArgs:" "\n"
++ "mov 0x2c(%esi),%eax" "\n"
++
++ "copyArgsLoop:" "\n"
++ "test %edx,%edx" "\n"
++ "je copyArgsDone" "\n"
++ "sub $0x1,%edx" "\n"
++ "mov (%eax,%edx,8),%ecx" "\n"
++ "mov 0x4(%eax,%edx,8),%ebx" "\n"
++ "mov %ecx,0x30(%ebp,%edx,8)" "\n"
++ "mov %ebx,0x34(%ebp,%edx,8)" "\n"
++ "jmp copyArgsLoop" "\n"
++
++ "copyArgsDone:" "\n"
++ "mov 0x34(%esp),%ecx" "\n"
++ "mov %ebp,(%ecx)" "\n"
++
++ "mov 0x30(%esp),%edi" "\n"
++ "mov %ebp,0x30(%esp)" "\n"
++ "mov %ebp,%ecx" "\n"
++ "call *%edi" "\n"
++
++ "cmpl $0x1,0x8(%ebp)" "\n"
++ "je calleeFramePopped" "\n"
++ "mov 0x0(%ebp),%ebp" "\n"
++
++ "calleeFramePopped:" "\n"
++ "mov 0x18(%ebp),%ecx" "\n"
++ "mov 0x10(%ebp),%ebx" "\n"
++ "mov %ebx,(%ecx)" "\n"
++
++ "add $0x1c,%esp" "\n"
++ "pop %ebx" "\n"
++ "pop %edi" "\n"
++ "pop %esi" "\n"
++ "pop %ebp" "\n"
++ "ret" "\n"
++ );
++}
++
++#endif // OS(WINDOWS) && ENABLE(JIT)
++
+ #endif // COMPILER(GCC)
+
+ #if COMPILER(MSVC)
+diff -upr -x .deps -x .libs -x '*.la' webkitgtk-2.4.1.old/Source/ThirdParty/ANGLE/GNUmakefile.am webkitgtk-2.4.1/Source/ThirdParty/ANGLE/GNUmakefile.am
+--- webkitgtk-2.4.1.old/Source/ThirdParty/ANGLE/GNUmakefile.am 2014-06-20 20:05:59 +0000
++++ webkitgtk-2.4.1/Source/ThirdParty/ANGLE/GNUmakefile.am 2014-05-24 05:04:11 +0000
+@@ -80,7 +80,6 @@ libANGLE_la_SOURCES = \
+ Source/ThirdParty/ANGLE/src/compiler/MMap.h \
+ Source/ThirdParty/ANGLE/src/compiler/NodeSearch.h \
+ Source/ThirdParty/ANGLE/src/compiler/osinclude.h \
+- Source/ThirdParty/ANGLE/src/compiler/ossource_posix.cpp \
+ Source/ThirdParty/ANGLE/src/compiler/OutputESSL.cpp \
+ Source/ThirdParty/ANGLE/src/compiler/OutputESSL.h \
+ Source/ThirdParty/ANGLE/src/compiler/OutputGLSLBase.cpp \
+@@ -161,3 +160,11 @@ libANGLE_la_SOURCES = \
+ Source/ThirdParty/ANGLE/src/compiler/VersionGLSL.h \
+ Source/ThirdParty/ANGLE/src/third_party/compiler/ArrayBoundsClamper.cpp \
+ Source/ThirdParty/ANGLE/src/third_party/compiler/ArrayBoundsClamper.h
++
++if OS_WIN32
++libANGLE_la_SOURCES += \
++ Source/ThirdParty/ANGLE/src/compiler/ossource_win.cpp
++else
++libANGLE_la_SOURCES += \
++ Source/ThirdParty/ANGLE/src/compiler/ossource_posix.cpp
++endif
+diff -upr -x .deps -x .libs -x '*.la' webkitgtk-2.4.1.old/Source/ThirdParty/ANGLE/src/compiler/ossource_win.cpp webkitgtk-2.4.1/Source/ThirdParty/ANGLE/src/compiler/ossource_win.cpp
+--- webkitgtk-2.4.1.old/Source/ThirdParty/ANGLE/src/compiler/ossource_win.cpp 2014-07-12 16:07:30 +0000
++++ webkitgtk-2.4.1/Source/ThirdParty/ANGLE/src/compiler/ossource_win.cpp 2014-05-24 05:04:11 +0000
+@@ -0,0 +1,57 @@
++//
++// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
++// Use of this source code is governed by a BSD-style license that can be
++// found in the LICENSE file.
++//
++
++#include "compiler/osinclude.h"
++//
++// This file contains contains the window's specific functions
++//
++
++#if !defined(ANGLE_OS_WIN)
++#error Trying to build a windows specific file in a non windows build.
++#endif
++
++
++//
++// Thread Local Storage Operations
++//
++OS_TLSIndex OS_AllocTLSIndex()
++{
++ DWORD dwIndex = TlsAlloc();
++ if (dwIndex == TLS_OUT_OF_INDEXES) {
++ assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage");
++ return OS_INVALID_TLS_INDEX;
++ }
++
++ return dwIndex;
++}
++
++
++bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
++{
++ if (nIndex == OS_INVALID_TLS_INDEX) {
++ assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
++ return false;
++ }
++
++ if (TlsSetValue(nIndex, lpvValue))
++ return true;
++ else
++ return false;
++}
++
++
++bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
++{
++ if (nIndex == OS_INVALID_TLS_INDEX) {
++ assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
++ return false;
++ }
++
++ if (TlsFree(nIndex))
++ return true;
++ else
++ return false;
++}
+diff -upr -x .deps -x .libs -x '*.la' webkitgtk-2.4.1.old/Source/WTF/GNUmakefile.list.am webkitgtk-2.4.1/Source/WTF/GNUmakefile.list.am
+--- webkitgtk-2.4.1.old/Source/WTF/GNUmakefile.list.am 2014-05-18 16:44:48 +0000
++++ webkitgtk-2.4.1/Source/WTF/GNUmakefile.list.am 2014-05-24 05:09:00 +0000
+@@ -256,3 +256,8 @@ wtf_sources += \
+ Source/WTF/wtf/unicode/UnicodeMacrosFromICU.h \
+ Source/WTF/wtf/unicode/icu/CollatorICU.cpp \
+ Source/WTF/wtf/unicode/icu/UnicodeIcu.h
++
++if TARGET_WIN32
++wtf_sources += \
++ Source/WTF/wtf/win/GdiObject.h
++endif # TARGET_WIN32
+diff -upr -x .deps -x .libs -x '*.la' webkitgtk-2.4.1.old/Source/WTF/wtf/Atomics.h webkitgtk-2.4.1/Source/WTF/wtf/Atomics.h
+--- webkitgtk-2.4.1.old/Source/WTF/wtf/Atomics.h 2014-06-20 20:05:59 +0000
++++ webkitgtk-2.4.1/Source/WTF/wtf/Atomics.h 2014-05-28 18:01:59 +0000
+@@ -260,7 +260,7 @@ inline void memoryBarrierBeforeUnlock()
+ inline bool weakCompareAndSwap(uint8_t* location, uint8_t expected, uint8_t newValue)
+ {
+ #if ENABLE(COMPARE_AND_SWAP)
+-#if !OS(WINDOWS) && (CPU(X86) || CPU(X86_64))
++#if !COMPILER(MSVC) && (CPU(X86) || CPU(X86_64))
+ unsigned char result;
+ asm volatile(
+ "lock; cmpxchgb %3, %2\n\t"
+diff -upr -x .deps -x .libs -x '*.la' webkitgtk-2.4.1.old/Source/WTF/wtf/MathExtras.h webkitgtk-2.4.1/Source/WTF/wtf/MathExtras.h
+--- webkitgtk-2.4.1.old/Source/WTF/wtf/MathExtras.h 2014-06-20 20:05:59 +0000
++++ webkitgtk-2.4.1/Source/WTF/wtf/MathExtras.h 2014-05-24 05:04:11 +0000
+@@ -67,6 +67,12 @@ const double piOverFourDouble = M_PI_4;
+ const float piOverFourFloat = static_cast<float>(M_PI_4);
+ #endif
+
++#ifndef M_SQRT2
++const double sqrtOfTwoDouble = 1.41421356237309504880;
++#else
++const double sqrtOfTwoDouble = M_SQRT2;
++#endif
++
+ #if OS(DARWIN)
+
+ // Work around a bug in the Mac OS X libc where ceil(-0.1) return +0.
+diff -upr -x .deps -x .libs -x '*.la' webkitgtk-2.4.1.old/Source/WTF/wtf/Platform.h webkitgtk-2.4.1/Source/WTF/wtf/Platform.h
+--- webkitgtk-2.4.1.old/Source/WTF/wtf/Platform.h 2014-06-20 20:05:59 +0000
++++ webkitgtk-2.4.1/Source/WTF/wtf/Platform.h 2014-05-24 05:04:11 +0000
+@@ -594,8 +594,6 @@
+ #define HAVE_ALIGNED_MALLOC 1
+ #define HAVE_ISDEBUGGERPRESENT 1
+
+-#include <WTF/WTFHeaderDetection.h>
+-
+ #endif
+
+ #if OS(WINDOWS)
+diff -upr -x .deps -x .libs -x '*.la' webkitgtk-2.4.1.old/Source/WTF/wtf/threads/BinarySemaphore.h webkitgtk-2.4.1/Source/WTF/wtf/threads/BinarySemaphore.h
+--- webkitgtk-2.4.1.old/Source/WTF/wtf/threads/BinarySemaphore.h 2014-05-18 16:44:58 +0000
++++ webkitgtk-2.4.1/Source/WTF/wtf/threads/BinarySemaphore.h 2014-05-29 17:02:56 +0000
+@@ -41,12 +41,12 @@ public:
+ WTF_EXPORT_PRIVATE void signal();
+ WTF_EXPORT_PRIVATE bool wait(double absoluteTime);
+
+-#if OS(WINDOWS)
++#if PLATFORM(WIN)
+ HANDLE event() const { return m_event; }
+ #endif
+
+ private:
+-#if OS(WINDOWS)
++#if PLATFORM(WIN)
+ HANDLE m_event;
+ #else
+ bool m_isSet;
+diff -upr -x .deps -x .libs -x '*.la' webkitgtk-2.4.1.old/Source/WTF/wtf/win/GDIObject.h webkitgtk-2.4.1/Source/WTF/wtf/win/GDIObject.h
+--- webkitgtk-2.4.1.old/Source/WTF/wtf/win/GDIObject.h 2014-07-12 06:21:32 +0000
++++ webkitgtk-2.4.1/Source/WTF/wtf/win/GDIObject.h 2014-05-24 12:26:42 +0000
+@@ -0,0 +1,131 @@
++/*
++ * Copyright (C) 2013 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. ``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 GDIObject_h
++#define GDIObject_h
++
++#include <algorithm>
++#include <cstddef>
++#include <memory>
++#include <windows.h>
++#include <wtf/Assertions.h>
++#include <wtf/Noncopyable.h>
++
++namespace WTF {
++
++template<typename T> void deleteObject(T);
++
++template<typename T> class GDIObject {
++ WTF_MAKE_NONCOPYABLE(GDIObject);
++public:
++ GDIObject() : m_object(0) { }
++ GDIObject(std::nullptr_t) : m_object(0) { }
++ ~GDIObject() { deleteObject<T>(m_object); }
++
++ T get() const { return m_object; }
++
++ void clear();
++ T leak() WARN_UNUSED_RETURN;
++
++ bool operator!() const { return !m_object; }
++
++ // This conversion operator allows implicit conversion to bool but not to other integer types.
++ typedef const void* UnspecifiedBoolType;
++ operator UnspecifiedBoolType() const { return m_object ? reinterpret_cast<UnspecifiedBoolType>(&m_object) : 0; }
++
++ GDIObject<T>& operator=(std::nullptr_t) { clear(); return *this; }
++
++ GDIObject(GDIObject&&);
++ template<typename U> GDIObject(GDIObject<U>&&);
++
++ GDIObject& operator=(GDIObject&&);
++ template<typename U> GDIObject& operator=(GDIObject<U>&&);
++
++ void swap(GDIObject& o) { std::swap(m_object, o.m_object); }
++
++private:
++ template<typename U> friend GDIObject<U> adoptGDIObject(U);
++ GDIObject(T object) : m_object(object) { }
++
++ GDIObject<T>& operator=(T);
++
++ T m_object;
++};
++
++template<typename T> inline void GDIObject<T>::clear()
++{
++ T object = m_object;
++ m_object = 0;
++ deleteObject(object);
++}
++
++template<typename T> inline T GDIObject<T>::leak()
++{
++ T object = m_object;
++ m_object = 0;
++ return object;
++}
++
++template<typename T> inline GDIObject<T>::GDIObject(GDIObject<T>&& other)
++ : m_object(other.leak())
++{
++}
++
++template<typename T> inline GDIObject<T>& GDIObject<T>::operator=(GDIObject<T>&& other)
++{
++ auto object = std::move(other);
++ swap(object);
++ return *this;
++}
++
++template<typename T> inline GDIObject<T> adoptGDIObject(T object)
++{
++ return GDIObject<T>(object);
++}
++
++template<typename T> inline void swap(GDIObject<T>& a, GDIObject<T>& b)
++{
++ a.swap(b);
++}
++
++// Nearly all GDI types use the same DeleteObject call.
++template<typename T> inline void deleteObject(T object)
++{
++ if (object)
++ ::DeleteObject(object);
++}
++
++template<> inline void deleteObject<HDC>(HDC hdc)
++{
++ if (hdc)
++ ::DeleteDC(hdc);
++}
++
++} // namespace WTF
++
++using WTF::GDIObject;
++using WTF::adoptGDIObject;
++
++#endif // GDIObject_h
+diff -upr -x .deps -x .libs -x '*.la' webkitgtk-2.4.1.old/Source/WebCore/GNUmakefile.list.am webkitgtk-2.4.1/Source/WebCore/GNUmakefile.list.am
+--- webkitgtk-2.4.1.old/Source/WebCore/GNUmakefile.list.am 2014-06-20 20:05:59 +0000
++++ webkitgtk-2.4.1/Source/WebCore/GNUmakefile.list.am 2014-05-24 05:09:00 +0000
+@@ -6252,9 +6252,11 @@ webcoregtk_sources += \
+ Source/WebCore/platform/graphics/glx/GLContextGLX.h
+ endif # END USE_GLX
+ else
++if !TARGET_WIN32
+ webcore_sources += \
+ Source/WebCore/plugins/PluginPackageNone.cpp \
+ Source/WebCore/plugins/PluginViewNone.cpp
++endif # !TARGET_WIN32
+ endif # END TARGET_X11
+
+ if TARGET_X11_OR_WAYLAND
+@@ -6281,9 +6283,12 @@ webcore_sources += \
+ Source/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp \
+ Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp \
+ Source/WebCore/platform/graphics/win/LocalWindowsContext.h \
++ Source/WebCore/platform/graphics/win/SharedGDIObject.h \
+ Source/WebCore/platform/graphics/win/TransformationMatrixWin.cpp \
+ Source/WebCore/platform/win/BitmapInfo.cpp \
+ Source/WebCore/platform/win/BitmapInfo.h \
++ Source/WebCore/platform/win/GDIObjectCounter.cpp \
++ Source/WebCore/platform/win/GDIObjectCounter.h \
+ Source/WebCore/platform/win/SystemInfo.cpp \
+ Source/WebCore/platform/win/SystemInfo.h \
+ Source/WebCore/platform/win/WebCoreInstanceHandle.cpp \
+diff -upr -x .deps -x .libs -x '*.la' webkitgtk-2.4.1.old/Source/WebCore/bindings/scripts/preprocessor.pm webkitgtk-2.4.1/Source/WebCore/bindings/scripts/preprocessor.pm
+--- webkitgtk-2.4.1.old/Source/WebCore/bindings/scripts/preprocessor.pm 2014-06-20 20:05:59 +0000
++++ webkitgtk-2.4.1/Source/WebCore/bindings/scripts/preprocessor.pm 2014-05-24 05:04:11 +0000
+@@ -51,6 +51,8 @@ sub applyPreprocessor
+ $preprocessor = "/usr/sfw/bin/gcc";
+ } elsif (-x "/usr/bin/clang") {
+ $preprocessor = "/usr/bin/clang";
++ } elsif ($Config{osname} eq 'msys') {
++ $preprocessor = "gcc";
+ } else {
+ $preprocessor = "/usr/bin/gcc";
+ }
+@@ -71,7 +73,7 @@ sub applyPreprocessor
+ @macros = map { "-D$_" } @macros;
+
+ my $pid = 0;
+- if ($Config{osname} eq "cygwin" || $Config{osname} eq 'MSWin32') {
++ if ($Config{osname} eq "cygwin" || $Config{osname} eq 'MSWin32' || $Config{osname} eq 'msys') {
+ # This call can fail if Windows rebases cygwin, so retry a few times until it succeeds.
+ for (my $tries = 0; !$pid && ($tries < 20); $tries++) {
+ eval {
+diff -upr -x .deps -x .libs -x '*.la' webkitgtk-2.4.1.old/Source/WebCore/dom/make_names.pl webkitgtk-2.4.1/Source/WebCore/dom/make_names.pl
+--- webkitgtk-2.4.1.old/Source/WebCore/dom/make_names.pl 2014-06-20 20:05:59 +0000
++++ webkitgtk-2.4.1/Source/WebCore/dom/make_names.pl 2014-05-24 05:04:11 +0000
+@@ -69,6 +69,8 @@ if ($ENV{CC}) {
+ $gccLocation = "/usr/sfw/bin/gcc";
+ } elsif ($Config::Config{"osname"} eq "darwin" && $ENV{SDKROOT}) {
+ chomp($gccLocation = `xcrun -find cc -sdk '$ENV{SDKROOT}'`);
++} elsif ($Config::Config{"osname"} eq "msys") {
++ $gccLocation = "gcc";
+ } else {
+ $gccLocation = "/usr/bin/cc";
+ }
+diff -upr -x .deps -x .libs -x '*.la' webkitgtk-2.4.1.old/Source/WebCore/platform/graphics/FontPlatformData.h webkitgtk-2.4.1/Source/WebCore/platform/graphics/FontPlatformData.h
+--- webkitgtk-2.4.1.old/Source/WebCore/platform/graphics/FontPlatformData.h 2014-06-20 20:05:59 +0000
++++ webkitgtk-2.4.1/Source/WebCore/platform/graphics/FontPlatformData.h 2014-05-24 05:04:11 +0000
+@@ -62,7 +62,6 @@ typedef const struct __CTFont* CTFontRef
+ #include <wtf/text/StringImpl.h>
+
+ #if PLATFORM(WIN)
+-#include <wtf/win/GDIObject.h>
+ typedef struct HFONT__* HFONT;
+ #endif
+
+diff -upr -x .deps -x .libs -x '*.la' webkitgtk-2.4.1.old/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp webkitgtk-2.4.1/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp
+--- webkitgtk-2.4.1.old/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp 2014-06-20 20:05:59 +0000
++++ webkitgtk-2.4.1/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp 2014-05-24 05:04:11 +0000
+@@ -32,6 +32,7 @@
+ #include <ft2build.h>
+ #include FT_TRUETYPE_TABLES_H
+ #include <wtf/text/WTFString.h>
++#include <wtf/MathExtras.h>
+
+ #if !PLATFORM(EFL)
+ #include <gdk/gdk.h>
+@@ -120,7 +121,7 @@ static void rotateCairoMatrixForVertical
+ // combination of rotation (R) and translation (T) applied on the
+ // horizontal matrix (H). V = H . R . T, where R rotates by -90 degrees
+ // and T translates by font size towards y axis.
+- cairo_matrix_rotate(matrix, -M_PI_2);
++ cairo_matrix_rotate(matrix, -piOverTwoDouble);
+ cairo_matrix_translate(matrix, 0.0, 1.0);
+ }
+
+diff -upr -x .deps -x .libs -x '*.la' webkitgtk-2.4.1.old/Source/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp webkitgtk-2.4.1/Source/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp
+--- webkitgtk-2.4.1.old/Source/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp 2014-06-20 20:05:59 +0000
++++ webkitgtk-2.4.1/Source/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp 2014-05-24 05:09:00 +0000
+@@ -32,6 +32,7 @@
+
+ #include <cairo-win32.h>
+ #include "GraphicsContextPlatformPrivateCairo.h"
++#include <wtf/win/GdiObject.h>
+
+ using namespace std;
+
+diff -upr -x .deps -x .libs -x '*.la' webkitgtk-2.4.1.old/Source/WebCore/platform/gtk/FileSystemGtk.cpp webkitgtk-2.4.1/Source/WebCore/platform/gtk/FileSystemGtk.cpp
+--- webkitgtk-2.4.1.old/Source/WebCore/platform/gtk/FileSystemGtk.cpp 2014-06-20 20:05:59 +0000
++++ webkitgtk-2.4.1/Source/WebCore/platform/gtk/FileSystemGtk.cpp 2014-05-24 05:04:11 +0000
+@@ -23,6 +23,10 @@
+ #include "config.h"
+ #include "FileSystem.h"
+
++#if OS(WINDOWS)
++#include <windows.h>
++#endif
++
+ #include "FileMetadata.h"
+ #include "UUID.h"
+ #include <gio/gio.h>
+diff -upr -x .deps -x .libs -x '*.la' webkitgtk-2.4.1.old/Source/WebCore/rendering/RenderBlock.h webkitgtk-2.4.1/Source/WebCore/rendering/RenderBlock.h
+--- webkitgtk-2.4.1.old/Source/WebCore/rendering/RenderBlock.h 2014-06-20 20:05:59 +0000
++++ webkitgtk-2.4.1/Source/WebCore/rendering/RenderBlock.h 2014-05-24 15:52:01 +0000
+@@ -613,8 +613,8 @@ public:
+ unsigned m_beingDestroyed : 1;
+ unsigned m_hasMarkupTruncation : 1;
+ unsigned m_hasBorderOrPaddingLogicalWidthChanged : 1;
+- enum LineLayoutPath { UndeterminedPath, SimpleLinesPath, LineBoxesPath, ForceLineBoxesPath };
+ unsigned m_lineLayoutPath : 2;
++ enum LineLayoutPath { UndeterminedPath, SimpleLinesPath, LineBoxesPath, ForceLineBoxesPath };
+
+ // RenderRubyBase objects need to be able to split and merge, moving their children around
+ // (calling moveChildTo, moveAllChildrenTo, and makeChildrenNonInline).
+diff -upr -x .deps -x .libs -x '*.la' webkitgtk-2.4.1.old/Source/WebCore/rendering/mathml/RenderMathMLMenclose.cpp webkitgtk-2.4.1/Source/WebCore/rendering/mathml/RenderMathMLMenclose.cpp
+--- webkitgtk-2.4.1.old/Source/WebCore/rendering/mathml/RenderMathMLMenclose.cpp 2014-06-20 20:05:59 +0000
++++ webkitgtk-2.4.1/Source/WebCore/rendering/mathml/RenderMathMLMenclose.cpp 2014-05-24 05:04:11 +0000
+@@ -71,8 +71,8 @@ void RenderMathMLMenclose::computePrefer
+ size_t notationalValueSize = notationValues.size();
+ for (size_t i = 0; i < notationalValueSize; i++) {
+ if (notationValues[i] == "circle") {
+- m_minPreferredLogicalWidth = minPreferredLogicalWidth() * float(M_SQRT2);
+- m_maxPreferredLogicalWidth = maxPreferredLogicalWidth() * float(M_SQRT2);
++ m_minPreferredLogicalWidth = minPreferredLogicalWidth() * float(sqrtOfTwoDouble);
++ m_maxPreferredLogicalWidth = maxPreferredLogicalWidth() * float(sqrtOfTwoDouble);
+ }
+ }
+
+@@ -86,7 +86,7 @@ void RenderMathMLMenclose::updateLogical
+ size_t notationalValueSize = notationValues.size();
+ for (size_t i = 0; i < notationalValueSize; i++)
+ if (notationValues[i] == "circle")
+- setLogicalHeight(logicalHeight() * float(M_SQRT2));
++ setLogicalHeight(logicalHeight() * float(sqrtOfTwoDouble));
+ }
+
+ void RenderMathMLMenclose::paint(PaintInfo& info, const LayoutPoint& paintOffset)
+diff -upr -x .deps -x .libs -x '*.la' webkitgtk-2.4.1.old/Source/autotools/FindDependencies.m4 webkitgtk-2.4.1/Source/autotools/FindDependencies.m4
+--- webkitgtk-2.4.1.old/Source/autotools/FindDependencies.m4 2014-06-20 20:05:59 +0000
++++ webkitgtk-2.4.1/Source/autotools/FindDependencies.m4 2014-05-24 05:04:11 +0000
+@@ -109,8 +109,14 @@ case "$host" in
+ UNICODE_LIBS="-licucore"
+ ;;
+ *-*-mingw*)
+- UNICODE_CFLAGS=""
+- UNICODE_LIBS="-licui18n -licuuc"
++ PKG_CHECK_MODULES(ICU, icu-i18n, ,)
++ if test "x$ICU_LIBS" = "x" ; then
++ UNICODE_CFLAGS=""
++ UNICODE_LIBS="-licui18n -licuuc"
++ else
++ UNICODE_CFLAGS="$ICU_CFLAGS"
++ UNICODE_LIBS="$ICU_LIBS"
++ fi
+ AC_CHECK_HEADERS([unicode/uchar.h], [], [AC_MSG_ERROR([Could not find ICU headers.])])
+ ;;
+ *)
+@@ -455,7 +461,14 @@ if test "$found_opengl" = "yes"; then
+ OPENGL_LIBS="-lGLESv2"
+ else
+ acceleration_description="$acceleration_description (gl"
+- OPENGL_LIBS="-lGL"
++ case "$host" in
++ *-*-mingw*)
++ OPENGL_LIBS="-lopengl32"
++ ;;
++ *)
++ OPENGL_LIBS="-lGL"
++ ;;
++ esac
+ fi
+ if test "$enable_egl" = "yes"; then
+ acceleration_description="$acceleration_description, egl"
+diff -upr -x .deps -x .libs -x '*.la' webkitgtk-2.4.1.old/Source/autotools/ReadCommandLineArguments.m4 webkitgtk-2.4.1/Source/autotools/ReadCommandLineArguments.m4
+--- webkitgtk-2.4.1.old/Source/autotools/ReadCommandLineArguments.m4 2014-06-20 20:05:59 +0000
++++ webkitgtk-2.4.1/Source/autotools/ReadCommandLineArguments.m4 2014-05-24 05:04:11 +0000
+@@ -83,7 +83,7 @@ AM_WEBKIT_DETERMINE_BUILD_TARGET_STATUS(
+ AM_WEBKIT_DETERMINE_BUILD_TARGET_STATUS([directfb], [enable_directfb_target], [build_targets])
+
+ AC_MSG_CHECKING([whether to build for the Win32 target])
+-AC_MSG_RESULT([$enable_wayland_target])
++AC_MSG_RESULT([$enable_win32_target])
+
+ AC_MSG_CHECKING([whether to enable spellcheck support])
+ AC_ARG_ENABLE([spellcheck],