9a1e75e1f8318b6861eddec09d28d87d4c38e47d
[WebKit-https.git] / Source / WebKit2 / UIProcess / mac / PageClientImpl.mm
1 /*
2  * Copyright (C) 2010, 2011 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 "PageClientImpl.h"
28
29 #if PLATFORM(MAC)
30
31 #import "_WKDownloadInternal.h"
32 #import "AttributedString.h"
33 #import "ColorSpaceData.h"
34 #import "DataReference.h"
35 #import "DictionaryPopupInfo.h"
36 #import "DownloadProxy.h"
37 #import "FindIndicator.h"
38 #import "NativeWebKeyboardEvent.h"
39 #import "NativeWebWheelEvent.h"
40 #import "StringUtilities.h"
41 #import "WKAPICast.h"
42 #import "WKFullScreenWindowController.h"
43 #import "WKStringCF.h"
44 #import "WKViewInternal.h"
45 #import "WebColorPickerMac.h"
46 #import "WebContextMenuProxyMac.h"
47 #import "WebEditCommandProxy.h"
48 #import "WebPopupMenuProxyMac.h"
49 #import "WindowServerConnection.h"
50 #import "_WKThumbnailView.h"
51 #import <WebCore/AlternativeTextUIController.h>
52 #import <WebCore/BitmapImage.h>
53 #import <WebCore/Cursor.h>
54 #import <WebCore/FloatRect.h>
55 #import <WebCore/GraphicsContext.h>
56 #import <WebCore/Image.h>
57 #import <WebCore/KeyboardEvent.h>
58 #import <WebCore/NotImplemented.h>
59 #import <WebCore/SharedBuffer.h>
60 #import <WebKitSystemInterface.h>
61 #import <wtf/text/CString.h>
62 #import <wtf/text/WTFString.h>
63
64 #if USE(DICTATION_ALTERNATIVES)
65 #import <AppKit/NSTextAlternatives.h>
66 #endif
67
68 @interface NSApplication (WebNSApplicationDetails)
69 - (NSCursor *)_cursorRectCursor;
70 @end
71
72 #if HAVE(OUT_OF_PROCESS_LAYER_HOSTING)
73 @interface NSWindow (WebNSWindowDetails)
74 - (BOOL)_hostsLayersInWindowServer;
75 @end
76 #endif
77
78 using namespace WebCore;
79 using namespace WebKit;
80
81 @interface WKEditCommandObjC : NSObject
82 {
83     RefPtr<WebEditCommandProxy> m_command;
84 }
85 - (id)initWithWebEditCommandProxy:(PassRefPtr<WebEditCommandProxy>)command;
86 - (WebEditCommandProxy*)command;
87 @end
88
89 @interface WKEditorUndoTargetObjC : NSObject
90 - (void)undoEditing:(id)sender;
91 - (void)redoEditing:(id)sender;
92 @end
93
94 @implementation WKEditCommandObjC
95
96 - (id)initWithWebEditCommandProxy:(PassRefPtr<WebEditCommandProxy>)command
97 {
98     self = [super init];
99     if (!self)
100         return nil;
101
102     m_command = command;
103     return self;
104 }
105
106 - (WebEditCommandProxy*)command
107 {
108     return m_command.get();
109 }
110
111 @end
112
113 @implementation WKEditorUndoTargetObjC
114
115 - (void)undoEditing:(id)sender
116 {
117     ASSERT([sender isKindOfClass:[WKEditCommandObjC class]]);
118     [sender command]->unapply();
119 }
120
121 - (void)redoEditing:(id)sender
122 {
123     ASSERT([sender isKindOfClass:[WKEditCommandObjC class]]);
124     [sender command]->reapply();
125 }
126
127 @end
128
129 namespace WebKit {
130
131 PageClientImpl::PageClientImpl(WKView* wkView, WKWebView *webView)
132     : m_wkView(wkView)
133     , m_webView(webView)
134     , m_undoTarget(adoptNS([[WKEditorUndoTargetObjC alloc] init]))
135 #if USE(DICTATION_ALTERNATIVES)
136     , m_alternativeTextUIController(adoptPtr(new AlternativeTextUIController))
137 #endif
138 {
139 #if !WK_API_ENABLED
140     ASSERT_UNUSED(m_webView, !m_webView);
141 #endif
142 }
143
144 PageClientImpl::~PageClientImpl()
145 {
146 }
147
148 std::unique_ptr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy()
149 {
150     return [m_wkView _createDrawingAreaProxy];
151 }
152
153 void PageClientImpl::setViewNeedsDisplay(const WebCore::IntRect& rect)
154 {
155     ASSERT_NOT_REACHED();
156 }
157
158 void PageClientImpl::displayView()
159 {
160     ASSERT_NOT_REACHED();
161 }
162
163 bool PageClientImpl::canScrollView()
164 {
165     return false;
166 }
167
168 void PageClientImpl::scrollView(const IntRect& scrollRect, const IntSize& scrollOffset)
169 {
170     ASSERT_NOT_REACHED();
171 }
172
173 void PageClientImpl::requestScroll(const FloatPoint& scrollPosition, bool isProgrammaticScroll)
174 {
175     ASSERT_NOT_REACHED();
176 }
177
178 IntSize PageClientImpl::viewSize()
179 {
180     return IntSize([m_wkView bounds].size);
181 }
182
183 NSView *PageClientImpl::activeView() const
184 {
185 #if WK_API_ENABLED
186     return m_wkView._thumbnailView ? (NSView *)m_wkView._thumbnailView : (NSView *)m_wkView;
187 #else
188     return m_wkView;
189 #endif
190 }
191
192 bool PageClientImpl::isViewWindowActive()
193 {
194     NSWindow *activeViewWindow = activeView().window;
195     return activeViewWindow.isKeyWindow || [NSApp keyWindow] == activeViewWindow;
196 }
197
198 bool PageClientImpl::isViewFocused()
199 {
200     return [m_wkView _isFocused];
201 }
202
203 void PageClientImpl::makeFirstResponder()
204 {
205      [[m_wkView window] makeFirstResponder:m_wkView];
206 }
207     
208 bool PageClientImpl::isViewVisible()
209 {
210     NSView *activeView = this->activeView();
211     NSWindow *activeViewWindow = activeView.window;
212
213     if (!activeViewWindow)
214         return false;
215
216     if (!activeViewWindow.isVisible)
217         return false;
218
219 #if __MAC_OS_X_VERSION_MIN_REQUIRED <= 1080
220     // Mountain Lion and previous do not support occlusion notifications, and as such will
221     // continue to report as "visible" when not on the active space.
222     if (!activeViewWindow.isOnActiveSpace)
223         return false;
224 #endif
225
226     if (activeView.isHiddenOrHasHiddenAncestor)
227         return false;
228
229 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
230     if ([m_wkView windowOcclusionDetectionEnabled] && (activeViewWindow.occlusionState & NSWindowOcclusionStateVisible) != NSWindowOcclusionStateVisible)
231         return false;
232 #endif
233
234     return true;
235 }
236
237 bool PageClientImpl::isViewVisibleOrOccluded()
238 {
239     return activeView().window.isVisible;
240 }
241
242 bool PageClientImpl::isViewInWindow()
243 {
244     return activeView().window;
245 }
246
247 bool PageClientImpl::isVisuallyIdle()
248 {
249     return WindowServerConnection::shared().applicationWindowModificationsHaveStopped() || !isViewVisible();
250 }
251
252 LayerHostingMode PageClientImpl::viewLayerHostingMode()
253 {
254 #if HAVE(OUT_OF_PROCESS_LAYER_HOSTING)
255     if ([activeView().window _hostsLayersInWindowServer])
256         return LayerHostingMode::OutOfProcess;
257 #endif
258     return LayerHostingMode::InProcess;
259 }
260
261 void PageClientImpl::viewWillMoveToAnotherWindow()
262 {
263     clearAllEditCommands();
264 }
265
266 ColorSpaceData PageClientImpl::colorSpace()
267 {
268     return [m_wkView _colorSpace];
269 }
270
271 void PageClientImpl::processDidExit()
272 {
273     [m_wkView _processDidExit];
274 }
275
276 void PageClientImpl::pageClosed()
277 {
278     [m_wkView _pageClosed];
279 #if USE(DICTATION_ALTERNATIVES)
280     m_alternativeTextUIController->clear();
281 #endif
282 }
283
284 void PageClientImpl::didRelaunchProcess()
285 {
286     [m_wkView _didRelaunchProcess];
287 }
288
289 void PageClientImpl::preferencesDidChange()
290 {
291     [m_wkView _preferencesDidChange];
292 }
293
294 void PageClientImpl::toolTipChanged(const String& oldToolTip, const String& newToolTip)
295 {
296     [m_wkView _toolTipChangedFrom:nsStringFromWebCoreString(oldToolTip) to:nsStringFromWebCoreString(newToolTip)];
297 }
298
299 void PageClientImpl::didCommitLoadForMainFrame(const String& mimeType, bool useCustomContentProvider)
300 {
301 }
302
303 void PageClientImpl::didFinishLoadingDataForCustomContentProvider(const String& suggestedFilename, const IPC::DataReference& dataReference)
304 {
305 }
306
307 void PageClientImpl::handleDownloadRequest(DownloadProxy* download)
308 {
309     ASSERT_ARG(download, download);
310 #if WK_API_ENABLED
311     ASSERT([download->wrapper() isKindOfClass:[_WKDownload class]]);
312     [static_cast<_WKDownload *>(download->wrapper()) setOriginatingWebView:m_webView];
313 #endif
314 }
315
316 void PageClientImpl::setCursor(const WebCore::Cursor& cursor)
317 {
318     // FIXME: Would be nice to share this code with WebKit1's WebChromeClient.
319
320     if ([NSApp _cursorRectCursor])
321         return;
322
323     if (!m_wkView)
324         return;
325
326     NSWindow *window = [m_wkView window];
327     if (!window || ![window isKeyWindow])
328         return;
329
330     NSCursor *platformCursor = cursor.platformCursor();
331     if ([NSCursor currentCursor] == platformCursor)
332         return;
333
334     [platformCursor set];
335 }
336
337 void PageClientImpl::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
338 {
339     [NSCursor setHiddenUntilMouseMoves:hiddenUntilMouseMoves];
340 }
341
342 void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttributes&)
343 {
344 }
345
346 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy> prpCommand, WebPageProxy::UndoOrRedo undoOrRedo)
347 {
348     RefPtr<WebEditCommandProxy> command = prpCommand;
349
350     RetainPtr<WKEditCommandObjC> commandObjC = adoptNS([[WKEditCommandObjC alloc] initWithWebEditCommandProxy:command]);
351     String actionName = WebEditCommandProxy::nameForEditAction(command->editAction());
352
353     NSUndoManager *undoManager = [m_wkView undoManager];
354     [undoManager registerUndoWithTarget:m_undoTarget.get() selector:((undoOrRedo == WebPageProxy::Undo) ? @selector(undoEditing:) : @selector(redoEditing:)) object:commandObjC.get()];
355     if (!actionName.isEmpty())
356         [undoManager setActionName:(NSString *)actionName];
357 }
358
359 void PageClientImpl::clearAllEditCommands()
360 {
361     [[m_wkView undoManager] removeAllActionsWithTarget:m_undoTarget.get()];
362 }
363
364 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
365 {
366     return (undoOrRedo == WebPageProxy::Undo) ? [[m_wkView undoManager] canUndo] : [[m_wkView undoManager] canRedo];
367 }
368
369 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
370 {
371     return (undoOrRedo == WebPageProxy::Undo) ? [[m_wkView undoManager] undo] : [[m_wkView undoManager] redo];
372 }
373
374 void PageClientImpl::setDragImage(const IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag)
375 {
376     RetainPtr<CGImageRef> dragCGImage = dragImage->makeCGImage();
377     RetainPtr<NSImage> dragNSImage = adoptNS([[NSImage alloc] initWithCGImage:dragCGImage.get() size:dragImage->size()]);
378
379     [m_wkView _setDragImage:dragNSImage.get() at:clientPosition linkDrag:isLinkDrag];
380 }
381
382 void PageClientImpl::setPromisedData(const String& pasteboardName, PassRefPtr<SharedBuffer> imageBuffer, const String& filename, const String& extension, const String& title, const String& url, const String& visibleUrl, PassRefPtr<SharedBuffer> archiveBuffer)
383 {
384     RefPtr<Image> image = BitmapImage::create();
385     image->setData(imageBuffer.get(), true);
386     [m_wkView _setPromisedData:image.get() withFileName:filename withExtension:extension withTitle:title withURL:url withVisibleURL:visibleUrl withArchive:archiveBuffer.get() forPasteboard:pasteboardName];
387 }
388
389 void PageClientImpl::updateSecureInputState()
390 {
391     [m_wkView _updateSecureInputState];
392 }
393
394 void PageClientImpl::resetSecureInputState()
395 {
396     [m_wkView _resetSecureInputState];
397 }
398
399 void PageClientImpl::notifyInputContextAboutDiscardedComposition()
400 {
401     [m_wkView _notifyInputContextAboutDiscardedComposition];
402 }
403
404 FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& rect)
405 {
406     return [m_wkView _convertToDeviceSpace:rect];
407 }
408
409 FloatRect PageClientImpl::convertToUserSpace(const FloatRect& rect)
410 {
411     return [m_wkView _convertToUserSpace:rect];
412 }
413    
414 IntPoint PageClientImpl::screenToRootView(const IntPoint& point)
415 {
416 #pragma clang diagnostic push
417 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
418     NSPoint windowCoord = [[m_wkView window] convertScreenToBase:point];
419 #pragma clang diagnostic pop
420     return IntPoint([m_wkView convertPoint:windowCoord fromView:nil]);
421 }
422     
423 IntRect PageClientImpl::rootViewToScreen(const IntRect& rect)
424 {
425     NSRect tempRect = rect;
426     tempRect = [m_wkView convertRect:tempRect toView:nil];
427 #pragma clang diagnostic push
428 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
429     tempRect.origin = [[m_wkView window] convertBaseToScreen:tempRect.origin];
430 #pragma clang diagnostic pop
431     return enclosingIntRect(tempRect);
432 }
433
434 void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent& event, bool eventWasHandled)
435 {
436     [m_wkView _doneWithKeyEvent:event.nativeEvent() eventWasHandled:eventWasHandled];
437 }
438
439 PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy* page)
440 {
441     return WebPopupMenuProxyMac::create(m_wkView, page);
442 }
443
444 PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy* page)
445 {
446     return WebContextMenuProxyMac::create(m_wkView, page);
447 }
448
449 #if ENABLE(INPUT_TYPE_COLOR)
450 PassRefPtr<WebColorPicker> PageClientImpl::createColorPicker(WebPageProxy* page, const WebCore::Color& initialColor,  const WebCore::IntRect& rect)
451 {
452     return WebColorPickerMac::create(page, initialColor, rect, wkView());
453 }
454 #endif
455
456 void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator> findIndicator, bool fadeOut, bool animate)
457 {
458     [m_wkView _setFindIndicator:findIndicator fadeOut:fadeOut animate:animate];
459 }
460
461 void PageClientImpl::accessibilityWebProcessTokenReceived(const IPC::DataReference& data)
462 {
463     NSData* remoteToken = [NSData dataWithBytes:data.data() length:data.size()];
464     [m_wkView _setAccessibilityWebProcessToken:remoteToken];
465 }
466     
467 void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
468 {
469     ASSERT(!layerTreeContext.isEmpty());
470
471     CALayer *renderLayer = WKMakeRenderLayer(layerTreeContext.contextID);
472     [m_wkView _setAcceleratedCompositingModeRootLayer:renderLayer];
473 }
474
475 void PageClientImpl::exitAcceleratedCompositingMode()
476 {
477     [m_wkView _setAcceleratedCompositingModeRootLayer:nil];
478 }
479
480 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
481 {
482     ASSERT(!layerTreeContext.isEmpty());
483
484     CALayer *renderLayer = WKMakeRenderLayer(layerTreeContext.contextID);
485     [m_wkView _setAcceleratedCompositingModeRootLayer:renderLayer];
486 }
487
488 void PageClientImpl::setAcceleratedCompositingRootLayer(CALayer *rootLayer)
489 {
490     [m_wkView _setAcceleratedCompositingModeRootLayer:rootLayer];
491 }
492
493 CALayer *PageClientImpl::acceleratedCompositingRootLayer() const
494 {
495     return m_wkView._acceleratedCompositingModeRootLayer;
496 }
497
498 RetainPtr<CGImageRef> PageClientImpl::takeViewSnapshot()
499 {
500     return [m_wkView _takeViewSnapshot];
501 }
502
503 void PageClientImpl::wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent& event)
504 {
505     [m_wkView _wheelEventWasNotHandledByWebCore:event.nativeEvent()];
506 }
507
508 void PageClientImpl::pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus)
509 {
510     [m_wkView _pluginFocusOrWindowFocusChanged:pluginHasFocusAndWindowHasFocus pluginComplexTextInputIdentifier:pluginComplexTextInputIdentifier];
511 }
512
513 void PageClientImpl::setPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, PluginComplexTextInputState pluginComplexTextInputState)
514 {
515     [m_wkView _setPluginComplexTextInputState:pluginComplexTextInputState pluginComplexTextInputIdentifier:pluginComplexTextInputIdentifier];
516 }
517
518 void PageClientImpl::didPerformDictionaryLookup(const AttributedString& text, const DictionaryPopupInfo& dictionaryPopupInfo)
519 {
520     RetainPtr<NSAttributedString> attributedString = text.string;
521     NSPoint textBaselineOrigin = dictionaryPopupInfo.origin;
522
523     // Convert to screen coordinates.
524     textBaselineOrigin = [m_wkView convertPoint:textBaselineOrigin toView:nil];
525     textBaselineOrigin = [m_wkView.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin;
526
527     WKShowWordDefinitionWindow(attributedString.get(), textBaselineOrigin, (NSDictionary *)dictionaryPopupInfo.options.get());
528 }
529
530 void PageClientImpl::dismissDictionaryLookupPanel()
531 {
532     // FIXME: We don't know which panel we are dismissing, it may not even be in the current page (see <rdar://problem/13875766>).
533     WKHideWordDefinitionWindow();
534 }
535
536 void PageClientImpl::showCorrectionPanel(AlternativeTextType type, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings)
537 {
538 #if USE(AUTOCORRECTION_PANEL)
539     if (!isViewVisible() || !isViewInWindow())
540         return;
541     m_correctionPanel.show(m_wkView, type, boundingBoxOfReplacedString, replacedString, replacementString, alternativeReplacementStrings);
542 #endif
543 }
544
545 void PageClientImpl::dismissCorrectionPanel(ReasonForDismissingAlternativeText reason)
546 {
547 #if USE(AUTOCORRECTION_PANEL)
548     m_correctionPanel.dismiss(reason);
549 #endif
550 }
551
552 String PageClientImpl::dismissCorrectionPanelSoon(WebCore::ReasonForDismissingAlternativeText reason)
553 {
554 #if USE(AUTOCORRECTION_PANEL)
555     return m_correctionPanel.dismiss(reason);
556 #else
557     return String();
558 #endif
559 }
560
561 void PageClientImpl::recordAutocorrectionResponse(AutocorrectionResponseType responseType, const String& replacedString, const String& replacementString)
562 {
563     NSCorrectionResponse response = responseType == AutocorrectionReverted ? NSCorrectionResponseReverted : NSCorrectionResponseEdited;
564     CorrectionPanel::recordAutocorrectionResponse(m_wkView, response, replacedString, replacementString);
565 }
566
567 void PageClientImpl::recommendedScrollbarStyleDidChange(int32_t newStyle)
568 {
569     NSArray *trackingAreas = [m_wkView trackingAreas];
570     NSUInteger count = [trackingAreas count];
571     ASSERT(count == 1);
572     
573     for (NSUInteger i = 0; i < count; ++i)
574         [m_wkView removeTrackingArea:[trackingAreas objectAtIndex:i]];
575
576     // Now re-create a tracking area with the appropriate options given the new scrollbar style
577     NSTrackingAreaOptions options = NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited | NSTrackingInVisibleRect;
578     if (newStyle == NSScrollerStyleLegacy)
579         options |= NSTrackingActiveAlways;
580     else
581         options |= NSTrackingActiveInKeyWindow;
582
583     NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect:[m_wkView frame]
584                                                                 options:options
585                                                                   owner:m_wkView
586                                                                userInfo:nil];
587     [m_wkView addTrackingArea:trackingArea];
588     [trackingArea release];
589 }
590
591 void PageClientImpl::intrinsicContentSizeDidChange(const IntSize& intrinsicContentSize)
592 {
593     [m_wkView _setIntrinsicContentSize:intrinsicContentSize];
594 }
595
596 bool PageClientImpl::executeSavedCommandBySelector(const String& selectorString)
597 {
598     return [m_wkView _executeSavedCommandBySelector:NSSelectorFromString(selectorString)];
599 }
600
601 void PageClientImpl::clearCustomSwipeViews()
602 {
603     return [m_wkView _setCustomSwipeViews:@[]];
604 }
605
606 #if USE(DICTATION_ALTERNATIVES)
607 uint64_t PageClientImpl::addDictationAlternatives(const RetainPtr<NSTextAlternatives>& alternatives)
608 {
609     return m_alternativeTextUIController->addAlternatives(alternatives);
610 }
611
612 void PageClientImpl::removeDictationAlternatives(uint64_t dictationContext)
613 {
614     m_alternativeTextUIController->removeAlternatives(dictationContext);
615 }
616
617 void PageClientImpl::showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext)
618 {
619     if (!isViewVisible() || !isViewInWindow())
620         return;
621     m_alternativeTextUIController->showAlternatives(m_wkView, boundingBoxOfDictatedText, dictationContext, ^(NSString* acceptedAlternative){
622         [m_wkView handleAcceptedAlternativeText:acceptedAlternative];
623     });
624 }
625
626 Vector<String> PageClientImpl::dictationAlternatives(uint64_t dictationContext)
627 {
628     return m_alternativeTextUIController->alternativesForContext(dictationContext);
629 }
630 #endif
631
632 #if ENABLE(FULLSCREEN_API)
633
634 WebFullScreenManagerProxyClient& PageClientImpl::fullScreenManagerProxyClient()
635 {
636     return *this;
637 }
638
639 // WebFullScreenManagerProxyClient
640
641 void PageClientImpl::closeFullScreenManager()
642 {
643     [m_wkView _closeFullScreenWindowController];
644 }
645
646 bool PageClientImpl::isFullScreen()
647 {
648     if (!m_wkView._hasFullScreenWindowController)
649         return false;
650
651     return m_wkView._fullScreenWindowController.isFullScreen;
652 }
653
654 void PageClientImpl::enterFullScreen()
655 {
656     [m_wkView._fullScreenWindowController enterFullScreen:nil];
657 }
658
659 void PageClientImpl::exitFullScreen()
660 {
661     [m_wkView._fullScreenWindowController exitFullScreen];
662 }
663
664 void PageClientImpl::beganEnterFullScreen(const IntRect& initialFrame, const IntRect& finalFrame)
665 {
666     [m_wkView._fullScreenWindowController beganEnterFullScreenWithInitialFrame:initialFrame finalFrame:finalFrame];
667 }
668
669 void PageClientImpl::beganExitFullScreen(const IntRect& initialFrame, const IntRect& finalFrame)
670 {
671     [m_wkView._fullScreenWindowController beganExitFullScreenWithInitialFrame:initialFrame finalFrame:finalFrame];
672 }
673
674 #endif // ENABLE(FULLSCREEN_API)
675
676 } // namespace WebKit
677
678 #endif // PLATFORM(MAC)