-
Notifications
You must be signed in to change notification settings - Fork 21
/
WKCWebView.cpp
5264 lines (4523 loc) · 150 KB
/
WKCWebView.cpp
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
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
WKCWebView.cpp
Copyright (C) 2007, 2008 Holger Hans Peter Freyther
Copyright (C) 2007, 2008, 2009 Christian Dywan <christian@imendio.com>
Copyright (C) 2007 Xan Lopez <xan@gnome.org>
Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com>
Copyright (C) 2008 Jan Alonzo <jmalonzo@unpluggable.com>
Copyright (C) 2008 Gustavo Noronha Silva <gns@gnome.org>
Copyright (C) 2008 Nuanti Ltd.
Copyright (C) 2008, 2009 Collabora Ltd.
Copyright (C) 2009 Igalia S.L.
Copyright (C) 2009 Movial Creative Technologies Inc.
Copyright (C) 2009 Bobby Powers
Copyright (c) 2010-2018 ACCESS CO., LTD. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#include "WKCWebView.h"
#include "WKCWebViewPrivate.h"
#include "WKCWebFrame.h"
#include "WKCWebFramePrivate.h"
#include "WKCPlatformEvents.h"
#include "WKCClientBuilders.h"
#include "WKCWebViewPrefs.h"
#include "WKCPrefs.h"
#include "WKCMemoryInfo.h"
#include "WKCPlatformStrategies.h"
#include "ChromeClientWKC.h"
#if ENABLE(CONTEXT_MENUS)
#include "ContextMenuClientWKC.h"
#endif
#include "BackForwardClientWKC.h"
#include "EditorClientWKC.h"
#include "DragClientWKC.h"
#include "FrameLoaderClientWKC.h"
#include "InspectorClientWKC.h"
#include "DropDownListClientWKC.h"
#include "GeolocationClientWKC.h"
#include "ProgressTrackerClientWKC.h"
#if ENABLE(REMOTE_INSPECTOR)
#include "WebInspectorServer.h"
#include "InspectorController.h"
#include "InspectorServerClientWKC.h"
#endif
#if ENABLE(DEVICE_ORIENTATION)
#include "DeviceMotionClientWKC.h"
#include "DeviceOrientationClientWKC.h"
#endif
#if ENABLE(MEDIA_STREAM)
#include "UserMediaClientImplWKC.h"
#endif
#if ENABLE(BATTERY_STATUS)
#include "BatteryClientWKC.h"
#endif
#if ENABLE(NOTIFICATIONS)
#include "NotificationClientWKC.h"
#endif
#if ENABLE(NAVIGATOR_CONTENT_UTILS)
#include "NavigatorContentUtilsClientWKC.h"
#endif
#if ENABLE(WKC_WEB_NFC)
#include "WebNfcClientWKC.h"
#endif
#include "DatabaseProviderWKC.h"
#include "StorageNamespaceProviderWKC.h"
#include "VisitedLinkStoreWKC.h"
#if ENABLE(GAMEPAD)
#include "GamepadProvider.h"
#include "GamepadProviderWKC.h"
#endif
#if ENABLE(VIBRATION)
#include "VibrationClient.h"
#include "VibrationClientWKC.h"
#endif
#include <wkc/wkcpeer.h>
#include <wkc/wkcfilepeer.h>
#include <wkc/wkcpasteboardpeer.h>
#include <wkc/wkcgpeer.h>
#include <wkc/wkcmpeer.h>
#include <wkc/wkcmediapeer.h>
#include <wkc/wkcpluginpeer.h>
#include <wkc/wkcglpeer.h>
#include <wkc/wkcsocket.h>
#include "WKCOverlayPrivate.h"
#include "helpers/WKCHistoryItem.h"
#include "helpers/WKCNode.h"
#include "helpers/WKCSettings.h"
#include "helpers/privates/WKCElementPrivate.h"
#include "helpers/privates/WKCHelpersEnumsPrivate.h"
#include "helpers/privates/WKCHistoryItemPrivate.h"
#include "helpers/privates/WKCResourceHandlePrivate.h"
#include "helpers/privates/WKCNodePrivate.h"
#include "helpers/privates/WKCPagePrivate.h"
#include "helpers/privates/WKCEventHandlerPrivate.h"
#include "helpers/privates/WKCFocusControllerPrivate.h"
#include "helpers/privates/WKCPluginDatabasePrivate.h"
#include "helpers/privates/WKCHitTestResultPrivate.h"
#include "helpers/privates/WKCBackForwardListPrivate.h"
#include "Base64.h"
#include "Chrome.h"
#include "Cookie.h"
#include "Page.h"
#include "PageConfiguration.h"
#include "PageGroup.h"
#include "Editor.h"
#include "EventHandler.h"
#include "Frame.h"
#include "FrameView.h"
#include "NodeList.h"
#include "HTMLElement.h"
#include "HTMLLinkElement.h"
#include "HistoryItem.h"
#include "HitTestRequest.h"
#include "HitTestResult.h"
#include "ImageBufferData.h"
#include "ImageWKC.h"
#include "RenderView.h"
#include "RenderText.h"
#include "FocusController.h"
#include "BackForwardList.h"
#include "PlatformKeyboardEvent.h"
#include "PlatformMouseEvent.h"
#include "PlatformTouchEvent.h"
#include "PlatformWheelEvent.h"
#include "ScriptController.h"
#include "StringImpl.h"
#include "DocumentLoader.h"
#include "ProgressTracker.h"
#include "HTMLAreaElement.h"
#include "HTMLInputElement.h"
#include "IconDatabase.h"
#include "PageCache.h"
#include "TextEncodingRegistry.h"
#include "Settings.h"
#include "FloatRect.h"
#include "MemoryCache.h"
#include "HTTPRequest.h"
#include "Text.h"
#include "UserGestureIndicator.h"
#include "RenderTextControl.h"
#include "SpatialNavigation.h"
#include "MouseEventWithHitTestResults.h"
#include "HTMLImageElement.h"
#include "BackForwardController.h"
#include "MainFrame.h"
#include "shadow/TextControlInnerElements.h"
#include "UserContentController.h"
#include "VisitedLinkStore.h"
#include "WebKit/Storage/WebStorageNamespaceProvider.h"
#include "SVGDocumentExtensions.h"
#include "InitializeThreading.h"
#include "PageGroup.h"
#include "Pasteboard.h"
#include "ImageSource.h"
#include "CookieJar.h"
#include "CSSValuePool.h"
#include "RenderLayer.h"
#include "FontCache.h"
#include "FontCascade.h"
#include "CrossOriginPreflightResultCache.h"
#include "ResourceHandleManagerWKC.h"
#include "SharedTimer.h"
#include "GCController.h"
#include "SQLiteFileSystem.h"
#include "WorkerThread.h"
#include "StorageNamespace.h"
#include "Storage.h"
#include "StorageArea.h"
#include "RenderFrameSet.h"
#include "BitmapImage.h"
#include "Modules/websockets/WebSocket.h"
#include "bindings/generic/RuntimeEnabledFeatures.h"
#include "shadow/SliderThumbElement.h"
#if ENABLE(CONTENT_EXTENSIONS)
#include "ContentExtensionCompiler.h"
#endif
#include <wkc/wkcheappeer.h>
#include "FastMalloc.h"
#include "NotImplemented.h"
#ifdef __MINGW32__
# ifdef LoadString
# undef LoadString
# endif
#endif // __MINGW32__
#if USE(MUTEX_DEBUG_LOG)
CRITICAL_SECTION gCriticalSection;
static bool gCriticalSectionFlag = false;
#endif
namespace WebCore {
extern WebCore::IntRect scrollbarTrackRect(Scrollbar& scrollbar);
extern void scrollbarSplitTrack(Scrollbar& scrollbar, const WebCore::IntRect& track, WebCore::IntRect& startTrack, WebCore::IntRect& thumb, WebCore::IntRect& endTrack);
extern WebCore::IntRect scrollbarBackButtonRect(Scrollbar& scrollbar, ScrollbarPart part);
extern WebCore::IntRect scrollbarForwardButtonRect(Scrollbar& scrollbar, ScrollbarPart part);
#if !LOG_DISABLED
extern void initializeLoggingChannelsIfNecessary();
#endif
extern void EventLoop_setCycleProc(bool(*)(void*), void*);
extern void initializeGamepads(int pads);
extern bool notifyGamepadEvent(int index, const WTF::String& id, long long timestamp, int naxes, const float* axes, int nbuttons, const float* buttons);
}
namespace WTF {
extern void finalizeMainThreadPlatform();
}
namespace JSC {
class JSGlobalData;
}
extern "C" {
void wkc_libxml2_resetVariables(void);
void wkc_libxslt_resetVariables(void);
void wkc_sqlite3_force_terminate(void);
#ifdef WKC_USE_WKC_OWN_CAIRO
void wkc_pixman_resetVariables(void);
cairo_public void wkc_cairo_resetVariables(void);
#endif
WKC_PEER_API int wkcFontEngineRegisterSystemFontPeer(int in_type, const unsigned char* in_data, unsigned int in_len);
#if ENABLE(GRAPHICS_CONTEXT_3D)
void ShResetVariables();
#endif
}
using namespace WTF;
#if 0
extern "C" void GUI_Printf(const char*, ...);
# define NX_DP(a) GUI_Printf a
#else
# define NX_DP(a) (void(0))
#endif
#if COMPILER(MSVC) && defined(_DEBUG)
#if 0
extern "C" void GUI_Printf(const char*, ...);
# define NX_MEM_DP LOG_ERROR
#else
# define NX_MEM_DP(...) ((void)0)
#endif
#else
# define NX_MEM_DP(...) ((void)0)
#endif /* COMPILER(MSVC) && defined(_DEBUG) */
namespace WKC {
WKC_WEB_VIEW_COMPILE_ASSERT(sizeof(WKCSocketStatistics) == sizeof(SocketStatistics), sizeof__WKCSocketStatistics);
WKC_DEFINE_GLOBAL_PTR(WTF::Vector<WKCWebViewPrivate*>*, gValidViews, 0);
// private container
WKCWebViewPrivate::WKCWebViewPrivate(WKCWebView* parent, WKCClientBuilders& builders)
: m_parent(parent),
m_clientBuilders(builders)
{
m_corePage = 0;
m_wkcCorePage = 0;
m_mainFrame = 0;
m_inspector = 0;
m_dropdownlist = 0;
m_settings = 0;
m_devicemotion = 0;
m_deviceorientation = 0;
m_notification = 0;
m_progress = 0;
m_offscreen = 0;
m_drawContext = 0;
#if USE(WKC_CAIRO)
m_offscreenFormat = 0;
m_offscreenBitmap = 0;
m_offscreenRowBytes = 0;
m_offscreenSize.fWidth = 0;
m_offscreenSize.fHeight = 0;
#endif
m_isZoomFullContent = true;
m_isTransparent = false;
m_loadStatus = ELoadStatusNone;
m_opticalZoomLevel = 1.f;
WKCFloatPoint_Set(&m_opticalZoomOffset, 0, 0);
m_encoding = 0;
m_customEncoding = 0;
m_focusedElement = 0;
m_elementFromPoint = 0;
#if ENABLE(REMOTE_INSPECTOR)
m_inspectorServerClient = 0;
m_inspectorIsEnabled = false;
#endif
m_editable = true;
m_forceTerminated = false;
m_viewState = WebCore::ViewState::NoFlags;
if (!gValidViews)
gValidViews = new WTF::Vector<WKCWebViewPrivate*>();
gValidViews->append(this);
m_rootGraphicsLayer = 0;
}
WKCWebViewPrivate::~WKCWebViewPrivate()
{
size_t pos = gValidViews->find(this);
if (pos!=WTF::notFound) {
gValidViews->remove(pos);
}
if (m_forceTerminated) {
return;
}
delete m_elementFromPoint;
#if ENABLE(REMOTE_INSPECTOR)
if (m_inspectorServerClient) {
if (m_inspector) {
m_inspector->setInspectorServerClient(0);
m_inspector = 0; // it may be deleted by Page
}
delete m_inspectorServerClient;
m_inspectorServerClient = 0;
}
#endif
if (m_offscreen) {
wkcOffscreenDeletePeer(m_offscreen);
}
m_offscreen = 0;
if (m_drawContext) {
wkcDrawContextDeletePeer(m_drawContext);
}
m_drawContext = 0;
if (m_encoding) {
WTF::fastFree(m_encoding);
m_encoding = 0;
}
if (m_customEncoding) {
WTF::fastFree(m_customEncoding);
m_customEncoding = 0;
}
if (m_corePage) {
m_corePage->settings().setUsesPageCache(false);
m_mainFrame->privateFrame()->core()->loader().detachFromParent();
}
if (m_wkcCorePage) {
delete m_wkcCorePage;
}
if (m_corePage) {
delete m_corePage;
m_corePage = 0;
}
if (m_dropdownlist) {
delete m_dropdownlist;
m_dropdownlist = 0;
}
delete m_focusedElement;
delete m_progress;
#if ENABLE(NAVIGATOR_CONTENT_UTILS)
// delete m_navigatorcontentutils;
m_navigatorcontentutils = 0;
#endif
#if ENABLE(NOTIFICATIONS)
delete m_notification;
m_notification = 0;
#endif
#if ENABLE(DEVICE_ORIENTATION)
delete m_deviceorientation;
delete m_devicemotion;
m_deviceorientation = 0;
m_devicemotion = 0;
#endif
// m_mainFrame will be deleted automatically...
if (m_settings) {
m_settings->~WKCSettings();
WTF::fastFree((void *)m_settings);
m_settings = 0;
}
if (WebCore::ResourceHandleManager::isExistSharedInstance()) {
WebCore::ResourceHandleManager::sharedInstance()->suspendNetworkThread();
}
}
bool
WKCWebViewPrivate::isValidView(WKCWebViewPrivate* view)
{
if (!gValidViews)
return false;
return gValidViews->find(view) != WTF::notFound;
}
WKCWebViewPrivate*
WKCWebViewPrivate::create(WKCWebView* parent, WKCClientBuilders& builders)
{
WKCWebViewPrivate* self = 0;
self = new WKCWebViewPrivate(parent, builders);
if (!self) return 0;
if (!self->construct()) {
delete self;
return 0;
}
return self;
}
bool
WKCWebViewPrivate::construct()
{
WKC::ChromeClientWKC* chrome = 0;
#if USE(WKC_CUSTOM_BACKFORWARD_LIST)
WKC::BackForwardClientWKC* backforward = 0;
#endif
#if ENABLE(CONTEXT_MENUS)
WKC::ContextMenuClientWKC* contextmenu = 0;
#endif
WKC::EditorClientWKC* editor = 0;
WKC::DragClientWKC* drag = 0;
#if ENABLE(GEOLOCATION)
WKC::GeolocationClientWKC* geolocation = 0;
#endif
#if ENABLE(MEDIA_STREAM)
WKC::UserMediaClientWKC* usermedia = 0;
#endif
#if ENABLE(BATTERY_STATUS)
WKC::BatteryClientWKC* batteryclient = 0;
#endif
#if ENABLE(WKC_WEB_NFC)
WKC::WebNfcClientWKC* webNfcClient = 0;
#endif
#if ENABLE(VIBRATION)
WKC::VibrationClientWKC* vibrationClient = 0;
#endif
WKC::FrameLoaderClientWKC* mainframeloaderclient = 0;
WebCore::Settings* settings = 0;
WebCore::PageConfiguration cli;
chrome = WKC::ChromeClientWKC::create(this);
if (!chrome) goto error_end;
backforward = WKC::BackForwardClientWKC::create(this);
if (!backforward) goto error_end;
#if ENABLE(CONTEXT_MENUS)
contextmenu = WKC::ContextMenuClientWKC::create(this);
if (!contextmenu) goto error_end;
#endif
editor = WKC::EditorClientWKC::create(this);
if (!editor) goto error_end;
drag = WKC::DragClientWKC::create(this);
if (!drag) goto error_end;
#if ENABLE(GEOLOCATION)
geolocation = WKC::GeolocationClientWKC::create(this);
if (!geolocation) goto error_end;
#endif
#if ENABLE(DEVICE_ORIENTATION)
m_devicemotion = WKC::DeviceMotionClientWKC::create(this);
if (!m_devicemotion) goto error_end;
m_deviceorientation = WKC::DeviceOrientationClientWKC::create(this);
if (!m_deviceorientation) goto error_end;
#endif
#if ENABLE(MEDIA_STREAM)
usermedia = WKC::UserMediaClientWKC::create(this);
if (!usermedia) goto error_end;
#endif
#if ENABLE(BATTERY_STATUS)
batteryclient = WKC::BatteryClientWKC::create(this);
if (!batteryclient) goto error_end;
#endif
#if ENABLE(NOTIFICATIONS)
m_notification = WKC::NotificationClientWKC::create(this);
if (!m_notification) goto error_end;
#endif
#if ENABLE(NAVIGATOR_CONTENT_UTILS)
m_navigatorcontentutils = WKC::NavigatorContentUtilsClientWKC::create(this);
if (!m_navigatorcontentutils) goto error_end;
#endif
#if ENABLE(WKC_WEB_NFC)
webNfcClient = WKC::WebNfcClientWKC::create(this);
if (!webNfcClient) goto error_end;
#endif
#if ENABLE(VIBRATION)
vibrationClient = WKC::VibrationClientWKC::create(this);
#endif
m_progress = WKC::ProgressTrackerClientWKC::create(this);
if (!m_progress) goto error_end;
mainframeloaderclient = WKC::FrameLoaderClientWKC::create();
if (!mainframeloaderclient) goto error_end;
m_inspector = WKC::InspectorClientWKC::create(this);
if (!m_inspector) goto error_end;
cli.chromeClient = chrome;
#if USE(WKC_CUSTOM_BACKFORWARD_LIST)
cli.backForwardClient = adoptRef(*backforward);
#endif
#if ENABLE(CONTEXT_MENUS)
cli.contextMenuClient = contextmenu;
#endif
cli.editorClient = editor;
cli.dragClient = drag;
cli.inspectorClient = m_inspector;
cli.progressTrackerClient = m_progress;
cli.loaderClientForMainFrame = mainframeloaderclient;
cli.alternativeTextClient = 0;
cli.databaseProvider = WKC::DatabaseProviderWKC::create(this);
cli.storageNamespaceProvider = WKC::StoragenamespaceProviderWKC::create(this);
cli.userContentController = WebCore::UserContentController::create();
cli.visitedLinkStore = WKC::VisitedLinkStoreWKC::create(this);
m_corePage = new WebCore::Page(cli);
if (!m_corePage) goto error_end;
m_wkcCorePage = new PagePrivate(m_corePage);
#if ENABLE(GEOLOCATION)
provideGeolocationTo(m_corePage, geolocation);
#endif
#if ENABLE(DEVICE_ORIENTATION)
provideDeviceMotionTo(m_corePage, m_devicemotion);
provideDeviceOrientationTo(m_corePage, m_deviceorientation);
#endif
#if ENABLE(MEDIA_STREAM)
provideUserMediaTo(m_corePage, usermedia);
#endif
#if ENABLE(BATTERY_STATUS)
provideBatteryTo(m_corePage, batteryclient);
#endif
#if ENABLE(NOTIFICATIONS)
provideNotification(m_corePage, m_notification);
#endif
#if ENABLE(NAVIGATOR_CONTENT_UTILS)
provideNavigatorContentUtilsTo(m_corePage, std::unique_ptr<WebCore::NavigatorContentUtilsClient>(m_navigatorcontentutils));
#endif
#if ENABLE(WKC_WEB_NFC)
provideWebNfcTo(m_corePage, webNfcClient);
#endif
#if ENABLE(VIBRATION)
if (vibrationClient)
provideVibrationTo(m_corePage, vibrationClient);
#endif
m_corePage->addLayoutMilestones(WebCore::DidFirstLayout | WebCore::DidFirstVisuallyNonEmptyLayout);
m_corePage->setIsPrerender();
m_mainFrame = WKC::WKCWebFrame::create(this, m_clientBuilders, 0, true);
if (!m_mainFrame) goto error_end;
if (!mainframeloaderclient->setMainFrame(m_mainFrame->privateFrame()))
goto error_end;
m_mainFrame->privateFrame()->core()->tree().setName("");
m_mainFrame->privateFrame()->core()->init();
m_dropdownlist = WKC::DropDownListClientWKC::create(this);
if (!m_dropdownlist) goto error_end;
settings = &m_corePage->settings();
m_settings = (WKC::WKCSettings *)WTF::fastMalloc(sizeof(WKC::WKCSettings));
m_settings = new (m_settings) WKC::WKCSettings(this);
if (!m_settings) goto error_end;
settings->setDefaultTextEncodingName("UTF-8");
settings->setSerifFontFamily("Times New Roman");
settings->setFixedFontFamily("Courier New");
settings->setSansSerifFontFamily("Arial");
settings->setStandardFontFamily("Times New Roman");
settings->setLoadsImagesAutomatically(true);
settings->setShrinksStandaloneImagesToFit(true);
settings->setShouldPrintBackgrounds(true);
settings->setScriptEnabled(true);
settings->setSpatialNavigationEnabled(true);
settings->setImagesEnabled(true);
settings->setMediaEnabled(true);
settings->setPluginsEnabled(false);
settings->setLocalStorageEnabled(false);
settings->setTextAreasAreResizable(true);
settings->setUserStyleSheetLocation(WebCore::URL());
settings->setDeveloperExtrasEnabled(false);
settings->setCaretBrowsingEnabled(false);
settings->setLocalStorageEnabled(false);
settings->setXSSAuditorEnabled(false);
settings->setJavaScriptCanOpenWindowsAutomatically(false);
settings->setJavaScriptCanAccessClipboard(false);
settings->setOfflineWebApplicationCacheEnabled(false);
settings->setAllowUniversalAccessFromFileURLs(false);
settings->setDOMPasteAllowed(false);
settings->setNeedsSiteSpecificQuirks(false);
settings->setUsesPageCache(false);
settings->setDefaultFixedFontSize(14);
settings->setDefaultFontSize(14);
settings->setDownloadableBinaryFontsEnabled(true);
settings->setShowDebugBorders(false);
settings->setAuthorAndUserStylesEnabled(true);
// settings->setAllowScriptsToCloseWindows(true);
settings->setDNSPrefetchingEnabled(true);
settings->setFixedBackgroundsPaintRelativeToDocument(true);
settings->setCanvasUsesAcceleratedDrawing(false);
settings->setAcceleratedDrawingEnabled(false);
settings->setAcceleratedFiltersEnabled(false);
WebCore::RuntimeEnabledFeatures::sharedFeatures().setCSSRegionsEnabled(true);
settings->setAcceleratedCompositingEnabled(false);
settings->setAcceleratedCompositingForFixedPositionEnabled(false);
settings->setAcceleratedCompositingForOverflowScrollEnabled(false);
settings->setExperimentalNotificationsEnabled(false);
settings->setWebGLEnabled(true);
settings->setWebGLErrorsToConsoleEnabled(true);
settings->setOpenGLMultisamplingEnabled(true);
settings->setWebAudioEnabled(false);
settings->setAccelerated2dCanvasEnabled(true);
settings->setMinimumAccelerated2dCanvasSize(64);
settings->setLoadDeferringEnabled(true);
settings->setPaginateDuringLayoutEnabled(true);
#if ENABLE(FULLSCREEN_API)
settings->setFullScreenEnabled(true);
#endif
settings->setAsynchronousSpellCheckingEnabled(false);
settings->setUsePreHTML5ParserQuirks(false);
settings->setForceCompositingMode(false);
settings->setAllowDisplayOfInsecureContent(false);
settings->setAllowRunningOfInsecureContent(false);
settings->setMaximumHTMLParserDOMTreeDepth(WebCore::Settings::defaultMaximumHTMLParserDOMTreeDepth);
settings->setHyperlinkAuditingEnabled(true);
settings->setCrossOriginCheckInGetMatchedCSSRulesDisabled(true);
settings->setLayoutFallbackWidth(1024);
settings->setWebSecurityEnabled(true);
settings->setXSSAuditorEnabled(true);
settings->setHiddenPageCSSAnimationSuspensionEnabled(true);
settings->setHiddenPageDOMTimerThrottlingEnabled(false);
#if ENABLE(WEB_SOCKETS)
WebCore::WebSocket::setIsAvailable(true);
#endif
#if ENABLE(VIDEO_TRACK)
WebCore::RuntimeEnabledFeatures::sharedFeatures().setWebkitVideoTrackEnabled(true);
settings->setShouldDisplaySubtitles(true);
settings->setShouldDisplayCaptions(true);
settings->setShouldDisplayTextDescriptions(true);
#endif
#if ENABLE(TEXT_AUTOSIZING)
settings->setTextAutosizingEnabled(true);
settings->setTextAutosizingFontScaleFactor(1.f);
#endif
#if ENABLE(CSS_REGIONS)
WebCore::RuntimeEnabledFeatures::sharedFeatures().setCSSRegionsEnabled(true);
#endif
#if ENABLE(CSS_COMPOSITING)
WebCore::RuntimeEnabledFeatures::sharedFeatures().setCSSCompositingEnabled(true);
#endif
#if ENABLE(INDEXED_DATABASE)
WebCore::RuntimeEnabledFeatures::sharedFeatures().setWebkitIndexedDBEnabled(true);
#endif
#if ENABLE(MEDIA_STREAM)
WebCore::RuntimeEnabledFeatures::sharedFeatures().setMediaStreamEnabled(true);
#endif
#if ENABLE(GAMEPAD)
WebCore::RuntimeEnabledFeatures::sharedFeatures().setGamepadsEnabled(true);
#endif
#if ENABLE(CSP_NEXT)
WebCore::RuntimeEnabledFeatures::sharedFeatures().setExperimentalContentSecurityPolicyFeaturesEnabled(true);
#endif
#if ENABLE(FONT_LOAD_EVENTS)
WebCore::RuntimeEnabledFeatures::sharedFeatures().setFontLoadEventsEnabled(true);
#endif
#if ENABLE(SERVICE_CONTROLS)
settings->setImageControlsEnabled(true);
#endif
#if ENABLE(REMOTE_INSPECTOR)
if (WebInspectorServer::sharedInstance()) {
m_inspectorServerClient = WKC::InspectorServerClientWKC::create(this);
m_inspectorServerClient->disableRemoteInspection();
m_inspector->setInspectorServerClient(m_inspectorServerClient);
}
#endif
#if 1
// temporalily disabled
WebCore::RuntimeEnabledFeatures::sharedFeatures().setInputTypeDateEnabled(false);
WebCore::RuntimeEnabledFeatures::sharedFeatures().setInputTypeTimeEnabled(false);
WebCore::RuntimeEnabledFeatures::sharedFeatures().setInputTypeMonthEnabled(false);
WebCore::RuntimeEnabledFeatures::sharedFeatures().setInputTypeWeekEnabled(false);
WebCore::RuntimeEnabledFeatures::sharedFeatures().setInputTypeDateTimeLocalEnabled(false);
#endif
m_corePage->setSessionID(WebCore::SessionID::defaultSessionID());
m_corePage->mainFrame().view()->setClipsRepaints(WKCWebView::clipsRepaints());
return true;
error_end:
if (m_settings) {
m_settings->~WKCSettings();
WTF::fastFree((void *)m_settings);
m_settings = 0;
}
if (m_dropdownlist) {
delete m_dropdownlist;
m_dropdownlist = 0;
}
if (m_corePage) {
delete m_corePage;
m_corePage = 0;
// m_mainFrame will be deleted automatically...
} else {
#if ENABLE(NAVIGATOR_CONTENT_UTILS)
delete m_navigatorcontentutils;
m_navigatorcontentutils = 0;
#endif
delete mainframeloaderclient;
delete m_progress;
#if ENABLE(NOTIFICATIONS)
delete m_notification;
m_notification = 0;
#endif
#if ENABLE(BATTERY_STATUS)
delete batteryclient;
#endif
#if ENABLE(MEDIA_STREAM)
delete usermedia;
#endif
#if ENABLE(DEVICE_ORIENTATION)
delete m_deviceorientation;
delete m_devicemotion;
m_deviceorientation = 0;
m_devicemotion = 0;
#endif
#if ENABLE(GEOLOCATION)
delete geolocation;
#endif
delete drag;
delete editor;
#if ENABLE(CONTEXT_MENUS)
delete contextmenu;
#endif
#if ENABLE(WKC_WEB_NFC)
delete webNfcClient;
#endif
#if ENABLE(VIBRATION)
delete vibrationClient;
#endif
delete backforward;
delete chrome;
}
if (m_inspector) {
delete m_inspector;
m_inspector = 0;
}
return false;
}
void
WKCWebViewPrivate::notifyForceTerminate()
{
NX_DP(("WKCWebViewPrivate::notifyForceTerminate\n"));
m_forceTerminated = true;
if (m_mainFrame) {
m_mainFrame->notifyForceTerminate();
}
if (WebCore::ResourceHandleManager::isExistSharedInstance()) {
WebCore::ResourceHandleManager::sharedInstance()->suspendNetworkThread();
}
}
WKC::WKCSettings*
WKCWebViewPrivate::settings()
{
return m_settings;
}
WKC::Page*
WKCWebViewPrivate::wkcCore() const
{
return &m_wkcCorePage->wkc();
}
// drawings
bool
WKCWebViewPrivate::setOffscreen(OffscreenFormat format, void* bitmap, int rowbytes, const WebCore::IntSize& offscreensize, const WebCore::IntSize& viewsize, bool fixedlayout, const WebCore::IntSize* desktopsize, bool needslayout)
{
int pformat = 0;
WKCSize size;
if (!desktopsize)
desktopsize = &offscreensize;
if (m_drawContext) {
wkcDrawContextDeletePeer(m_drawContext);
m_drawContext = 0;
}
if (m_offscreen) {
wkcOffscreenDeletePeer(m_offscreen);
m_offscreen = 0;
}
switch (format) {
case EOffscreenFormatPolygon:
pformat = WKC_OFFSCREEN_TYPE_POLYGON;
break;
case EOffscreenFormatCairo16:
pformat = WKC_OFFSCREEN_TYPE_CAIRO16;
break;
case EOffscreenFormatCairo32:
pformat = WKC_OFFSCREEN_TYPE_CAIRO32;
break;
case EOffscreenFormatCairoSurface:
pformat = WKC_OFFSCREEN_TYPE_CAIROSURFACE;
break;
default:
return false;
}
size.fWidth = offscreensize.width();
size.fHeight = offscreensize.height();
#if USE(WKC_CAIRO)
m_offscreenFormat = pformat;
m_offscreenBitmap = bitmap;
m_offscreenRowBytes = rowbytes;
m_offscreenSize = size;
#endif
m_offscreen = wkcOffscreenNewPeer(pformat, bitmap, rowbytes, &size);
if (!m_offscreen) return false;
m_drawContext = wkcDrawContextNewPeer(m_offscreen);
if (!m_drawContext) return false;
if (needslayout) {
m_desktopSize = *desktopsize;
m_defaultDesktopSize = *desktopsize;
m_defaultViewSize = viewsize;
m_viewSize = viewsize;
WebCore::Frame* frame = (WebCore::Frame *)&core()->mainFrame();
if (!frame || !frame->view()) {
return false;
}
if (fixedlayout) {
frame->view()->setUseFixedLayout(true);
frame->view()->setFixedLayoutSize(viewsize);
} else {
frame->view()->setUseFixedLayout(false);
}
frame->view()->resize(desktopsize->width(), desktopsize->height());
frame->view()->forceLayout();
frame->view()->adjustViewSize();
}
return true;
}
void
WKCWebViewPrivate::notifyResizeDesktopSize(const WebCore::IntSize& size, bool sendresizeevent)
{
m_desktopSize = size;
WebCore::Frame* frame = (WebCore::Frame *)&core()->mainFrame();
if (!frame || !frame->view()) {
return;
}
frame->view()->resize(size.width(), size.height());
if (sendresizeevent)
frame->view()->sendResizeEventIfNeeded();
frame->view()->forceLayout();
frame->view()->adjustViewSize();
updateOverlay(WebCore::IntRect(), true);
}
void
WKCWebViewPrivate::notifyResizeViewSize(const WebCore::IntSize& size)
{
WebCore::Frame* frame = (WebCore::Frame *)&core()->mainFrame();
if (!frame) return;
WebCore::FrameView* view = frame->view();
if (!view) return;
m_viewSize = size;
view->setFixedLayoutSize(size);
}
const WebCore::IntSize&
WKCWebViewPrivate::desktopSize() const
{
return m_desktopSize;
}
const WebCore::IntSize&
WKCWebViewPrivate::viewSize() const
{
return m_viewSize;
}
const WebCore::IntSize&
WKCWebViewPrivate::defaultDesktopSize() const
{
return m_defaultDesktopSize;
}
const WebCore::IntSize&
WKCWebViewPrivate::defaultViewSize() const
{
return m_defaultViewSize;
}
void
WKCWebViewPrivate::notifyRelayout()
{
WebCore::Frame* frame = (WebCore::Frame *)&core()->mainFrame();
if (!frame || !frame->contentRenderer() || !frame->view()) {
return;
}
frame->view()->updateLayoutAndStyleIfNeededRecursive();
}
void
WKCWebViewPrivate::notifyPaintOffscreenFrom(const WebCore::IntRect& rect, const WKCPoint& p)
{
#if USE(WKC_CAIRO)
if (!recoverFromCairoError())
return;
#else
if (!m_offscreen)
return;
#endif
WebCore::Frame* frame = (WebCore::Frame *)&core()->mainFrame();
if (!frame || !frame->contentRenderer() || !frame->view()) {
return;
}
WebCore::GraphicsContext ctx((PlatformGraphicsContext *)m_drawContext);
wkcOffscreenBeginPaintPeer(m_offscreen);
float transX, transY;