6cb709e224030e91108a031643b9d33f01d31742
[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     void updateMainFrameScrollOffsetPinning();
744
745     bool mainFrameHasCustomContentProvider() const;
746     void addMIMETypeWithCustomContentProvider(const String&);
747
748     void mainFrameDidLayout();
749
750     bool canRunBeforeUnloadConfirmPanel() const { return m_canRunBeforeUnloadConfirmPanel; }
751     void setCanRunBeforeUnloadConfirmPanel(bool canRunBeforeUnloadConfirmPanel) { m_canRunBeforeUnloadConfirmPanel = canRunBeforeUnloadConfirmPanel; }
752
753     bool canRunModal() const { return m_canRunModal; }
754     void setCanRunModal(bool canRunModal) { m_canRunModal = canRunModal; }
755
756     void runModal();
757
758     void setDeviceScaleFactor(float);
759     float deviceScaleFactor() const;
760
761     void forceRepaintWithoutCallback();
762
763     void unmarkAllMisspellings();
764     void unmarkAllBadGrammar();
765 #if PLATFORM(COCOA)
766     void handleAlternativeTextUIResult(const String&);
767 #endif
768
769     // For testing purpose.
770     void simulateMouseDown(int button, WebCore::IntPoint, int clickCount, WKEventModifiers, double time);
771     void simulateMouseUp(int button, WebCore::IntPoint, int clickCount, WKEventModifiers, double time);
772     void simulateMouseMotion(WebCore::IntPoint, double time);
773
774 #if ENABLE(CONTEXT_MENUS)
775     void contextMenuShowing() { m_isShowingContextMenu = true; }
776 #endif
777
778     void wheelEvent(const WebWheelEvent&);
779
780     void wheelEventHandlersChanged(bool);
781     void recomputeShortCircuitHorizontalWheelEventsState();
782
783     void updateVisibilityState(bool isInitialState = false);
784
785 #if PLATFORM(IOS)
786     void setViewportConfigurationMinimumLayoutSize(const WebCore::FloatSize&);
787     void setMaximumUnobscuredSize(const WebCore::FloatSize&);
788     void setDeviceOrientation(int32_t);
789     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);
790     void synchronizeDynamicViewportUpdate(double& newTargetScale, WebCore::FloatPoint& newScrollPosition, uint64_t& nextValidLayerTreeTransactionID);
791     void updateVisibleContentRects(const VisibleContentRectUpdateInfo&, double oldestTimestamp);
792     bool scaleWasSetByUIProcess() const { return m_scaleWasSetByUIProcess; }
793     void willStartUserTriggeredZooming();
794     void applicationWillResignActive();
795     void applicationDidEnterBackground();
796     void applicationWillEnterForeground();
797     void applicationDidBecomeActive();
798     void zoomToRect(WebCore::FloatRect, double minimumScale, double maximumScale);
799     void completePendingSyntheticClickForContentChangeObserver();
800 #endif
801
802 #if ENABLE(IOS_TOUCH_EVENTS)
803     void dispatchTouchEvent(const WebTouchEvent&, bool& handled);
804 #endif
805
806 #if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL)
807     uint64_t nativeWindowHandle() { return m_nativeWindowHandle; }
808 #endif
809
810     bool shouldUseCustomContentProviderForResponse(const WebCore::ResourceResponse&);
811     bool canPluginHandleResponse(const WebCore::ResourceResponse& response);
812
813     bool asynchronousPluginInitializationEnabled() const { return m_asynchronousPluginInitializationEnabled; }
814     void setAsynchronousPluginInitializationEnabled(bool enabled) { m_asynchronousPluginInitializationEnabled = enabled; }
815     bool asynchronousPluginInitializationEnabledForAllPlugins() const { return m_asynchronousPluginInitializationEnabledForAllPlugins; }
816     void setAsynchronousPluginInitializationEnabledForAllPlugins(bool enabled) { m_asynchronousPluginInitializationEnabledForAllPlugins = enabled; }
817     bool artificialPluginInitializationDelayEnabled() const { return m_artificialPluginInitializationDelayEnabled; }
818     void setArtificialPluginInitializationDelayEnabled(bool enabled) { m_artificialPluginInitializationDelayEnabled = enabled; }
819     void setTabToLinksEnabled(bool enabled) { m_tabToLinks = enabled; }
820     bool tabToLinksEnabled() const { return m_tabToLinks; }
821
822     bool scrollingPerformanceLoggingEnabled() const { return m_scrollingPerformanceLoggingEnabled; }
823     void setScrollingPerformanceLoggingEnabled(bool);
824
825 #if PLATFORM(COCOA)
826     bool shouldUsePDFPlugin() const;
827     bool pdfPluginEnabled() const { return m_pdfPluginEnabled; }
828     void setPDFPluginEnabled(bool enabled) { m_pdfPluginEnabled = enabled; }
829 #endif
830
831     void savePDFToFileInDownloadsFolder(const String& suggestedFilename, const String& originatingURLString, const uint8_t* data, unsigned long size);
832 #if PLATFORM(COCOA)
833     void savePDFToTemporaryFolderAndOpenWithNativeApplication(const String& suggestedFilename, const String& originatingURLString, const uint8_t* data, unsigned long size, const String& pdfUUID);
834 #endif
835
836     bool mainFrameIsScrollable() const { return m_mainFrameIsScrollable; }
837
838     void setMinimumLayoutSize(const WebCore::IntSize&);
839     WebCore::IntSize minimumLayoutSize() const { return m_minimumLayoutSize; }
840
841     void setAutoSizingShouldExpandToViewHeight(bool shouldExpand);
842     bool autoSizingShouldExpandToViewHeight() { return m_autoSizingShouldExpandToViewHeight; }
843
844     bool canShowMIMEType(const String& MIMEType) const;
845
846     void addTextCheckingRequest(uint64_t requestID, PassRefPtr<WebCore::TextCheckingRequest>);
847     void didFinishCheckingText(uint64_t requestID, const Vector<WebCore::TextCheckingResult>&);
848     void didCancelCheckingText(uint64_t requestID);
849
850 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
851     void determinePrimarySnapshottedPlugIn();
852     void determinePrimarySnapshottedPlugInTimerFired();
853     void resetPrimarySnapshottedPlugIn();
854     bool matchesPrimaryPlugIn(const String& pageOrigin, const String& pluginOrigin, const String& mimeType) const;
855     bool plugInIntersectsSearchRect(WebCore::HTMLPlugInImageElement& pluginImageElement);
856     bool plugInIsPrimarySize(WebCore::HTMLPlugInImageElement& pluginImageElement, unsigned &pluginArea);
857 #endif
858
859     unsigned extendIncrementalRenderingSuppression();
860     void stopExtendingIncrementalRenderingSuppression(unsigned token);
861     bool shouldExtendIncrementalRenderingSuppression() { return !m_activeRenderingSuppressionTokens.isEmpty(); }
862
863     WebCore::ScrollPinningBehavior scrollPinningBehavior() { return m_scrollPinningBehavior; }
864     void setScrollPinningBehavior(uint32_t /* WebCore::ScrollPinningBehavior */ pinning);
865
866     WTF::Optional<WebCore::ScrollbarOverlayStyle> scrollbarOverlayStyle() { return m_scrollbarOverlayStyle; }
867     void setScrollbarOverlayStyle(WTF::Optional<uint32_t /* WebCore::ScrollbarOverlayStyle */> scrollbarStyle);
868
869     PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(WebCore::Frame&, const WebCore::ResourceRequest&, const WebCore::SubstituteData&);
870
871     void getBytecodeProfile(uint64_t callbackID);
872     
873     // Some platforms require accessibility-enabled processes to spin the run loop so that the WebProcess doesn't hang.
874     // While this is not ideal, it does not have to be applied to every platform at the moment.
875     static bool synchronousMessagesShouldSpinRunLoop();
876
877 #if ENABLE(SERVICE_CONTROLS) || ENABLE(TELEPHONE_NUMBER_DETECTION)
878     void handleTelephoneNumberClick(const String& number, const WebCore::IntPoint&);
879     void handleSelectionServiceClick(WebCore::FrameSelection&, const Vector<String>& telephoneNumbers, const WebCore::IntPoint&);
880 #endif
881
882     void didChangeScrollOffsetForFrame(WebCore::Frame*);
883
884     void setMainFrameProgressCompleted(bool completed) { m_mainFrameProgressCompleted = completed; }
885     bool shouldDispatchFakeMouseMoveEvents() const { return m_shouldDispatchFakeMouseMoveEvents; }
886
887     void setPageActivityState(WebCore::PageActivityState::Flags);
888
889     void postMessage(const String& messageName, API::Object* messageBody);
890     void postSynchronousMessage(const String& messageName, API::Object* messageBody, RefPtr<API::Object>& returnData);
891
892 private:
893     WebPage(uint64_t pageID, const WebPageCreationParameters&);
894
895     // IPC::MessageSender
896     virtual IPC::Connection* messageSenderConnection() override;
897     virtual uint64_t messageSenderDestinationID() override;
898
899     void platformInitialize();
900     void platformDetach();
901     void platformEditorState(WebCore::Frame&, EditorState& result, IncludePostLayoutDataHint) const;
902
903     void didReceiveWebPageMessage(IPC::Connection&, IPC::MessageDecoder&);
904     void didReceiveSyncWebPageMessage(IPC::Connection&, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&);
905
906 #if PLATFORM(IOS)
907     void resetViewportDefaultConfiguration(WebFrame* mainFrame);
908     void viewportConfigurationChanged();
909     void updateViewportSizeForCSSViewportUnits();
910
911     static void convertSelectionRectsToRootView(WebCore::FrameView*, Vector<WebCore::SelectionRect>&);
912     PassRefPtr<WebCore::Range> rangeForWebSelectionAtPosition(const WebCore::IntPoint&, const WebCore::VisiblePosition&, SelectionFlags&);
913     PassRefPtr<WebCore::Range> rangeForBlockAtPoint(const WebCore::IntPoint&);
914     void computeExpandAndShrinkThresholdsForHandle(const WebCore::IntPoint&, SelectionHandlePosition, float& growThreshold, float& shrinkThreshold);
915     PassRefPtr<WebCore::Range> changeBlockSelection(const WebCore::IntPoint&, SelectionHandlePosition, float& growThreshold, float& shrinkThreshold, SelectionFlags&);
916     PassRefPtr<WebCore::Range> expandedRangeFromHandle(WebCore::Range*, SelectionHandlePosition);
917     PassRefPtr<WebCore::Range> contractedRangeFromHandle(WebCore::Range* currentRange, SelectionHandlePosition, SelectionFlags&);
918     void getAssistedNodeInformation(AssistedNodeInformation&);
919     void platformInitializeAccessibility();
920     void handleSyntheticClick(WebCore::Node* nodeRespondingToClick, const WebCore::FloatPoint& location);
921     void completeSyntheticClick(WebCore::Node* nodeRespondingToClick, const WebCore::FloatPoint& location);
922     void sendTapHighlightForNodeIfNecessary(uint64_t requestID, WebCore::Node*);
923     void resetTextAutosizingBeforeLayoutIfNeeded(const WebCore::FloatSize& oldSize, const WebCore::FloatSize& newSize);
924     WebCore::VisiblePosition visiblePositionInFocusedNodeForPoint(WebCore::Frame&, const WebCore::IntPoint&);
925     void volatilityTimerFired();
926 #endif
927 #if !PLATFORM(COCOA)
928     static const char* interpretKeyEvent(const WebCore::KeyboardEvent*);
929 #endif
930     bool performDefaultBehaviorForKeyEvent(const WebKeyboardEvent&);
931
932 #if PLATFORM(MAC)
933     bool executeKeypressCommandsInternal(const Vector<WebCore::KeypressCommand>&, WebCore::KeyboardEvent*);
934 #endif
935
936     String sourceForFrame(WebFrame*);
937
938     void loadDataImpl(uint64_t navigationID, PassRefPtr<WebCore::SharedBuffer>, const String& MIMEType, const String& encodingName, const WebCore::URL& baseURL, const WebCore::URL& failingURL, const UserData&);
939     void loadString(uint64_t navigationID, const String&, const String& MIMEType, const WebCore::URL& baseURL, const WebCore::URL& failingURL, const UserData&);
940
941     bool platformHasLocalDataForURL(const WebCore::URL&);
942
943     // Actions
944     void tryClose();
945     void loadRequest(uint64_t navigationID, const WebCore::ResourceRequest&, const SandboxExtension::Handle&, uint64_t shouldOpenExternalURLsPolicy, const UserData&);
946     void loadData(const IPC::DataReference&, const String& MIMEType, const String& encodingName, const String& baseURL, const UserData&);
947     void loadHTMLString(uint64_t navigationID, const String& htmlString, const String& baseURL, const UserData&);
948     void loadAlternateHTMLString(const String& htmlString, const String& baseURL, const String& unreachableURL, const String& provisionalLoadErrorURL, const UserData&);
949     void loadPlainTextString(const String&, const UserData&);
950     void loadWebArchiveData(const IPC::DataReference&, const UserData&);
951     void navigateToPDFLinkWithSimulatedClick(const String& url, WebCore::IntPoint documentPoint, WebCore::IntPoint screenPoint);
952     void reload(uint64_t navigationID, bool reloadFromOrigin, const SandboxExtension::Handle&);
953     void goForward(uint64_t navigationID, uint64_t);
954     void goBack(uint64_t navigationID, uint64_t);
955     void goToBackForwardItem(uint64_t navigationID, uint64_t);
956     void tryRestoreScrollPosition();
957     void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&, uint64_t callbackID);
958     void setWindowResizerSize(const WebCore::IntSize&);
959     void updateIsInWindow(bool isInitialState = false);
960     void setViewState(WebCore::ViewState::Flags, bool wantsDidUpdateViewState, const Vector<uint64_t>& callbackIDs);
961     void validateCommand(const String&, uint64_t);
962     void executeEditCommand(const String&);
963     void setEditable(bool);
964
965     void updateUserActivity();
966
967     void mouseEvent(const WebMouseEvent&);
968     void mouseEventSyncForTesting(const WebMouseEvent&, bool&);
969     void wheelEventSyncForTesting(const WebWheelEvent&, bool&);
970     void keyEvent(const WebKeyboardEvent&);
971     void keyEventSyncForTesting(const WebKeyboardEvent&, bool&);
972 #if ENABLE(IOS_TOUCH_EVENTS)
973     void touchEventSync(const WebTouchEvent&, bool& handled);
974 #elif ENABLE(TOUCH_EVENTS)
975     void touchEvent(const WebTouchEvent&);
976     void touchEventSyncForTesting(const WebTouchEvent&, bool& handled);
977 #endif
978 #if ENABLE(CONTEXT_MENUS)
979     void contextMenuHidden() { m_isShowingContextMenu = false; }
980 #endif
981
982     static bool scroll(WebCore::Page*, WebCore::ScrollDirection, WebCore::ScrollGranularity);
983     static bool logicalScroll(WebCore::Page*, WebCore::ScrollLogicalDirection, WebCore::ScrollGranularity);
984
985     void loadURLInFrame(const String&, uint64_t frameID);
986
987     void restoreSession(const Vector<BackForwardListItemState>&);
988     void didRemoveBackForwardItem(uint64_t);
989
990 #if ENABLE(REMOTE_INSPECTOR)
991     void setAllowsRemoteInspection(bool);
992 #endif
993
994     void setDrawsBackground(bool);
995     void setDrawsTransparentBackground(bool);
996
997     void setTopContentInset(float);
998
999     void viewWillStartLiveResize();
1000     void viewWillEndLiveResize();
1001
1002     void getContentsAsString(uint64_t callbackID);
1003 #if ENABLE(MHTML)
1004     void getContentsAsMHTMLData(uint64_t callbackID, bool useBinaryEncoding);
1005 #endif
1006     void getMainResourceDataOfFrame(uint64_t frameID, uint64_t callbackID);
1007     void getResourceDataFromFrame(uint64_t frameID, const String& resourceURL, uint64_t callbackID);
1008     void getRenderTreeExternalRepresentation(uint64_t callbackID);
1009     void getSelectionOrContentsAsString(uint64_t callbackID);
1010     void getSelectionAsWebArchiveData(uint64_t callbackID);
1011     void getSourceForFrame(uint64_t frameID, uint64_t callbackID);
1012     void getWebArchiveOfFrame(uint64_t frameID, uint64_t callbackID);
1013     void runJavaScriptInMainFrame(const String&, uint64_t callbackID);
1014     void forceRepaint(uint64_t callbackID);
1015     void takeSnapshot(WebCore::IntRect snapshotRect, WebCore::IntSize bitmapSize, uint32_t options, uint64_t callbackID);
1016
1017     void preferencesDidChange(const WebPreferencesStore&);
1018     void platformPreferencesDidChange(const WebPreferencesStore&);
1019     void updatePreferences(const WebPreferencesStore&);
1020
1021     void didReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, uint32_t policyAction, uint64_t navigationID, uint64_t downloadID);
1022     void setUserAgent(const String&);
1023     void setCustomTextEncodingName(const String&);
1024     void suspendActiveDOMObjectsAndAnimations();
1025     void resumeActiveDOMObjectsAndAnimations();
1026
1027 #if PLATFORM(COCOA)
1028     void performDictionaryLookupAtLocation(const WebCore::FloatPoint&);
1029     void performDictionaryLookupOfCurrentSelection();
1030     void performDictionaryLookupForRange(WebCore::Frame*, WebCore::Range&, NSDictionary *options, WebCore::TextIndicatorPresentationTransition);
1031     DictionaryPopupInfo dictionaryPopupInfoForRange(WebCore::Frame* frame, WebCore::Range& range, NSDictionary **options, WebCore::TextIndicatorPresentationTransition presentationTransition);
1032 #if ENABLE(PDFKIT_PLUGIN)
1033     DictionaryPopupInfo dictionaryPopupInfoForSelectionInPDFPlugin(PDFSelection *, PDFPlugin&, NSDictionary **options, WebCore::TextIndicatorPresentationTransition);
1034 #endif
1035
1036     void windowAndViewFramesChanged(const WebCore::FloatRect& windowFrameInScreenCoordinates, const WebCore::FloatRect& windowFrameInUnflippedScreenCoordinates, const WebCore::FloatRect& viewFrameInWindowCoordinates, const WebCore::FloatPoint& accessibilityViewCoordinates);
1037
1038     RetainPtr<PDFDocument> pdfDocumentForPrintingFrame(WebCore::Frame*);
1039     void computePagesForPrintingPDFDocument(uint64_t frameID, const PrintInfo&, Vector<WebCore::IntRect>& resultPageRects);
1040     void drawPDFDocument(CGContextRef, PDFDocument *, const PrintInfo&, const WebCore::IntRect&);
1041     void drawPagesToPDFFromPDFDocument(CGContextRef, PDFDocument *, const PrintInfo&, uint32_t first, uint32_t count);
1042 #endif
1043
1044     void setMainFrameIsScrollable(bool);
1045
1046     void unapplyEditCommand(uint64_t commandID);
1047     void reapplyEditCommand(uint64_t commandID);
1048     void didRemoveEditCommand(uint64_t commandID);
1049
1050     void findString(const String&, uint32_t findOptions, uint32_t maxMatchCount);
1051     void findStringMatches(const String&, uint32_t findOptions, uint32_t maxMatchCount);
1052     void getImageForFindMatch(uint32_t matchIndex);
1053     void selectFindMatch(uint32_t matchIndex);
1054     void hideFindUI();
1055     void countStringMatches(const String&, uint32_t findOptions, uint32_t maxMatchCount);
1056
1057 #if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
1058     void findZoomableAreaForPoint(const WebCore::IntPoint&, const WebCore::IntSize& area);
1059 #endif
1060
1061     void didChangeSelectedIndexForActivePopupMenu(int32_t newIndex);
1062     void setTextForActivePopupMenu(int32_t index);
1063
1064 #if PLATFORM(GTK)
1065     void failedToShowPopupMenu();
1066 #endif
1067
1068 #if PLATFORM(IOS)
1069     void didChooseFilesForOpenPanelWithDisplayStringAndIcon(const Vector<String>&, const String& displayString, const IPC::DataReference& iconData);
1070 #endif
1071     void didChooseFilesForOpenPanel(const Vector<String>&);
1072     void didCancelForOpenPanel();
1073 #if ENABLE(SANDBOX_EXTENSIONS)
1074     void extendSandboxForFileFromOpenPanel(const SandboxExtension::Handle&);
1075 #endif
1076
1077     void didReceiveGeolocationPermissionDecision(uint64_t geolocationID, bool allowed);
1078
1079     void didReceiveNotificationPermissionDecision(uint64_t notificationID, bool allowed);
1080
1081 #if ENABLE(MEDIA_STREAM)
1082     void didReceiveUserMediaPermissionDecision(uint64_t userMediaID, bool allowed);
1083 #endif
1084
1085     void advanceToNextMisspelling(bool startBeforeSelection);
1086     void changeSpellingToWord(const String& word);
1087 #if USE(APPKIT)
1088     void uppercaseWord();
1089     void lowercaseWord();
1090     void capitalizeWord();
1091 #endif
1092
1093 #if ENABLE(CONTEXT_MENUS)
1094     void didSelectItemFromActiveContextMenu(const WebContextMenuItemData&);
1095 #endif
1096
1097     void changeSelectedIndex(int32_t index);
1098     void setCanStartMediaTimerFired();
1099
1100     bool canHandleUserEvents() const;
1101
1102     static bool platformCanHandleRequest(const WebCore::ResourceRequest&);
1103
1104     static PluginView* focusedPluginViewForFrame(WebCore::Frame&);
1105     static PluginView* pluginViewForFrame(WebCore::Frame*);
1106
1107     static PassRefPtr<WebCore::Range> rangeFromEditingRange(WebCore::Frame&, const EditingRange&);
1108
1109     void reportUsedFeatures();
1110
1111 #if PLATFORM(MAC)
1112     void performImmediateActionHitTestAtLocation(WebCore::FloatPoint);
1113     PassRefPtr<WebCore::Range> lookupTextAtLocation(WebCore::FloatPoint, NSDictionary **options);
1114     void immediateActionDidUpdate();
1115     void immediateActionDidCancel();
1116     void immediateActionDidComplete();
1117     void setFont(const String& fontFamily, double fontSize, uint64_t fontTraits);
1118
1119     void dataDetectorsDidPresentUI(WebCore::PageOverlay::PageOverlayID);
1120     void dataDetectorsDidChangeUI(WebCore::PageOverlay::PageOverlayID);
1121     void dataDetectorsDidHideUI(WebCore::PageOverlay::PageOverlayID);
1122 #endif
1123
1124     void setShouldDispatchFakeMouseMoveEvents(bool dispatch) { m_shouldDispatchFakeMouseMoveEvents = dispatch; }
1125
1126 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
1127     void playbackTargetSelected(uint64_t, const WebCore::MediaPlaybackTargetContext& outputDevice) const;
1128     void playbackTargetAvailabilityDidChange(uint64_t, bool);
1129     void setShouldPlayToPlaybackTarget(uint64_t, bool);
1130 #endif
1131
1132     void clearWheelEventTestTrigger();
1133
1134     void setShouldScaleViewToFitDocument(bool);
1135
1136     uint64_t m_pageID;
1137
1138     std::unique_ptr<WebCore::Page> m_page;
1139     RefPtr<WebFrame> m_mainFrame;
1140     RefPtr<InjectedBundleBackForwardList> m_backForwardList;
1141
1142     RefPtr<WebPageGroupProxy> m_pageGroup;
1143
1144     String m_userAgent;
1145
1146     WebCore::IntSize m_viewSize;
1147     std::unique_ptr<DrawingArea> m_drawingArea;
1148
1149     HashSet<PluginView*> m_pluginViews;
1150     bool m_hasSeenPlugin;
1151
1152     HashMap<uint64_t, RefPtr<WebCore::TextCheckingRequest>> m_pendingTextCheckingRequestMap;
1153
1154     bool m_useFixedLayout;
1155
1156     bool m_drawsBackground;
1157     bool m_drawsTransparentBackground;
1158
1159     WebCore::Color m_underlayColor;
1160
1161     bool m_isInRedo;
1162     bool m_isClosed;
1163
1164     bool m_tabToLinks;
1165     
1166     bool m_asynchronousPluginInitializationEnabled;
1167     bool m_asynchronousPluginInitializationEnabledForAllPlugins;
1168     bool m_artificialPluginInitializationDelayEnabled;
1169
1170     bool m_scrollingPerformanceLoggingEnabled;
1171
1172     bool m_mainFrameIsScrollable;
1173
1174 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
1175     bool m_readyToFindPrimarySnapshottedPlugin;
1176     bool m_didFindPrimarySnapshottedPlugin;
1177     unsigned m_numberOfPrimarySnapshotDetectionAttempts;
1178     String m_primaryPlugInPageOrigin;
1179     String m_primaryPlugInOrigin;
1180     String m_primaryPlugInMimeType;
1181     RunLoop::Timer<WebPage> m_determinePrimarySnapshottedPlugInTimer;
1182 #endif
1183
1184     // The layer hosting mode.
1185     LayerHostingMode m_layerHostingMode;
1186
1187 #if PLATFORM(COCOA)
1188     bool m_pdfPluginEnabled;
1189
1190     bool m_hasCachedWindowFrame;
1191
1192     // The frame of the containing window in screen coordinates.
1193     WebCore::FloatRect m_windowFrameInScreenCoordinates;
1194
1195     // The frame of the containing window in unflipped screen coordinates.
1196     WebCore::FloatRect m_windowFrameInUnflippedScreenCoordinates;
1197
1198     // The frame of the view in window coordinates.
1199     WebCore::FloatRect m_viewFrameInWindowCoordinates;
1200
1201     // The accessibility position of the view.
1202     WebCore::FloatPoint m_accessibilityPosition;
1203     
1204     RetainPtr<WKAccessibilityWebPageObject> m_mockAccessibilityElement;
1205
1206     ViewGestureGeometryCollector m_viewGestureGeometryCollector;
1207
1208 #elif HAVE(ACCESSIBILITY) && (PLATFORM(GTK) || PLATFORM(EFL))
1209     GRefPtr<WebPageAccessibilityObject> m_accessibilityObject;
1210 #endif
1211
1212 #if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL)
1213     // Our view's window in the UI process.
1214     uint64_t m_nativeWindowHandle;
1215 #endif
1216
1217 #if !PLATFORM(IOS)
1218     RefPtr<PageBanner> m_headerBanner;
1219     RefPtr<PageBanner> m_footerBanner;
1220 #endif // !PLATFORM(IOS)
1221
1222     RunLoop::Timer<WebPage> m_setCanStartMediaTimer;
1223     bool m_mayStartMediaWhenInWindow;
1224
1225     HashMap<uint64_t, RefPtr<WebUndoStep>> m_undoStepMap;
1226
1227     WebCore::IntSize m_windowResizerSize;
1228
1229 #if ENABLE(CONTEXT_MENUS)
1230     std::unique_ptr<API::InjectedBundle::PageContextMenuClient> m_contextMenuClient;
1231 #endif
1232     InjectedBundlePageEditorClient m_editorClient;
1233     std::unique_ptr<API::InjectedBundle::FormClient> m_formClient;
1234     InjectedBundlePageLoaderClient m_loaderClient;
1235     InjectedBundlePagePolicyClient m_policyClient;
1236     InjectedBundlePageResourceLoadClient m_resourceLoadClient;
1237     std::unique_ptr<API::InjectedBundle::PageUIClient> m_uiClient;
1238 #if ENABLE(FULLSCREEN_API)
1239     InjectedBundlePageFullScreenClient m_fullScreenClient;
1240 #endif
1241     InjectedBundlePageDiagnosticLoggingClient m_logDiagnosticMessageClient;
1242
1243     FindController m_findController;
1244
1245     RefPtr<WebInspector> m_inspector;
1246     RefPtr<WebInspectorUI> m_inspectorUI;
1247 #if PLATFORM(IOS)
1248     RefPtr<WebVideoFullscreenManager> m_videoFullscreenManager;
1249 #endif
1250 #if ENABLE(FULLSCREEN_API)
1251     RefPtr<WebFullScreenManager> m_fullScreenManager;
1252 #endif
1253     RefPtr<WebPopupMenu> m_activePopupMenu;
1254 #if ENABLE(CONTEXT_MENUS)
1255     RefPtr<WebContextMenu> m_contextMenu;
1256 #endif
1257 #if ENABLE(INPUT_TYPE_COLOR)
1258     WebColorChooser* m_activeColorChooser;
1259 #endif
1260     RefPtr<WebOpenPanelResultListener> m_activeOpenPanelResultListener;
1261     RefPtr<NotificationPermissionRequestManager> m_notificationPermissionRequestManager;
1262
1263     RefPtr<WebUserContentController> m_userContentController;
1264
1265 #if ENABLE(GEOLOCATION)
1266     GeolocationPermissionRequestManager m_geolocationPermissionRequestManager;
1267 #endif
1268
1269 #if ENABLE(MEDIA_STREAM)
1270     UserMediaPermissionRequestManager m_userMediaPermissionRequestManager;
1271 #endif
1272
1273     std::unique_ptr<WebCore::PrintContext> m_printContext;
1274 #if PLATFORM(GTK)
1275     RefPtr<WebPrintOperationGtk> m_printOperation;
1276 #endif
1277
1278     SandboxExtensionTracker m_sandboxExtensionTracker;
1279
1280     RefPtr<SandboxExtension> m_pendingDropSandboxExtension;
1281     Vector<RefPtr<SandboxExtension>> m_pendingDropExtensionsForFileUpload;
1282
1283     bool m_canRunBeforeUnloadConfirmPanel;
1284
1285     bool m_canRunModal;
1286     bool m_isRunningModal;
1287
1288 #if ENABLE(DRAG_SUPPORT)
1289     bool m_isStartingDrag;
1290 #endif
1291
1292     bool m_cachedMainFrameIsPinnedToLeftSide;
1293     bool m_cachedMainFrameIsPinnedToRightSide;
1294     bool m_cachedMainFrameIsPinnedToTopSide;
1295     bool m_cachedMainFrameIsPinnedToBottomSide;
1296     bool m_canShortCircuitHorizontalWheelEvents;
1297     bool m_hasWheelEventHandlers;
1298
1299     unsigned m_cachedPageCount;
1300
1301     HashSet<unsigned long> m_trackedNetworkResourceRequestIdentifiers;
1302
1303     WebCore::IntSize m_minimumLayoutSize;
1304     bool m_autoSizingShouldExpandToViewHeight;
1305
1306 #if ENABLE(CONTEXT_MENUS)
1307     bool m_isShowingContextMenu;
1308 #endif
1309     
1310 #if PLATFORM(IOS)
1311     RefPtr<WebCore::Node> m_assistedNode;
1312     RefPtr<WebCore::Range> m_currentWordRange;
1313     RefPtr<WebCore::Node> m_interactionNode;
1314     WebCore::IntPoint m_lastInteractionLocation;
1315     
1316     enum SelectionAnchor {
1317         Start,
1318         End
1319     };
1320     SelectionAnchor m_selectionAnchor;
1321
1322     RefPtr<WebCore::Node> m_potentialTapNode;
1323     WebCore::FloatPoint m_potentialTapLocation;
1324
1325     WebCore::ViewportConfiguration m_viewportConfiguration;
1326     uint64_t m_firstLayerTreeTransactionIDAfterDidCommitLoad;
1327     bool m_hasReceivedVisibleContentRectsAfterDidCommitLoad;
1328     bool m_scaleWasSetByUIProcess;
1329     bool m_userHasChangedPageScaleFactor;
1330     bool m_hasStablePageScaleFactor;
1331     bool m_userIsInteracting;
1332     bool m_hasPendingBlurNotification;
1333     bool m_useTestingViewportConfiguration;
1334     bool m_isInStableState;
1335     std::chrono::milliseconds m_oldestNonStableUpdateVisibleContentRectsTimestamp;
1336     std::chrono::milliseconds m_estimatedLatency;
1337     WebCore::FloatSize m_screenSize;
1338     WebCore::FloatSize m_availableScreenSize;
1339     RefPtr<WebCore::Range> m_currentBlockSelection;
1340     WebCore::IntSize m_blockSelectionDesiredSize;
1341     WebCore::FloatSize m_maximumUnobscuredSize;
1342     int32_t m_deviceOrientation;
1343     bool m_inDynamicSizeUpdate;
1344     HashMap<std::pair<WebCore::IntSize, double>, WebCore::IntPoint> m_dynamicSizeUpdateHistory;
1345     RefPtr<WebCore::Node> m_pendingSyntheticClickNode;
1346     WebCore::FloatPoint m_pendingSyntheticClickLocation;
1347     WebCore::FloatRect m_previousExposedContentRect;
1348     WebCore::Timer m_volatilityTimer;
1349 #endif
1350
1351     WebInspectorClient* m_inspectorClient;
1352
1353     HashSet<String, CaseFoldingHash> m_mimeTypesWithCustomContentProviders;
1354     WebCore::Color m_backgroundColor;
1355
1356     HashSet<unsigned> m_activeRenderingSuppressionTokens;
1357     unsigned m_maximumRenderingSuppressionToken;
1358     
1359     WebCore::ScrollPinningBehavior m_scrollPinningBehavior;
1360     WTF::Optional<WebCore::ScrollbarOverlayStyle> m_scrollbarOverlayStyle;
1361
1362     bool m_useAsyncScrolling;
1363
1364     WebCore::ViewState::Flags m_viewState;
1365     WebCore::PageActivityState::Flags m_activityState;
1366
1367     bool m_processSuppressionEnabled;
1368     UserActivity m_userActivity;
1369
1370     uint64_t m_pendingNavigationID;
1371
1372 #if ENABLE(WEBGL)
1373     WebCore::WebGLLoadPolicy m_systemWebGLPolicy;
1374 #endif
1375
1376     bool m_mainFrameProgressCompleted;
1377     bool m_shouldDispatchFakeMouseMoveEvents;
1378     bool m_isEditorStateMissingPostLayoutData { false };
1379 };
1380
1381 } // namespace WebKit
1382
1383 #endif // WebPage_h