Add support for lookup on iOS.
[WebKit-https.git] / Source / WebKit2 / WebProcess / WebPage / WebPage.h
1 /*
2  * Copyright (C) 2010, 2011, 2013 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #ifndef WebPage_h
27 #define WebPage_h
28
29 #include "APIInjectedBundleFormClient.h"
30 #include "APIInjectedBundlePageContextMenuClient.h"
31 #include "APIInjectedBundlePageUIClient.h"
32 #include "APIObject.h"
33 #include "DictionaryPopupInfo.h"
34 #include "FindController.h"
35 #include "GeolocationPermissionRequestManager.h"
36 #include "ImageOptions.h"
37 #include "InjectedBundlePageDiagnosticLoggingClient.h"
38 #include "InjectedBundlePageEditorClient.h"
39 #include "InjectedBundlePageFullScreenClient.h"
40 #include "InjectedBundlePageLoaderClient.h"
41 #include "InjectedBundlePagePolicyClient.h"
42 #include "InjectedBundlePageResourceLoadClient.h"
43 #include "LayerTreeHost.h"
44 #include "MessageReceiver.h"
45 #include "MessageSender.h"
46 #include "Plugin.h"
47 #include "SandboxExtension.h"
48 #include "ShareableBitmap.h"
49 #include "UserData.h"
50 #include "UserMediaPermissionRequestManager.h"
51 #include <WebCore/DictationAlternative.h>
52 #include <WebCore/DragData.h>
53 #include <WebCore/Editor.h>
54 #include <WebCore/FrameLoaderTypes.h>
55 #include <WebCore/HitTestResult.h>
56 #include <WebCore/IntRect.h>
57 #include <WebCore/IntSizeHash.h>
58 #include <WebCore/Page.h>
59 #include <WebCore/PageOverlay.h>
60 #include <WebCore/PageVisibilityState.h>
61 #include <WebCore/ScrollTypes.h>
62 #include <WebCore/TextChecking.h>
63 #include <WebCore/TextIndicator.h>
64 #include <WebCore/UserActivity.h>
65 #include <WebCore/ViewState.h>
66 #include <WebCore/ViewportConfiguration.h>
67 #include <WebCore/WebCoreKeyboardUIMode.h>
68 #include <memory>
69 #include <wtf/HashMap.h>
70 #include <wtf/PassRefPtr.h>
71 #include <wtf/RefPtr.h>
72 #include <wtf/RunLoop.h>
73 #include <wtf/text/WTFString.h>
74
75 #if HAVE(ACCESSIBILITY) && (PLATFORM(GTK) || PLATFORM(EFL))
76 #include "WebPageAccessibilityObject.h"
77 #include <wtf/gobject/GRefPtr.h>
78 #endif
79
80 #if PLATFORM(GTK)
81 #include "ArgumentCodersGtk.h"
82 #include "WebPrintOperationGtk.h"
83 #endif
84
85 #if PLATFORM(IOS)
86 #include "GestureTypes.h"
87 #import "WebPageMessages.h"
88 #endif
89
90 #if ENABLE(IOS_TOUCH_EVENTS)
91 #include <WebKitAdditions/PlatformTouchEventIOS.h>
92 #elif ENABLE(TOUCH_EVENTS)
93 #include <WebCore/PlatformTouchEvent.h>
94 #endif
95
96 #if ENABLE(CONTEXT_MENUS)
97 #include "InjectedBundlePageContextMenuClient.h"
98 #endif
99
100 #if PLATFORM(COCOA)
101 #include "ViewGestureGeometryCollector.h"
102 #include <wtf/RetainPtr.h>
103 OBJC_CLASS CALayer;
104 OBJC_CLASS NSDictionary;
105 OBJC_CLASS NSObject;
106 OBJC_CLASS WKAccessibilityWebPageObject;
107
108 #define ENABLE_PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC 1
109 #endif
110
111 namespace API {
112 class Array;
113 }
114
115 namespace IPC {
116 class ArgumentDecoder;
117 class Connection;
118 }
119
120 namespace WebCore {
121 class DocumentLoader;
122 class GraphicsContext;
123 class Frame;
124 class FrameView;
125 class HTMLPlugInElement;
126 class HTMLPlugInImageElement;
127 class IntPoint;
128 class KeyboardEvent;
129 class Page;
130 class PrintContext;
131 class Range;
132 class ResourceResponse;
133 class ResourceRequest;
134 class SharedBuffer;
135 class SubstituteData;
136 class TextCheckingRequest;
137 class URL;
138 class VisibleSelection;
139 struct Highlight;
140 struct KeypressCommand;
141 struct MediaPlaybackTargetContext;
142 struct TextCheckingResult;
143 }
144
145 namespace WebKit {
146 class DrawingArea;
147 class InjectedBundleBackForwardList;
148 class NotificationPermissionRequestManager;
149 class PDFPlugin;
150 class PageBanner;
151 class PluginView;
152 class VisibleContentRectUpdateInfo;
153 class WebColorChooser;
154 class WebContextMenu;
155 class WebContextMenuItemData;
156 class WebEvent;
157 class WebFrame;
158 class WebFullScreenManager;
159 class WebImage;
160 class WebInspector;
161 class WebInspectorClient;
162 class WebInspectorUI;
163 class WebKeyboardEvent;
164 class WebMouseEvent;
165 class WebNotificationClient;
166 class WebOpenPanelResultListener;
167 class WebPageGroupProxy;
168 class WebPageOverlay;
169 class WebPopupMenu;
170 class WebUndoStep;
171 class WebUserContentController;
172 class WebVideoFullscreenManager;
173 class WebWheelEvent;
174 struct AssistedNodeInformation;
175 struct AttributedString;
176 struct BackForwardListItemState;
177 struct EditingRange;
178 struct EditorState;
179 struct InteractionInformationAtPosition;
180 struct PrintInfo;
181 struct WebPageCreationParameters;
182 struct WebPreferencesStore;
183
184 #if PLATFORM(COCOA)
185 class RemoteLayerTreeTransaction;
186 #endif
187
188 #if ENABLE(TOUCH_EVENTS)
189 class WebTouchEvent;
190 #endif
191
192 class WebPage : public API::ObjectImpl<API::Object::Type::BundlePage>, public IPC::MessageReceiver, public IPC::MessageSender {
193 public:
194     static PassRefPtr<WebPage> create(uint64_t pageID, const WebPageCreationParameters&);
195     virtual ~WebPage();
196
197     void reinitializeWebPage(const WebPageCreationParameters&);
198
199     void close();
200
201     static WebPage* fromCorePage(WebCore::Page*);
202
203     WebCore::Page* corePage() const { return m_page.get(); }
204     uint64_t pageID() const { return m_pageID; }
205     WebCore::SessionID sessionID() const { return m_page->sessionID(); }
206     bool usesEphemeralSession() const { return m_page->usesEphemeralSession(); }
207
208     void setSessionID(WebCore::SessionID);
209
210     void setSize(const WebCore::IntSize&);
211     const WebCore::IntSize& size() const { return m_viewSize; }
212     WebCore::IntRect bounds() const { return WebCore::IntRect(WebCore::IntPoint(), size()); }
213     
214     InjectedBundleBackForwardList* backForwardList();
215     DrawingArea* drawingArea() const { return m_drawingArea.get(); }
216 #if ENABLE(ASYNC_SCROLLING)
217     WebCore::ScrollingCoordinator* scrollingCoordinator() const;
218 #endif
219
220     WebPageGroupProxy* pageGroup() const { return m_pageGroup.get(); }
221
222     void scrollMainFrameIfNotAtMaxScrollPosition(const WebCore::IntSize& scrollOffset);
223
224     bool scrollBy(uint32_t scrollDirection, uint32_t scrollGranularity);
225
226     void centerSelectionInVisibleArea();
227
228 #if PLATFORM(COCOA)
229     void willCommitLayerTree(RemoteLayerTreeTransaction&);
230     void didFlushLayerTreeAtTime(std::chrono::milliseconds);
231 #endif
232
233     WebInspector* inspector();
234     WebInspectorUI* inspectorUI();
235     bool isInspectorPage() { return !!m_inspectorUI; }
236
237 #if PLATFORM(IOS)
238     WebVideoFullscreenManager* videoFullscreenManager();
239 #endif
240
241 #if ENABLE(FULLSCREEN_API)
242     WebFullScreenManager* fullScreenManager();
243 #endif
244
245     // -- Called by the DrawingArea.
246     // FIXME: We could genericize these into a DrawingArea client interface. Would that be beneficial?
247     void drawRect(WebCore::GraphicsContext&, const WebCore::IntRect&);
248     void layoutIfNeeded();
249
250     // -- Called from WebCore clients.
251     bool handleEditingKeyboardEvent(WebCore::KeyboardEvent*);
252
253     void didStartPageTransition();
254     void didCompletePageTransition();
255     void didCommitLoad(WebFrame*);
256     void didFinishLoad(WebFrame*);
257     void show();
258     String userAgent(const WebCore::URL&) const;
259     String userAgent(WebFrame*, const WebCore::URL&) const;
260     String platformUserAgent(const WebCore::URL&) const;
261     WebCore::IntRect windowResizerRect() const;
262     WebCore::KeyboardUIMode keyboardUIMode();
263
264     WebUndoStep* webUndoStep(uint64_t);
265     void addWebUndoStep(uint64_t, WebUndoStep*);
266     void removeWebEditCommand(uint64_t);
267     bool isInRedo() const { return m_isInRedo; }
268
269     void setActivePopupMenu(WebPopupMenu*);
270
271 #if ENABLE(INPUT_TYPE_COLOR)
272     WebColorChooser* activeColorChooser() const { return m_activeColorChooser; }
273     void setActiveColorChooser(WebColorChooser*);
274     void didChooseColor(const WebCore::Color&);
275     void didEndColorPicker();
276 #endif
277
278     WebOpenPanelResultListener* activeOpenPanelResultListener() const { return m_activeOpenPanelResultListener.get(); }
279     void setActiveOpenPanelResultListener(PassRefPtr<WebOpenPanelResultListener>);
280
281     void didReceiveMessage(IPC::Connection&, IPC::MessageDecoder&) override;
282     void didReceiveSyncMessage(IPC::Connection&, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&) override;
283
284     // -- InjectedBundle methods
285 #if ENABLE(CONTEXT_MENUS)
286     void setInjectedBundleContextMenuClient(std::unique_ptr<API::InjectedBundle::PageContextMenuClient>);
287 #endif
288     void initializeInjectedBundleEditorClient(WKBundlePageEditorClientBase*);
289     void setInjectedBundleFormClient(std::unique_ptr<API::InjectedBundle::FormClient>);
290     void initializeInjectedBundleLoaderClient(WKBundlePageLoaderClientBase*);
291     void initializeInjectedBundlePolicyClient(WKBundlePagePolicyClientBase*);
292     void initializeInjectedBundleResourceLoadClient(WKBundlePageResourceLoadClientBase*);
293     void setInjectedBundleUIClient(std::unique_ptr<API::InjectedBundle::PageUIClient>);
294 #if ENABLE(FULLSCREEN_API)
295     void initializeInjectedBundleFullScreenClient(WKBundlePageFullScreenClientBase*);
296 #endif
297     void initializeInjectedBundleDiagnosticLoggingClient(WKBundlePageDiagnosticLoggingClientBase*);
298
299 #if ENABLE(CONTEXT_MENUS)
300     API::InjectedBundle::PageContextMenuClient& injectedBundleContextMenuClient() { return *m_contextMenuClient.get(); }
301 #endif
302     InjectedBundlePageEditorClient& injectedBundleEditorClient() { return m_editorClient; }
303     API::InjectedBundle::FormClient& injectedBundleFormClient() { return *m_formClient.get(); }
304     InjectedBundlePageLoaderClient& injectedBundleLoaderClient() { return m_loaderClient; }
305     InjectedBundlePagePolicyClient& injectedBundlePolicyClient() { return m_policyClient; }
306     InjectedBundlePageResourceLoadClient& injectedBundleResourceLoadClient() { return m_resourceLoadClient; }
307     API::InjectedBundle::PageUIClient& injectedBundleUIClient() { return *m_uiClient.get(); }
308     InjectedBundlePageDiagnosticLoggingClient& injectedBundleDiagnosticLoggingClient() { return m_logDiagnosticMessageClient; }
309 #if ENABLE(FULLSCREEN_API)
310     InjectedBundlePageFullScreenClient& injectedBundleFullScreenClient() { return m_fullScreenClient; }
311 #endif
312
313     bool findStringFromInjectedBundle(const String&, FindOptions);
314
315     WebFrame* mainWebFrame() const { return m_mainFrame.get(); }
316
317     WebCore::MainFrame* mainFrame() const; // May return 0.
318     WebCore::FrameView* mainFrameView() const; // May return 0.
319
320     PassRefPtr<WebCore::Range> currentSelectionAsRange();
321
322 #if ENABLE(NETSCAPE_PLUGIN_API)
323     PassRefPtr<Plugin> createPlugin(WebFrame*, WebCore::HTMLPlugInElement*, const Plugin::Parameters&, String& newMIMEType);
324 #endif
325
326 #if ENABLE(WEBGL)
327     WebCore::WebGLLoadPolicy webGLPolicyForURL(WebFrame*, const String&);
328     WebCore::WebGLLoadPolicy resolveWebGLPolicyForURL(WebFrame*, const String&);
329 #endif // ENABLE(WEBGL)
330     
331     enum class IncludePostLayoutDataHint { No, Yes };
332     EditorState editorState(IncludePostLayoutDataHint = IncludePostLayoutDataHint::Yes) const;
333     void sendPostLayoutEditorStateIfNeeded();
334
335     String renderTreeExternalRepresentation() const;
336     String renderTreeExternalRepresentationForPrinting() const;
337     uint64_t renderTreeSize() const;
338
339     void setTracksRepaints(bool);
340     bool isTrackingRepaints() const;
341     void resetTrackedRepaints();
342     Ref<API::Array> trackedRepaintRects();
343
344     void executeEditingCommand(const String& commandName, const String& argument);
345     bool isEditingCommandEnabled(const String& commandName);
346     void clearMainFrameName();
347     void sendClose();
348
349     void sendSetWindowFrame(const WebCore::FloatRect&);
350
351     double textZoomFactor() const;
352     void setTextZoomFactor(double);
353     double pageZoomFactor() const;
354     void setPageZoomFactor(double);
355     void setPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor);
356     void windowScreenDidChange(uint32_t);
357
358     void scalePage(double scale, const WebCore::IntPoint& origin);
359     void scalePageInViewCoordinates(double scale, WebCore::IntPoint centerInViewCoordinates);
360     double pageScaleFactor() const;
361     double totalScaleFactor() const;
362     double viewScaleFactor() const { return m_viewScaleFactor; }
363     void scaleView(double scale);
364
365     void setUseFixedLayout(bool);
366     bool useFixedLayout() const { return m_useFixedLayout; }
367     void setFixedLayoutSize(const WebCore::IntSize&);
368     WebCore::IntSize fixedLayoutSize() const;
369
370     void listenForLayoutMilestones(uint32_t /* LayoutMilestones */);
371
372     void setSuppressScrollbarAnimations(bool);
373     
374     void setEnableVerticalRubberBanding(bool);
375     void setEnableHorizontalRubberBanding(bool);
376     
377     void setBackgroundExtendsBeyondPage(bool);
378
379     void setPaginationMode(uint32_t /* WebCore::Pagination::Mode */);
380     void setPaginationBehavesLikeColumns(bool);
381     void setPageLength(double);
382     void setGapBetweenPages(double);
383
384     void postInjectedBundleMessage(const String& messageName, const UserData&);
385
386     bool drawsBackground() const { return m_drawsBackground; }
387     bool drawsTransparentBackground() const { return m_drawsTransparentBackground; }
388
389     void setUnderlayColor(const WebCore::Color& color) { m_underlayColor = color; }
390     WebCore::Color underlayColor() const { return m_underlayColor; }
391
392     void stopLoading();
393     void stopLoadingFrame(uint64_t frameID);
394     bool defersLoading() const;
395     void setDefersLoading(bool deferLoading);
396
397     void enterAcceleratedCompositingMode(WebCore::GraphicsLayer*);
398     void exitAcceleratedCompositingMode();
399
400     void addPluginView(PluginView*);
401     void removePluginView(PluginView*);
402
403     bool isVisible() const { return m_viewState & WebCore::ViewState::IsVisible; }
404     bool isVisibleOrOccluded() const { return m_viewState & WebCore::ViewState::IsVisibleOrOccluded; }
405
406     LayerHostingMode layerHostingMode() const { return m_layerHostingMode; }
407     void setLayerHostingMode(unsigned);
408
409 #if PLATFORM(COCOA)
410     void updatePluginsActiveAndFocusedState();
411     const WebCore::FloatRect& windowFrameInScreenCoordinates() const { return m_windowFrameInScreenCoordinates; }
412     const WebCore::FloatRect& windowFrameInUnflippedScreenCoordinates() const { return m_windowFrameInUnflippedScreenCoordinates; }
413     const WebCore::FloatRect& viewFrameInWindowCoordinates() const { return m_viewFrameInWindowCoordinates; }
414
415     bool hasCachedWindowFrame() const { return m_hasCachedWindowFrame; }
416
417 #if !PLATFORM(IOS)
418     void setTopOverhangImage(PassRefPtr<WebImage>);
419     void setBottomOverhangImage(PassRefPtr<WebImage>);
420 #endif // !PLATFORM(IOS)
421
422     void updateHeaderAndFooterLayersForDeviceScaleChange(float scaleFactor);
423 #endif // PLATFORM(COCOA)
424
425     bool windowIsFocused() const;
426     bool windowAndWebPageAreFocused() const;
427
428 #if !PLATFORM(IOS)
429     void setHeaderPageBanner(PassRefPtr<PageBanner>);
430     PageBanner* headerPageBanner();
431     void setFooterPageBanner(PassRefPtr<PageBanner>);
432     PageBanner* footerPageBanner();
433
434     void hidePageBanners();
435     void showPageBanners();
436     
437 #endif // !PLATFORM(IOS)
438
439     WebCore::IntPoint screenToRootView(const WebCore::IntPoint&);
440     WebCore::IntRect rootViewToScreen(const WebCore::IntRect&);
441     
442 #if PLATFORM(IOS)
443     WebCore::IntPoint accessibilityScreenToRootView(const WebCore::IntPoint&);
444     WebCore::IntRect rootViewToAccessibilityScreen(const WebCore::IntRect&);
445 #endif
446     
447     PassRefPtr<WebImage> scaledSnapshotWithOptions(const WebCore::IntRect&, double additionalScaleFactor, SnapshotOptions);
448     PassRefPtr<WebImage> snapshotAtSize(const WebCore::IntRect&, const WebCore::IntSize& bitmapSize, SnapshotOptions);
449     PassRefPtr<WebImage> snapshotNode(WebCore::Node&, SnapshotOptions, unsigned maximumPixelCount = std::numeric_limits<unsigned>::max());
450
451     static const WebEvent* currentEvent();
452
453     FindController& findController() { return m_findController; }
454
455 #if ENABLE(GEOLOCATION)
456     GeolocationPermissionRequestManager& geolocationPermissionRequestManager() { return m_geolocationPermissionRequestManager; }
457 #endif
458
459 #if PLATFORM(IOS) || PLATFORM(EFL)
460     void savePageState(WebCore::HistoryItem&);
461     void restorePageState(const WebCore::HistoryItem&);
462 #endif
463
464 #if ENABLE(MEDIA_STREAM)
465     UserMediaPermissionRequestManager& userMediaPermissionRequestManager() { return m_userMediaPermissionRequestManager; }
466 #endif
467
468 #if PLATFORM(IOS)
469     WebCore::FloatSize screenSize() const;
470     WebCore::FloatSize availableScreenSize() const;
471     int32_t deviceOrientation() const { return m_deviceOrientation; }
472     void viewportPropertiesDidChange(const WebCore::ViewportArguments&);
473     void didReceiveMobileDocType(bool);
474
475     void setUseTestingViewportConfiguration(bool useTestingViewport) { m_useTestingViewportConfiguration = useTestingViewport; }
476     bool isUsingTestingViewportConfiguration() const { return m_useTestingViewportConfiguration; }
477
478     double minimumPageScaleFactor() const;
479     double maximumPageScaleFactor() const;
480     bool allowsUserScaling() const;
481     bool hasStablePageScaleFactor() const { return m_hasStablePageScaleFactor; }
482
483     void handleTap(const WebCore::IntPoint&, uint64_t lastLayerTreeTransactionId);
484     void potentialTapAtPosition(uint64_t requestID, const WebCore::FloatPoint&);
485     void commitPotentialTap(uint64_t lastLayerTreeTransactionId);
486     void commitPotentialTapFailed();
487     void cancelPotentialTap();
488     void tapHighlightAtPosition(uint64_t requestID, const WebCore::FloatPoint&);
489
490     void inspectorNodeSearchMovedToPosition(const WebCore::FloatPoint&);
491     void inspectorNodeSearchEndedAtPosition(const WebCore::FloatPoint&);
492
493     void blurAssistedNode();
494     void selectWithGesture(const WebCore::IntPoint&, uint32_t granularity, uint32_t gestureType, uint32_t gestureState, uint64_t callbackID);
495     void updateSelectionWithTouches(const WebCore::IntPoint& point, uint32_t touches, bool baseIsStart, uint64_t callbackID);
496     void updateBlockSelectionWithTouch(const WebCore::IntPoint&, uint32_t touch, uint32_t handlePosition);
497     void selectWithTwoTouches(const WebCore::IntPoint& from, const WebCore::IntPoint& to, uint32_t gestureType, uint32_t gestureState, uint64_t callbackID);
498     void extendSelection(uint32_t granularity);
499     void selectWordBackward();
500     void moveSelectionByOffset(int32_t offset, uint64_t callbackID);
501     void selectTextWithGranularityAtPoint(const WebCore::IntPoint&, uint32_t granularity, uint64_t callbackID);
502     void selectPositionAtBoundaryWithDirection(const WebCore::IntPoint&, uint32_t granularity, uint32_t direction, uint64_t callbackID);
503     void selectPositionAtPoint(const WebCore::IntPoint&, uint64_t callbackID);
504     void beginSelectionInDirection(uint32_t direction, uint64_t callbackID);
505     void updateSelectionWithExtentPoint(const WebCore::IntPoint&, uint64_t callbackID);
506
507     void elementDidFocus(WebCore::Node*);
508     void elementDidBlur(WebCore::Node*);
509     void requestDictationContext(uint64_t callbackID);
510     void replaceDictatedText(const String& oldText, const String& newText);
511     void replaceSelectedText(const String& oldText, const String& newText);
512     void requestAutocorrectionData(const String& textForAutocorrection, uint64_t callbackID);
513     void applyAutocorrection(const String& correction, const String& originalText, uint64_t callbackID);
514     void syncApplyAutocorrection(const String& correction, const String& originalText, bool& correctionApplied);
515     void requestAutocorrectionContext(uint64_t callbackID);
516     void getAutocorrectionContext(String& beforeText, String& markedText, String& selectedText, String& afterText, uint64_t& location, uint64_t& length);
517     void getPositionInformation(const WebCore::IntPoint&, InteractionInformationAtPosition&);
518     void requestPositionInformation(const WebCore::IntPoint&);
519     void startInteractionWithElementAtPosition(const WebCore::IntPoint&);
520     void stopInteraction();
521     void performActionOnElement(uint32_t action);
522     void focusNextAssistedNode(bool isForward, uint64_t callbackID);
523     void setAssistedNodeValue(const String&);
524     void setAssistedNodeValueAsNumber(double);
525     void setAssistedNodeSelectedIndex(uint32_t index, bool allowMultipleSelection);
526     void resetAssistedNodeForFrame(WebFrame*);
527     WebCore::IntRect rectForElementAtInteractionLocation();
528     void updateSelectionAppearance();
529     void getLookupContextAtPoint(const WebCore::IntPoint, uint64_t callbackID);
530
531 #if ENABLE(IOS_TOUCH_EVENTS)
532     void dispatchAsynchronousTouchEvents(const Vector<WebTouchEvent, 1>& queue);
533 #endif
534
535     void contentSizeCategoryDidChange(const String&);
536     void executeEditCommandWithCallback(const String&, uint64_t callbackID);
537
538     std::chrono::milliseconds eventThrottlingDelay() const;
539
540     void showInspectorHighlight(const WebCore::Highlight&);
541     void hideInspectorHighlight();
542
543     void showInspectorIndication();
544     void hideInspectorIndication();
545
546     void enableInspectorNodeSearch();
547     void disableInspectorNodeSearch();
548 #endif
549
550     NotificationPermissionRequestManager* notificationPermissionRequestManager();
551
552     void pageDidScroll();
553 #if USE(TILED_BACKING_STORE)
554     void pageDidRequestScroll(const WebCore::IntPoint&);
555     void setFixedVisibleContentRect(const WebCore::IntRect&);
556     void sendViewportAttributesChanged();
557 #endif
558
559 #if ENABLE(CONTEXT_MENUS)
560     WebContextMenu* contextMenu();
561     WebContextMenu* contextMenuAtPointInWindow(const WebCore::IntPoint&);
562 #endif
563     
564     bool hasLocalDataForURL(const WebCore::URL&);
565     String cachedResponseMIMETypeForURL(const WebCore::URL&);
566     String cachedSuggestedFilenameForURL(const WebCore::URL&);
567     PassRefPtr<WebCore::SharedBuffer> cachedResponseDataForURL(const WebCore::URL&);
568
569     static bool canHandleRequest(const WebCore::ResourceRequest&);
570
571     class SandboxExtensionTracker {
572     public:
573         ~SandboxExtensionTracker();
574
575         void invalidate();
576
577         void beginLoad(WebFrame*, const SandboxExtension::Handle& handle);
578         void willPerformLoadDragDestinationAction(PassRefPtr<SandboxExtension> pendingDropSandboxExtension);
579         void didStartProvisionalLoad(WebFrame*);
580         void didCommitProvisionalLoad(WebFrame*);
581         void didFailProvisionalLoad(WebFrame*);
582
583     private:
584         void setPendingProvisionalSandboxExtension(PassRefPtr<SandboxExtension>);
585
586         RefPtr<SandboxExtension> m_pendingProvisionalSandboxExtension;
587         RefPtr<SandboxExtension> m_provisionalSandboxExtension;
588         RefPtr<SandboxExtension> m_committedSandboxExtension;
589     };
590
591     SandboxExtensionTracker& sandboxExtensionTracker() { return m_sandboxExtensionTracker; }
592
593 #if PLATFORM(EFL)
594     void setThemePath(const String&);
595 #endif
596
597 #if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
598     void commitPageTransitionViewport();
599 #endif
600
601 #if PLATFORM(GTK)
602     void setComposition(const String& text, const Vector<WebCore::CompositionUnderline>& underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeLength);
603     void confirmComposition(const String& text, int64_t selectionStart, int64_t selectionLength);
604     void cancelComposition();
605 #endif
606
607 #if PLATFORM (GTK) && HAVE(GTK_GESTURES)
608     void getCenterForZoomGesture(const WebCore::IntPoint& centerInViewCoordinates, WebCore::IntPoint& result);
609 #endif
610
611     void didChangeSelection();
612     void discardedComposition();
613
614 #if PLATFORM(COCOA)
615     void registerUIProcessAccessibilityTokens(const IPC::DataReference& elemenToken, const IPC::DataReference& windowToken);
616     WKAccessibilityWebPageObject* accessibilityRemoteObject();
617     NSObject *accessibilityObjectForMainFramePlugin();
618     const WebCore::FloatPoint& accessibilityPosition() const { return m_accessibilityPosition; }
619     
620     void sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String& textInput);
621
622     void insertTextAsync(const String& text, const EditingRange& replacementRange, bool registerUndoGroup = false);
623     void getMarkedRangeAsync(uint64_t callbackID);
624     void getSelectedRangeAsync(uint64_t callbackID);
625     void characterIndexForPointAsync(const WebCore::IntPoint&, uint64_t callbackID);
626     void firstRectForCharacterRangeAsync(const EditingRange&, uint64_t callbackID);
627     void setCompositionAsync(const String& text, Vector<WebCore::CompositionUnderline> underlines, const EditingRange& selectionRange, const EditingRange& replacementRange);
628     void confirmCompositionAsync();
629
630 #if PLATFORM(MAC)
631     void insertDictatedTextAsync(const String& text, const EditingRange& replacementRange, const Vector<WebCore::DictationAlternative>& dictationAlternativeLocations, bool registerUndoGroup = false);
632     void attributedSubstringForCharacterRangeAsync(const EditingRange&, uint64_t callbackID);
633     void fontAtSelection(uint64_t callbackID);
634 #if !USE(ASYNC_NSTEXTINPUTCLIENT)
635     void insertText(const String& text, const EditingRange& replacementRange, bool& handled, EditorState& newState);
636     void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, const EditingRange& selectionRange, const EditingRange& replacementRange, EditorState& newState);
637     void confirmComposition(EditorState& newState);
638     void insertDictatedText(const String& text, const EditingRange& replacementRange, const Vector<WebCore::DictationAlternative>& dictationAlternativeLocations, bool& handled, EditorState& newState);
639     void getAttributedSubstringFromRange(const EditingRange&, AttributedString&);
640     void getMarkedRange(EditingRange&);
641     void getSelectedRange(EditingRange&);
642     void characterIndexForPoint(const WebCore::IntPoint point, uint64_t& result);
643     void firstRectForCharacterRange(const EditingRange&, WebCore::IntRect& resultRect);
644     void executeKeypressCommands(const Vector<WebCore::KeypressCommand>&, bool& handled, EditorState& newState);
645     void cancelComposition(EditorState& newState);
646 #endif
647 #endif
648
649     void readSelectionFromPasteboard(const WTF::String& pasteboardName, bool& result);
650     void getStringSelectionForPasteboard(WTF::String& stringValue);
651     void getDataSelectionForPasteboard(const WTF::String pasteboardType, SharedMemory::Handle& handle, uint64_t& size);
652     void shouldDelayWindowOrderingEvent(const WebKit::WebMouseEvent&, bool& result);
653     void acceptsFirstMouse(int eventNumber, const WebKit::WebMouseEvent&, bool& result);
654     bool performNonEditingBehaviorForSelector(const String&, WebCore::KeyboardEvent*);
655
656 #if ENABLE(SERVICE_CONTROLS)
657     void replaceSelectionWithPasteboardData(const Vector<String>& types, const IPC::DataReference&);
658 #endif
659
660 #elif PLATFORM(EFL)
661     void confirmComposition(const String& compositionString);
662     void setComposition(const WTF::String& compositionString, const WTF::Vector<WebCore::CompositionUnderline>& underlines, uint64_t cursorPosition);
663     void cancelComposition();
664 #endif
665
666 #if HAVE(ACCESSIBILITY) && (PLATFORM(GTK) || PLATFORM(EFL))
667     void updateAccessibilityTree();
668 #endif
669
670     void setCompositionForTesting(const String& compositionString, uint64_t from, uint64_t length);
671     bool hasCompositionForTesting();
672     void confirmCompositionForTesting(const String& compositionString);
673
674     // FIXME: This a dummy message, to avoid breaking the build for platforms that don't require
675     // any synchronous messages, and should be removed when <rdar://problem/8775115> is fixed.
676     void dummy(bool&);
677
678 #if PLATFORM(COCOA)
679     bool isSpeaking();
680     void speak(const String&);
681     void stopSpeaking();
682
683     void performDictionaryLookupForSelection(WebCore::Frame*, const WebCore::VisibleSelection&, WebCore::TextIndicatorPresentationTransition);
684 #endif
685
686     bool isSmartInsertDeleteEnabled();
687     void setSmartInsertDeleteEnabled(bool);
688
689     bool isSelectTrailingWhitespaceEnabled();
690     void setSelectTrailingWhitespaceEnabled(bool);
691
692     void replaceSelectionWithText(WebCore::Frame*, const String&);
693     void clearSelection();
694     void restoreSelectionInFocusedEditableElement();
695
696 #if ENABLE(DRAG_SUPPORT)
697 #if PLATFORM(GTK)
698     void performDragControllerAction(uint64_t action, WebCore::DragData);
699 #else
700     void performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const WTF::String& dragStorageName, uint32_t flags, const SandboxExtension::Handle&, const SandboxExtension::HandleArray&);
701 #endif
702     void dragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t operation);
703
704     void willPerformLoadDragDestinationAction();
705     void mayPerformUploadDragDestinationAction();
706
707     void willStartDrag() { ASSERT(!m_isStartingDrag); m_isStartingDrag = true; }
708     void didStartDrag() { ASSERT(m_isStartingDrag); m_isStartingDrag = false; }
709 #endif // ENABLE(DRAG_SUPPORT)
710
711     void beginPrinting(uint64_t frameID, const PrintInfo&);
712     void endPrinting();
713     void computePagesForPrinting(uint64_t frameID, const PrintInfo&, uint64_t callbackID);
714     void computePagesForPrintingImpl(uint64_t frameID, const PrintInfo&, Vector<WebCore::IntRect>& pageRects, double& totalScaleFactor);
715 #if PLATFORM(COCOA)
716     void drawRectToImage(uint64_t frameID, const PrintInfo&, const WebCore::IntRect&, const WebCore::IntSize&, uint64_t callbackID);
717     void drawPagesToPDF(uint64_t frameID, const PrintInfo&, uint32_t first, uint32_t count, uint64_t callbackID);
718     void drawPagesToPDFImpl(uint64_t frameID, const PrintInfo&, uint32_t first, uint32_t count, RetainPtr<CFMutableDataRef>& pdfPageData);
719 #if PLATFORM(IOS)
720     void computePagesForPrintingAndStartDrawingToPDF(uint64_t frameID, const PrintInfo&, uint32_t firstPage, PassRefPtr<Messages::WebPage::ComputePagesForPrintingAndStartDrawingToPDF::DelayedReply>);
721 #endif
722 #elif PLATFORM(GTK)
723     void drawPagesForPrinting(uint64_t frameID, const PrintInfo&, uint64_t callbackID);
724     void didFinishPrintOperation(const WebCore::ResourceError&, uint64_t callbackID);
725 #endif
726
727     void addResourceRequest(unsigned long, const WebCore::ResourceRequest&);
728     void removeResourceRequest(unsigned long);
729
730     void setMediaVolume(float);
731     void setMuted(bool);
732     void setMayStartMediaWhenInWindow(bool);
733
734     void updateMainFrameScrollOffsetPinning();
735
736     bool mainFrameHasCustomContentProvider() const;
737     void addMIMETypeWithCustomContentProvider(const String&);
738
739     void mainFrameDidLayout();
740
741     bool canRunBeforeUnloadConfirmPanel() const { return m_canRunBeforeUnloadConfirmPanel; }
742     void setCanRunBeforeUnloadConfirmPanel(bool canRunBeforeUnloadConfirmPanel) { m_canRunBeforeUnloadConfirmPanel = canRunBeforeUnloadConfirmPanel; }
743
744     bool canRunModal() const { return m_canRunModal; }
745     void setCanRunModal(bool canRunModal) { m_canRunModal = canRunModal; }
746
747     void runModal();
748
749     void setDeviceScaleFactor(float);
750     float deviceScaleFactor() const;
751
752     void forceRepaintWithoutCallback();
753
754     void unmarkAllMisspellings();
755     void unmarkAllBadGrammar();
756 #if PLATFORM(COCOA)
757     void handleAlternativeTextUIResult(const String&);
758 #endif
759
760     // For testing purpose.
761     void simulateMouseDown(int button, WebCore::IntPoint, int clickCount, WKEventModifiers, double time);
762     void simulateMouseUp(int button, WebCore::IntPoint, int clickCount, WKEventModifiers, double time);
763     void simulateMouseMotion(WebCore::IntPoint, double time);
764
765 #if ENABLE(CONTEXT_MENUS)
766     void contextMenuShowing() { m_isShowingContextMenu = true; }
767 #endif
768
769     void wheelEvent(const WebWheelEvent&);
770
771     void wheelEventHandlersChanged(bool);
772     void recomputeShortCircuitHorizontalWheelEventsState();
773
774     void updateVisibilityState(bool isInitialState = false);
775
776 #if PLATFORM(IOS)
777     void setViewportConfigurationMinimumLayoutSize(const WebCore::FloatSize&);
778     void setMaximumUnobscuredSize(const WebCore::FloatSize&);
779     void setDeviceOrientation(int32_t);
780     void dynamicViewportSizeUpdate(const WebCore::FloatSize& minimumLayoutSize, const WebCore::FloatSize& maximumUnobscuredSize, const WebCore::FloatRect& targetExposedContentRect, const WebCore::FloatRect& targetUnobscuredRect, const WebCore::FloatRect& targetUnobscuredRectInScrollViewCoordinates, double scale, int32_t deviceOrientation, uint64_t dynamicViewportSizeUpdateID);
781     void synchronizeDynamicViewportUpdate(double& newTargetScale, WebCore::FloatPoint& newScrollPosition, uint64_t& nextValidLayerTreeTransactionID);
782     void updateVisibleContentRects(const VisibleContentRectUpdateInfo&, double oldestTimestamp);
783     bool scaleWasSetByUIProcess() const { return m_scaleWasSetByUIProcess; }
784     void willStartUserTriggeredZooming();
785     void applicationWillResignActive();
786     void applicationWillEnterForeground();
787     void applicationDidBecomeActive();
788     void zoomToRect(WebCore::FloatRect, double minimumScale, double maximumScale);
789     void completePendingSyntheticClickForContentChangeObserver();
790 #endif
791
792 #if ENABLE(IOS_TOUCH_EVENTS)
793     void dispatchTouchEvent(const WebTouchEvent&, bool& handled);
794 #endif
795
796 #if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL)
797     uint64_t nativeWindowHandle() { return m_nativeWindowHandle; }
798 #endif
799
800     bool shouldUseCustomContentProviderForResponse(const WebCore::ResourceResponse&);
801     bool canPluginHandleResponse(const WebCore::ResourceResponse& response);
802
803     bool asynchronousPluginInitializationEnabled() const { return m_asynchronousPluginInitializationEnabled; }
804     void setAsynchronousPluginInitializationEnabled(bool enabled) { m_asynchronousPluginInitializationEnabled = enabled; }
805     bool asynchronousPluginInitializationEnabledForAllPlugins() const { return m_asynchronousPluginInitializationEnabledForAllPlugins; }
806     void setAsynchronousPluginInitializationEnabledForAllPlugins(bool enabled) { m_asynchronousPluginInitializationEnabledForAllPlugins = enabled; }
807     bool artificialPluginInitializationDelayEnabled() const { return m_artificialPluginInitializationDelayEnabled; }
808     void setArtificialPluginInitializationDelayEnabled(bool enabled) { m_artificialPluginInitializationDelayEnabled = enabled; }
809     void setTabToLinksEnabled(bool enabled) { m_tabToLinks = enabled; }
810     bool tabToLinksEnabled() const { return m_tabToLinks; }
811
812     bool scrollingPerformanceLoggingEnabled() const { return m_scrollingPerformanceLoggingEnabled; }
813     void setScrollingPerformanceLoggingEnabled(bool);
814
815 #if PLATFORM(COCOA)
816     bool shouldUsePDFPlugin() const;
817     bool pdfPluginEnabled() const { return m_pdfPluginEnabled; }
818     void setPDFPluginEnabled(bool enabled) { m_pdfPluginEnabled = enabled; }
819 #endif
820
821     void savePDFToFileInDownloadsFolder(const String& suggestedFilename, const String& originatingURLString, const uint8_t* data, unsigned long size);
822 #if PLATFORM(COCOA)
823     void savePDFToTemporaryFolderAndOpenWithNativeApplication(const String& suggestedFilename, const String& originatingURLString, const uint8_t* data, unsigned long size, const String& pdfUUID);
824 #endif
825
826     bool mainFrameIsScrollable() const { return m_mainFrameIsScrollable; }
827
828     void setMinimumLayoutSize(const WebCore::IntSize&);
829     WebCore::IntSize minimumLayoutSize() const { return m_minimumLayoutSize; }
830
831     void setAutoSizingShouldExpandToViewHeight(bool shouldExpand);
832     bool autoSizingShouldExpandToViewHeight() { return m_autoSizingShouldExpandToViewHeight; }
833
834     bool canShowMIMEType(const String& MIMEType) const;
835
836     void addTextCheckingRequest(uint64_t requestID, PassRefPtr<WebCore::TextCheckingRequest>);
837     void didFinishCheckingText(uint64_t requestID, const Vector<WebCore::TextCheckingResult>&);
838     void didCancelCheckingText(uint64_t requestID);
839
840 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
841     void determinePrimarySnapshottedPlugIn();
842     void determinePrimarySnapshottedPlugInTimerFired();
843     void resetPrimarySnapshottedPlugIn();
844     bool matchesPrimaryPlugIn(const String& pageOrigin, const String& pluginOrigin, const String& mimeType) const;
845     bool plugInIntersectsSearchRect(WebCore::HTMLPlugInImageElement& pluginImageElement);
846     bool plugInIsPrimarySize(WebCore::HTMLPlugInImageElement& pluginImageElement, unsigned &pluginArea);
847 #endif
848
849     unsigned extendIncrementalRenderingSuppression();
850     void stopExtendingIncrementalRenderingSuppression(unsigned token);
851     bool shouldExtendIncrementalRenderingSuppression() { return !m_activeRenderingSuppressionTokens.isEmpty(); }
852
853     WebCore::ScrollPinningBehavior scrollPinningBehavior() { return m_scrollPinningBehavior; }
854     void setScrollPinningBehavior(uint32_t /* WebCore::ScrollPinningBehavior */ pinning);
855
856     PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(WebCore::Frame&, const WebCore::ResourceRequest&, const WebCore::SubstituteData&);
857
858     void getBytecodeProfile(uint64_t callbackID);
859     
860     // Some platforms require accessibility-enabled processes to spin the run loop so that the WebProcess doesn't hang.
861     // While this is not ideal, it does not have to be applied to every platform at the moment.
862     static bool synchronousMessagesShouldSpinRunLoop();
863
864 #if ENABLE(SERVICE_CONTROLS) || ENABLE(TELEPHONE_NUMBER_DETECTION)
865     void handleTelephoneNumberClick(const String& number, const WebCore::IntPoint&);
866     void handleSelectionServiceClick(WebCore::FrameSelection&, const Vector<String>& telephoneNumbers, const WebCore::IntPoint&);
867 #endif
868
869     void didChangeScrollOffsetForFrame(WebCore::Frame*);
870
871     void setMainFrameProgressCompleted(bool completed) { m_mainFrameProgressCompleted = completed; }
872     bool shouldDispatchFakeMouseMoveEvents() const { return m_shouldDispatchFakeMouseMoveEvents; }
873
874     void setPageActivityState(WebCore::PageActivityState::Flags);
875
876     void postMessage(const String& messageName, API::Object* messageBody);
877     void postSynchronousMessage(const String& messageName, API::Object* messageBody, RefPtr<API::Object>& returnData);
878
879 private:
880     WebPage(uint64_t pageID, const WebPageCreationParameters&);
881
882     // IPC::MessageSender
883     virtual IPC::Connection* messageSenderConnection() override;
884     virtual uint64_t messageSenderDestinationID() override;
885
886     void platformInitialize();
887     void platformDetach();
888     void platformEditorState(WebCore::Frame&, EditorState& result, IncludePostLayoutDataHint) const;
889
890     void didReceiveWebPageMessage(IPC::Connection&, IPC::MessageDecoder&);
891     void didReceiveSyncWebPageMessage(IPC::Connection&, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&);
892
893 #if PLATFORM(IOS)
894     void resetViewportDefaultConfiguration(WebFrame* mainFrame);
895     void viewportConfigurationChanged();
896     void updateViewportSizeForCSSViewportUnits();
897
898     static void convertSelectionRectsToRootView(WebCore::FrameView*, Vector<WebCore::SelectionRect>&);
899     PassRefPtr<WebCore::Range> rangeForWebSelectionAtPosition(const WebCore::IntPoint&, const WebCore::VisiblePosition&, SelectionFlags&);
900     PassRefPtr<WebCore::Range> rangeForBlockAtPoint(const WebCore::IntPoint&);
901     void computeExpandAndShrinkThresholdsForHandle(const WebCore::IntPoint&, SelectionHandlePosition, float& growThreshold, float& shrinkThreshold);
902     PassRefPtr<WebCore::Range> changeBlockSelection(const WebCore::IntPoint&, SelectionHandlePosition, float& growThreshold, float& shrinkThreshold, SelectionFlags&);
903     PassRefPtr<WebCore::Range> expandedRangeFromHandle(WebCore::Range*, SelectionHandlePosition);
904     PassRefPtr<WebCore::Range> contractedRangeFromHandle(WebCore::Range* currentRange, SelectionHandlePosition, SelectionFlags&);
905     void getAssistedNodeInformation(AssistedNodeInformation&);
906     void platformInitializeAccessibility();
907     void handleSyntheticClick(WebCore::Node* nodeRespondingToClick, const WebCore::FloatPoint& location);
908     void completeSyntheticClick(WebCore::Node* nodeRespondingToClick, const WebCore::FloatPoint& location);
909     void sendTapHighlightForNodeIfNecessary(uint64_t requestID, WebCore::Node*);
910     void resetTextAutosizingBeforeLayoutIfNeeded(const WebCore::FloatSize& oldSize, const WebCore::FloatSize& newSize);
911     WebCore::VisiblePosition visiblePositionInFocusedNodeForPoint(WebCore::Frame&, const WebCore::IntPoint&);
912 #endif
913 #if !PLATFORM(COCOA)
914     static const char* interpretKeyEvent(const WebCore::KeyboardEvent*);
915 #endif
916     bool performDefaultBehaviorForKeyEvent(const WebKeyboardEvent&);
917
918 #if PLATFORM(MAC)
919     bool executeKeypressCommandsInternal(const Vector<WebCore::KeypressCommand>&, WebCore::KeyboardEvent*);
920 #endif
921
922     String sourceForFrame(WebFrame*);
923
924     void loadDataImpl(uint64_t navigationID, PassRefPtr<WebCore::SharedBuffer>, const String& MIMEType, const String& encodingName, const WebCore::URL& baseURL, const WebCore::URL& failingURL, const UserData&);
925     void loadString(uint64_t navigationID, const String&, const String& MIMEType, const WebCore::URL& baseURL, const WebCore::URL& failingURL, const UserData&);
926
927     bool platformHasLocalDataForURL(const WebCore::URL&);
928
929     // Actions
930     void tryClose();
931     void loadRequest(uint64_t navigationID, const WebCore::ResourceRequest&, const SandboxExtension::Handle&, const UserData&);
932     void loadData(const IPC::DataReference&, const String& MIMEType, const String& encodingName, const String& baseURL, const UserData&);
933     void loadHTMLString(uint64_t navigationID, const String& htmlString, const String& baseURL, const UserData&);
934     void loadAlternateHTMLString(const String& htmlString, const String& baseURL, const String& unreachableURL, const UserData&);
935     void loadPlainTextString(const String&, const UserData&);
936     void loadWebArchiveData(const IPC::DataReference&, const UserData&);
937     void navigateToURLWithSimulatedClick(const String& url, WebCore::IntPoint documentPoint, WebCore::IntPoint screenPoint);
938     void reload(uint64_t navigationID, bool reloadFromOrigin, const SandboxExtension::Handle&);
939     void goForward(uint64_t navigationID, uint64_t);
940     void goBack(uint64_t navigationID, uint64_t);
941     void goToBackForwardItem(uint64_t navigationID, uint64_t);
942     void tryRestoreScrollPosition();
943     void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&, uint64_t callbackID);
944     void setWindowResizerSize(const WebCore::IntSize&);
945     void updateIsInWindow(bool isInitialState = false);
946     void setViewState(WebCore::ViewState::Flags, bool wantsDidUpdateViewState, const Vector<uint64_t>& callbackIDs);
947     void validateCommand(const String&, uint64_t);
948     void executeEditCommand(const String&);
949     void setEditable(bool);
950
951     void updateUserActivity();
952
953     void mouseEvent(const WebMouseEvent&);
954     void mouseEventSyncForTesting(const WebMouseEvent&, bool&);
955     void wheelEventSyncForTesting(const WebWheelEvent&, bool&);
956     void keyEvent(const WebKeyboardEvent&);
957     void keyEventSyncForTesting(const WebKeyboardEvent&, bool&);
958 #if ENABLE(IOS_TOUCH_EVENTS)
959     void touchEventSync(const WebTouchEvent&, bool& handled);
960 #elif ENABLE(TOUCH_EVENTS)
961     void touchEvent(const WebTouchEvent&);
962     void touchEventSyncForTesting(const WebTouchEvent&, bool& handled);
963 #endif
964 #if ENABLE(CONTEXT_MENUS)
965     void contextMenuHidden() { m_isShowingContextMenu = false; }
966 #endif
967
968     static bool scroll(WebCore::Page*, WebCore::ScrollDirection, WebCore::ScrollGranularity);
969     static bool logicalScroll(WebCore::Page*, WebCore::ScrollLogicalDirection, WebCore::ScrollGranularity);
970
971     void loadURLInFrame(const String&, uint64_t frameID);
972
973     void restoreSession(const Vector<BackForwardListItemState>&);
974     void didRemoveBackForwardItem(uint64_t);
975
976 #if ENABLE(REMOTE_INSPECTOR)
977     void setAllowsRemoteInspection(bool);
978 #endif
979
980     void setDrawsBackground(bool);
981     void setDrawsTransparentBackground(bool);
982
983     void setTopContentInset(float);
984
985     void viewWillStartLiveResize();
986     void viewWillEndLiveResize();
987
988     void getContentsAsString(uint64_t callbackID);
989 #if ENABLE(MHTML)
990     void getContentsAsMHTMLData(uint64_t callbackID, bool useBinaryEncoding);
991 #endif
992     void getMainResourceDataOfFrame(uint64_t frameID, uint64_t callbackID);
993     void getResourceDataFromFrame(uint64_t frameID, const String& resourceURL, uint64_t callbackID);
994     void getRenderTreeExternalRepresentation(uint64_t callbackID);
995     void getSelectionOrContentsAsString(uint64_t callbackID);
996     void getSelectionAsWebArchiveData(uint64_t callbackID);
997     void getSourceForFrame(uint64_t frameID, uint64_t callbackID);
998     void getWebArchiveOfFrame(uint64_t frameID, uint64_t callbackID);
999     void runJavaScriptInMainFrame(const String&, uint64_t callbackID);
1000     void forceRepaint(uint64_t callbackID);
1001     void takeSnapshot(WebCore::IntRect snapshotRect, WebCore::IntSize bitmapSize, uint32_t options, uint64_t callbackID);
1002
1003     void preferencesDidChange(const WebPreferencesStore&);
1004     void platformPreferencesDidChange(const WebPreferencesStore&);
1005     void updatePreferences(const WebPreferencesStore&);
1006
1007     void didReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, uint32_t policyAction, uint64_t navigationID, uint64_t downloadID);
1008     void setUserAgent(const String&);
1009     void setCustomTextEncodingName(const String&);
1010     void suspendActiveDOMObjectsAndAnimations();
1011     void resumeActiveDOMObjectsAndAnimations();
1012
1013 #if PLATFORM(COCOA)
1014     void performDictionaryLookupAtLocation(const WebCore::FloatPoint&);
1015     void performDictionaryLookupOfCurrentSelection();
1016     void performDictionaryLookupForRange(WebCore::Frame*, WebCore::Range&, NSDictionary *options, WebCore::TextIndicatorPresentationTransition);
1017     DictionaryPopupInfo dictionaryPopupInfoForRange(WebCore::Frame* frame, WebCore::Range& range, NSDictionary **options, WebCore::TextIndicatorPresentationTransition presentationTransition);
1018 #if ENABLE(PDFKIT_PLUGIN)
1019     DictionaryPopupInfo dictionaryPopupInfoForSelectionInPDFPlugin(PDFSelection *, PDFPlugin&, NSDictionary **options, WebCore::TextIndicatorPresentationTransition);
1020 #endif
1021
1022     void windowAndViewFramesChanged(const WebCore::FloatRect& windowFrameInScreenCoordinates, const WebCore::FloatRect& windowFrameInUnflippedScreenCoordinates, const WebCore::FloatRect& viewFrameInWindowCoordinates, const WebCore::FloatPoint& accessibilityViewCoordinates);
1023
1024     RetainPtr<PDFDocument> pdfDocumentForPrintingFrame(WebCore::Frame*);
1025     void computePagesForPrintingPDFDocument(uint64_t frameID, const PrintInfo&, Vector<WebCore::IntRect>& resultPageRects);
1026     void drawPDFDocument(CGContextRef, PDFDocument *, const PrintInfo&, const WebCore::IntRect&);
1027     void drawPagesToPDFFromPDFDocument(CGContextRef, PDFDocument *, const PrintInfo&, uint32_t first, uint32_t count);
1028 #endif
1029
1030     void setMainFrameIsScrollable(bool);
1031
1032     void unapplyEditCommand(uint64_t commandID);
1033     void reapplyEditCommand(uint64_t commandID);
1034     void didRemoveEditCommand(uint64_t commandID);
1035
1036     void findString(const String&, uint32_t findOptions, uint32_t maxMatchCount);
1037     void findStringMatches(const String&, uint32_t findOptions, uint32_t maxMatchCount);
1038     void getImageForFindMatch(uint32_t matchIndex);
1039     void selectFindMatch(uint32_t matchIndex);
1040     void hideFindUI();
1041     void countStringMatches(const String&, uint32_t findOptions, uint32_t maxMatchCount);
1042
1043 #if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
1044     void findZoomableAreaForPoint(const WebCore::IntPoint&, const WebCore::IntSize& area);
1045 #endif
1046
1047     void didChangeSelectedIndexForActivePopupMenu(int32_t newIndex);
1048     void setTextForActivePopupMenu(int32_t index);
1049
1050 #if PLATFORM(GTK)
1051     void failedToShowPopupMenu();
1052 #endif
1053
1054 #if PLATFORM(IOS)
1055     void didChooseFilesForOpenPanelWithDisplayStringAndIcon(const Vector<String>&, const String& displayString, const IPC::DataReference& iconData);
1056 #endif
1057     void didChooseFilesForOpenPanel(const Vector<String>&);
1058     void didCancelForOpenPanel();
1059 #if ENABLE(SANDBOX_EXTENSIONS)
1060     void extendSandboxForFileFromOpenPanel(const SandboxExtension::Handle&);
1061 #endif
1062
1063     void didReceiveGeolocationPermissionDecision(uint64_t geolocationID, bool allowed);
1064
1065     void didReceiveNotificationPermissionDecision(uint64_t notificationID, bool allowed);
1066
1067 #if ENABLE(MEDIA_STREAM)
1068     void didReceiveUserMediaPermissionDecision(uint64_t userMediaID, bool allowed);
1069 #endif
1070
1071     void advanceToNextMisspelling(bool startBeforeSelection);
1072     void changeSpellingToWord(const String& word);
1073 #if USE(APPKIT)
1074     void uppercaseWord();
1075     void lowercaseWord();
1076     void capitalizeWord();
1077 #endif
1078
1079 #if ENABLE(CONTEXT_MENUS)
1080     void didSelectItemFromActiveContextMenu(const WebContextMenuItemData&);
1081 #endif
1082
1083     void changeSelectedIndex(int32_t index);
1084     void setCanStartMediaTimerFired();
1085
1086     bool canHandleUserEvents() const;
1087
1088     static bool platformCanHandleRequest(const WebCore::ResourceRequest&);
1089
1090     static PluginView* focusedPluginViewForFrame(WebCore::Frame&);
1091     static PluginView* pluginViewForFrame(WebCore::Frame*);
1092
1093     static PassRefPtr<WebCore::Range> rangeFromEditingRange(WebCore::Frame&, const EditingRange&);
1094
1095     void reportUsedFeatures();
1096
1097 #if PLATFORM(MAC)
1098     void performActionMenuHitTestAtLocation(WebCore::FloatPoint, bool forImmediateAction);
1099     PassRefPtr<WebCore::Range> lookupTextAtLocation(WebCore::FloatPoint, NSDictionary **options);
1100     void selectLastActionMenuRange();
1101     void focusAndSelectLastActionMenuHitTestResult();
1102     void immediateActionDidUpdate();
1103     void immediateActionDidCancel();
1104     void immediateActionDidComplete();
1105     void setFont(const String& fontFamily, double fontSize, uint64_t fontTraits);
1106
1107     void dataDetectorsDidPresentUI(WebCore::PageOverlay::PageOverlayID);
1108     void dataDetectorsDidChangeUI(WebCore::PageOverlay::PageOverlayID);
1109     void dataDetectorsDidHideUI(WebCore::PageOverlay::PageOverlayID);
1110 #endif
1111
1112     void setShouldDispatchFakeMouseMoveEvents(bool dispatch) { m_shouldDispatchFakeMouseMoveEvents = dispatch; }
1113
1114 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
1115     void playbackTargetSelected(uint64_t, const WebCore::MediaPlaybackTargetContext& outputDevice) const;
1116     void playbackTargetAvailabilityDidChange(uint64_t, bool);
1117     void setShouldPlayToPlaybackTarget(uint64_t, bool);
1118 #endif
1119
1120     uint64_t m_pageID;
1121
1122     std::unique_ptr<WebCore::Page> m_page;
1123     RefPtr<WebFrame> m_mainFrame;
1124     RefPtr<InjectedBundleBackForwardList> m_backForwardList;
1125
1126     RefPtr<WebPageGroupProxy> m_pageGroup;
1127
1128     String m_userAgent;
1129
1130     WebCore::IntSize m_viewSize;
1131     std::unique_ptr<DrawingArea> m_drawingArea;
1132
1133     HashSet<PluginView*> m_pluginViews;
1134     bool m_hasSeenPlugin;
1135
1136     HashMap<uint64_t, RefPtr<WebCore::TextCheckingRequest>> m_pendingTextCheckingRequestMap;
1137
1138     bool m_useFixedLayout;
1139
1140     bool m_drawsBackground;
1141     bool m_drawsTransparentBackground;
1142
1143     WebCore::Color m_underlayColor;
1144
1145     bool m_isInRedo;
1146     bool m_isClosed;
1147
1148     bool m_tabToLinks;
1149     
1150     bool m_asynchronousPluginInitializationEnabled;
1151     bool m_asynchronousPluginInitializationEnabledForAllPlugins;
1152     bool m_artificialPluginInitializationDelayEnabled;
1153
1154     bool m_scrollingPerformanceLoggingEnabled;
1155
1156     bool m_mainFrameIsScrollable;
1157
1158 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
1159     bool m_readyToFindPrimarySnapshottedPlugin;
1160     bool m_didFindPrimarySnapshottedPlugin;
1161     unsigned m_numberOfPrimarySnapshotDetectionAttempts;
1162     String m_primaryPlugInPageOrigin;
1163     String m_primaryPlugInOrigin;
1164     String m_primaryPlugInMimeType;
1165     RunLoop::Timer<WebPage> m_determinePrimarySnapshottedPlugInTimer;
1166 #endif
1167
1168     // The layer hosting mode.
1169     LayerHostingMode m_layerHostingMode;
1170
1171 #if PLATFORM(COCOA)
1172     bool m_pdfPluginEnabled;
1173
1174     bool m_hasCachedWindowFrame;
1175
1176     // The frame of the containing window in screen coordinates.
1177     WebCore::FloatRect m_windowFrameInScreenCoordinates;
1178
1179     // The frame of the containing window in unflipped screen coordinates.
1180     WebCore::FloatRect m_windowFrameInUnflippedScreenCoordinates;
1181
1182     // The frame of the view in window coordinates.
1183     WebCore::FloatRect m_viewFrameInWindowCoordinates;
1184
1185     // The accessibility position of the view.
1186     WebCore::FloatPoint m_accessibilityPosition;
1187     
1188     RetainPtr<WKAccessibilityWebPageObject> m_mockAccessibilityElement;
1189
1190     ViewGestureGeometryCollector m_viewGestureGeometryCollector;
1191
1192 #elif HAVE(ACCESSIBILITY) && (PLATFORM(GTK) || PLATFORM(EFL))
1193     GRefPtr<WebPageAccessibilityObject> m_accessibilityObject;
1194 #endif
1195
1196 #if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL)
1197     // Our view's window in the UI process.
1198     uint64_t m_nativeWindowHandle;
1199 #endif
1200
1201 #if !PLATFORM(IOS)
1202     RefPtr<PageBanner> m_headerBanner;
1203     RefPtr<PageBanner> m_footerBanner;
1204 #endif // !PLATFORM(IOS)
1205
1206     RunLoop::Timer<WebPage> m_setCanStartMediaTimer;
1207     bool m_mayStartMediaWhenInWindow;
1208
1209     HashMap<uint64_t, RefPtr<WebUndoStep>> m_undoStepMap;
1210
1211     WebCore::IntSize m_windowResizerSize;
1212
1213 #if ENABLE(CONTEXT_MENUS)
1214     std::unique_ptr<API::InjectedBundle::PageContextMenuClient> m_contextMenuClient;
1215 #endif
1216     InjectedBundlePageEditorClient m_editorClient;
1217     std::unique_ptr<API::InjectedBundle::FormClient> m_formClient;
1218     InjectedBundlePageLoaderClient m_loaderClient;
1219     InjectedBundlePagePolicyClient m_policyClient;
1220     InjectedBundlePageResourceLoadClient m_resourceLoadClient;
1221     std::unique_ptr<API::InjectedBundle::PageUIClient> m_uiClient;
1222 #if ENABLE(FULLSCREEN_API)
1223     InjectedBundlePageFullScreenClient m_fullScreenClient;
1224 #endif
1225     InjectedBundlePageDiagnosticLoggingClient m_logDiagnosticMessageClient;
1226
1227     FindController m_findController;
1228
1229     RefPtr<WebInspector> m_inspector;
1230     RefPtr<WebInspectorUI> m_inspectorUI;
1231 #if PLATFORM(IOS)
1232     RefPtr<WebVideoFullscreenManager> m_videoFullscreenManager;
1233 #endif
1234 #if ENABLE(FULLSCREEN_API)
1235     RefPtr<WebFullScreenManager> m_fullScreenManager;
1236 #endif
1237     RefPtr<WebPopupMenu> m_activePopupMenu;
1238 #if ENABLE(CONTEXT_MENUS)
1239     RefPtr<WebContextMenu> m_contextMenu;
1240 #endif
1241 #if ENABLE(INPUT_TYPE_COLOR)
1242     WebColorChooser* m_activeColorChooser;
1243 #endif
1244     RefPtr<WebOpenPanelResultListener> m_activeOpenPanelResultListener;
1245     RefPtr<NotificationPermissionRequestManager> m_notificationPermissionRequestManager;
1246
1247     RefPtr<WebUserContentController> m_userContentController;
1248
1249 #if ENABLE(GEOLOCATION)
1250     GeolocationPermissionRequestManager m_geolocationPermissionRequestManager;
1251 #endif
1252
1253 #if ENABLE(MEDIA_STREAM)
1254     UserMediaPermissionRequestManager m_userMediaPermissionRequestManager;
1255 #endif
1256
1257     std::unique_ptr<WebCore::PrintContext> m_printContext;
1258 #if PLATFORM(GTK)
1259     RefPtr<WebPrintOperationGtk> m_printOperation;
1260 #endif
1261
1262     SandboxExtensionTracker m_sandboxExtensionTracker;
1263
1264     RefPtr<SandboxExtension> m_pendingDropSandboxExtension;
1265     Vector<RefPtr<SandboxExtension>> m_pendingDropExtensionsForFileUpload;
1266
1267     bool m_canRunBeforeUnloadConfirmPanel;
1268
1269     bool m_canRunModal;
1270     bool m_isRunningModal;
1271
1272 #if ENABLE(DRAG_SUPPORT)
1273     bool m_isStartingDrag;
1274 #endif
1275
1276     bool m_cachedMainFrameIsPinnedToLeftSide;
1277     bool m_cachedMainFrameIsPinnedToRightSide;
1278     bool m_cachedMainFrameIsPinnedToTopSide;
1279     bool m_cachedMainFrameIsPinnedToBottomSide;
1280     bool m_canShortCircuitHorizontalWheelEvents;
1281     bool m_hasWheelEventHandlers;
1282
1283     unsigned m_cachedPageCount;
1284
1285     HashSet<unsigned long> m_trackedNetworkResourceRequestIdentifiers;
1286
1287     WebCore::IntSize m_minimumLayoutSize;
1288     bool m_autoSizingShouldExpandToViewHeight;
1289
1290 #if ENABLE(CONTEXT_MENUS)
1291     bool m_isShowingContextMenu;
1292 #endif
1293     
1294 #if PLATFORM(IOS)
1295     RefPtr<WebCore::Node> m_assistedNode;
1296     RefPtr<WebCore::Range> m_currentWordRange;
1297     RefPtr<WebCore::Node> m_interactionNode;
1298     WebCore::IntPoint m_lastInteractionLocation;
1299     
1300     enum SelectionAnchor {
1301         Start,
1302         End
1303     };
1304     SelectionAnchor m_selectionAnchor;
1305
1306     RefPtr<WebCore::Node> m_potentialTapNode;
1307     WebCore::FloatPoint m_potentialTapLocation;
1308
1309     WebCore::ViewportConfiguration m_viewportConfiguration;
1310     uint64_t m_firstLayerTreeTransactionIDAfterDidCommitLoad;
1311     bool m_hasReceivedVisibleContentRectsAfterDidCommitLoad;
1312     bool m_scaleWasSetByUIProcess;
1313     bool m_userHasChangedPageScaleFactor;
1314     bool m_hasStablePageScaleFactor;
1315     bool m_userIsInteracting;
1316     bool m_hasPendingBlurNotification;
1317     bool m_useTestingViewportConfiguration;
1318     bool m_isInStableState;
1319     std::chrono::milliseconds m_oldestNonStableUpdateVisibleContentRectsTimestamp;
1320     std::chrono::milliseconds m_estimatedLatency;
1321     WebCore::FloatSize m_screenSize;
1322     WebCore::FloatSize m_availableScreenSize;
1323     RefPtr<WebCore::Range> m_currentBlockSelection;
1324     WebCore::IntSize m_blockSelectionDesiredSize;
1325     WebCore::FloatSize m_maximumUnobscuredSize;
1326     int32_t m_deviceOrientation;
1327     bool m_inDynamicSizeUpdate;
1328     HashMap<std::pair<WebCore::IntSize, double>, WebCore::IntPoint> m_dynamicSizeUpdateHistory;
1329     RefPtr<WebCore::Node> m_pendingSyntheticClickNode;
1330     WebCore::FloatPoint m_pendingSyntheticClickLocation;
1331 #endif
1332
1333     WebInspectorClient* m_inspectorClient;
1334
1335     HashSet<String, CaseFoldingHash> m_mimeTypesWithCustomContentProviders;
1336     WebCore::Color m_backgroundColor;
1337
1338     HashSet<unsigned> m_activeRenderingSuppressionTokens;
1339     unsigned m_maximumRenderingSuppressionToken;
1340     
1341     WebCore::ScrollPinningBehavior m_scrollPinningBehavior;
1342
1343     bool m_useAsyncScrolling;
1344
1345     WebCore::ViewState::Flags m_viewState;
1346     WebCore::PageActivityState::Flags m_activityState;
1347
1348     bool m_processSuppressionEnabled;
1349     UserActivity m_userActivity;
1350
1351     uint64_t m_pendingNavigationID;
1352
1353     double m_viewScaleFactor { 1 };
1354
1355 #if ENABLE(WEBGL)
1356     WebCore::WebGLLoadPolicy m_systemWebGLPolicy;
1357 #endif
1358
1359 #if PLATFORM(MAC)
1360     RefPtr<WebCore::Range> m_lastActionMenuRangeForSelection;
1361     WebCore::HitTestResult m_lastActionMenuHitTestResult;
1362     RefPtr<WebPageOverlay> m_lastActionMenuHitPageOverlay;
1363 #endif
1364
1365     bool m_mainFrameProgressCompleted;
1366     bool m_shouldDispatchFakeMouseMoveEvents;
1367     bool m_isEditorStateMissingPostLayoutData { false };
1368 };
1369
1370 } // namespace WebKit
1371
1372 #endif // WebPage_h