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