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