447cd907a88fbf5d6c3a4c6ab47a9a3815c80d76
[WebKit-https.git] / Source / WebKit2 / UIProcess / API / 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 USE(DICTATION_ALTERNATIVES)
30 #import <AppKit/NSTextAlternatives.h>
31 #endif
32 #import "AttributedString.h"
33 #import "ColorSpaceData.h"
34 #import "DataReference.h"
35 #import "DictionaryPopupInfo.h"
36 #import "FindIndicator.h"
37 #import "NativeWebKeyboardEvent.h"
38 #import "WKAPICast.h"
39 #import "WKStringCF.h"
40 #import "WKViewInternal.h"
41 #import "StringUtilities.h"
42 #import "WebContextMenuProxyMac.h"
43 #import "WebEditCommandProxy.h"
44 #import "WebPopupMenuProxyMac.h"
45 #import <WebCore/AlternativeTextUIController.h>
46 #import <WebCore/BitmapImage.h>
47 #import <WebCore/Cursor.h>
48 #import <WebCore/FloatRect.h>
49 #import <WebCore/FoundationExtras.h>
50 #import <WebCore/GraphicsContext.h>
51 #import <WebCore/Image.h>
52 #import <WebCore/KeyboardEvent.h>
53 #import <WebCore/NotImplemented.h>
54 #import <WebCore/SharedBuffer.h>
55 #import <wtf/PassOwnPtr.h>
56 #import <wtf/text/CString.h>
57 #import <wtf/text/WTFString.h>
58 #import <WebKitSystemInterface.h>
59
60 @interface NSApplication (WebNSApplicationDetails)
61 - (NSCursor *)_cursorRectCursor;
62 @end
63
64 #if HAVE(LAYER_HOSTING_IN_WINDOW_SERVER)
65 @interface NSWindow (WebNSWindowDetails)
66 - (BOOL)_hostsLayersInWindowServer;
67 @end
68 #endif
69
70 using namespace WebCore;
71 using namespace WebKit;
72
73 @interface WKEditCommandObjC : NSObject
74 {
75     RefPtr<WebEditCommandProxy> m_command;
76 }
77 - (id)initWithWebEditCommandProxy:(PassRefPtr<WebEditCommandProxy>)command;
78 - (WebEditCommandProxy*)command;
79 @end
80
81 @interface WKEditorUndoTargetObjC : NSObject
82 - (void)undoEditing:(id)sender;
83 - (void)redoEditing:(id)sender;
84 @end
85
86 @implementation WKEditCommandObjC
87
88 - (id)initWithWebEditCommandProxy:(PassRefPtr<WebEditCommandProxy>)command
89 {
90     self = [super init];
91     if (!self)
92         return nil;
93
94     m_command = command;
95     return self;
96 }
97
98 - (WebEditCommandProxy*)command
99 {
100     return m_command.get();
101 }
102
103 @end
104
105 @implementation WKEditorUndoTargetObjC
106
107 - (void)undoEditing:(id)sender
108 {
109     ASSERT([sender isKindOfClass:[WKEditCommandObjC class]]);
110     [sender command]->unapply();
111 }
112
113 - (void)redoEditing:(id)sender
114 {
115     ASSERT([sender isKindOfClass:[WKEditCommandObjC class]]);
116     [sender command]->reapply();
117 }
118
119 @end
120
121 namespace WebKit {
122
123 PassOwnPtr<PageClientImpl> PageClientImpl::create(WKView* wkView)
124 {
125     return adoptPtr(new PageClientImpl(wkView));
126 }
127
128 PageClientImpl::PageClientImpl(WKView* wkView)
129     : m_wkView(wkView)
130     , m_undoTarget(adoptNS([[WKEditorUndoTargetObjC alloc] init]))
131 #if USE(DICTATION_ALTERNATIVES)
132     , m_alternativeTextUIController(adoptPtr(new AlternativeTextUIController))
133 #endif
134 {
135 }
136
137 PageClientImpl::~PageClientImpl()
138 {
139 }
140
141 PassOwnPtr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy()
142 {
143     return [m_wkView _createDrawingAreaProxy];
144 }
145
146 void PageClientImpl::setViewNeedsDisplay(const WebCore::IntRect& rect)
147 {
148     [m_wkView setNeedsDisplayInRect:rect];
149 }
150
151 void PageClientImpl::displayView()
152 {
153     [m_wkView displayIfNeeded];
154 }
155
156 bool PageClientImpl::canScrollView()
157 {
158     // -scrollRect:by: does nothing in layer-backed views <rdar://problem/12961719>.
159     return ![m_wkView layer];
160 }
161
162 void PageClientImpl::scrollView(const IntRect& scrollRect, const IntSize& scrollOffset)
163 {
164     NSRect clippedScrollRect = NSIntersectionRect(scrollRect, NSOffsetRect(scrollRect, -scrollOffset.width(), -scrollOffset.height()));
165
166     [m_wkView _cacheWindowBottomCornerRect];
167
168     [m_wkView translateRectsNeedingDisplayInRect:clippedScrollRect by:scrollOffset];
169     [m_wkView scrollRect:clippedScrollRect by:scrollOffset];
170 }
171
172 IntSize PageClientImpl::viewSize()
173 {
174     return IntSize([m_wkView bounds].size);
175 }
176
177 bool PageClientImpl::isViewWindowActive()
178 {
179     return [[m_wkView window] isKeyWindow] || [NSApp keyWindow] == [m_wkView window];
180 }
181
182 bool PageClientImpl::isViewFocused()
183 {
184     return [m_wkView _isFocused];
185 }
186
187 void PageClientImpl::makeFirstResponder()
188 {
189      [[m_wkView window] makeFirstResponder:m_wkView];
190 }
191     
192 bool PageClientImpl::isViewVisible()
193 {
194     if (![m_wkView window])
195         return false;
196
197     if (![[m_wkView window] isVisible])
198         return false;
199
200 #if __MAC_OS_X_VERSION_MIN_REQUIRED <= 1080
201     // Mountain Lion and previous do not support occlusion notifications, and as such will
202     // continue to report as "visible" when not on the active space.
203     if (![[m_wkView window] isOnActiveSpace])
204         return false;
205 #endif
206
207     if ([m_wkView isHiddenOrHasHiddenAncestor])
208         return false;
209
210     if ([m_wkView _isWindowOccluded])
211         return false;
212
213     return true;
214 }
215
216 bool PageClientImpl::isViewInWindow()
217 {
218     return [m_wkView window];
219 }
220
221 void PageClientImpl::viewWillMoveToAnotherWindow()
222 {
223     clearAllEditCommands();
224 }
225
226 LayerHostingMode PageClientImpl::viewLayerHostingMode()
227 {
228 #if HAVE(LAYER_HOSTING_IN_WINDOW_SERVER)
229     if (![m_wkView window])
230         return LayerHostingModeDefault;
231
232     return [[m_wkView window] _hostsLayersInWindowServer] ? LayerHostingModeInWindowServer : LayerHostingModeDefault;
233 #else
234     return LayerHostingModeDefault;
235 #endif
236 }
237
238 ColorSpaceData PageClientImpl::colorSpace()
239 {
240     return [m_wkView _colorSpace];
241 }
242
243 void PageClientImpl::processDidCrash()
244 {
245     [m_wkView _processDidCrash];
246 }
247
248 void PageClientImpl::pageClosed()
249 {
250     [m_wkView _pageClosed];
251 #if USE(DICTATION_ALTERNATIVES)
252     m_alternativeTextUIController->clear();
253 #endif
254 }
255
256 void PageClientImpl::didRelaunchProcess()
257 {
258     [m_wkView _didRelaunchProcess];
259 }
260
261 void PageClientImpl::toolTipChanged(const String& oldToolTip, const String& newToolTip)
262 {
263     [m_wkView _toolTipChangedFrom:nsStringFromWebCoreString(oldToolTip) to:nsStringFromWebCoreString(newToolTip)];
264 }
265
266 void PageClientImpl::setCursor(const WebCore::Cursor& cursor)
267 {
268     if (![NSApp _cursorRectCursor])
269         [m_wkView _setCursor:cursor.platformCursor()];
270 }
271
272 void PageClientImpl::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
273 {
274     [NSCursor setHiddenUntilMouseMoves:hiddenUntilMouseMoves];
275 }
276
277 void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttributes&)
278 {
279 }
280
281 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy> prpCommand, WebPageProxy::UndoOrRedo undoOrRedo)
282 {
283     RefPtr<WebEditCommandProxy> command = prpCommand;
284
285     RetainPtr<WKEditCommandObjC> commandObjC = adoptNS([[WKEditCommandObjC alloc] initWithWebEditCommandProxy:command]);
286     String actionName = WebEditCommandProxy::nameForEditAction(command->editAction());
287
288     NSUndoManager *undoManager = [m_wkView undoManager];
289     [undoManager beginUndoGrouping];
290     [undoManager registerUndoWithTarget:m_undoTarget.get() selector:((undoOrRedo == WebPageProxy::Undo) ? @selector(undoEditing:) : @selector(redoEditing:)) object:commandObjC.get()];
291     if (!actionName.isEmpty())
292         [undoManager setActionName:(NSString *)actionName];
293     [undoManager endUndoGrouping];
294 }
295
296 void PageClientImpl::clearAllEditCommands()
297 {
298     [[m_wkView undoManager] removeAllActionsWithTarget:m_undoTarget.get()];
299 }
300
301 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
302 {
303     return (undoOrRedo == WebPageProxy::Undo) ? [[m_wkView undoManager] canUndo] : [[m_wkView undoManager] canRedo];
304 }
305
306 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
307 {
308     return (undoOrRedo == WebPageProxy::Undo) ? [[m_wkView undoManager] undo] : [[m_wkView undoManager] redo];
309 }
310
311 bool PageClientImpl::interpretKeyEvent(const NativeWebKeyboardEvent& event, Vector<WebCore::KeypressCommand>& commands)
312 {
313     return [m_wkView _interpretKeyEvent:event.nativeEvent() savingCommandsTo:commands];
314 }
315
316 void PageClientImpl::setDragImage(const IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag)
317 {
318     RetainPtr<CGImageRef> dragCGImage = dragImage->makeCGImage();
319     RetainPtr<NSImage> dragNSImage = adoptNS([[NSImage alloc] initWithCGImage:dragCGImage.get() size:dragImage->size()]);
320
321     [m_wkView _setDragImage:dragNSImage.get() at:clientPosition linkDrag:isLinkDrag];
322 }
323
324 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)
325 {
326     RefPtr<Image> image = BitmapImage::create();
327     image->setData(imageBuffer.get(), true);
328     [m_wkView _setPromisedData:image.get() withFileName:filename withExtension:extension withTitle:title withURL:url withVisibleURL:visibleUrl withArchive:archiveBuffer.get() forPasteboard:pasteboardName];
329 }
330
331 void PageClientImpl::updateTextInputState(bool updateSecureInputState)
332 {
333     [m_wkView _updateTextInputStateIncludingSecureInputState:updateSecureInputState];
334 }
335
336 void PageClientImpl::resetSecureInputState()
337 {
338     [m_wkView _resetSecureInputState];
339 }
340
341 void PageClientImpl::notifyInputContextAboutDiscardedComposition()
342 {
343     [m_wkView _notifyInputContextAboutDiscardedComposition];
344 }
345
346 FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& rect)
347 {
348     return [m_wkView _convertToDeviceSpace:rect];
349 }
350
351 FloatRect PageClientImpl::convertToUserSpace(const FloatRect& rect)
352 {
353     return [m_wkView _convertToUserSpace:rect];
354 }
355    
356 IntPoint PageClientImpl::screenToWindow(const IntPoint& point)
357 {
358     NSPoint windowCoord = [[m_wkView window] convertScreenToBase:point];
359     return IntPoint([m_wkView convertPoint:windowCoord fromView:nil]);
360 }
361     
362 IntRect PageClientImpl::windowToScreen(const IntRect& rect)
363 {
364     NSRect tempRect = rect;
365     tempRect = [m_wkView convertRect:tempRect toView:nil];
366     tempRect.origin = [[m_wkView window] convertBaseToScreen:tempRect.origin];
367     return enclosingIntRect(tempRect);
368 }
369
370 #if ENABLE(GESTURE_EVENTS)
371 void PageClientImpl::doneWithGestureEvent(const WebGestureEvent&, bool wasEventHandled)
372 {
373     notImplemented();
374 }
375 #endif
376
377 void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent& event, bool eventWasHandled)
378 {
379     [m_wkView _doneWithKeyEvent:event.nativeEvent() eventWasHandled:eventWasHandled];
380 }
381
382 PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy* page)
383 {
384     return WebPopupMenuProxyMac::create(m_wkView, page);
385 }
386
387 PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy* page)
388 {
389     return WebContextMenuProxyMac::create(m_wkView, page);
390 }
391
392 #if ENABLE(INPUT_TYPE_COLOR)
393 PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&,  const WebCore::IntRect&)
394 {
395     notImplemented();
396     return 0;
397 }
398 #endif
399
400 void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator> findIndicator, bool fadeOut, bool animate)
401 {
402     [m_wkView _setFindIndicator:findIndicator fadeOut:fadeOut animate:animate];
403 }
404
405 void PageClientImpl::accessibilityWebProcessTokenReceived(const CoreIPC::DataReference& data)
406 {
407     NSData* remoteToken = [NSData dataWithBytes:data.data() length:data.size()];
408     [m_wkView _setAccessibilityWebProcessToken:remoteToken];
409 }
410     
411 void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
412 {
413     ASSERT(!layerTreeContext.isEmpty());
414
415     CALayer *renderLayer = WKMakeRenderLayer(layerTreeContext.contextID);
416     [m_wkView _setAcceleratedCompositingModeRootLayer:renderLayer];
417 }
418
419 void PageClientImpl::exitAcceleratedCompositingMode()
420 {
421     [m_wkView _setAcceleratedCompositingModeRootLayer:nil];
422 }
423
424 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
425 {
426     ASSERT(!layerTreeContext.isEmpty());
427
428     CALayer *renderLayer = WKMakeRenderLayer(layerTreeContext.contextID);
429     [m_wkView _setAcceleratedCompositingModeRootLayer:renderLayer];
430 }
431
432 void PageClientImpl::setAcceleratedCompositingRootLayer(CALayer *rootLayer)
433 {
434     [m_wkView _setAcceleratedCompositingModeRootLayer:rootLayer];
435 }
436
437 void PageClientImpl::pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus)
438 {
439     [m_wkView _pluginFocusOrWindowFocusChanged:pluginHasFocusAndWindowHasFocus pluginComplexTextInputIdentifier:pluginComplexTextInputIdentifier];
440 }
441
442 void PageClientImpl::setPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, PluginComplexTextInputState pluginComplexTextInputState)
443 {
444     [m_wkView _setPluginComplexTextInputState:pluginComplexTextInputState pluginComplexTextInputIdentifier:pluginComplexTextInputIdentifier];
445 }
446
447 CGContextRef PageClientImpl::containingWindowGraphicsContext()
448 {
449     NSWindow *window = [m_wkView window];
450
451     // Don't try to get the graphics context if the NSWindow doesn't have a window device.
452     if ([window windowNumber] <= 0)
453         return 0;
454
455     return static_cast<CGContextRef>([[window graphicsContext] graphicsPort]);
456 }
457
458 void PageClientImpl::didCommitLoadForMainFrame(bool useCustomRepresentation)
459 {
460     [m_wkView _setPageHasCustomRepresentation:useCustomRepresentation];
461 }
462
463 void PageClientImpl::didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference& dataReference)
464 {
465     [m_wkView _didFinishLoadingDataForCustomRepresentationWithSuggestedFilename:suggestedFilename dataReference:dataReference];
466 }
467
468 double PageClientImpl::customRepresentationZoomFactor()
469 {
470     return [m_wkView _customRepresentationZoomFactor];
471 }
472
473 void PageClientImpl::setCustomRepresentationZoomFactor(double zoomFactor)
474 {
475     [m_wkView _setCustomRepresentationZoomFactor:zoomFactor];
476 }
477
478 void PageClientImpl::findStringInCustomRepresentation(const String& string, FindOptions options, unsigned maxMatchCount)
479 {
480     [m_wkView _findStringInCustomRepresentation:string withFindOptions:options maxMatchCount:maxMatchCount];
481 }
482
483 void PageClientImpl::countStringMatchesInCustomRepresentation(const String& string, FindOptions options, unsigned maxMatchCount)
484 {
485     [m_wkView _countStringMatchesInCustomRepresentation:string withFindOptions:options maxMatchCount:maxMatchCount];
486 }
487
488 void PageClientImpl::flashBackingStoreUpdates(const Vector<IntRect>&)
489 {
490     notImplemented();
491 }
492
493 void PageClientImpl::didPerformDictionaryLookup(const AttributedString& text, const DictionaryPopupInfo& dictionaryPopupInfo)
494 {
495     RetainPtr<NSAttributedString> attributedString = text.string;
496     NSPoint textBaselineOrigin = dictionaryPopupInfo.origin;
497
498     // Convert to screen coordinates.
499     textBaselineOrigin = [m_wkView convertPoint:textBaselineOrigin toView:nil];
500     textBaselineOrigin = [m_wkView.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin;
501
502     WKShowWordDefinitionWindow(attributedString.get(), textBaselineOrigin, (NSDictionary *)dictionaryPopupInfo.options.get());
503 }
504
505 void PageClientImpl::dismissDictionaryLookupPanel()
506 {
507     WKHideWordDefinitionWindow();
508 }
509
510 void PageClientImpl::showCorrectionPanel(AlternativeTextType type, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings)
511 {
512 #if USE(AUTOCORRECTION_PANEL)
513     if (!isViewVisible() || !isViewInWindow())
514         return;
515     m_correctionPanel.show(m_wkView, type, boundingBoxOfReplacedString, replacedString, replacementString, alternativeReplacementStrings);
516 #endif
517 }
518
519 void PageClientImpl::dismissCorrectionPanel(ReasonForDismissingAlternativeText reason)
520 {
521 #if USE(AUTOCORRECTION_PANEL)
522     m_correctionPanel.dismiss(reason);
523 #endif
524 }
525
526 String PageClientImpl::dismissCorrectionPanelSoon(WebCore::ReasonForDismissingAlternativeText reason)
527 {
528 #if USE(AUTOCORRECTION_PANEL)
529     return m_correctionPanel.dismiss(reason);
530 #else
531     return String();
532 #endif
533 }
534
535 void PageClientImpl::recordAutocorrectionResponse(AutocorrectionResponseType responseType, const String& replacedString, const String& replacementString)
536 {
537     NSCorrectionResponse response = responseType == AutocorrectionReverted ? NSCorrectionResponseReverted : NSCorrectionResponseEdited;
538     CorrectionPanel::recordAutocorrectionResponse(m_wkView, response, replacedString, replacementString);
539 }
540
541 void PageClientImpl::recommendedScrollbarStyleDidChange(int32_t newStyle)
542 {
543     NSArray *trackingAreas = [m_wkView trackingAreas];
544     NSUInteger count = [trackingAreas count];
545     ASSERT(count == 1);
546     
547     for (NSUInteger i = 0; i < count; ++i)
548         [m_wkView removeTrackingArea:[trackingAreas objectAtIndex:i]];
549
550     // Now re-create a tracking area with the appropriate options given the new scrollbar style
551     NSTrackingAreaOptions options = NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited | NSTrackingInVisibleRect;
552     if (newStyle == NSScrollerStyleLegacy)
553         options |= NSTrackingActiveAlways;
554     else
555         options |= NSTrackingActiveInKeyWindow;
556
557     NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect:[m_wkView frame]
558                                                                 options:options
559                                                                   owner:m_wkView
560                                                                userInfo:nil];
561     [m_wkView addTrackingArea:trackingArea];
562     [trackingArea release];
563 }
564
565 void PageClientImpl::intrinsicContentSizeDidChange(const IntSize& intrinsicContentSize)
566 {
567     [m_wkView _setIntrinsicContentSize:intrinsicContentSize];
568 }
569
570 bool PageClientImpl::executeSavedCommandBySelector(const String& selectorString)
571 {
572     return [m_wkView _executeSavedCommandBySelector:NSSelectorFromString(selectorString)];
573 }
574
575 #if USE(DICTATION_ALTERNATIVES)
576 uint64_t PageClientImpl::addDictationAlternatives(const RetainPtr<NSTextAlternatives>& alternatives)
577 {
578     return m_alternativeTextUIController->addAlternatives(alternatives);
579 }
580
581 void PageClientImpl::removeDictationAlternatives(uint64_t dictationContext)
582 {
583     m_alternativeTextUIController->removeAlternatives(dictationContext);
584 }
585
586 void PageClientImpl::showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext)
587 {
588     if (!isViewVisible() || !isViewInWindow())
589         return;
590     m_alternativeTextUIController->showAlternatives(m_wkView, boundingBoxOfDictatedText, dictationContext, ^(NSString* acceptedAlternative){
591         [m_wkView handleAcceptedAlternativeText:acceptedAlternative];
592     });
593 }
594
595 Vector<String> PageClientImpl::dictationAlternatives(uint64_t dictationContext)
596 {
597     return m_alternativeTextUIController->alternativesForContext(dictationContext);
598 }
599 #endif
600
601 } // namespace WebKit