Text input is largely broken when there are subframes loading
[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 registerUndoWithTarget:m_undoTarget.get() selector:((undoOrRedo == WebPageProxy::Undo) ? @selector(undoEditing:) : @selector(redoEditing:)) object:commandObjC.get()];
290     if (!actionName.isEmpty())
291         [undoManager setActionName:(NSString *)actionName];
292 }
293
294 void PageClientImpl::clearAllEditCommands()
295 {
296     [[m_wkView undoManager] removeAllActionsWithTarget:m_undoTarget.get()];
297 }
298
299 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
300 {
301     return (undoOrRedo == WebPageProxy::Undo) ? [[m_wkView undoManager] canUndo] : [[m_wkView undoManager] canRedo];
302 }
303
304 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
305 {
306     return (undoOrRedo == WebPageProxy::Undo) ? [[m_wkView undoManager] undo] : [[m_wkView undoManager] redo];
307 }
308
309 bool PageClientImpl::interpretKeyEvent(const NativeWebKeyboardEvent& event, Vector<WebCore::KeypressCommand>& commands)
310 {
311     return [m_wkView _interpretKeyEvent:event.nativeEvent() savingCommandsTo:commands];
312 }
313
314 void PageClientImpl::setDragImage(const IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag)
315 {
316     RetainPtr<CGImageRef> dragCGImage = dragImage->makeCGImage();
317     RetainPtr<NSImage> dragNSImage = adoptNS([[NSImage alloc] initWithCGImage:dragCGImage.get() size:dragImage->size()]);
318
319     [m_wkView _setDragImage:dragNSImage.get() at:clientPosition linkDrag:isLinkDrag];
320 }
321
322 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)
323 {
324     RefPtr<Image> image = BitmapImage::create();
325     image->setData(imageBuffer.get(), true);
326     [m_wkView _setPromisedData:image.get() withFileName:filename withExtension:extension withTitle:title withURL:url withVisibleURL:visibleUrl withArchive:archiveBuffer.get() forPasteboard:pasteboardName];
327 }
328
329 void PageClientImpl::updateSecureInputState()
330 {
331     [m_wkView _updateSecureInputState];
332 }
333
334 void PageClientImpl::resetSecureInputState()
335 {
336     [m_wkView _resetSecureInputState];
337 }
338
339 void PageClientImpl::notifyInputContextAboutDiscardedComposition()
340 {
341     [m_wkView _notifyInputContextAboutDiscardedComposition];
342 }
343
344 FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& rect)
345 {
346     return [m_wkView _convertToDeviceSpace:rect];
347 }
348
349 FloatRect PageClientImpl::convertToUserSpace(const FloatRect& rect)
350 {
351     return [m_wkView _convertToUserSpace:rect];
352 }
353    
354 IntPoint PageClientImpl::screenToWindow(const IntPoint& point)
355 {
356     NSPoint windowCoord = [[m_wkView window] convertScreenToBase:point];
357     return IntPoint([m_wkView convertPoint:windowCoord fromView:nil]);
358 }
359     
360 IntRect PageClientImpl::windowToScreen(const IntRect& rect)
361 {
362     NSRect tempRect = rect;
363     tempRect = [m_wkView convertRect:tempRect toView:nil];
364     tempRect.origin = [[m_wkView window] convertBaseToScreen:tempRect.origin];
365     return enclosingIntRect(tempRect);
366 }
367
368 #if ENABLE(GESTURE_EVENTS)
369 void PageClientImpl::doneWithGestureEvent(const WebGestureEvent&, bool wasEventHandled)
370 {
371     notImplemented();
372 }
373 #endif
374
375 void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent& event, bool eventWasHandled)
376 {
377     [m_wkView _doneWithKeyEvent:event.nativeEvent() eventWasHandled:eventWasHandled];
378 }
379
380 PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy* page)
381 {
382     return WebPopupMenuProxyMac::create(m_wkView, page);
383 }
384
385 PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy* page)
386 {
387     return WebContextMenuProxyMac::create(m_wkView, page);
388 }
389
390 #if ENABLE(INPUT_TYPE_COLOR)
391 PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&,  const WebCore::IntRect&)
392 {
393     notImplemented();
394     return 0;
395 }
396 #endif
397
398 void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator> findIndicator, bool fadeOut, bool animate)
399 {
400     [m_wkView _setFindIndicator:findIndicator fadeOut:fadeOut animate:animate];
401 }
402
403 void PageClientImpl::accessibilityWebProcessTokenReceived(const CoreIPC::DataReference& data)
404 {
405     NSData* remoteToken = [NSData dataWithBytes:data.data() length:data.size()];
406     [m_wkView _setAccessibilityWebProcessToken:remoteToken];
407 }
408     
409 void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
410 {
411     ASSERT(!layerTreeContext.isEmpty());
412
413     CALayer *renderLayer = WKMakeRenderLayer(layerTreeContext.contextID);
414     [m_wkView _setAcceleratedCompositingModeRootLayer:renderLayer];
415 }
416
417 void PageClientImpl::exitAcceleratedCompositingMode()
418 {
419     [m_wkView _setAcceleratedCompositingModeRootLayer:nil];
420 }
421
422 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
423 {
424     ASSERT(!layerTreeContext.isEmpty());
425
426     CALayer *renderLayer = WKMakeRenderLayer(layerTreeContext.contextID);
427     [m_wkView _setAcceleratedCompositingModeRootLayer:renderLayer];
428 }
429
430 void PageClientImpl::setAcceleratedCompositingRootLayer(CALayer *rootLayer)
431 {
432     [m_wkView _setAcceleratedCompositingModeRootLayer:rootLayer];
433 }
434
435 void PageClientImpl::pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus)
436 {
437     [m_wkView _pluginFocusOrWindowFocusChanged:pluginHasFocusAndWindowHasFocus pluginComplexTextInputIdentifier:pluginComplexTextInputIdentifier];
438 }
439
440 void PageClientImpl::setPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, PluginComplexTextInputState pluginComplexTextInputState)
441 {
442     [m_wkView _setPluginComplexTextInputState:pluginComplexTextInputState pluginComplexTextInputIdentifier:pluginComplexTextInputIdentifier];
443 }
444
445 CGContextRef PageClientImpl::containingWindowGraphicsContext()
446 {
447     NSWindow *window = [m_wkView window];
448
449     // Don't try to get the graphics context if the NSWindow doesn't have a window device.
450     if ([window windowNumber] <= 0)
451         return 0;
452
453     return static_cast<CGContextRef>([[window graphicsContext] graphicsPort]);
454 }
455
456 void PageClientImpl::didCommitLoadForMainFrame(bool useCustomRepresentation)
457 {
458     [m_wkView _setPageHasCustomRepresentation:useCustomRepresentation];
459 }
460
461 void PageClientImpl::didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference& dataReference)
462 {
463     [m_wkView _didFinishLoadingDataForCustomRepresentationWithSuggestedFilename:suggestedFilename dataReference:dataReference];
464 }
465
466 double PageClientImpl::customRepresentationZoomFactor()
467 {
468     return [m_wkView _customRepresentationZoomFactor];
469 }
470
471 void PageClientImpl::setCustomRepresentationZoomFactor(double zoomFactor)
472 {
473     [m_wkView _setCustomRepresentationZoomFactor:zoomFactor];
474 }
475
476 void PageClientImpl::findStringInCustomRepresentation(const String& string, FindOptions options, unsigned maxMatchCount)
477 {
478     [m_wkView _findStringInCustomRepresentation:string withFindOptions:options maxMatchCount:maxMatchCount];
479 }
480
481 void PageClientImpl::countStringMatchesInCustomRepresentation(const String& string, FindOptions options, unsigned maxMatchCount)
482 {
483     [m_wkView _countStringMatchesInCustomRepresentation:string withFindOptions:options maxMatchCount:maxMatchCount];
484 }
485
486 void PageClientImpl::flashBackingStoreUpdates(const Vector<IntRect>&)
487 {
488     notImplemented();
489 }
490
491 void PageClientImpl::didPerformDictionaryLookup(const AttributedString& text, const DictionaryPopupInfo& dictionaryPopupInfo)
492 {
493     RetainPtr<NSAttributedString> attributedString = text.string;
494     NSPoint textBaselineOrigin = dictionaryPopupInfo.origin;
495
496     // Convert to screen coordinates.
497     textBaselineOrigin = [m_wkView convertPoint:textBaselineOrigin toView:nil];
498     textBaselineOrigin = [m_wkView.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin;
499
500     WKShowWordDefinitionWindow(attributedString.get(), textBaselineOrigin, (NSDictionary *)dictionaryPopupInfo.options.get());
501 }
502
503 void PageClientImpl::dismissDictionaryLookupPanel()
504 {
505     // FIXME: We don't know which panel we are dismissing, it may not even be in the current page (see <rdar://problem/13875766>).
506     WKHideWordDefinitionWindow();
507 }
508
509 void PageClientImpl::showCorrectionPanel(AlternativeTextType type, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings)
510 {
511 #if USE(AUTOCORRECTION_PANEL)
512     if (!isViewVisible() || !isViewInWindow())
513         return;
514     m_correctionPanel.show(m_wkView, type, boundingBoxOfReplacedString, replacedString, replacementString, alternativeReplacementStrings);
515 #endif
516 }
517
518 void PageClientImpl::dismissCorrectionPanel(ReasonForDismissingAlternativeText reason)
519 {
520 #if USE(AUTOCORRECTION_PANEL)
521     m_correctionPanel.dismiss(reason);
522 #endif
523 }
524
525 String PageClientImpl::dismissCorrectionPanelSoon(WebCore::ReasonForDismissingAlternativeText reason)
526 {
527 #if USE(AUTOCORRECTION_PANEL)
528     return m_correctionPanel.dismiss(reason);
529 #else
530     return String();
531 #endif
532 }
533
534 void PageClientImpl::recordAutocorrectionResponse(AutocorrectionResponseType responseType, const String& replacedString, const String& replacementString)
535 {
536     NSCorrectionResponse response = responseType == AutocorrectionReverted ? NSCorrectionResponseReverted : NSCorrectionResponseEdited;
537     CorrectionPanel::recordAutocorrectionResponse(m_wkView, response, replacedString, replacementString);
538 }
539
540 void PageClientImpl::recommendedScrollbarStyleDidChange(int32_t newStyle)
541 {
542     NSArray *trackingAreas = [m_wkView trackingAreas];
543     NSUInteger count = [trackingAreas count];
544     ASSERT(count == 1);
545     
546     for (NSUInteger i = 0; i < count; ++i)
547         [m_wkView removeTrackingArea:[trackingAreas objectAtIndex:i]];
548
549     // Now re-create a tracking area with the appropriate options given the new scrollbar style
550     NSTrackingAreaOptions options = NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited | NSTrackingInVisibleRect;
551     if (newStyle == NSScrollerStyleLegacy)
552         options |= NSTrackingActiveAlways;
553     else
554         options |= NSTrackingActiveInKeyWindow;
555
556     NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect:[m_wkView frame]
557                                                                 options:options
558                                                                   owner:m_wkView
559                                                                userInfo:nil];
560     [m_wkView addTrackingArea:trackingArea];
561     [trackingArea release];
562 }
563
564 void PageClientImpl::intrinsicContentSizeDidChange(const IntSize& intrinsicContentSize)
565 {
566     [m_wkView _setIntrinsicContentSize:intrinsicContentSize];
567 }
568
569 bool PageClientImpl::executeSavedCommandBySelector(const String& selectorString)
570 {
571     return [m_wkView _executeSavedCommandBySelector:NSSelectorFromString(selectorString)];
572 }
573
574 #if USE(DICTATION_ALTERNATIVES)
575 uint64_t PageClientImpl::addDictationAlternatives(const RetainPtr<NSTextAlternatives>& alternatives)
576 {
577     return m_alternativeTextUIController->addAlternatives(alternatives);
578 }
579
580 void PageClientImpl::removeDictationAlternatives(uint64_t dictationContext)
581 {
582     m_alternativeTextUIController->removeAlternatives(dictationContext);
583 }
584
585 void PageClientImpl::showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext)
586 {
587     if (!isViewVisible() || !isViewInWindow())
588         return;
589     m_alternativeTextUIController->showAlternatives(m_wkView, boundingBoxOfDictatedText, dictationContext, ^(NSString* acceptedAlternative){
590         [m_wkView handleAcceptedAlternativeText:acceptedAlternative];
591     });
592 }
593
594 Vector<String> PageClientImpl::dictationAlternatives(uint64_t dictationContext)
595 {
596     return m_alternativeTextUIController->alternativesForContext(dictationContext);
597 }
598 #endif
599
600 } // namespace WebKit