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