8ffc13069c58e5d22b988b4d36428155da10f4f2
[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
530 #if ENABLE(IOS_TOUCH_EVENTS)
531     void dispatchAsynchronousTouchEvents(const Vector<WebTouchEvent, 1>& queue);
532 #endif
533
534     void contentSizeCategoryDidChange(const String&);
535     void executeEditCommandWithCallback(const String&, uint64_t callbackID);
536
537     std::chrono::milliseconds eventThrottlingDelay() const;
538
539     void showInspectorHighlight(const WebCore::Highlight&);
540     void hideInspectorHighlight();
541
542     void showInspectorIndication();
543     void hideInspectorIndication();
544
545     void enableInspectorNodeSearch();
546     void disableInspectorNodeSearch();
547 #endif
548
549     NotificationPermissionRequestManager* notificationPermissionRequestManager();
550
551     void pageDidScroll();
552 #if USE(TILED_BACKING_STORE)
553     void pageDidRequestScroll(const WebCore::IntPoint&);
554     void setFixedVisibleContentRect(const WebCore::IntRect&);
555     void sendViewportAttributesChanged();
556 #endif
557
558 #if ENABLE(CONTEXT_MENUS)
559     WebContextMenu* contextMenu();
560     WebContextMenu* contextMenuAtPointInWindow(const WebCore::IntPoint&);
561 #endif
562     
563     bool hasLocalDataForURL(const WebCore::URL&);
564     String cachedResponseMIMETypeForURL(const WebCore::URL&);
565     String cachedSuggestedFilenameForURL(const WebCore::URL&);
566     PassRefPtr<WebCore::SharedBuffer> cachedResponseDataForURL(const WebCore::URL&);
567
568     static bool canHandleRequest(const WebCore::ResourceRequest&);
569
570     class SandboxExtensionTracker {
571     public:
572         ~SandboxExtensionTracker();
573
574         void invalidate();
575
576         void beginLoad(WebFrame*, const SandboxExtension::Handle& handle);
577         void willPerformLoadDragDestinationAction(PassRefPtr<SandboxExtension> pendingDropSandboxExtension);
578         void didStartProvisionalLoad(WebFrame*);
579         void didCommitProvisionalLoad(WebFrame*);
580         void didFailProvisionalLoad(WebFrame*);
581
582     private:
583         void setPendingProvisionalSandboxExtension(PassRefPtr<SandboxExtension>);
584
585         RefPtr<SandboxExtension> m_pendingProvisionalSandboxExtension;
586         RefPtr<SandboxExtension> m_provisionalSandboxExtension;
587         RefPtr<SandboxExtension> m_committedSandboxExtension;
588     };
589
590     SandboxExtensionTracker& sandboxExtensionTracker() { return m_sandboxExtensionTracker; }
591
592 #if PLATFORM(EFL)
593     void setThemePath(const String&);
594 #endif
595
596 #if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
597     void commitPageTransitionViewport();
598 #endif
599
600 #if PLATFORM(GTK)
601     void setComposition(const String& text, const Vector<WebCore::CompositionUnderline>& underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeLength);
602     void confirmComposition(const String& text, int64_t selectionStart, int64_t selectionLength);
603     void cancelComposition();
604 #endif
605
606 #if PLATFORM (GTK) && HAVE(GTK_GESTURES)
607     void getCenterForZoomGesture(const WebCore::IntPoint& centerInViewCoordinates, WebCore::IntPoint& result);
608 #endif
609
610     void didChangeSelection();
611     void discardedComposition();
612
613 #if PLATFORM(COCOA)
614     void registerUIProcessAccessibilityTokens(const IPC::DataReference& elemenToken, const IPC::DataReference& windowToken);
615     WKAccessibilityWebPageObject* accessibilityRemoteObject();
616     NSObject *accessibilityObjectForMainFramePlugin();
617     const WebCore::FloatPoint& accessibilityPosition() const { return m_accessibilityPosition; }
618     
619     void sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String& textInput);
620
621     void insertTextAsync(const String& text, const EditingRange& replacementRange, bool registerUndoGroup = false);
622     void getMarkedRangeAsync(uint64_t callbackID);
623     void getSelectedRangeAsync(uint64_t callbackID);
624     void characterIndexForPointAsync(const WebCore::IntPoint&, uint64_t callbackID);
625     void firstRectForCharacterRangeAsync(const EditingRange&, uint64_t callbackID);
626     void setCompositionAsync(const String& text, Vector<WebCore::CompositionUnderline> underlines, const EditingRange& selectionRange, const EditingRange& replacementRange);
627     void confirmCompositionAsync();
628
629 #if PLATFORM(MAC)
630     void insertDictatedTextAsync(const String& text, const EditingRange& replacementRange, const Vector<WebCore::DictationAlternative>& dictationAlternativeLocations, bool registerUndoGroup = false);
631     void attributedSubstringForCharacterRangeAsync(const EditingRange&, uint64_t callbackID);
632     void fontAtSelection(uint64_t callbackID);
633 #if !USE(ASYNC_NSTEXTINPUTCLIENT)
634     void insertText(const String& text, const EditingRange& replacementRange, bool& handled, EditorState& newState);
635     void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, const EditingRange& selectionRange, const EditingRange& replacementRange, EditorState& newState);
636     void confirmComposition(EditorState& newState);
637     void insertDictatedText(const String& text, const EditingRange& replacementRange, const Vector<WebCore::DictationAlternative>& dictationAlternativeLocations, bool& handled, EditorState& newState);
638     void getAttributedSubstringFromRange(const EditingRange&, AttributedString&);
639     void getMarkedRange(EditingRange&);
640     void getSelectedRange(EditingRange&);
641     void characterIndexForPoint(const WebCore::IntPoint point, uint64_t& result);
642     void firstRectForCharacterRange(const EditingRange&, WebCore::IntRect& resultRect);
643     void executeKeypressCommands(const Vector<WebCore::KeypressCommand>&, bool& handled, EditorState& newState);
644     void cancelComposition(EditorState& newState);
645 #endif
646 #endif
647
648     void readSelectionFromPasteboard(const WTF::String& pasteboardName, bool& result);
649     void getStringSelectionForPasteboard(WTF::String& stringValue);
650     void getDataSelectionForPasteboard(const WTF::String pasteboardType, SharedMemory::Handle& handle, uint64_t& size);
651     void shouldDelayWindowOrderingEvent(const WebKit::WebMouseEvent&, bool& result);
652     void acceptsFirstMouse(int eventNumber, const WebKit::WebMouseEvent&, bool& result);
653     bool performNonEditingBehaviorForSelector(const String&, WebCore::KeyboardEvent*);
654
655 #if ENABLE(SERVICE_CONTROLS)
656     void replaceSelectionWithPasteboardData(const Vector<String>& types, const IPC::DataReference&);
657 #endif
658
659 #elif PLATFORM(EFL)
660     void confirmComposition(const String& compositionString);
661     void setComposition(const WTF::String& compositionString, const WTF::Vector<WebCore::CompositionUnderline>& underlines, uint64_t cursorPosition);
662     void cancelComposition();
663 #endif
664
665 #if HAVE(ACCESSIBILITY) && (PLATFORM(GTK) || PLATFORM(EFL))
666     void updateAccessibilityTree();
667 #endif
668
669     void setCompositionForTesting(const String& compositionString, uint64_t from, uint64_t length);
670     bool hasCompositionForTesting();
671     void confirmCompositionForTesting(const String& compositionString);
672
673     // FIXME: This a dummy message, to avoid breaking the build for platforms that don't require
674     // any synchronous messages, and should be removed when <rdar://problem/8775115> is fixed.
675     void dummy(bool&);
676
677 #if PLATFORM(COCOA)
678     bool isSpeaking();
679     void speak(const String&);
680     void stopSpeaking();
681
682     void performDictionaryLookupForSelection(WebCore::Frame*, const WebCore::VisibleSelection&, WebCore::TextIndicatorPresentationTransition);
683 #endif
684
685     bool isSmartInsertDeleteEnabled();
686     void setSmartInsertDeleteEnabled(bool);
687
688     bool isSelectTrailingWhitespaceEnabled();
689     void setSelectTrailingWhitespaceEnabled(bool);
690
691     void replaceSelectionWithText(WebCore::Frame*, const String&);
692     void clearSelection();
693     void restoreSelectionInFocusedEditableElement();
694
695 #if ENABLE(DRAG_SUPPORT)
696 #if PLATFORM(GTK)
697     void performDragControllerAction(uint64_t action, WebCore::DragData);
698 #else
699     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&);
700 #endif
701     void dragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t operation);
702
703     void willPerformLoadDragDestinationAction();
704     void mayPerformUploadDragDestinationAction();
705
706     void willStartDrag() { ASSERT(!m_isStartingDrag); m_isStartingDrag = true; }
707     void didStartDrag() { ASSERT(m_isStartingDrag); m_isStartingDrag = false; }
708 #endif // ENABLE(DRAG_SUPPORT)
709
710     void beginPrinting(uint64_t frameID, const PrintInfo&);
711     void endPrinting();
712     void computePagesForPrinting(uint64_t frameID, const PrintInfo&, uint64_t callbackID);
713     void computePagesForPrintingImpl(uint64_t frameID, const PrintInfo&, Vector<WebCore::IntRect>& pageRects, double& totalScaleFactor);
714 #if PLATFORM(COCOA)
715     void drawRectToImage(uint64_t frameID, const PrintInfo&, const WebCore::IntRect&, const WebCore::IntSize&, uint64_t callbackID);
716     void drawPagesToPDF(uint64_t frameID, const PrintInfo&, uint32_t first, uint32_t count, uint64_t callbackID);
717     void drawPagesToPDFImpl(uint64_t frameID, const PrintInfo&, uint32_t first, uint32_t count, RetainPtr<CFMutableDataRef>& pdfPageData);
718 #if PLATFORM(IOS)
719     void computePagesForPrintingAndStartDrawingToPDF(uint64_t frameID, const PrintInfo&, uint32_t firstPage, PassRefPtr<Messages::WebPage::ComputePagesForPrintingAndStartDrawingToPDF::DelayedReply>);
720 #endif
721 #elif PLATFORM(GTK)
722     void drawPagesForPrinting(uint64_t frameID, const PrintInfo&, uint64_t callbackID);
723     void didFinishPrintOperation(const WebCore::ResourceError&, uint64_t callbackID);
724 #endif
725
726     void addResourceRequest(unsigned long, const WebCore::ResourceRequest&);
727     void removeResourceRequest(unsigned long);
728
729     void setMediaVolume(float);
730     void setMuted(bool);
731     void setMayStartMediaWhenInWindow(bool);
732
733     void updateMainFrameScrollOffsetPinning();
734
735     bool mainFrameHasCustomContentProvider() const;
736     void addMIMETypeWithCustomContentProvider(const String&);
737
738     void mainFrameDidLayout();
739
740     bool canRunBeforeUnloadConfirmPanel() const { return m_canRunBeforeUnloadConfirmPanel; }
741     void setCanRunBeforeUnloadConfirmPanel(bool canRunBeforeUnloadConfirmPanel) { m_canRunBeforeUnloadConfirmPanel = canRunBeforeUnloadConfirmPanel; }
742
743     bool canRunModal() const { return m_canRunModal; }
744     void setCanRunModal(bool canRunModal) { m_canRunModal = canRunModal; }
745
746     void runModal();
747
748     void setDeviceScaleFactor(float);
749     float deviceScaleFactor() const;
750
751     void forceRepaintWithoutCallback();
752
753     void unmarkAllMisspellings();
754     void unmarkAllBadGrammar();
755 #if PLATFORM(COCOA)
756     void handleAlternativeTextUIResult(const String&);
757 #endif
758
759     // For testing purpose.
760     void simulateMouseDown(int button, WebCore::IntPoint, int clickCount, WKEventModifiers, double time);
761     void simulateMouseUp(int button, WebCore::IntPoint, int clickCount, WKEventModifiers, double time);
762     void simulateMouseMotion(WebCore::IntPoint, double time);
763
764 #if ENABLE(CONTEXT_MENUS)
765     void contextMenuShowing() { m_isShowingContextMenu = true; }
766 #endif
767
768     void wheelEvent(const WebWheelEvent&);
769
770     void wheelEventHandlersChanged(bool);
771     void recomputeShortCircuitHorizontalWheelEventsState();
772
773     void updateVisibilityState(bool isInitialState = false);
774
775 #if PLATFORM(IOS)
776     void setViewportConfigurationMinimumLayoutSize(const WebCore::FloatSize&);
777     void setMaximumUnobscuredSize(const WebCore::FloatSize&);
778     void setDeviceOrientation(int32_t);
779     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);
780     void synchronizeDynamicViewportUpdate(double& newTargetScale, WebCore::FloatPoint& newScrollPosition, uint64_t& nextValidLayerTreeTransactionID);
781     void updateVisibleContentRects(const VisibleContentRectUpdateInfo&, double oldestTimestamp);
782     bool scaleWasSetByUIProcess() const { return m_scaleWasSetByUIProcess; }
783     void willStartUserTriggeredZooming();
784     void applicationWillResignActive();
785     void applicationWillEnterForeground();
786     void applicationDidBecomeActive();
787     void zoomToRect(WebCore::FloatRect, double minimumScale, double maximumScale);
788     void completePendingSyntheticClickForContentChangeObserver();
789 #endif
790
791 #if ENABLE(IOS_TOUCH_EVENTS)
792     void dispatchTouchEvent(const WebTouchEvent&, bool& handled);
793 #endif
794
795 #if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL)
796     uint64_t nativeWindowHandle() { return m_nativeWindowHandle; }
797 #endif
798
799     bool shouldUseCustomContentProviderForResponse(const WebCore::ResourceResponse&);
800     bool canPluginHandleResponse(const WebCore::ResourceResponse& response);
801
802     bool asynchronousPluginInitializationEnabled() const { return m_asynchronousPluginInitializationEnabled; }
803     void setAsynchronousPluginInitializationEnabled(bool enabled) { m_asynchronousPluginInitializationEnabled = enabled; }
804     bool asynchronousPluginInitializationEnabledForAllPlugins() const { return m_asynchronousPluginInitializationEnabledForAllPlugins; }
805     void setAsynchronousPluginInitializationEnabledForAllPlugins(bool enabled) { m_asynchronousPluginInitializationEnabledForAllPlugins = enabled; }
806     bool artificialPluginInitializationDelayEnabled() const { return m_artificialPluginInitializationDelayEnabled; }
807     void setArtificialPluginInitializationDelayEnabled(bool enabled) { m_artificialPluginInitializationDelayEnabled = enabled; }
808     void setTabToLinksEnabled(bool enabled) { m_tabToLinks = enabled; }
809     bool tabToLinksEnabled() const { return m_tabToLinks; }
810
811     bool scrollingPerformanceLoggingEnabled() const { return m_scrollingPerformanceLoggingEnabled; }
812     void setScrollingPerformanceLoggingEnabled(bool);
813
814 #if PLATFORM(COCOA)
815     bool shouldUsePDFPlugin() const;
816     bool pdfPluginEnabled() const { return m_pdfPluginEnabled; }
817     void setPDFPluginEnabled(bool enabled) { m_pdfPluginEnabled = enabled; }
818 #endif
819
820     void savePDFToFileInDownloadsFolder(const String& suggestedFilename, const String& originatingURLString, const uint8_t* data, unsigned long size);
821 #if PLATFORM(COCOA)
822     void savePDFToTemporaryFolderAndOpenWithNativeApplication(const String& suggestedFilename, const String& originatingURLString, const uint8_t* data, unsigned long size, const String& pdfUUID);
823 #endif
824
825     bool mainFrameIsScrollable() const { return m_mainFrameIsScrollable; }
826
827     void setMinimumLayoutSize(const WebCore::IntSize&);
828     WebCore::IntSize minimumLayoutSize() const { return m_minimumLayoutSize; }
829
830     void setAutoSizingShouldExpandToViewHeight(bool shouldExpand);
831     bool autoSizingShouldExpandToViewHeight() { return m_autoSizingShouldExpandToViewHeight; }
832
833     bool canShowMIMEType(const String& MIMEType) const;
834
835     void addTextCheckingRequest(uint64_t requestID, PassRefPtr<WebCore::TextCheckingRequest>);
836     void didFinishCheckingText(uint64_t requestID, const Vector<WebCore::TextCheckingResult>&);
837     void didCancelCheckingText(uint64_t requestID);
838
839 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
840     void determinePrimarySnapshottedPlugIn();
841     void determinePrimarySnapshottedPlugInTimerFired();
842     void resetPrimarySnapshottedPlugIn();
843     bool matchesPrimaryPlugIn(const String& pageOrigin, const String& pluginOrigin, const String& mimeType) const;
844     bool plugInIntersectsSearchRect(WebCore::HTMLPlugInImageElement& pluginImageElement);
845     bool plugInIsPrimarySize(WebCore::HTMLPlugInImageElement& pluginImageElement, unsigned &pluginArea);
846 #endif
847
848     unsigned extendIncrementalRenderingSuppression();
849     void stopExtendingIncrementalRenderingSuppression(unsigned token);
850     bool shouldExtendIncrementalRenderingSuppression() { return !m_activeRenderingSuppressionTokens.isEmpty(); }
851
852     WebCore::ScrollPinningBehavior scrollPinningBehavior() { return m_scrollPinningBehavior; }
853     void setScrollPinningBehavior(uint32_t /* WebCore::ScrollPinningBehavior */ pinning);
854
855     PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(WebCore::Frame&, const WebCore::ResourceRequest&, const WebCore::SubstituteData&);
856
857     void getBytecodeProfile(uint64_t callbackID);
858     
859     // Some platforms require accessibility-enabled processes to spin the run loop so that the WebProcess doesn't hang.
860     // While this is not ideal, it does not have to be applied to every platform at the moment.
861     static bool synchronousMessagesShouldSpinRunLoop();
862
863 #if ENABLE(SERVICE_CONTROLS) || ENABLE(TELEPHONE_NUMBER_DETECTION)
864     void handleTelephoneNumberClick(const String& number, const WebCore::IntPoint&);
865     void handleSelectionServiceClick(WebCore::FrameSelection&, const Vector<String>& telephoneNumbers, const WebCore::IntPoint&);
866 #endif
867
868     void didChangeScrollOffsetForFrame(WebCore::Frame*);
869
870     void setMainFrameProgressCompleted(bool completed) { m_mainFrameProgressCompleted = completed; }
871     bool shouldDispatchFakeMouseMoveEvents() const { return m_shouldDispatchFakeMouseMoveEvents; }
872
873     void setPageActivityState(WebCore::PageActivityState::Flags);
874
875     void postMessage(const String& messageName, API::Object* messageBody);
876     void postSynchronousMessage(const String& messageName, API::Object* messageBody, RefPtr<API::Object>& returnData);
877
878 private:
879     WebPage(uint64_t pageID, const WebPageCreationParameters&);
880
881     // IPC::MessageSender
882     virtual IPC::Connection* messageSenderConnection() override;
883     virtual uint64_t messageSenderDestinationID() override;
884
885     void platformInitialize();
886     void platformDetach();
887     void platformEditorState(WebCore::Frame&, EditorState& result, IncludePostLayoutDataHint) const;
888
889     void didReceiveWebPageMessage(IPC::Connection&, IPC::MessageDecoder&);
890     void didReceiveSyncWebPageMessage(IPC::Connection&, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&);
891
892 #if PLATFORM(IOS)
893     void resetViewportDefaultConfiguration(WebFrame* mainFrame);
894     void viewportConfigurationChanged();
895     void updateViewportSizeForCSSViewportUnits();
896
897     static void convertSelectionRectsToRootView(WebCore::FrameView*, Vector<WebCore::SelectionRect>&);
898     PassRefPtr<WebCore::Range> rangeForWebSelectionAtPosition(const WebCore::IntPoint&, const WebCore::VisiblePosition&, SelectionFlags&);
899     PassRefPtr<WebCore::Range> rangeForBlockAtPoint(const WebCore::IntPoint&);
900     void computeExpandAndShrinkThresholdsForHandle(const WebCore::IntPoint&, SelectionHandlePosition, float& growThreshold, float& shrinkThreshold);
901     PassRefPtr<WebCore::Range> changeBlockSelection(const WebCore::IntPoint&, SelectionHandlePosition, float& growThreshold, float& shrinkThreshold, SelectionFlags&);
902     PassRefPtr<WebCore::Range> expandedRangeFromHandle(WebCore::Range*, SelectionHandlePosition);
903     PassRefPtr<WebCore::Range> contractedRangeFromHandle(WebCore::Range* currentRange, SelectionHandlePosition, SelectionFlags&);
904     void getAssistedNodeInformation(AssistedNodeInformation&);
905     void platformInitializeAccessibility();
906     void handleSyntheticClick(WebCore::Node* nodeRespondingToClick, const WebCore::FloatPoint& location);
907     void completeSyntheticClick(WebCore::Node* nodeRespondingToClick, const WebCore::FloatPoint& location);
908     void sendTapHighlightForNodeIfNecessary(uint64_t requestID, WebCore::Node*);
909     void resetTextAutosizingBeforeLayoutIfNeeded(const WebCore::FloatSize& oldSize, const WebCore::FloatSize& newSize);
910     WebCore::VisiblePosition visiblePositionInFocusedNodeForPoint(WebCore::Frame&, const WebCore::IntPoint&);
911 #endif
912 #if !PLATFORM(COCOA)
913     static const char* interpretKeyEvent(const WebCore::KeyboardEvent*);
914 #endif
915     bool performDefaultBehaviorForKeyEvent(const WebKeyboardEvent&);
916
917 #if PLATFORM(MAC)
918     bool executeKeypressCommandsInternal(const Vector<WebCore::KeypressCommand>&, WebCore::KeyboardEvent*);
919 #endif
920
921     String sourceForFrame(WebFrame*);
922
923     void loadDataImpl(uint64_t navigationID, PassRefPtr<WebCore::SharedBuffer>, const String& MIMEType, const String& encodingName, const WebCore::URL& baseURL, const WebCore::URL& failingURL, const UserData&);
924     void loadString(uint64_t navigationID, const String&, const String& MIMEType, const WebCore::URL& baseURL, const WebCore::URL& failingURL, const UserData&);
925
926     bool platformHasLocalDataForURL(const WebCore::URL&);
927
928     // Actions
929     void tryClose();
930     void loadRequest(uint64_t navigationID, const WebCore::ResourceRequest&, const SandboxExtension::Handle&, const UserData&);
931     void loadData(const IPC::DataReference&, const String& MIMEType, const String& encodingName, const String& baseURL, const UserData&);
932     void loadHTMLString(uint64_t navigationID, const String& htmlString, const String& baseURL, const UserData&);
933     void loadAlternateHTMLString(const String& htmlString, const String& baseURL, const String& unreachableURL, const UserData&);
934     void loadPlainTextString(const String&, const UserData&);
935     void loadWebArchiveData(const IPC::DataReference&, const UserData&);
936     void navigateToURLWithSimulatedClick(const String& url, WebCore::IntPoint documentPoint, WebCore::IntPoint screenPoint);
937     void reload(uint64_t navigationID, bool reloadFromOrigin, const SandboxExtension::Handle&);
938     void goForward(uint64_t navigationID, uint64_t);
939     void goBack(uint64_t navigationID, uint64_t);
940     void goToBackForwardItem(uint64_t navigationID, uint64_t);
941     void tryRestoreScrollPosition();
942     void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&, uint64_t callbackID);
943     void setWindowResizerSize(const WebCore::IntSize&);
944     void updateIsInWindow(bool isInitialState = false);
945     void setViewState(WebCore::ViewState::Flags, bool wantsDidUpdateViewState, const Vector<uint64_t>& callbackIDs);
946     void validateCommand(const String&, uint64_t);
947     void executeEditCommand(const String&);
948     void setEditable(bool);
949
950     void updateUserActivity();
951
952     void mouseEvent(const WebMouseEvent&);
953     void mouseEventSyncForTesting(const WebMouseEvent&, bool&);
954     void wheelEventSyncForTesting(const WebWheelEvent&, bool&);
955     void keyEvent(const WebKeyboardEvent&);
956     void keyEventSyncForTesting(const WebKeyboardEvent&, bool&);
957 #if ENABLE(IOS_TOUCH_EVENTS)
958     void touchEventSync(const WebTouchEvent&, bool& handled);
959 #elif ENABLE(TOUCH_EVENTS)
960     void touchEvent(const WebTouchEvent&);
961     void touchEventSyncForTesting(const WebTouchEvent&, bool& handled);
962 #endif
963 #if ENABLE(CONTEXT_MENUS)
964     void contextMenuHidden() { m_isShowingContextMenu = false; }
965 #endif
966
967     static bool scroll(WebCore::Page*, WebCore::ScrollDirection, WebCore::ScrollGranularity);
968     static bool logicalScroll(WebCore::Page*, WebCore::ScrollLogicalDirection, WebCore::ScrollGranularity);
969
970     void loadURLInFrame(const String&, uint64_t frameID);
971
972     void restoreSession(const Vector<BackForwardListItemState>&);
973     void didRemoveBackForwardItem(uint64_t);
974
975 #if ENABLE(REMOTE_INSPECTOR)
976     void setAllowsRemoteInspection(bool);
977 #endif
978
979     void setDrawsBackground(bool);
980     void setDrawsTransparentBackground(bool);
981
982     void setTopContentInset(float);
983
984     void viewWillStartLiveResize();
985     void viewWillEndLiveResize();
986
987     void getContentsAsString(uint64_t callbackID);
988 #if ENABLE(MHTML)
989     void getContentsAsMHTMLData(uint64_t callbackID, bool useBinaryEncoding);
990 #endif
991     void getMainResourceDataOfFrame(uint64_t frameID, uint64_t callbackID);
992     void getResourceDataFromFrame(uint64_t frameID, const String& resourceURL, uint64_t callbackID);
993     void getRenderTreeExternalRepresentation(uint64_t callbackID);
994     void getSelectionOrContentsAsString(uint64_t callbackID);
995     void getSelectionAsWebArchiveData(uint64_t callbackID);
996     void getSourceForFrame(uint64_t frameID, uint64_t callbackID);
997     void getWebArchiveOfFrame(uint64_t frameID, uint64_t callbackID);
998     void runJavaScriptInMainFrame(const String&, uint64_t callbackID);
999     void forceRepaint(uint64_t callbackID);
1000     void takeSnapshot(WebCore::IntRect snapshotRect, WebCore::IntSize bitmapSize, uint32_t options, uint64_t callbackID);
1001
1002     void preferencesDidChange(const WebPreferencesStore&);
1003     void platformPreferencesDidChange(const WebPreferencesStore&);
1004     void updatePreferences(const WebPreferencesStore&);
1005
1006     void didReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, uint32_t policyAction, uint64_t navigationID, uint64_t downloadID);
1007     void setUserAgent(const String&);
1008     void setCustomTextEncodingName(const String&);
1009     void suspendActiveDOMObjectsAndAnimations();
1010     void resumeActiveDOMObjectsAndAnimations();
1011
1012 #if PLATFORM(COCOA)
1013     void performDictionaryLookupAtLocation(const WebCore::FloatPoint&);
1014     void performDictionaryLookupOfCurrentSelection();
1015     void performDictionaryLookupForRange(WebCore::Frame*, WebCore::Range&, NSDictionary *options, WebCore::TextIndicatorPresentationTransition);
1016     DictionaryPopupInfo dictionaryPopupInfoForRange(WebCore::Frame* frame, WebCore::Range& range, NSDictionary **options, WebCore::TextIndicatorPresentationTransition presentationTransition);
1017 #if ENABLE(PDFKIT_PLUGIN)
1018     DictionaryPopupInfo dictionaryPopupInfoForSelectionInPDFPlugin(PDFSelection *, PDFPlugin&, NSDictionary **options, WebCore::TextIndicatorPresentationTransition);
1019 #endif
1020
1021     void windowAndViewFramesChanged(const WebCore::FloatRect& windowFrameInScreenCoordinates, const WebCore::FloatRect& windowFrameInUnflippedScreenCoordinates, const WebCore::FloatRect& viewFrameInWindowCoordinates, const WebCore::FloatPoint& accessibilityViewCoordinates);
1022
1023     RetainPtr<PDFDocument> pdfDocumentForPrintingFrame(WebCore::Frame*);
1024     void computePagesForPrintingPDFDocument(uint64_t frameID, const PrintInfo&, Vector<WebCore::IntRect>& resultPageRects);
1025     void drawPDFDocument(CGContextRef, PDFDocument *, const PrintInfo&, const WebCore::IntRect&);
1026     void drawPagesToPDFFromPDFDocument(CGContextRef, PDFDocument *, const PrintInfo&, uint32_t first, uint32_t count);
1027 #endif
1028
1029     void setMainFrameIsScrollable(bool);
1030
1031     void unapplyEditCommand(uint64_t commandID);
1032     void reapplyEditCommand(uint64_t commandID);
1033     void didRemoveEditCommand(uint64_t commandID);
1034
1035     void findString(const String&, uint32_t findOptions, uint32_t maxMatchCount);
1036     void findStringMatches(const String&, uint32_t findOptions, uint32_t maxMatchCount);
1037     void getImageForFindMatch(uint32_t matchIndex);
1038     void selectFindMatch(uint32_t matchIndex);
1039     void hideFindUI();
1040     void countStringMatches(const String&, uint32_t findOptions, uint32_t maxMatchCount);
1041
1042 #if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
1043     void findZoomableAreaForPoint(const WebCore::IntPoint&, const WebCore::IntSize& area);
1044 #endif
1045
1046     void didChangeSelectedIndexForActivePopupMenu(int32_t newIndex);
1047     void setTextForActivePopupMenu(int32_t index);
1048
1049 #if PLATFORM(GTK)
1050     void failedToShowPopupMenu();
1051 #endif
1052
1053 #if PLATFORM(IOS)
1054     void didChooseFilesForOpenPanelWithDisplayStringAndIcon(const Vector<String>&, const String& displayString, const IPC::DataReference& iconData);
1055 #endif
1056     void didChooseFilesForOpenPanel(const Vector<String>&);
1057     void didCancelForOpenPanel();
1058 #if ENABLE(SANDBOX_EXTENSIONS)
1059     void extendSandboxForFileFromOpenPanel(const SandboxExtension::Handle&);
1060 #endif
1061
1062     void didReceiveGeolocationPermissionDecision(uint64_t geolocationID, bool allowed);
1063
1064     void didReceiveNotificationPermissionDecision(uint64_t notificationID, bool allowed);
1065
1066 #if ENABLE(MEDIA_STREAM)
1067     void didReceiveUserMediaPermissionDecision(uint64_t userMediaID, bool allowed);
1068 #endif
1069
1070     void advanceToNextMisspelling(bool startBeforeSelection);
1071     void changeSpellingToWord(const String& word);
1072 #if USE(APPKIT)
1073     void uppercaseWord();
1074     void lowercaseWord();
1075     void capitalizeWord();
1076 #endif
1077
1078 #if ENABLE(CONTEXT_MENUS)
1079     void didSelectItemFromActiveContextMenu(const WebContextMenuItemData&);
1080 #endif
1081
1082     void changeSelectedIndex(int32_t index);
1083     void setCanStartMediaTimerFired();
1084
1085     bool canHandleUserEvents() const;
1086
1087     static bool platformCanHandleRequest(const WebCore::ResourceRequest&);
1088
1089     static PluginView* focusedPluginViewForFrame(WebCore::Frame&);
1090     static PluginView* pluginViewForFrame(WebCore::Frame*);
1091
1092     static PassRefPtr<WebCore::Range> rangeFromEditingRange(WebCore::Frame&, const EditingRange&);
1093
1094     void reportUsedFeatures();
1095
1096 #if PLATFORM(MAC)
1097     void performActionMenuHitTestAtLocation(WebCore::FloatPoint, bool forImmediateAction);
1098     PassRefPtr<WebCore::Range> lookupTextAtLocation(WebCore::FloatPoint, NSDictionary **options);
1099     void selectLastActionMenuRange();
1100     void focusAndSelectLastActionMenuHitTestResult();
1101     void immediateActionDidUpdate();
1102     void immediateActionDidCancel();
1103     void immediateActionDidComplete();
1104     void setFont(const String& fontFamily, double fontSize, uint64_t fontTraits);
1105
1106     void dataDetectorsDidPresentUI(WebCore::PageOverlay::PageOverlayID);
1107     void dataDetectorsDidChangeUI(WebCore::PageOverlay::PageOverlayID);
1108     void dataDetectorsDidHideUI(WebCore::PageOverlay::PageOverlayID);
1109 #endif
1110
1111     void setShouldDispatchFakeMouseMoveEvents(bool dispatch) { m_shouldDispatchFakeMouseMoveEvents = dispatch; }
1112
1113 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
1114     void playbackTargetSelected(uint64_t, const WebCore::MediaPlaybackTargetContext& outputDevice) const;
1115     void playbackTargetAvailabilityDidChange(uint64_t, bool);
1116     void setShouldPlayToPlaybackTarget(uint64_t, bool);
1117 #endif
1118
1119     uint64_t m_pageID;
1120
1121     std::unique_ptr<WebCore::Page> m_page;
1122     RefPtr<WebFrame> m_mainFrame;
1123     RefPtr<InjectedBundleBackForwardList> m_backForwardList;
1124
1125     RefPtr<WebPageGroupProxy> m_pageGroup;
1126
1127     String m_userAgent;
1128
1129     WebCore::IntSize m_viewSize;
1130     std::unique_ptr<DrawingArea> m_drawingArea;
1131
1132     HashSet<PluginView*> m_pluginViews;
1133     bool m_hasSeenPlugin;
1134
1135     HashMap<uint64_t, RefPtr<WebCore::TextCheckingRequest>> m_pendingTextCheckingRequestMap;
1136
1137     bool m_useFixedLayout;
1138
1139     bool m_drawsBackground;
1140     bool m_drawsTransparentBackground;
1141
1142     WebCore::Color m_underlayColor;
1143
1144     bool m_isInRedo;
1145     bool m_isClosed;
1146
1147     bool m_tabToLinks;
1148     
1149     bool m_asynchronousPluginInitializationEnabled;
1150     bool m_asynchronousPluginInitializationEnabledForAllPlugins;
1151     bool m_artificialPluginInitializationDelayEnabled;
1152
1153     bool m_scrollingPerformanceLoggingEnabled;
1154
1155     bool m_mainFrameIsScrollable;
1156
1157 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
1158     bool m_readyToFindPrimarySnapshottedPlugin;
1159     bool m_didFindPrimarySnapshottedPlugin;
1160     unsigned m_numberOfPrimarySnapshotDetectionAttempts;
1161     String m_primaryPlugInPageOrigin;
1162     String m_primaryPlugInOrigin;
1163     String m_primaryPlugInMimeType;
1164     RunLoop::Timer<WebPage> m_determinePrimarySnapshottedPlugInTimer;
1165 #endif
1166
1167     // The layer hosting mode.
1168     LayerHostingMode m_layerHostingMode;
1169
1170 #if PLATFORM(COCOA)
1171     bool m_pdfPluginEnabled;
1172
1173     bool m_hasCachedWindowFrame;
1174
1175     // The frame of the containing window in screen coordinates.
1176     WebCore::FloatRect m_windowFrameInScreenCoordinates;
1177
1178     // The frame of the containing window in unflipped screen coordinates.
1179     WebCore::FloatRect m_windowFrameInUnflippedScreenCoordinates;
1180
1181     // The frame of the view in window coordinates.
1182     WebCore::FloatRect m_viewFrameInWindowCoordinates;
1183
1184     // The accessibility position of the view.
1185     WebCore::FloatPoint m_accessibilityPosition;
1186     
1187     RetainPtr<WKAccessibilityWebPageObject> m_mockAccessibilityElement;
1188
1189     ViewGestureGeometryCollector m_viewGestureGeometryCollector;
1190
1191 #elif HAVE(ACCESSIBILITY) && (PLATFORM(GTK) || PLATFORM(EFL))
1192     GRefPtr<WebPageAccessibilityObject> m_accessibilityObject;
1193 #endif
1194
1195 #if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL)
1196     // Our view's window in the UI process.
1197     uint64_t m_nativeWindowHandle;
1198 #endif
1199
1200 #if !PLATFORM(IOS)
1201     RefPtr<PageBanner> m_headerBanner;
1202     RefPtr<PageBanner> m_footerBanner;
1203 #endif // !PLATFORM(IOS)
1204
1205     RunLoop::Timer<WebPage> m_setCanStartMediaTimer;
1206     bool m_mayStartMediaWhenInWindow;
1207
1208     HashMap<uint64_t, RefPtr<WebUndoStep>> m_undoStepMap;
1209
1210     WebCore::IntSize m_windowResizerSize;
1211
1212 #if ENABLE(CONTEXT_MENUS)
1213     std::unique_ptr<API::InjectedBundle::PageContextMenuClient> m_contextMenuClient;
1214 #endif
1215     InjectedBundlePageEditorClient m_editorClient;
1216     std::unique_ptr<API::InjectedBundle::FormClient> m_formClient;
1217     InjectedBundlePageLoaderClient m_loaderClient;
1218     InjectedBundlePagePolicyClient m_policyClient;
1219     InjectedBundlePageResourceLoadClient m_resourceLoadClient;
1220     std::unique_ptr<API::InjectedBundle::PageUIClient> m_uiClient;
1221 #if ENABLE(FULLSCREEN_API)
1222     InjectedBundlePageFullScreenClient m_fullScreenClient;
1223 #endif
1224     InjectedBundlePageDiagnosticLoggingClient m_logDiagnosticMessageClient;
1225
1226     FindController m_findController;
1227
1228     RefPtr<WebInspector> m_inspector;
1229     RefPtr<WebInspectorUI> m_inspectorUI;
1230 #if PLATFORM(IOS)
1231     RefPtr<WebVideoFullscreenManager> m_videoFullscreenManager;
1232 #endif
1233 #if ENABLE(FULLSCREEN_API)
1234     RefPtr<WebFullScreenManager> m_fullScreenManager;
1235 #endif
1236     RefPtr<WebPopupMenu> m_activePopupMenu;
1237 #if ENABLE(CONTEXT_MENUS)
1238     RefPtr<WebContextMenu> m_contextMenu;
1239 #endif
1240 #if ENABLE(INPUT_TYPE_COLOR)
1241     WebColorChooser* m_activeColorChooser;
1242 #endif
1243     RefPtr<WebOpenPanelResultListener> m_activeOpenPanelResultListener;
1244     RefPtr<NotificationPermissionRequestManager> m_notificationPermissionRequestManager;
1245
1246     RefPtr<WebUserContentController> m_userContentController;
1247
1248 #if ENABLE(GEOLOCATION)
1249     GeolocationPermissionRequestManager m_geolocationPermissionRequestManager;
1250 #endif
1251
1252 #if ENABLE(MEDIA_STREAM)
1253     UserMediaPermissionRequestManager m_userMediaPermissionRequestManager;
1254 #endif
1255
1256     std::unique_ptr<WebCore::PrintContext> m_printContext;
1257 #if PLATFORM(GTK)
1258     RefPtr<WebPrintOperationGtk> m_printOperation;
1259 #endif
1260
1261     SandboxExtensionTracker m_sandboxExtensionTracker;
1262
1263     RefPtr<SandboxExtension> m_pendingDropSandboxExtension;
1264     Vector<RefPtr<SandboxExtension>> m_pendingDropExtensionsForFileUpload;
1265
1266     bool m_canRunBeforeUnloadConfirmPanel;
1267
1268     bool m_canRunModal;
1269     bool m_isRunningModal;
1270
1271 #if ENABLE(DRAG_SUPPORT)
1272     bool m_isStartingDrag;
1273 #endif
1274
1275     bool m_cachedMainFrameIsPinnedToLeftSide;
1276     bool m_cachedMainFrameIsPinnedToRightSide;
1277     bool m_cachedMainFrameIsPinnedToTopSide;
1278     bool m_cachedMainFrameIsPinnedToBottomSide;
1279     bool m_canShortCircuitHorizontalWheelEvents;
1280     bool m_hasWheelEventHandlers;
1281
1282     unsigned m_cachedPageCount;
1283
1284     HashSet<unsigned long> m_trackedNetworkResourceRequestIdentifiers;
1285
1286     WebCore::IntSize m_minimumLayoutSize;
1287     bool m_autoSizingShouldExpandToViewHeight;
1288
1289 #if ENABLE(CONTEXT_MENUS)
1290     bool m_isShowingContextMenu;
1291 #endif
1292     
1293 #if PLATFORM(IOS)
1294     RefPtr<WebCore::Node> m_assistedNode;
1295     RefPtr<WebCore::Range> m_currentWordRange;
1296     RefPtr<WebCore::Node> m_interactionNode;
1297     WebCore::IntPoint m_lastInteractionLocation;
1298     
1299     enum SelectionAnchor {
1300         Start,
1301         End
1302     };
1303     SelectionAnchor m_selectionAnchor;
1304
1305     RefPtr<WebCore::Node> m_potentialTapNode;
1306     WebCore::FloatPoint m_potentialTapLocation;
1307
1308     WebCore::ViewportConfiguration m_viewportConfiguration;
1309     uint64_t m_firstLayerTreeTransactionIDAfterDidCommitLoad;
1310     bool m_hasReceivedVisibleContentRectsAfterDidCommitLoad;
1311     bool m_scaleWasSetByUIProcess;
1312     bool m_userHasChangedPageScaleFactor;
1313     bool m_hasStablePageScaleFactor;
1314     bool m_userIsInteracting;
1315     bool m_hasPendingBlurNotification;
1316     bool m_useTestingViewportConfiguration;
1317     bool m_isInStableState;
1318     std::chrono::milliseconds m_oldestNonStableUpdateVisibleContentRectsTimestamp;
1319     std::chrono::milliseconds m_estimatedLatency;
1320     WebCore::FloatSize m_screenSize;
1321     WebCore::FloatSize m_availableScreenSize;
1322     RefPtr<WebCore::Range> m_currentBlockSelection;
1323     WebCore::IntSize m_blockSelectionDesiredSize;
1324     WebCore::FloatSize m_maximumUnobscuredSize;
1325     int32_t m_deviceOrientation;
1326     bool m_inDynamicSizeUpdate;
1327     HashMap<std::pair<WebCore::IntSize, double>, WebCore::IntPoint> m_dynamicSizeUpdateHistory;
1328     RefPtr<WebCore::Node> m_pendingSyntheticClickNode;
1329     WebCore::FloatPoint m_pendingSyntheticClickLocation;
1330 #endif
1331
1332     WebInspectorClient* m_inspectorClient;
1333
1334     HashSet<String, CaseFoldingHash> m_mimeTypesWithCustomContentProviders;
1335     WebCore::Color m_backgroundColor;
1336
1337     HashSet<unsigned> m_activeRenderingSuppressionTokens;
1338     unsigned m_maximumRenderingSuppressionToken;
1339     
1340     WebCore::ScrollPinningBehavior m_scrollPinningBehavior;
1341
1342     bool m_useAsyncScrolling;
1343
1344     WebCore::ViewState::Flags m_viewState;
1345     WebCore::PageActivityState::Flags m_activityState;
1346
1347     bool m_processSuppressionEnabled;
1348     UserActivity m_userActivity;
1349
1350     uint64_t m_pendingNavigationID;
1351
1352     double m_viewScaleFactor { 1 };
1353
1354 #if ENABLE(WEBGL)
1355     WebCore::WebGLLoadPolicy m_systemWebGLPolicy;
1356 #endif
1357
1358 #if PLATFORM(MAC)
1359     RefPtr<WebCore::Range> m_lastActionMenuRangeForSelection;
1360     WebCore::HitTestResult m_lastActionMenuHitTestResult;
1361     RefPtr<WebPageOverlay> m_lastActionMenuHitPageOverlay;
1362 #endif
1363
1364     bool m_mainFrameProgressCompleted;
1365     bool m_shouldDispatchFakeMouseMoveEvents;
1366     bool m_isEditorStateMissingPostLayoutData { false };
1367 };
1368
1369 } // namespace WebKit
1370
1371 #endif // WebPage_h