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