/
PageClientImplIOS.mm
1131 lines (923 loc) · 35.4 KB
/
PageClientImplIOS.mm
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
/*
* Copyright (C) 2012-2019 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.
*/
#import "config.h"
#import "PageClientImplIOS.h"
#if PLATFORM(IOS_FAMILY)
#import "APIData.h"
#import "ApplicationStateTracker.h"
#import "DataReference.h"
#import "DrawingAreaProxy.h"
#import "EndowmentStateTracker.h"
#import "FrameInfoData.h"
#import "InteractionInformationAtPosition.h"
#import "NativeWebKeyboardEvent.h"
#import "NavigationState.h"
#import "PlatformXRSystem.h"
#import "RemoteLayerTreeNode.h"
#import "RunningBoardServicesSPI.h"
#import "StringUtilities.h"
#import "TapHandlingResult.h"
#import "UIKitSPI.h"
#import "UndoOrRedo.h"
#import "ViewSnapshotStore.h"
#import "WKContentView.h"
#import "WKContentViewInteraction.h"
#import "WKEditCommand.h"
#import "WKGeolocationProviderIOS.h"
#import "WKPasswordView.h"
#import "WKProcessPoolInternal.h"
#import "WKWebViewConfigurationInternal.h"
#import "WKWebViewContentProviderRegistry.h"
#import "WKWebViewIOS.h"
#import "WKWebViewInternal.h"
#import "WKWebViewPrivateForTesting.h"
#import "WebContextMenuProxy.h"
#import "WebDataListSuggestionsDropdownIOS.h"
#import "WebEditCommandProxy.h"
#import "WebPageProxy.h"
#import "WebProcessProxy.h"
#import "_WKDownloadInternal.h"
#import <WebCore/Cursor.h>
#import <WebCore/DOMPasteAccess.h>
#import <WebCore/DictionaryLookup.h>
#import <WebCore/NotImplemented.h>
#import <WebCore/PlatformScreen.h>
#import <WebCore/PromisedAttachmentInfo.h>
#import <WebCore/ScreenOrientationType.h>
#import <WebCore/ShareData.h>
#import <WebCore/SharedBuffer.h>
#import <WebCore/TextIndicator.h>
#import <WebCore/ValidationBubble.h>
#import <wtf/BlockPtr.h>
#import <wtf/cocoa/Entitlements.h>
#define MESSAGE_CHECK(assertion) MESSAGE_CHECK_BASE(assertion, m_webView.get()->_page->process().connection())
@interface UIWindow ()
- (BOOL)_isHostedInAnotherProcess;
@end
namespace WebKit {
using namespace WebCore;
PageClientImpl::PageClientImpl(WKContentView *contentView, WKWebView *webView)
: PageClientImplCocoa(webView)
, m_contentView(contentView)
, m_undoTarget(adoptNS([[WKEditorUndoTarget alloc] init]))
{
}
PageClientImpl::~PageClientImpl()
{
}
std::unique_ptr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy(WebProcessProxy& process)
{
return [m_contentView _createDrawingAreaProxy:process];
}
void PageClientImpl::setViewNeedsDisplay(const Region&)
{
ASSERT_NOT_REACHED();
}
void PageClientImpl::requestScroll(const FloatPoint& scrollPosition, const IntPoint& scrollOrigin, ScrollIsAnimated animated)
{
[m_webView _scrollToContentScrollPosition:scrollPosition scrollOrigin:scrollOrigin animated:animated == ScrollIsAnimated::Yes];
}
WebCore::FloatPoint PageClientImpl::viewScrollPosition()
{
if (UIScrollView *scroller = [m_contentView _scroller])
return scroller.contentOffset;
return { };
}
IntSize PageClientImpl::viewSize()
{
return IntSize([m_webView bounds].size);
}
bool PageClientImpl::isViewWindowActive()
{
// FIXME: https://bugs.webkit.org/show_bug.cgi?id=133098
return isViewVisible() || [m_webView _isRetainingActiveFocusedState];
}
bool PageClientImpl::isViewFocused()
{
return (isViewInWindow() && ![m_webView _isBackground] && [m_webView _contentViewIsFirstResponder]) || [m_webView _isRetainingActiveFocusedState];
}
bool PageClientImpl::isViewVisible()
{
if (isViewInWindow() && ![m_webView _isBackground])
return true;
if ([m_webView _isShowingVideoPictureInPicture])
return true;
if ([m_webView _mayAutomaticallyShowVideoPictureInPicture])
return true;
#if ENABLE(WEBXR) && !USE(OPENXR)
auto page = m_webView.get()->_page;
if (page && page->xrSystem() && page->xrSystem()->hasActiveSession())
return true;
#endif
return false;
}
bool PageClientImpl::canTakeForegroundAssertions()
{
if (EndowmentStateTracker::singleton().isVisible()) {
// If the application is visible according to the UIKit visibility endowment then we can take
// foreground assertions. Note that for view services, the visibility endownment from the host
// application gets propagated to the view service.
return true;
}
// If there is no run time limitation, then it means that the process is allowed to run for an extended
// period of time in the background (e.g. a daemon) and we let such processes take foreground assertions.
return [RBSProcessHandle currentProcess].activeLimitations.runTime == RBSProcessTimeLimitationNone;
}
bool PageClientImpl::isViewInWindow()
{
// FIXME: in WebKitTestRunner, m_webView is nil, so check the content view instead.
if (auto webView = m_webView.get())
return [webView window];
return [m_contentView window];
}
bool PageClientImpl::isViewVisibleOrOccluded()
{
return isViewVisible();
}
bool PageClientImpl::isVisuallyIdle()
{
return !isViewVisible();
}
void PageClientImpl::processDidExit()
{
[m_contentView _processDidExit];
[m_webView _processDidExit];
}
void PageClientImpl::processWillSwap()
{
[m_contentView _processWillSwap];
[m_webView _processWillSwap];
}
void PageClientImpl::didRelaunchProcess()
{
[m_contentView _didRelaunchProcess];
[m_webView _didRelaunchProcess];
}
#if HAVE(VISIBILITY_PROPAGATION_VIEW)
void PageClientImpl::didCreateContextInWebProcessForVisibilityPropagation(LayerHostingContextID)
{
[m_contentView _webProcessDidCreateContextForVisibilityPropagation];
}
#if ENABLE(GPU_PROCESS)
void PageClientImpl::didCreateContextInGPUProcessForVisibilityPropagation(LayerHostingContextID)
{
[m_contentView _gpuProcessDidCreateContextForVisibilityPropagation];
}
#endif // ENABLE(GPU_PROCESS)
#endif // HAVE(VISIBILITY_PROPAGATION_VIEW)
#if ENABLE(GPU_PROCESS)
void PageClientImpl::gpuProcessDidExit()
{
[m_contentView _gpuProcessDidExit];
PageClientImplCocoa::gpuProcessDidExit();
}
#endif
void PageClientImpl::preferencesDidChange()
{
notImplemented();
}
void PageClientImpl::toolTipChanged(const String&, const String&)
{
notImplemented();
}
void PageClientImpl::didNotHandleTapAsClick(const WebCore::IntPoint& point)
{
[m_contentView _didNotHandleTapAsClick:point];
}
void PageClientImpl::didHandleTapAsHover()
{
[m_contentView _didHandleTapAsHover];
}
void PageClientImpl::didCompleteSyntheticClick()
{
[m_contentView _didCompleteSyntheticClick];
}
void PageClientImpl::decidePolicyForGeolocationPermissionRequest(WebFrameProxy& frame, const FrameInfoData& frameInfo, Function<void(bool)>& completionHandler)
{
[[wrapper(m_webView.get()->_page->process().processPool()) _geolocationProvider] decidePolicyForGeolocationRequestFromOrigin:FrameInfoData { frameInfo } completionHandler:std::exchange(completionHandler, nullptr) view:m_webView.get().get()];
}
void PageClientImpl::didStartProvisionalLoadForMainFrame()
{
[m_webView _didStartProvisionalLoadForMainFrame];
[m_contentView _didStartProvisionalLoadForMainFrame];
[m_webView _hidePasswordView];
}
void PageClientImpl::didFailProvisionalLoadForMainFrame()
{
[m_webView _hidePasswordView];
}
void PageClientImpl::didCommitLoadForMainFrame(const String& mimeType, bool useCustomContentProvider)
{
[m_webView _hidePasswordView];
[m_webView _setHasCustomContentView:useCustomContentProvider loadedMIMEType:mimeType];
[m_contentView _didCommitLoadForMainFrame];
}
void PageClientImpl::didChangeContentSize(const WebCore::IntSize&)
{
notImplemented();
}
void PageClientImpl::disableDoubleTapGesturesDuringTapIfNecessary(WebKit::TapIdentifier requestID)
{
[m_contentView _disableDoubleTapGesturesDuringTapIfNecessary:requestID];
}
void PageClientImpl::handleSmartMagnificationInformationForPotentialTap(WebKit::TapIdentifier requestID, const WebCore::FloatRect& renderRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale, bool nodeIsRootLevel)
{
[m_contentView _handleSmartMagnificationInformationForPotentialTap:requestID renderRect:renderRect fitEntireRect:fitEntireRect viewportMinimumScale:viewportMinimumScale viewportMaximumScale:viewportMaximumScale nodeIsRootLevel:nodeIsRootLevel];
}
double PageClientImpl::minimumZoomScale() const
{
if (UIScrollView *scroller = [m_webView scrollView])
return scroller.minimumZoomScale;
return 1;
}
WebCore::FloatRect PageClientImpl::documentRect() const
{
return [m_contentView bounds];
}
void PageClientImpl::setCursor(const Cursor& cursor)
{
// The Web process may have asked to change the cursor when the view was in an active window, but
// if it is no longer in a window or the window is not active, then the cursor should not change.
if (!isViewWindowActive())
return;
cursor.setAsPlatformCursor();
}
void PageClientImpl::setCursorHiddenUntilMouseMoves(bool)
{
notImplemented();
}
void PageClientImpl::didChangeViewportProperties(const ViewportAttributes&)
{
notImplemented();
}
void PageClientImpl::registerEditCommand(Ref<WebEditCommandProxy>&& command, UndoOrRedo undoOrRedo)
{
auto actionName = command->label();
auto commandObjC = adoptNS([[WKEditCommand alloc] initWithWebEditCommandProxy:WTFMove(command)]);
NSUndoManager *undoManager = [m_contentView undoManagerForWebView];
[undoManager registerUndoWithTarget:m_undoTarget.get() selector:((undoOrRedo == UndoOrRedo::Undo) ? @selector(undoEditing:) : @selector(redoEditing:)) object:commandObjC.get()];
if (!actionName.isEmpty())
[undoManager setActionName:(NSString *)actionName];
}
void PageClientImpl::clearAllEditCommands()
{
[[m_contentView undoManager] removeAllActionsWithTarget:m_undoTarget.get()];
}
bool PageClientImpl::canUndoRedo(UndoOrRedo undoOrRedo)
{
return (undoOrRedo == UndoOrRedo::Undo) ? [[m_contentView undoManager] canUndo] : [[m_contentView undoManager] canRedo];
}
void PageClientImpl::executeUndoRedo(UndoOrRedo undoOrRedo)
{
return (undoOrRedo == UndoOrRedo::Undo) ? [[m_contentView undoManager] undo] : [[m_contentView undoManager] redo];
}
void PageClientImpl::accessibilityWebProcessTokenReceived(const IPC::DataReference& data)
{
NSData *remoteToken = [NSData dataWithBytes:data.data() length:data.size()];
[m_contentView _setAccessibilityWebProcessToken:remoteToken];
}
bool PageClientImpl::interpretKeyEvent(const NativeWebKeyboardEvent& event, bool isCharEvent)
{
return [m_contentView _interpretKeyEvent:event.nativeEvent() isCharEvent:isCharEvent];
}
void PageClientImpl::positionInformationDidChange(const InteractionInformationAtPosition& info)
{
[m_contentView _positionInformationDidChange:info];
}
void PageClientImpl::saveImageToLibrary(Ref<SharedBuffer>&& imageBuffer)
{
RetainPtr<NSData> imageData = imageBuffer->createNSData();
UIImageDataWriteToSavedPhotosAlbum(imageData.get(), nil, NULL, NULL);
}
bool PageClientImpl::executeSavedCommandBySelector(const String&)
{
notImplemented();
return false;
}
void PageClientImpl::selectionDidChange()
{
[m_contentView _selectionChanged];
}
void PageClientImpl::updateSecureInputState()
{
notImplemented();
}
void PageClientImpl::resetSecureInputState()
{
notImplemented();
}
void PageClientImpl::notifyInputContextAboutDiscardedComposition()
{
notImplemented();
}
void PageClientImpl::assistiveTechnologyMakeFirstResponder()
{
[m_contentView becomeFirstResponder];
}
void PageClientImpl::makeFirstResponder()
{
notImplemented();
}
FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& rect)
{
return rect;
}
FloatRect PageClientImpl::convertToUserSpace(const FloatRect& rect)
{
return rect;
}
IntPoint PageClientImpl::screenToRootView(const IntPoint& point)
{
return IntPoint([m_contentView convertPoint:point fromView:nil]);
}
IntRect PageClientImpl::rootViewToScreen(const IntRect& rect)
{
return enclosingIntRect([m_contentView convertRect:rect toView:nil]);
}
IntPoint PageClientImpl::accessibilityScreenToRootView(const IntPoint& point)
{
CGPoint rootViewPoint = point;
if ([m_contentView respondsToSelector:@selector(accessibilityConvertPointFromSceneReferenceCoordinates:)])
rootViewPoint = [m_contentView accessibilityConvertPointFromSceneReferenceCoordinates:rootViewPoint];
return IntPoint(rootViewPoint);
}
IntRect PageClientImpl::rootViewToAccessibilityScreen(const IntRect& rect)
{
CGRect rootViewRect = rect;
if ([m_contentView respondsToSelector:@selector(accessibilityConvertRectToSceneReferenceCoordinates:)])
rootViewRect = [m_contentView accessibilityConvertRectToSceneReferenceCoordinates:rootViewRect];
return enclosingIntRect(rootViewRect);
}
void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent& event, bool eventWasHandled)
{
[m_contentView _didHandleKeyEvent:event.nativeEvent() eventWasHandled:eventWasHandled];
}
#if ENABLE(TOUCH_EVENTS)
void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent& nativeWebTouchEvent, bool eventHandled)
{
[m_contentView _webTouchEvent:nativeWebTouchEvent preventsNativeGestures:eventHandled];
}
#endif
#if ENABLE(IOS_TOUCH_EVENTS)
void PageClientImpl::doneDeferringTouchStart(bool preventNativeGestures)
{
[m_contentView _doneDeferringTouchStart:preventNativeGestures];
}
void PageClientImpl::doneDeferringTouchMove(bool preventNativeGestures)
{
[m_contentView _doneDeferringTouchMove:preventNativeGestures];
}
void PageClientImpl::doneDeferringTouchEnd(bool preventNativeGestures)
{
[m_contentView _doneDeferringTouchEnd:preventNativeGestures];
}
#endif // ENABLE(IOS_TOUCH_EVENTS)
#if ENABLE(IMAGE_ANALYSIS)
void PageClientImpl::requestTextRecognition(const URL& imageURL, const ShareableBitmapHandle& imageData, const String& sourceLanguageIdentifier, const String& targetLanguageIdentifier, CompletionHandler<void(TextRecognitionResult&&)>&& completion)
{
[m_contentView requestTextRecognition:imageURL imageData:imageData sourceLanguageIdentifier:sourceLanguageIdentifier targetLanguageIdentifier:targetLanguageIdentifier completionHandler:WTFMove(completion)];
}
#endif // ENABLE(IMAGE_ANALYSIS)
WebCore::DataOwnerType PageClientImpl::dataOwnerForPasteboard(PasteboardAccessIntent intent) const
{
return [m_contentView _dataOwnerForPasteboard:intent];
}
RefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy&)
{
return nullptr;
}
void PageClientImpl::setTextIndicator(Ref<TextIndicator> textIndicator, WebCore::TextIndicatorLifetime)
{
[m_contentView setUpTextIndicator:textIndicator];
}
void PageClientImpl::clearTextIndicator(WebCore::TextIndicatorDismissalAnimation dismissalAnimation)
{
[m_contentView clearTextIndicator:dismissalAnimation];
}
void PageClientImpl::setTextIndicatorAnimationProgress(float animationProgress)
{
[m_contentView setTextIndicatorAnimationProgress:animationProgress];
}
void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
{
}
void PageClientImpl::makeViewBlank(bool makeBlank)
{
[m_contentView layer].opacity = makeBlank ? 0 : 1;
}
void PageClientImpl::showSafeBrowsingWarning(const SafeBrowsingWarning& warning, CompletionHandler<void(std::variant<WebKit::ContinueUnsafeLoad, URL>&&)>&& completionHandler)
{
if (auto webView = m_webView.get())
[webView _showSafeBrowsingWarning:warning completionHandler:WTFMove(completionHandler)];
else
completionHandler(ContinueUnsafeLoad::No);
}
void PageClientImpl::clearSafeBrowsingWarning()
{
[m_webView _clearSafeBrowsingWarning];
}
void PageClientImpl::clearSafeBrowsingWarningIfForMainFrameNavigation()
{
[m_webView _clearSafeBrowsingWarningIfForMainFrameNavigation];
}
void PageClientImpl::exitAcceleratedCompositingMode()
{
notImplemented();
}
void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
{
}
void PageClientImpl::didPerformDictionaryLookup(const DictionaryPopupInfo& dictionaryPopupInfo)
{
#if ENABLE(REVEAL)
DictionaryLookup::showPopup(dictionaryPopupInfo, m_contentView.getAutoreleased(), nullptr);
#else
UNUSED_PARAM(dictionaryPopupInfo);
#endif // ENABLE(REVEAL)
}
bool PageClientImpl::effectiveAppearanceIsDark() const
{
return [m_webView _effectiveAppearanceIsDark];
}
bool PageClientImpl::effectiveUserInterfaceLevelIsElevated() const
{
return [m_webView _effectiveUserInterfaceLevelIsElevated];
}
void PageClientImpl::setRemoteLayerTreeRootNode(RemoteLayerTreeNode* rootNode)
{
[m_contentView _setAcceleratedCompositingRootView:rootNode ? rootNode->uiView() : nil];
}
CALayer *PageClientImpl::acceleratedCompositingRootLayer() const
{
notImplemented();
return nullptr;
}
RefPtr<ViewSnapshot> PageClientImpl::takeViewSnapshot(std::optional<WebCore::IntRect>&&)
{
return [m_webView _takeViewSnapshot];
}
void PageClientImpl::wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent& event)
{
notImplemented();
}
void PageClientImpl::commitPotentialTapFailed()
{
[m_contentView _commitPotentialTapFailed];
}
void PageClientImpl::didGetTapHighlightGeometries(WebKit::TapIdentifier requestID, const WebCore::Color& color, const Vector<WebCore::FloatQuad>& highlightedQuads, const WebCore::IntSize& topLeftRadius, const WebCore::IntSize& topRightRadius, const WebCore::IntSize& bottomLeftRadius, const WebCore::IntSize& bottomRightRadius, bool nodeHasBuiltInClickHandling)
{
[m_contentView _didGetTapHighlightForRequest:requestID color:color quads:highlightedQuads topLeftRadius:topLeftRadius topRightRadius:topRightRadius bottomLeftRadius:bottomLeftRadius bottomRightRadius:bottomRightRadius nodeHasBuiltInClickHandling:nodeHasBuiltInClickHandling];
}
void PageClientImpl::didCommitLayerTree(const RemoteLayerTreeTransaction& layerTreeTransaction)
{
[m_contentView _didCommitLayerTree:layerTreeTransaction];
}
void PageClientImpl::layerTreeCommitComplete()
{
[m_contentView _layerTreeCommitComplete];
}
void PageClientImpl::couldNotRestorePageState()
{
[m_webView _couldNotRestorePageState];
}
void PageClientImpl::restorePageState(std::optional<WebCore::FloatPoint> scrollPosition, const WebCore::FloatPoint& scrollOrigin, const WebCore::FloatBoxExtent& obscuredInsetsOnSave, double scale)
{
[m_webView _restorePageScrollPosition:scrollPosition scrollOrigin:scrollOrigin previousObscuredInset:obscuredInsetsOnSave scale:scale];
}
void PageClientImpl::restorePageCenterAndScale(std::optional<WebCore::FloatPoint> center, double scale)
{
[m_webView _restorePageStateToUnobscuredCenter:center scale:scale];
}
void PageClientImpl::elementDidFocus(const FocusedElementInformation& nodeInformation, bool userIsInteracting, bool blurPreviousNode, OptionSet<WebCore::ActivityState> activityStateChanges, API::Object* userData)
{
auto userObject = userData ? userData->toNSObject() : RetainPtr<NSObject<NSSecureCoding>>();
[m_contentView _elementDidFocus:nodeInformation userIsInteracting:userIsInteracting blurPreviousNode:blurPreviousNode activityStateChanges:activityStateChanges userObject:userObject.get()];
}
void PageClientImpl::updateInputContextAfterBlurringAndRefocusingElement()
{
[m_contentView _updateInputContextAfterBlurringAndRefocusingElement];
}
bool PageClientImpl::isFocusingElement()
{
return [m_contentView isFocusingElement];
}
void PageClientImpl::elementDidBlur()
{
[m_contentView _elementDidBlur];
}
void PageClientImpl::focusedElementDidChangeInputMode(WebCore::InputMode mode)
{
[m_contentView _didUpdateInputMode:mode];
}
void PageClientImpl::didUpdateEditorState()
{
[m_contentView _didUpdateEditorState];
}
void PageClientImpl::showPlaybackTargetPicker(bool hasVideo, const IntRect& elementRect, WebCore::RouteSharingPolicy policy, const String& contextUID)
{
[m_contentView _showPlaybackTargetPicker:hasVideo fromRect:elementRect routeSharingPolicy:policy routingContextUID:contextUID];
}
bool PageClientImpl::handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, const FrameInfoData& frameInfo, API::OpenPanelParameters* parameters, WebOpenPanelResultListenerProxy* listener)
{
[m_contentView _showRunOpenPanel:parameters frameInfo:frameInfo resultListener:listener];
return true;
}
bool PageClientImpl::showShareSheet(const ShareDataWithParsedURL& shareData, WTF::CompletionHandler<void(bool)>&& completionHandler)
{
[m_contentView _showShareSheet:shareData inRect:std::nullopt completionHandler:WTFMove(completionHandler)];
return true;
}
void PageClientImpl::showContactPicker(const WebCore::ContactsRequestData& requestData, WTF::CompletionHandler<void(std::optional<Vector<WebCore::ContactInfo>>&&)>&& completionHandler)
{
[m_contentView _showContactPicker:requestData completionHandler:WTFMove(completionHandler)];
}
void PageClientImpl::showInspectorHighlight(const WebCore::InspectorOverlay::Highlight& highlight)
{
[m_contentView _showInspectorHighlight:highlight];
}
void PageClientImpl::hideInspectorHighlight()
{
[m_contentView _hideInspectorHighlight];
}
void PageClientImpl::showInspectorIndication()
{
[m_contentView setShowingInspectorIndication:YES];
}
void PageClientImpl::hideInspectorIndication()
{
[m_contentView setShowingInspectorIndication:NO];
}
void PageClientImpl::enableInspectorNodeSearch()
{
[m_contentView _enableInspectorNodeSearch];
}
void PageClientImpl::disableInspectorNodeSearch()
{
[m_contentView _disableInspectorNodeSearch];
}
#if ENABLE(FULLSCREEN_API)
WebFullScreenManagerProxyClient& PageClientImpl::fullScreenManagerProxyClient()
{
return *this;
}
// WebFullScreenManagerProxyClient
void PageClientImpl::closeFullScreenManager()
{
[m_webView closeFullScreenWindowController];
}
bool PageClientImpl::isFullScreen()
{
if (![m_webView hasFullScreenWindowController])
return false;
return [m_webView fullScreenWindowController].isFullScreen;
}
void PageClientImpl::enterFullScreen(FloatSize videoDimensions)
{
[[m_webView fullScreenWindowController] enterFullScreen:videoDimensions];
}
void PageClientImpl::exitFullScreen()
{
[[m_webView fullScreenWindowController] exitFullScreen];
}
static UIInterfaceOrientationMask toUIInterfaceOrientationMask(WebCore::ScreenOrientationType orientation)
{
switch (orientation) {
case WebCore::ScreenOrientationType::PortraitPrimary:
return UIInterfaceOrientationMaskPortrait;
case WebCore::ScreenOrientationType::PortraitSecondary:
return UIInterfaceOrientationMaskPortraitUpsideDown;
case WebCore::ScreenOrientationType::LandscapePrimary:
return UIInterfaceOrientationMaskLandscapeLeft;
case WebCore::ScreenOrientationType::LandscapeSecondary:
return UIInterfaceOrientationMaskLandscapeRight;
}
ASSERT_NOT_REACHED();
return UIInterfaceOrientationMaskPortrait;
}
bool PageClientImpl::lockFullscreenOrientation(WebCore::ScreenOrientationType orientation)
{
[[m_webView fullScreenWindowController] setSupportedOrientations:toUIInterfaceOrientationMask(orientation)];
return true;
}
void PageClientImpl::unlockFullscreenOrientation()
{
[[m_webView fullScreenWindowController] resetSupportedOrientations];
}
void PageClientImpl::beganEnterFullScreen(const IntRect& initialFrame, const IntRect& finalFrame)
{
[[m_webView fullScreenWindowController] beganEnterFullScreenWithInitialFrame:initialFrame finalFrame:finalFrame];
}
void PageClientImpl::beganExitFullScreen(const IntRect& initialFrame, const IntRect& finalFrame)
{
[[m_webView fullScreenWindowController] beganExitFullScreenWithInitialFrame:initialFrame finalFrame:finalFrame];
}
#endif // ENABLE(FULLSCREEN_API)
void PageClientImpl::didFinishLoadingDataForCustomContentProvider(const String& suggestedFilename, const IPC::DataReference& dataReference)
{
RetainPtr<NSData> data = adoptNS([[NSData alloc] initWithBytes:dataReference.data() length:dataReference.size()]);
[m_webView _didFinishLoadingDataForCustomContentProviderWithSuggestedFilename:suggestedFilename data:data.get()];
}
void PageClientImpl::scrollingNodeScrollViewWillStartPanGesture(ScrollingNodeID)
{
[m_contentView scrollViewWillStartPanOrPinchGesture];
}
void PageClientImpl::scrollingNodeScrollViewDidScroll(ScrollingNodeID)
{
[m_contentView _didScroll];
}
void PageClientImpl::scrollingNodeScrollWillStartScroll(ScrollingNodeID nodeID)
{
[m_contentView _scrollingNodeScrollingWillBegin:nodeID];
}
void PageClientImpl::scrollingNodeScrollDidEndScroll(ScrollingNodeID nodeID)
{
[m_contentView _scrollingNodeScrollingDidEnd:nodeID];
}
Vector<String> PageClientImpl::mimeTypesWithCustomContentProviders()
{
return [m_webView _contentProviderRegistry]._mimeTypesWithCustomContentProviders;
}
void PageClientImpl::navigationGestureDidBegin()
{
[m_webView _navigationGestureDidBegin];
NavigationState::fromWebPage(*m_webView.get()->_page).navigationGestureDidBegin();
}
void PageClientImpl::navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem& item)
{
NavigationState::fromWebPage(*m_webView.get()->_page).navigationGestureWillEnd(willNavigate, item);
}
void PageClientImpl::navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem& item)
{
NavigationState::fromWebPage(*m_webView.get()->_page).navigationGestureDidEnd(willNavigate, item);
[m_webView _navigationGestureDidEnd];
}
void PageClientImpl::navigationGestureDidEnd()
{
[m_webView _navigationGestureDidEnd];
}
void PageClientImpl::willRecordNavigationSnapshot(WebBackForwardListItem& item)
{
NavigationState::fromWebPage(*m_webView.get()->_page).willRecordNavigationSnapshot(item);
}
void PageClientImpl::didRemoveNavigationGestureSnapshot()
{
NavigationState::fromWebPage(*m_webView.get()->_page).navigationGestureSnapshotWasRemoved();
}
void PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame()
{
}
void PageClientImpl::didFinishNavigation(API::Navigation* navigation)
{
[m_webView _didFinishNavigation:navigation];
}
void PageClientImpl::didFailNavigation(API::Navigation* navigation)
{
[m_webView _didFailNavigation:navigation];
}
void PageClientImpl::didSameDocumentNavigationForMainFrame(SameDocumentNavigationType navigationType)
{
[m_webView _didSameDocumentNavigationForMainFrame:navigationType];
}
void PageClientImpl::didChangeBackgroundColor()
{
[m_webView _updateScrollViewBackground];
}
void PageClientImpl::videoControlsManagerDidChange()
{
[m_webView _videoControlsManagerDidChange];
}
void PageClientImpl::refView()
{
[m_contentView retain];
[m_webView retain];
}
void PageClientImpl::derefView()
{
[m_contentView release];
[m_webView release];
}
void PageClientImpl::didRestoreScrollPosition()
{
}
WebCore::UserInterfaceLayoutDirection PageClientImpl::userInterfaceLayoutDirection()
{
if (!m_webView)
return WebCore::UserInterfaceLayoutDirection::LTR;
return ([UIView userInterfaceLayoutDirectionForSemanticContentAttribute:[m_webView semanticContentAttribute]] == UIUserInterfaceLayoutDirectionLeftToRight) ? WebCore::UserInterfaceLayoutDirection::LTR : WebCore::UserInterfaceLayoutDirection::RTL;
}
Ref<ValidationBubble> PageClientImpl::createValidationBubble(const String& message, const ValidationBubble::Settings& settings)
{
return ValidationBubble::create(m_contentView.getAutoreleased(), message, settings);
}
#if ENABLE(INPUT_TYPE_COLOR)
RefPtr<WebColorPicker> PageClientImpl::createColorPicker(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&, Vector<WebCore::Color>&&)
{
return nullptr;
}
#endif
#if ENABLE(DATALIST_ELEMENT)
RefPtr<WebDataListSuggestionsDropdown> PageClientImpl::createDataListSuggestionsDropdown(WebPageProxy& page)
{
return WebDataListSuggestionsDropdownIOS::create(page, m_contentView.getAutoreleased());
}
#endif
#if ENABLE(DATE_AND_TIME_INPUT_TYPES)
RefPtr<WebDateTimePicker> PageClientImpl::createDateTimePicker(WebPageProxy&)
{
return nullptr;
}
#endif
#if ENABLE(DRAG_SUPPORT)
void PageClientImpl::didPerformDragOperation(bool handled)
{
[m_contentView _didPerformDragOperation:handled];
}
void PageClientImpl::didHandleDragStartRequest(bool started)
{
[m_contentView _didHandleDragStartRequest:started];
}
void PageClientImpl::didHandleAdditionalDragItemsRequest(bool added)
{
[m_contentView _didHandleAdditionalDragItemsRequest:added];
}
void PageClientImpl::startDrag(const DragItem& item, const ShareableBitmapHandle& image)
{
auto bitmap = ShareableBitmap::create(image);
if (!bitmap)
return;
[m_contentView _startDrag:bitmap->makeCGImageCopy() item:item];
}
void PageClientImpl::willReceiveEditDragSnapshot()
{
[m_contentView _willReceiveEditDragSnapshot];
}
void PageClientImpl::didReceiveEditDragSnapshot(std::optional<TextIndicatorData> data)
{
[m_contentView _didReceiveEditDragSnapshot:data];
}
void PageClientImpl::didChangeDragCaretRect(const IntRect& previousCaretRect, const IntRect& caretRect)
{
[m_contentView _didChangeDragCaretRect:previousCaretRect currentRect:caretRect];
}
#endif
#if USE(QUICK_LOOK)
void PageClientImpl::requestPasswordForQuickLookDocument(const String& fileName, WTF::Function<void(const String&)>&& completionHandler)
{
auto passwordHandler = makeBlockPtr([completionHandler = WTFMove(completionHandler)](NSString *password) {
completionHandler(password);
});
if (WKPasswordView *passwordView = [m_webView _passwordView]) {
ASSERT(fileName == String { passwordView.documentName });
[passwordView showPasswordFailureAlert];
passwordView.userDidEnterPassword = passwordHandler.get();
return;
}
[m_webView _showPasswordViewWithDocumentName:fileName passwordHandler:passwordHandler.get()];
NavigationState::fromWebPage(*m_webView.get()->_page).didRequestPasswordForQuickLookDocument();
}
#endif
void PageClientImpl::requestDOMPasteAccess(WebCore::DOMPasteAccessCategory pasteAccessCategory, const WebCore::IntRect& elementRect, const String& originIdentifier, CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&& completionHandler)
{
[m_contentView _requestDOMPasteAccessForCategory:pasteAccessCategory elementRect:elementRect originIdentifier:originIdentifier completionHandler:WTFMove(completionHandler)];
}
void PageClientImpl::cancelPointersForGestureRecognizer(UIGestureRecognizer* gestureRecognizer)
{
[m_contentView cancelPointersForGestureRecognizer:gestureRecognizer];
}
std::optional<unsigned> PageClientImpl::activeTouchIdentifierForGestureRecognizer(UIGestureRecognizer* gestureRecognizer)
{
return [m_contentView activeTouchIdentifierForGestureRecognizer:gestureRecognizer];
}
void PageClientImpl::handleAutocorrectionContext(const WebAutocorrectionContext& context)
{
[m_contentView _handleAutocorrectionContext:context];
}
void PageClientImpl::showDictationAlternativeUI(const WebCore::FloatRect&, WebCore::DictationContext)
{
notImplemented();