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