[iOS]: WK2 Inspector Node Search
[WebKit-https.git] / Source / WebKit2 / UIProcess / ios / WebPageProxyIOS.mm
1 /*
2  * Copyright (C) 2012 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 "WebPageProxy.h"
28
29 #if PLATFORM(IOS)
30
31 #import "APIUIClient.h"
32 #import "DataReference.h"
33 #import "EditingRange.h"
34 #import "NativeWebKeyboardEvent.h"
35 #import "PageClient.h"
36 #import "RemoteLayerTreeDrawingAreaProxyMessages.h"
37 #import "RemoteLayerTreeTransaction.h"
38 #import "ViewUpdateDispatcherMessages.h"
39 #import "WKBrowsingContextControllerInternal.h"
40 #import "WebContextUserMessageCoders.h"
41 #import "WebKitSystemInterfaceIOS.h"
42 #import "WebPageMessages.h"
43 #import "WebProcessProxy.h"
44 #import "WebVideoFullscreenManagerProxy.h"
45 #import <WebCore/FrameView.h>
46 #import <WebCore/NotImplemented.h>
47 #import <WebCore/SharedBuffer.h>
48 #import <WebCore/UserAgent.h>
49
50 #if USE(QUICK_LOOK)
51 #import "APILoaderClient.h"
52 #import <wtf/text/WTFString.h>
53 #endif
54
55 using namespace WebCore;
56
57 namespace WebKit {
58
59 void WebPageProxy::platformInitialize()
60 {
61 }
62
63 static String userVisibleWebKitVersionString()
64 {
65     // If the version is longer than 3 digits then the leading digits represent the version of the OS. Our user agent
66     // string should not include the leading digits, so strip them off and report the rest as the version. <rdar://problem/4997547>
67     NSString *fullVersion = [[NSBundle bundleForClass:NSClassFromString(@"WKView")] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
68     NSRange nonDigitRange = [fullVersion rangeOfCharacterFromSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]];
69     if (nonDigitRange.location == NSNotFound && fullVersion.length > 3)
70         return [fullVersion substringFromIndex:fullVersion.length - 3];
71     if (nonDigitRange.location != NSNotFound && nonDigitRange.location > 3)
72         return [fullVersion substringFromIndex:nonDigitRange.location - 3];
73     return fullVersion;
74 }
75
76 String WebPageProxy::standardUserAgent(const String& applicationName)
77 {
78     return standardUserAgentWithApplicationName(applicationName, userVisibleWebKitVersionString());
79 }
80
81 void WebPageProxy::getIsSpeaking(bool&)
82 {
83     notImplemented();
84 }
85
86 void WebPageProxy::speak(const String&)
87 {
88     notImplemented();
89 }
90
91 void WebPageProxy::stopSpeaking()
92 {
93     notImplemented();
94 }
95
96 void WebPageProxy::searchWithSpotlight(const String&)
97 {
98     notImplemented();
99 }
100
101 void WebPageProxy::searchTheWeb(const String&)
102 {
103     notImplemented();
104 }
105
106 void WebPageProxy::windowAndViewFramesChanged(const FloatRect&, const FloatPoint&)
107 {
108     notImplemented();
109 }
110
111 String WebPageProxy::stringSelectionForPasteboard()
112 {
113     notImplemented();
114     return String();
115 }
116
117 PassRefPtr<WebCore::SharedBuffer> WebPageProxy::dataSelectionForPasteboard(const String&)
118 {
119     notImplemented();
120     return 0;
121 }
122
123 bool WebPageProxy::readSelectionFromPasteboard(const String&)
124 {
125     notImplemented();
126     return false;
127 }
128
129 void WebPageProxy::performDictionaryLookupAtLocation(const WebCore::FloatPoint&)
130 {
131     notImplemented();
132 }
133
134 void WebPageProxy::gestureCallback(const WebCore::IntPoint& point, uint32_t gestureType, uint32_t gestureState, uint32_t flags, uint64_t callbackID)
135 {
136     auto callback = m_callbacks.take<GestureCallback>(callbackID);
137     if (!callback) {
138         ASSERT_NOT_REACHED();
139         return;
140     }
141     
142     callback->performCallbackWithReturnValue(point, gestureType, gestureState, flags);
143 }
144
145 void WebPageProxy::touchesCallback(const WebCore::IntPoint& point, uint32_t touches, uint64_t callbackID)
146 {
147     auto callback = m_callbacks.take<TouchesCallback>(callbackID);
148     if (!callback) {
149         ASSERT_NOT_REACHED();
150         return;
151     }
152
153     callback->performCallbackWithReturnValue(point, touches);
154 }
155
156 void WebPageProxy::autocorrectionDataCallback(const Vector<WebCore::FloatRect>& rects, const String& fontName, float fontSize, uint64_t fontTraits, uint64_t callbackID)
157 {
158     auto callback = m_callbacks.take<AutocorrectionDataCallback>(callbackID);
159     if (!callback) {
160         ASSERT_NOT_REACHED();
161         return;
162     }
163
164     callback->performCallbackWithReturnValue(rects, fontName, fontSize, fontTraits);
165 }
166
167 void WebPageProxy::dictationContextCallback(const String& selectedText, const String& beforeText, const String& afterText, uint64_t callbackID)
168 {
169     auto callback = m_callbacks.take<DictationContextCallback>(callbackID);
170     if (!callback) {
171         ASSERT_NOT_REACHED();
172         return;
173     }
174
175     callback->performCallbackWithReturnValue(selectedText, beforeText, afterText);
176 }
177
178 void WebPageProxy::autocorrectionContextCallback(const String& beforeText, const String& markedText, const String& selectedText, const String& afterText, uint64_t location, uint64_t length, uint64_t callbackID)
179 {
180     auto callback = m_callbacks.take<AutocorrectionContextCallback>(callbackID);
181     if (!callback) {
182         ASSERT_NOT_REACHED();
183         return;
184     }
185
186     callback->performCallbackWithReturnValue(beforeText, markedText, selectedText, afterText, location, length);
187 }
188
189 bool WebPageProxy::updateVisibleContentRects(const VisibleContentRectUpdateInfo& visibleContentRectUpdateInfo)
190 {
191     if (visibleContentRectUpdateInfo == m_lastVisibleContentRectUpdate)
192         return false;
193
194     m_lastVisibleContentRectUpdate = visibleContentRectUpdateInfo;
195     m_process->send(Messages::ViewUpdateDispatcher::VisibleContentRectUpdate(m_pageID, visibleContentRectUpdateInfo), 0);
196     return true;
197 }
198
199 static inline float adjustedUnexposedEdge(float documentEdge, float exposedRectEdge, float factor)
200 {
201     if (exposedRectEdge < documentEdge)
202         return documentEdge - factor * (documentEdge - exposedRectEdge);
203     
204     return exposedRectEdge;
205 }
206
207 static inline float adjustedUnexposedMaxEdge(float documentEdge, float exposedRectEdge, float factor)
208 {
209     if (exposedRectEdge > documentEdge)
210         return documentEdge + factor * (exposedRectEdge - documentEdge);
211     
212     return exposedRectEdge;
213 }
214
215 WebCore::FloatRect WebPageProxy::computeCustomFixedPositionRect(const FloatRect& unobscuredContentRect, double displayedContentScale, UnobscuredRectConstraint constraint) const
216 {
217     FloatRect constrainedUnobscuredRect = unobscuredContentRect;
218     FloatSize contentsSize = m_pageClient.contentsSize();
219     FloatRect documentRect = FloatRect(FloatPoint(), contentsSize);
220
221     if (constraint == UnobscuredRectConstraint::ConstrainedToDocumentRect)
222         constrainedUnobscuredRect.intersect(documentRect);
223
224     double minimumScale = m_pageClient.minimumZoomScale();
225     
226     if (displayedContentScale < minimumScale) {
227         const CGFloat slope = 12;
228         CGFloat factor = std::max<CGFloat>(1 - slope * (minimumScale - displayedContentScale), 0);
229             
230         constrainedUnobscuredRect.setX(adjustedUnexposedEdge(documentRect.x(), constrainedUnobscuredRect.x(), factor));
231         constrainedUnobscuredRect.setY(adjustedUnexposedEdge(documentRect.y(), constrainedUnobscuredRect.y(), factor));
232         constrainedUnobscuredRect.setWidth(adjustedUnexposedMaxEdge(documentRect.maxX(), constrainedUnobscuredRect.maxX(), factor) - constrainedUnobscuredRect.x());
233         constrainedUnobscuredRect.setHeight(adjustedUnexposedMaxEdge(documentRect.maxY(), constrainedUnobscuredRect.maxY(), factor) - constrainedUnobscuredRect.y());
234     }
235     
236     return FrameView::rectForViewportConstrainedObjects(enclosingLayoutRect(constrainedUnobscuredRect), roundedLayoutSize(contentsSize), displayedContentScale, false, StickToViewportBounds);
237 }
238
239 void WebPageProxy::scrollViewWillStartPanGesture()
240 {
241     m_pageClient.scrollViewWillStartPanGesture();
242 }
243
244 void WebPageProxy::dynamicViewportSizeUpdate(const FloatSize& minimumLayoutSize, const WebCore::FloatSize& minimumLayoutSizeForMinimalUI, const WebCore::FloatSize& maximumUnobscuredSize, const FloatRect& targetExposedContentRect, const FloatRect& targetUnobscuredRect, const FloatRect& targetUnobscuredRectInScrollViewCoordinates,  double targetScale, int32_t deviceOrientation)
245 {
246     m_dynamicViewportSizeUpdateInProgress = true;
247     m_process->send(Messages::WebPage::DynamicViewportSizeUpdate(minimumLayoutSize, minimumLayoutSizeForMinimalUI, maximumUnobscuredSize, targetExposedContentRect, targetUnobscuredRect, targetUnobscuredRectInScrollViewCoordinates, targetScale, deviceOrientation), m_pageID);
248 }
249
250 void WebPageProxy::synchronizeDynamicViewportUpdate()
251 {
252     if (m_dynamicViewportSizeUpdateInProgress) {
253         // We do not want the UIProcess to finish animated resize with the old content size, scale, etc.
254         // If that happens, the UIProcess would start pushing new VisibleContentRectUpdateInfo to the WebProcess with
255         // invalid informations.
256         //
257         // Ideally, the animated resize should just be transactional, and the UIProcess would remain in the "resize" state
258         // until both DynamicViewportUpdateChangedTarget and the associated commitLayerTree are finished.
259         // The tricky part with such implementation is if a second animated resize starts before the end of the previous one.
260         // In that case, the values used for the target state needs to be computed from the output of the previous animated resize.
261         //
262         // The following is a workaround to have the UIProcess in a consistent state.
263         // Instead of handling nested resize, we block the UIProcess until the animated resize finishes.
264         m_dynamicViewportSizeUpdateInProgress = false;
265         double newScale;
266         FloatPoint newScrollPosition;
267         if (m_process->sendSync(Messages::WebPage::SynchronizeDynamicViewportUpdate(), Messages::WebPage::SynchronizeDynamicViewportUpdate::Reply(newScale, newScrollPosition), m_pageID, std::chrono::seconds(2))) {
268             m_pageClient.dynamicViewportUpdateChangedTarget(newScale, newScrollPosition);
269
270             m_process->connection()->waitForAndDispatchImmediately<Messages::RemoteLayerTreeDrawingAreaProxy::CommitLayerTree>(m_pageID, std::chrono::seconds(1));
271         }
272     }
273 }
274
275 void WebPageProxy::setViewportConfigurationMinimumLayoutSize(const WebCore::FloatSize& size)
276 {
277     m_process->send(Messages::WebPage::SetViewportConfigurationMinimumLayoutSize(size), m_pageID);
278 }
279
280 void WebPageProxy::setViewportConfigurationMinimumLayoutSizeForMinimalUI(const WebCore::FloatSize& size)
281 {
282     m_process->send(Messages::WebPage::SetViewportConfigurationMinimumLayoutSizeForMinimalUI(size), m_pageID);
283 }
284
285 void WebPageProxy::setMaximumUnobscuredSize(const WebCore::FloatSize& size)
286 {
287     m_process->send(Messages::WebPage::SetMaximumUnobscuredSize(size), m_pageID);
288 }
289
290 void WebPageProxy::setDeviceOrientation(int32_t deviceOrientation)
291 {
292     if (deviceOrientation != m_deviceOrientation) {
293         m_deviceOrientation = deviceOrientation;
294         if (isValid())
295             m_process->send(Messages::WebPage::SetDeviceOrientation(deviceOrientation), m_pageID);
296     }
297 }
298
299 void WebPageProxy::didCommitLayerTree(const WebKit::RemoteLayerTreeTransaction& layerTreeTransaction)
300 {
301     m_pageExtendedBackgroundColor = layerTreeTransaction.pageExtendedBackgroundColor();
302
303     m_pageClient.didCommitLayerTree(layerTreeTransaction);
304 }
305
306 void WebPageProxy::selectWithGesture(const WebCore::IntPoint point, WebCore::TextGranularity granularity, uint32_t gestureType, uint32_t gestureState, std::function<void (const WebCore::IntPoint&, uint32_t, uint32_t, uint32_t, CallbackBase::Error)> callbackFunction)
307 {
308     RefPtr<GestureCallback> callback = GestureCallback::create(std::move(callbackFunction));
309
310     if (!isValid()) {
311         callback->invalidate();
312         return;
313     }
314     
315     uint64_t callbackID = callback->callbackID();
316     m_callbacks.put(callback);
317     m_process->send(Messages::WebPage::SelectWithGesture(point, (uint32_t)granularity, gestureType, gestureState, callbackID), m_pageID);
318 }
319
320 void WebPageProxy::updateSelectionWithTouches(const WebCore::IntPoint point, uint32_t touches, bool baseIsStart, std::function<void (const WebCore::IntPoint&, uint32_t, CallbackBase::Error)> callbackFunction)
321 {
322     RefPtr<TouchesCallback> callback = TouchesCallback::create(std::move(callbackFunction));
323
324     if (!isValid()) {
325         callback->invalidate();
326         return;
327     }
328
329     uint64_t callbackID = callback->callbackID();
330     m_callbacks.put(callback);
331     m_process->send(Messages::WebPage::UpdateSelectionWithTouches(point, touches, baseIsStart, callbackID), m_pageID);
332 }
333     
334 void WebPageProxy::replaceDictatedText(const String& oldText, const String& newText)
335 {
336     m_process->send(Messages::WebPage::ReplaceDictatedText(oldText, newText), m_pageID);
337 }
338
339 void WebPageProxy::replaceSelectedText(const String& oldText, const String& newText)
340 {
341     m_process->send(Messages::WebPage::ReplaceSelectedText(oldText, newText), m_pageID);
342 }
343
344 void WebPageProxy::requestAutocorrectionData(const String& textForAutocorrection, std::function<void (const Vector<WebCore::FloatRect>&, const String&, double, uint64_t, CallbackBase::Error)> callbackFunction)
345 {
346     RefPtr<AutocorrectionDataCallback> callback = AutocorrectionDataCallback::create(std::move(callbackFunction));
347
348     if (!isValid()) {
349         callback->invalidate();
350         return;
351     }
352
353     uint64_t callbackID = callback->callbackID();
354     m_callbacks.put(callback);
355     m_process->send(Messages::WebPage::RequestAutocorrectionData(textForAutocorrection, callbackID), m_pageID);
356 }
357
358 void WebPageProxy::applyAutocorrection(const String& correction, const String& originalText, std::function<void (const String&, CallbackBase::Error)> callbackFunction)
359 {
360     RefPtr<StringCallback> callback = StringCallback::create(std::move(callbackFunction));
361
362     if (!isValid()) {
363         callback->invalidate();
364         return;
365     }
366
367     uint64_t callbackID = callback->callbackID();
368     m_callbacks.put(callback);
369     m_process->send(Messages::WebPage::ApplyAutocorrection(correction, originalText, callbackID), m_pageID);
370 }
371
372 bool WebPageProxy::applyAutocorrection(const String& correction, const String& originalText)
373 {
374     bool autocorrectionApplied = false;
375     m_process->sendSync(Messages::WebPage::SyncApplyAutocorrection(correction, originalText), Messages::WebPage::SyncApplyAutocorrection::Reply(autocorrectionApplied), m_pageID);
376     return autocorrectionApplied;
377 }
378
379 void WebPageProxy::requestDictationContext(std::function<void (const String&, const String&, const String&, CallbackBase::Error)> callbackFunction)
380 {
381     RefPtr<DictationContextCallback> callback = DictationContextCallback::create(std::move(callbackFunction));
382
383     if (!isValid()) {
384         callback->invalidate();
385         return;
386     }
387
388     uint64_t callbackID = callback->callbackID();
389     m_callbacks.put(callback);
390     m_process->send(Messages::WebPage::RequestDictationContext(callbackID), m_pageID);
391 }
392
393 void WebPageProxy::requestAutocorrectionContext(std::function<void (const String&, const String&, const String&, const String&, uint64_t, uint64_t, CallbackBase::Error)> callbackFunction)
394 {
395     RefPtr<AutocorrectionContextCallback> callback = AutocorrectionContextCallback::create(std::move(callbackFunction));
396
397     if (!isValid()) {
398         callback->invalidate();
399         return;
400     }
401
402     uint64_t callbackID = callback->callbackID();
403     m_callbacks.put(callback);
404     m_process->send(Messages::WebPage::RequestAutocorrectionContext(callbackID), m_pageID);
405 }
406
407 void WebPageProxy::getAutocorrectionContext(String& beforeContext, String& markedText, String& selectedText, String& afterContext, uint64_t& location, uint64_t& length)
408 {
409     m_process->sendSync(Messages::WebPage::GetAutocorrectionContext(), Messages::WebPage::GetAutocorrectionContext::Reply(beforeContext, markedText, selectedText, afterContext, location, length), m_pageID);
410 }
411
412 void WebPageProxy::selectWithTwoTouches(const WebCore::IntPoint from, const WebCore::IntPoint to, uint32_t gestureType, uint32_t gestureState, std::function<void (const WebCore::IntPoint&, uint32_t, uint32_t, uint32_t, CallbackBase::Error)> callbackFunction)
413 {
414     RefPtr<GestureCallback> callback = GestureCallback::create(std::move(callbackFunction));
415
416     if (!isValid()) {
417         callback->invalidate();
418         return;
419     }
420
421     uint64_t callbackID = callback->callbackID();
422     m_callbacks.put(callback);
423     m_process->send(Messages::WebPage::SelectWithTwoTouches(from, to, gestureType, gestureState, callbackID), m_pageID);
424 }
425
426 void WebPageProxy::updateBlockSelectionWithTouch(const WebCore::IntPoint point, uint32_t touch, uint32_t handlePosition)
427 {
428     m_process->send(Messages::WebPage::UpdateBlockSelectionWithTouch(point, touch, handlePosition), m_pageID);
429 }
430
431 void WebPageProxy::didReceivePositionInformation(const InteractionInformationAtPosition& info)
432 {
433     m_pageClient.positionInformationDidChange(info);
434 }
435
436 void WebPageProxy::getPositionInformation(const WebCore::IntPoint& point, InteractionInformationAtPosition& info)
437 {
438     m_process->sendSync(Messages::WebPage::GetPositionInformation(point), Messages::WebPage::GetPositionInformation::Reply(info), m_pageID);
439 }
440
441 void WebPageProxy::requestPositionInformation(const WebCore::IntPoint& point)
442 {
443     m_process->send(Messages::WebPage::RequestPositionInformation(point), m_pageID);
444 }
445
446 void WebPageProxy::startInteractionWithElementAtPosition(const WebCore::IntPoint& point)
447 {
448     m_process->send(Messages::WebPage::StartInteractionWithElementAtPosition(point), m_pageID);
449 }
450
451 void WebPageProxy::stopInteraction()
452 {
453     m_process->send(Messages::WebPage::StopInteraction(), m_pageID);
454 }
455
456 void WebPageProxy::performActionOnElement(uint32_t action)
457 {
458     m_process->send(Messages::WebPage::PerformActionOnElement(action), m_pageID);
459 }
460
461 void WebPageProxy::saveImageToLibrary(const SharedMemory::Handle& imageHandle, uint64_t imageSize)
462 {
463     RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::create(imageHandle, SharedMemory::ReadOnly);
464     RefPtr<SharedBuffer> buffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryBuffer->data()), imageSize);
465     m_pageClient.saveImageToLibrary(buffer);
466 }
467
468 void WebPageProxy::didUpdateBlockSelectionWithTouch(uint32_t touch, uint32_t flags, float growThreshold, float shrinkThreshold)
469 {
470     m_pageClient.didUpdateBlockSelectionWithTouch(touch, flags, growThreshold, shrinkThreshold);
471 }
472
473 void WebPageProxy::applicationWillEnterForeground()
474 {
475     m_process->send(Messages::WebPage::ApplicationWillEnterForeground(), m_pageID);
476 }
477
478 void WebPageProxy::applicationWillResignActive()
479 {
480     m_process->send(Messages::WebPage::ApplicationWillResignActive(), m_pageID);
481 }
482
483 void WebPageProxy::applicationDidBecomeActive()
484 {
485     m_process->send(Messages::WebPage::ApplicationDidBecomeActive(), m_pageID);
486 }
487
488 void WebPageProxy::notifyRevealedSelection()
489 {
490     m_pageClient.selectionDidChange();
491 }
492
493 void WebPageProxy::extendSelection(WebCore::TextGranularity granularity)
494 {
495     m_process->send(Messages::WebPage::ExtendSelection(static_cast<uint32_t>(granularity)), m_pageID);
496 }
497
498 void WebPageProxy::selectWordBackward()
499 {
500     m_process->send(Messages::WebPage::SelectWordBackward(), m_pageID);
501 }
502
503 void WebPageProxy::interpretKeyEvent(const EditorState& state, bool isCharEvent, bool& handled)
504 {
505     m_editorState = state;
506     handled = m_pageClient.interpretKeyEvent(m_keyEventQueue.first(), isCharEvent);
507 }
508
509 // Complex text input support for plug-ins.
510 void WebPageProxy::sendComplexTextInputToPlugin(uint64_t, const String&)
511 {
512     notImplemented();
513 }
514
515 void WebPageProxy::setSmartInsertDeleteEnabled(bool)
516 {
517     notImplemented();
518 }
519
520 void WebPageProxy::registerWebProcessAccessibilityToken(const IPC::DataReference& data)
521 {
522     m_pageClient.accessibilityWebProcessTokenReceived(data);
523 }    
524
525 void WebPageProxy::makeFirstResponder()
526 {
527     notImplemented();
528 }
529
530 void WebPageProxy::registerUIProcessAccessibilityTokens(const IPC::DataReference& elementToken, const IPC::DataReference& windowToken)
531 {
532     if (!isValid())
533         return;
534     
535     process().send(Messages::WebPage::RegisterUIProcessAccessibilityTokens(elementToken, windowToken), m_pageID);
536 }
537
538 void WebPageProxy::pluginFocusOrWindowFocusChanged(uint64_t, bool)
539 {
540     notImplemented();
541 }
542
543 void WebPageProxy::setPluginComplexTextInputState(uint64_t, uint64_t)
544 {
545     notImplemented();
546 }
547
548 void WebPageProxy::executeSavedCommandBySelector(const String&, bool&)
549 {
550     notImplemented();
551 }
552
553 bool WebPageProxy::shouldDelayWindowOrderingForEvent(const WebKit::WebMouseEvent&)
554 {
555     notImplemented();
556     return false;
557 }
558
559 bool WebPageProxy::acceptsFirstMouse(int, const WebKit::WebMouseEvent&)
560 {
561     notImplemented();
562     return false;
563 }
564
565 void WebPageProxy::willStartUserTriggeredZooming()
566 {
567     process().send(Messages::WebPage::WillStartUserTriggeredZooming(), m_pageID);
568 }
569
570 void WebPageProxy::potentialTapAtPosition(const WebCore::FloatPoint& position, uint64_t& requestID)
571 {
572     process().send(Messages::WebPage::PotentialTapAtPosition(requestID, position), m_pageID);
573 }
574
575 void WebPageProxy::commitPotentialTap()
576 {
577     process().send(Messages::WebPage::CommitPotentialTap(), m_pageID);
578 }
579
580 void WebPageProxy::cancelPotentialTap()
581 {
582     process().send(Messages::WebPage::CancelPotentialTap(), m_pageID);
583 }
584
585 void WebPageProxy::tapHighlightAtPosition(const WebCore::FloatPoint& position, uint64_t& requestID)
586 {
587     process().send(Messages::WebPage::TapHighlightAtPosition(requestID, position), m_pageID);
588 }
589
590 void WebPageProxy::inspectorNodeSearchMovedToPosition(const WebCore::FloatPoint& position)
591 {
592     process().send(Messages::WebPage::InspectorNodeSearchMovedToPosition(position), m_pageID);
593 }
594
595 void WebPageProxy::inspectorNodeSearchEndedAtPosition(const WebCore::FloatPoint& position)
596 {
597     process().send(Messages::WebPage::InspectorNodeSearchEndedAtPosition(position), m_pageID);
598 }
599
600 void WebPageProxy::blurAssistedNode()
601 {
602     process().send(Messages::WebPage::BlurAssistedNode(), m_pageID);
603 }
604
605 FloatSize WebPageProxy::screenSize()
606 {
607     return FloatSize(WKGetScreenSize());
608 }
609
610 FloatSize WebPageProxy::availableScreenSize()
611 {
612     return FloatSize(WKGetAvailableScreenSize());
613 }
614     
615 float WebPageProxy::textAutosizingWidth()
616 {
617     return WKGetScreenSize().width;
618 }
619
620 void WebPageProxy::dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition)
621 {
622     if (m_dynamicViewportSizeUpdateInProgress) {
623         m_dynamicViewportSizeUpdateInProgress = false;
624         m_pageClient.dynamicViewportUpdateChangedTarget(newScale, newScrollPosition);
625     }
626 }
627
628 void WebPageProxy::restorePageState(const WebCore::FloatRect& exposedRect, double scale)
629 {
630     m_pageClient.restorePageState(exposedRect, scale);
631 }
632
633 void WebPageProxy::restorePageCenterAndScale(const WebCore::FloatPoint& center, double scale)
634 {
635     m_pageClient.restorePageCenterAndScale(center, scale);
636 }
637
638 void WebPageProxy::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)
639 {
640     m_pageClient.didGetTapHighlightGeometries(requestID, color, highlightedQuads, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius);
641 }
642
643 void WebPageProxy::startAssistingNode(const AssistedNodeInformation& information, bool userIsInteracting, bool blurPreviousNode, IPC::MessageDecoder& decoder)
644 {
645     RefPtr<API::Object> userData;
646     WebContextUserMessageDecoder messageDecoder(userData, process());
647     if (!decoder.decode(messageDecoder))
648         return;
649
650     m_pageClient.startAssistingNode(information, userIsInteracting, blurPreviousNode, userData.get());
651 }
652
653 void WebPageProxy::stopAssistingNode()
654 {
655     m_pageClient.stopAssistingNode();
656 }
657
658 #if ENABLE(INSPECTOR)
659 void WebPageProxy::showInspectorHighlight(const WebCore::Highlight& highlight)
660 {
661     m_pageClient.showInspectorHighlight(highlight);
662 }
663
664 void WebPageProxy::hideInspectorHighlight()
665 {
666     m_pageClient.hideInspectorHighlight();
667 }
668
669 void WebPageProxy::showInspectorIndication()
670 {
671     m_pageClient.showInspectorIndication();
672 }
673
674 void WebPageProxy::hideInspectorIndication()
675 {
676     m_pageClient.hideInspectorIndication();
677 }
678
679 void WebPageProxy::enableInspectorNodeSearch()
680 {
681     m_pageClient.enableInspectorNodeSearch();
682 }
683
684 void WebPageProxy::disableInspectorNodeSearch()
685 {
686     m_pageClient.disableInspectorNodeSearch();
687 }
688 #endif
689
690 void WebPageProxy::focusNextAssistedNode(bool isForward)
691 {
692     process().send(Messages::WebPage::FocusNextAssistedNode(isForward), m_pageID);
693 }
694
695 void WebPageProxy::setAssistedNodeValue(const String& value)
696 {
697     process().send(Messages::WebPage::SetAssistedNodeValue(value), m_pageID);
698 }
699
700 void WebPageProxy::setAssistedNodeValueAsNumber(double value)
701 {
702     process().send(Messages::WebPage::SetAssistedNodeValueAsNumber(value), m_pageID);
703 }
704
705 void WebPageProxy::setAssistedNodeSelectedIndex(uint32_t index, bool allowMultipleSelection)
706 {
707     process().send(Messages::WebPage::SetAssistedNodeSelectedIndex(index, allowMultipleSelection), m_pageID);
708 }
709
710 void WebPageProxy::didPerformDictionaryLookup(const AttributedString&, const DictionaryPopupInfo&)
711 {
712     notImplemented();
713 }
714
715 void WebPageProxy::savePDFToTemporaryFolderAndOpenWithNativeApplication(const String&, const String&, const IPC::DataReference&, const String&)
716 {
717     notImplemented();
718 }
719
720 void WebPageProxy::savePDFToTemporaryFolderAndOpenWithNativeApplicationRaw(const String&, const String&, const uint8_t*, unsigned long, const String&)
721 {
722     notImplemented();
723 }
724
725 void WebPageProxy::openPDFFromTemporaryFolderWithNativeApplication(const String&)
726 {
727     notImplemented();
728 }
729
730 void WebPageProxy::setAcceleratedCompositingRootLayer(LayerOrView* rootLayer)
731 {
732     m_pageClient.setAcceleratedCompositingRootLayer(rootLayer);
733 }
734
735 void WebPageProxy::showPlaybackTargetPicker(bool hasVideo, const IntRect& elementRect)
736 {
737     m_pageClient.showPlaybackTargetPicker(hasVideo, elementRect);
738 }
739
740 void WebPageProxy::zoomToRect(FloatRect rect, double minimumScale, double maximumScale)
741 {
742     m_pageClient.zoomToRect(rect, minimumScale, maximumScale);
743 }
744
745 void WebPageProxy::commitPotentialTapFailed()
746 {
747     m_pageClient.commitPotentialTapFailed();
748 }
749
750 void WebPageProxy::didNotHandleTapAsClick(const WebCore::IntPoint& point)
751 {
752     m_uiClient->didNotHandleTapAsClick(point);
753 }
754
755 void WebPageProxy::viewportMetaTagWidthDidChange(float width)
756 {
757     m_pageClient.didChangeViewportMetaTagWidth(width);
758 }
759
760 void WebPageProxy::setUsesMinimalUI(bool usesMinimalUI)
761 {
762     m_pageClient.setUsesMinimalUI(usesMinimalUI);
763 }
764
765 void WebPageProxy::didFinishDrawingPagesToPDF(const IPC::DataReference& pdfData)
766 {
767     m_pageClient.didFinishDrawingPagesToPDF(pdfData);
768 }
769
770 void WebPageProxy::contentSizeCategoryDidChange(const String& contentSizeCategory)
771 {
772     process().send(Messages::WebPage::ContentSizeCategoryDidChange(contentSizeCategory), m_pageID);
773 }
774
775 #if USE(QUICK_LOOK)
776     
777 void WebPageProxy::didStartLoadForQuickLookDocumentInMainFrame(const String& fileName, const String& uti)
778 {
779     // Ensure that fileName isn't really a path name
780     static_assert(notFound + 1 == 0, "The following line assumes WTF::notFound equals -1");
781     m_loaderClient->didStartLoadForQuickLookDocumentInMainFrame(fileName.substring(fileName.reverseFind('/') + 1), uti);
782 }
783
784 void WebPageProxy::didFinishLoadForQuickLookDocumentInMainFrame(const QuickLookDocumentData& data)
785 {
786     m_loaderClient->didFinishLoadForQuickLookDocumentInMainFrame(data);
787 }
788 #endif
789
790 } // namespace WebKit
791
792 #endif // PLATFORM(IOS)