(Finally...) get rid of WKViewIOS
[WebKit-https.git] / Source / WebKit2 / UIProcess / ios / PageClientImplIOS.mm
1 /*
2  * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #import "config.h"
27 #import "PageClientImplIOS.h"
28
29 #if PLATFORM(IOS)
30
31 #import "APIData.h"
32 #import "DataReference.h"
33 #import "DownloadProxy.h"
34 #import "InteractionInformationAtPosition.h"
35 #import "NativeWebKeyboardEvent.h"
36 #import "NavigationState.h"
37 #import "UIKitSPI.h"
38 #import "ViewSnapshotStore.h"
39 #import "WKContentView.h"
40 #import "WKContentViewInteraction.h"
41 #import "WKGeolocationProviderIOS.h"
42 #import "WKProcessPoolInternal.h"
43 #import "WKWebViewConfigurationInternal.h"
44 #import "WKWebViewContentProviderRegistry.h"
45 #import "WKWebViewInternal.h"
46 #import "WebContextMenuProxy.h"
47 #import "WebEditCommandProxy.h"
48 #import "WebProcessProxy.h"
49 #import "_WKDownloadInternal.h"
50 #import <WebCore/NotImplemented.h>
51 #import <WebCore/PlatformScreen.h>
52 #import <WebCore/SharedBuffer.h>
53 #import <WebCore/TextIndicator.h>
54
55 #define MESSAGE_CHECK(assertion) MESSAGE_CHECK_BASE(assertion, m_webView->_page->process().connection())
56
57 using namespace WebCore;
58 using namespace WebKit;
59
60 @interface WKEditCommandObjC : NSObject
61 {
62     RefPtr<WebEditCommandProxy> m_command;
63 }
64 - (id)initWithWebEditCommandProxy:(PassRefPtr<WebEditCommandProxy>)command;
65 - (WebEditCommandProxy*)command;
66 @end
67
68 @interface WKEditorUndoTargetObjC : NSObject
69 - (void)undoEditing:(id)sender;
70 - (void)redoEditing:(id)sender;
71 @end
72
73 @implementation WKEditCommandObjC
74
75 - (id)initWithWebEditCommandProxy:(PassRefPtr<WebEditCommandProxy>)command
76 {
77     self = [super init];
78     if (!self)
79         return nil;
80     
81     m_command = command;
82     return self;
83 }
84
85 - (WebEditCommandProxy *)command
86 {
87     return m_command.get();
88 }
89
90 @end
91
92 @implementation WKEditorUndoTargetObjC
93
94 - (void)undoEditing:(id)sender
95 {
96     ASSERT([sender isKindOfClass:[WKEditCommandObjC class]]);
97     [sender command]->unapply();
98 }
99
100 - (void)redoEditing:(id)sender
101 {
102     ASSERT([sender isKindOfClass:[WKEditCommandObjC class]]);
103     [sender command]->reapply();
104 }
105
106 @end
107
108 namespace WebKit {
109
110 PageClientImpl::PageClientImpl(WKContentView *contentView, WKWebView *webView)
111     : m_contentView(contentView)
112     , m_webView(webView)
113     , m_undoTarget(adoptNS([[WKEditorUndoTargetObjC alloc] init]))
114 {
115 }
116
117 PageClientImpl::~PageClientImpl()
118 {
119 }
120
121 std::unique_ptr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy()
122 {
123     return [m_contentView _createDrawingAreaProxy];
124 }
125
126 void PageClientImpl::setViewNeedsDisplay(const IntRect& rect)
127 {
128     ASSERT_NOT_REACHED();
129 }
130
131 void PageClientImpl::displayView()
132 {
133     ASSERT_NOT_REACHED();
134 }
135
136 bool PageClientImpl::canScrollView()
137 {
138     notImplemented();
139     return false;
140 }
141
142 void PageClientImpl::scrollView(const IntRect&, const IntSize&)
143 {
144     ASSERT_NOT_REACHED();
145 }
146
147 void PageClientImpl::requestScroll(const FloatPoint& scrollPosition, const IntPoint& scrollOrigin, bool isProgrammaticScroll)
148 {
149     UNUSED_PARAM(isProgrammaticScroll);
150     [m_webView _scrollToContentOffset:scrollPosition scrollOrigin:scrollOrigin];
151 }
152
153 IntSize PageClientImpl::viewSize()
154 {
155     if (UIScrollView *scroller = [m_contentView _scroller])
156         return IntSize(scroller.bounds.size);
157
158     return IntSize(m_contentView.bounds.size);
159 }
160
161 bool PageClientImpl::isViewWindowActive()
162 {
163     // FIXME: https://bugs.webkit.org/show_bug.cgi?id=133098
164     return isViewVisible() || (m_webView && m_webView->_activeFocusedStateRetainCount);
165 }
166
167 bool PageClientImpl::isViewFocused()
168 {
169     // FIXME: https://bugs.webkit.org/show_bug.cgi?id=133098
170     return isViewWindowActive() || (m_webView && m_webView->_activeFocusedStateRetainCount);
171 }
172
173 bool PageClientImpl::isViewVisible()
174 {
175     if (isViewInWindow() && !m_contentView.isBackground)
176         return true;
177     
178     if ([m_webView _isShowingVideoPictureInPicture])
179         return true;
180     
181     if ([m_webView _mayAutomaticallyShowVideoPictureInPicture])
182         return true;
183     
184     return false;
185 }
186
187 bool PageClientImpl::isViewInWindow()
188 {
189     // FIXME: in WebKitTestRunner, m_webView is nil, so check the content view instead.
190     if (m_webView)
191         return [m_webView window];
192
193     return [m_contentView window];
194 }
195
196 bool PageClientImpl::isViewVisibleOrOccluded()
197 {
198     return isViewVisible();
199 }
200
201 bool PageClientImpl::isVisuallyIdle()
202 {
203     return !isViewVisible();
204 }
205
206 void PageClientImpl::processDidExit()
207 {
208     [m_contentView _processDidExit];
209     [m_webView _processDidExit];
210 }
211
212 void PageClientImpl::didRelaunchProcess()
213 {
214     [m_contentView _didRelaunchProcess];
215     [m_webView _didRelaunchProcess];
216 }
217
218 void PageClientImpl::pageClosed()
219 {
220     notImplemented();
221 }
222
223 void PageClientImpl::preferencesDidChange()
224 {
225     notImplemented();
226 }
227
228 void PageClientImpl::toolTipChanged(const String&, const String&)
229 {
230     notImplemented();
231 }
232
233 bool PageClientImpl::decidePolicyForGeolocationPermissionRequest(WebFrameProxy& frame, API::SecurityOrigin& origin, GeolocationPermissionRequestProxy& request)
234 {
235     [[wrapper(m_webView->_page->process().processPool()) _geolocationProvider] decidePolicyForGeolocationRequestFromOrigin:origin.securityOrigin() frame:frame request:request view:m_webView];
236     return true;
237 }
238
239 void PageClientImpl::didCommitLoadForMainFrame(const String& mimeType, bool useCustomContentProvider)
240 {
241     [m_webView _setHasCustomContentView:useCustomContentProvider loadedMIMEType:mimeType];
242     [m_contentView _didCommitLoadForMainFrame];
243 }
244
245 void PageClientImpl::handleDownloadRequest(DownloadProxy* download)
246 {
247     ASSERT_ARG(download, download);
248     ASSERT([download->wrapper() isKindOfClass:[_WKDownload class]]);
249     [static_cast<_WKDownload *>(download->wrapper()) setOriginatingWebView:m_webView];
250 }
251
252 void PageClientImpl::didChangeContentSize(const WebCore::IntSize&)
253 {
254     notImplemented();
255 }
256
257 void PageClientImpl::didChangeViewportMetaTagWidth(float newWidth)
258 {
259     [m_webView _setViewportMetaTagWidth:newWidth];
260 }
261
262 double PageClientImpl::minimumZoomScale() const
263 {
264     if (UIScrollView *scroller = [m_webView scrollView])
265         return scroller.minimumZoomScale;
266
267     return 1;
268 }
269
270 WebCore::FloatRect PageClientImpl::documentRect() const
271 {
272     return [m_contentView bounds];
273 }
274
275 void PageClientImpl::setCursor(const Cursor&)
276 {
277     notImplemented();
278 }
279
280 void PageClientImpl::setCursorHiddenUntilMouseMoves(bool)
281 {
282     notImplemented();
283 }
284
285 void PageClientImpl::didChangeViewportProperties(const ViewportAttributes&)
286 {
287     notImplemented();
288 }
289
290 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy> prpCommand, WebPageProxy::UndoOrRedo undoOrRedo)
291 {
292     RefPtr<WebEditCommandProxy> command = prpCommand;
293     
294     RetainPtr<WKEditCommandObjC> commandObjC = adoptNS([[WKEditCommandObjC alloc] initWithWebEditCommandProxy:command]);
295     String actionName = WebEditCommandProxy::nameForEditAction(command->editAction());
296     
297     NSUndoManager *undoManager = [m_contentView undoManager];
298     [undoManager registerUndoWithTarget:m_undoTarget.get() selector:((undoOrRedo == WebPageProxy::Undo) ? @selector(undoEditing:) : @selector(redoEditing:)) object:commandObjC.get()];
299     if (!actionName.isEmpty())
300         [undoManager setActionName:(NSString *)actionName];
301 }
302
303 #if USE(INSERTION_UNDO_GROUPING)
304 void PageClientImpl::registerInsertionUndoGrouping()
305 {
306     notImplemented();
307 }
308 #endif
309
310 void PageClientImpl::clearAllEditCommands()
311 {
312     [[m_contentView undoManager] removeAllActionsWithTarget:m_undoTarget.get()];
313 }
314
315 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
316 {
317     return (undoOrRedo == WebPageProxy::Undo) ? [[m_contentView undoManager] canUndo] : [[m_contentView undoManager] canRedo];
318 }
319
320 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
321 {
322     return (undoOrRedo == WebPageProxy::Undo) ? [[m_contentView undoManager] undo] : [[m_contentView undoManager] redo];
323 }
324
325 void PageClientImpl::accessibilityWebProcessTokenReceived(const IPC::DataReference& data)
326 {
327     NSData *remoteToken = [NSData dataWithBytes:data.data() length:data.size()];
328     [m_contentView _setAccessibilityWebProcessToken:remoteToken];
329 }
330
331 bool PageClientImpl::interpretKeyEvent(const NativeWebKeyboardEvent& event, bool isCharEvent)
332 {
333     return [m_contentView _interpretKeyEvent:event.nativeEvent() isCharEvent:isCharEvent];
334 }
335
336 void PageClientImpl::positionInformationDidChange(const InteractionInformationAtPosition& info)
337 {
338     [m_contentView _positionInformationDidChange:info];
339 }
340
341 void PageClientImpl::saveImageToLibrary(PassRefPtr<SharedBuffer> imageBuffer)
342 {
343     RetainPtr<NSData> imageData = imageBuffer->createNSData();
344     UIImageDataWriteToSavedPhotosAlbum(imageData.get(), nil, NULL, NULL);
345 }
346
347 bool PageClientImpl::executeSavedCommandBySelector(const String&)
348 {
349     notImplemented();
350     return false;
351 }
352
353 void PageClientImpl::setDragImage(const IntPoint&, PassRefPtr<ShareableBitmap>, bool)
354 {
355     notImplemented();
356 }
357
358 void PageClientImpl::selectionDidChange()
359 {
360     [m_contentView _selectionChanged];
361 }
362
363 void PageClientImpl::updateSecureInputState()
364 {
365     notImplemented();
366 }
367
368 void PageClientImpl::resetSecureInputState()
369 {
370     notImplemented();
371 }
372
373 void PageClientImpl::notifyInputContextAboutDiscardedComposition()
374 {
375     notImplemented();
376 }
377
378 void PageClientImpl::makeFirstResponder()
379 {
380     notImplemented();
381 }
382
383 FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& rect)
384 {
385     notImplemented();
386     return FloatRect();
387 }
388
389 FloatRect PageClientImpl::convertToUserSpace(const FloatRect& rect)
390 {
391     notImplemented();
392     return FloatRect();
393 }
394
395 IntPoint PageClientImpl::screenToRootView(const IntPoint& point)
396 {
397     return IntPoint([m_contentView convertPoint:point fromView:nil]);
398 }
399
400 IntRect PageClientImpl::rootViewToScreen(const IntRect& rect)
401 {
402     return enclosingIntRect([m_contentView convertRect:rect toView:nil]);
403 }
404     
405 IntPoint PageClientImpl::accessibilityScreenToRootView(const IntPoint& point)
406 {
407     CGPoint rootViewPoint = point;
408     if ([m_contentView respondsToSelector:@selector(accessibilityConvertPointFromSceneReferenceCoordinates:)])
409         rootViewPoint = [m_contentView accessibilityConvertPointFromSceneReferenceCoordinates:rootViewPoint];
410     return IntPoint(rootViewPoint);
411 }
412     
413 IntRect PageClientImpl::rootViewToAccessibilityScreen(const IntRect& rect)
414 {
415     CGRect rootViewRect = rect;
416     if ([m_contentView respondsToSelector:@selector(accessibilityConvertRectToSceneReferenceCoordinates:)])
417         rootViewRect = [m_contentView accessibilityConvertRectToSceneReferenceCoordinates:rootViewRect];
418     return enclosingIntRect(rootViewRect);
419 }
420     
421 void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent& event, bool)
422 {
423     [m_contentView _didHandleKeyEvent:event.nativeEvent()];
424 }
425
426 #if ENABLE(TOUCH_EVENTS)
427 void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent& nativeWebtouchEvent, bool eventHandled)
428 {
429     [m_contentView _webTouchEvent:nativeWebtouchEvent preventsNativeGestures:eventHandled];
430 }
431 #endif
432
433 RefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy*)
434 {
435     notImplemented();
436     return nullptr;
437 }
438
439 RefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy*)
440 {
441     notImplemented();
442     return nullptr;
443 }
444
445 void PageClientImpl::setTextIndicator(Ref<TextIndicator> textIndicator, TextIndicatorWindowLifetime)
446 {
447 }
448
449 void PageClientImpl::clearTextIndicator(TextIndicatorWindowDismissalAnimation)
450 {
451 }
452
453 void PageClientImpl::setTextIndicatorAnimationProgress(float)
454 {
455 }
456
457 void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
458 {
459 }
460
461 void PageClientImpl::exitAcceleratedCompositingMode()
462 {
463     notImplemented();
464 }
465
466 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
467 {
468 }
469
470 void PageClientImpl::setAcceleratedCompositingRootLayer(LayerOrView *rootLayer)
471 {
472     [m_contentView _setAcceleratedCompositingRootView:rootLayer];
473 }
474
475 LayerOrView *PageClientImpl::acceleratedCompositingRootLayer() const
476 {
477     notImplemented();
478     return nullptr;
479 }
480
481 PassRefPtr<ViewSnapshot> PageClientImpl::takeViewSnapshot()
482 {
483     return [m_webView _takeViewSnapshot];
484 }
485
486 void PageClientImpl::wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent& event)
487 {
488     notImplemented();
489 }
490
491 void PageClientImpl::commitPotentialTapFailed()
492 {
493     [m_contentView _commitPotentialTapFailed];
494 }
495
496 void PageClientImpl::didGetTapHighlightGeometries(uint64_t 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)
497 {
498     [m_contentView _didGetTapHighlightForRequest:requestID color:color quads:highlightedQuads topLeftRadius:topLeftRadius topRightRadius:topRightRadius bottomLeftRadius:bottomLeftRadius bottomRightRadius:bottomRightRadius];
499 }
500
501 void PageClientImpl::didCommitLayerTree(const RemoteLayerTreeTransaction& layerTreeTransaction)
502 {
503     [m_contentView _didCommitLayerTree:layerTreeTransaction];
504 }
505
506 void PageClientImpl::dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition, uint64_t nextValidLayerTreeTransactionID)
507 {
508     [m_webView _dynamicViewportUpdateChangedTargetToScale:newScale position:newScrollPosition nextValidLayerTreeTransactionID:nextValidLayerTreeTransactionID];
509 }
510
511 void PageClientImpl::couldNotRestorePageState()
512 {
513     [m_webView _couldNotRestorePageState];
514 }
515
516 void PageClientImpl::restorePageState(const WebCore::FloatRect& exposedRect, double scale)
517 {
518     [m_webView _restorePageStateToExposedRect:exposedRect scale:scale];
519 }
520
521 void PageClientImpl::restorePageCenterAndScale(const WebCore::FloatPoint& center, double scale)
522 {
523     [m_webView _restorePageStateToUnobscuredCenter:center scale:scale];
524 }
525
526 void PageClientImpl::startAssistingNode(const AssistedNodeInformation& nodeInformation, bool userIsInteracting, bool blurPreviousNode, API::Object* userData)
527 {
528     MESSAGE_CHECK(!userData || userData->type() == API::Object::Type::Data);
529
530     NSObject <NSSecureCoding> *userObject = nil;
531     if (API::Data* data = static_cast<API::Data*>(userData)) {
532         auto nsData = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<void*>(static_cast<const void*>(data->bytes())) length:data->size() freeWhenDone:NO]);
533         auto unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingWithData:nsData.get()]);
534         [unarchiver setRequiresSecureCoding:YES];
535         @try {
536             userObject = [unarchiver decodeObjectOfClass:[NSObject class] forKey:@"userObject"];
537         } @catch (NSException *exception) {
538             LOG_ERROR("Failed to decode user data: %@", exception);
539         }
540     }
541
542     [m_contentView _startAssistingNode:nodeInformation userIsInteracting:userIsInteracting blurPreviousNode:blurPreviousNode userObject:userObject];
543 }
544
545 bool PageClientImpl::isAssistingNode()
546 {
547     return [m_contentView isAssistingNode];
548 }
549
550 void PageClientImpl::stopAssistingNode()
551 {
552     [m_contentView _stopAssistingNode];
553 }
554
555 void PageClientImpl::didUpdateBlockSelectionWithTouch(uint32_t touch, uint32_t flags, float growThreshold, float shrinkThreshold)
556 {
557     [m_contentView _didUpdateBlockSelectionWithTouch:(SelectionTouch)touch withFlags:(SelectionFlags)flags growThreshold:growThreshold shrinkThreshold:shrinkThreshold];
558 }
559
560 void PageClientImpl::showPlaybackTargetPicker(bool hasVideo, const IntRect& elementRect)
561 {
562     [m_contentView _showPlaybackTargetPicker:hasVideo fromRect:elementRect];
563 }
564
565 bool PageClientImpl::handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, WebOpenPanelParameters* parameters, WebOpenPanelResultListenerProxy* listener)
566 {
567     [m_contentView _showRunOpenPanel:parameters resultListener:listener];
568     return true;
569 }
570
571 void PageClientImpl::showInspectorHighlight(const WebCore::Highlight& highlight)
572 {
573     [m_contentView _showInspectorHighlight:highlight];
574 }
575
576 void PageClientImpl::hideInspectorHighlight()
577 {
578     [m_contentView _hideInspectorHighlight];
579 }
580
581 void PageClientImpl::showInspectorIndication()
582 {
583     [m_contentView setShowingInspectorIndication:YES];
584 }
585
586 void PageClientImpl::hideInspectorIndication()
587 {
588     [m_contentView setShowingInspectorIndication:NO];
589 }
590
591 void PageClientImpl::enableInspectorNodeSearch()
592 {
593     [m_contentView _enableInspectorNodeSearch];
594 }
595
596 void PageClientImpl::disableInspectorNodeSearch()
597 {
598     [m_contentView _disableInspectorNodeSearch];
599 }
600
601 #if ENABLE(FULLSCREEN_API)
602
603 WebFullScreenManagerProxyClient& PageClientImpl::fullScreenManagerProxyClient()
604 {
605     return *this;
606 }
607
608 // WebFullScreenManagerProxyClient
609
610 void PageClientImpl::closeFullScreenManager()
611 {
612 }
613
614 bool PageClientImpl::isFullScreen()
615 {
616     return false;
617 }
618
619 void PageClientImpl::enterFullScreen()
620 {
621 }
622
623 void PageClientImpl::exitFullScreen()
624 {
625 }
626
627 void PageClientImpl::beganEnterFullScreen(const IntRect&, const IntRect&)
628 {
629 }
630
631 void PageClientImpl::beganExitFullScreen(const IntRect&, const IntRect&)
632 {
633 }
634
635 #endif // ENABLE(FULLSCREEN_API)
636
637 void PageClientImpl::didFinishLoadingDataForCustomContentProvider(const String& suggestedFilename, const IPC::DataReference& dataReference)
638 {
639     RetainPtr<NSData> data = adoptNS([[NSData alloc] initWithBytes:dataReference.data() length:dataReference.size()]);
640     [m_webView _didFinishLoadingDataForCustomContentProviderWithSuggestedFilename:suggestedFilename data:data.get()];
641 }
642
643 void PageClientImpl::zoomToRect(FloatRect rect, double minimumScale, double maximumScale)
644 {
645     [m_contentView _zoomToRect:rect withOrigin:rect.center() fitEntireRect:YES minimumScale:minimumScale maximumScale:maximumScale minimumScrollDistance:0];
646 }
647
648 void PageClientImpl::overflowScrollViewWillStartPanGesture()
649 {
650     [m_contentView scrollViewWillStartPanOrPinchGesture];
651 }
652
653 void PageClientImpl::overflowScrollViewDidScroll()
654 {
655     [m_contentView _didScroll];
656 }
657
658 void PageClientImpl::overflowScrollWillStartScroll()
659 {
660     [m_contentView _overflowScrollingWillBegin];
661 }
662
663 void PageClientImpl::overflowScrollDidEndScroll()
664 {
665     [m_contentView _overflowScrollingDidEnd];
666 }
667
668 void PageClientImpl::didFinishDrawingPagesToPDF(const IPC::DataReference& pdfData)
669 {
670     RetainPtr<CFDataRef> data = adoptCF(CFDataCreate(kCFAllocatorDefault, pdfData.data(), pdfData.size()));
671     RetainPtr<CGDataProviderRef> dataProvider = adoptCF(CGDataProviderCreateWithCFData(data.get()));
672     m_webView._printedDocument = adoptCF(CGPDFDocumentCreateWithProvider(dataProvider.get())).get();
673 }
674
675 Vector<String> PageClientImpl::mimeTypesWithCustomContentProviders()
676 {
677     return m_webView.configuration._contentProviderRegistry._mimeTypesWithCustomContentProviders;
678 }
679
680 void PageClientImpl::navigationGestureDidBegin()
681 {
682     [m_webView _navigationGestureDidBegin];
683     NavigationState::fromWebPage(*m_webView->_page).navigationGestureDidBegin();
684 }
685
686 void PageClientImpl::navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem& item)
687 {
688     NavigationState::fromWebPage(*m_webView->_page).navigationGestureWillEnd(willNavigate, item);
689 }
690
691 void PageClientImpl::navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem& item)
692 {
693     NavigationState::fromWebPage(*m_webView->_page).navigationGestureDidEnd(willNavigate, item);
694     [m_webView _navigationGestureDidEnd];
695 }
696
697 void PageClientImpl::navigationGestureDidEnd()
698 {
699     [m_webView _navigationGestureDidEnd];
700 }
701
702 void PageClientImpl::willRecordNavigationSnapshot(WebBackForwardListItem& item)
703 {
704     NavigationState::fromWebPage(*m_webView->_page).willRecordNavigationSnapshot(item);
705 }
706
707 void PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame()
708 {
709 }
710
711 void PageClientImpl::didFinishLoadForMainFrame()
712 {
713     [m_webView _didFinishLoadForMainFrame];
714 }
715
716 void PageClientImpl::didFailLoadForMainFrame()
717 {
718     [m_webView _didFailLoadForMainFrame];
719 }
720
721 void PageClientImpl::didSameDocumentNavigationForMainFrame(SameDocumentNavigationType navigationType)
722 {
723     [m_webView _didSameDocumentNavigationForMainFrame:navigationType];
724 }
725
726 void PageClientImpl::didChangeBackgroundColor()
727 {
728     [m_webView _updateScrollViewBackground];
729 }
730
731 void PageClientImpl::refView()
732 {
733     [m_contentView retain];
734     [m_webView retain];
735 }
736
737 void PageClientImpl::derefView()
738 {
739     [m_contentView release];
740     [m_webView release];
741 }
742
743 } // namespace WebKit
744
745 #endif // PLATFORM(IOS)