aboutsummaryrefslogtreecommitdiffstats
path: root/win32/patches/webkitgtk.patch
blob: 7cc42fc0f34811babaf25904a0e9da6fa1ac3123 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
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],