Allow UI clients to handle vertical wheel events.
[WebKit-https.git] / Source / WebKit2 / WebProcess / WebPage / WebPage.h
1 /*
2  * Copyright (C) 2010, 2011 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 "APIObject.h"
30 #include "DrawingArea.h"
31 #include "FindController.h"
32 #include "GeolocationPermissionRequestManager.h"
33 #include "ImageOptions.h"
34 #include "ImmutableArray.h"
35 #if ENABLE(CONTEXT_MENUS)
36 #include "InjectedBundlePageContextMenuClient.h"
37 #endif
38 #include "InjectedBundlePageDiagnosticLoggingClient.h"
39 #include "InjectedBundlePageEditorClient.h"
40 #include "InjectedBundlePageFormClient.h"
41 #include "InjectedBundlePageFullScreenClient.h"
42 #include "InjectedBundlePageLoaderClient.h"
43 #include "InjectedBundlePagePolicyClient.h"
44 #include "InjectedBundlePageResourceLoadClient.h"
45 #include "InjectedBundlePageUIClient.h"
46 #include "MessageReceiver.h"
47 #include "MessageSender.h"
48 #include "TapHighlightController.h"
49 #include "Plugin.h"
50 #include "SandboxExtension.h"
51 #include "ShareableBitmap.h"
52 #include "WebUndoStep.h"
53 #include <WebCore/DictationAlternative.h>
54 #include <WebCore/DragData.h>
55 #include <WebCore/Editor.h>
56 #include <WebCore/FrameLoaderTypes.h>
57 #include <WebCore/IntRect.h>
58 #include <WebCore/Page.h>
59 #include <WebCore/PageVisibilityState.h>
60 #include <WebCore/PlatformScreen.h>
61 #include <WebCore/ScrollTypes.h>
62 #include <WebCore/WebCoreKeyboardUIMode.h>
63 #include <wtf/HashMap.h>
64 #include <wtf/OwnPtr.h>
65 #include <wtf/PassRefPtr.h>
66 #include <wtf/RefPtr.h>
67 #include <wtf/text/WTFString.h>
68
69 #if PLATFORM(QT)
70 #include "ArgumentCodersQt.h"
71 #include "QtNetworkAccessManager.h"
72 #include "QtNetworkReply.h"
73 #include "QtNetworkReplyData.h"
74 #include "QtNetworkRequestData.h"
75 #include <QNetworkReply>
76 #include <QNetworkRequest>
77 #endif
78
79 #if HAVE(ACCESSIBILITY) && (PLATFORM(GTK) || PLATFORM(EFL))
80 #include "WebPageAccessibilityObject.h"
81 #include <wtf/gobject/GRefPtr.h>
82 #endif
83
84 #if PLATFORM(GTK)
85 #include "ArgumentCodersGtk.h"
86 #include "WebPrintOperationGtk.h"
87 #endif
88
89 #if ENABLE(TOUCH_EVENTS)
90 #include <WebCore/PlatformTouchEvent.h>
91 #endif
92
93 #if PLATFORM(MAC)
94 #include "DictionaryPopupInfo.h"
95 #include "LayerHostingContext.h"
96 #include <wtf/RetainPtr.h>
97 OBJC_CLASS NSDictionary;
98 OBJC_CLASS NSObject;
99 OBJC_CLASS WKAccessibilityWebPageObject;
100 #endif
101
102 namespace CoreIPC {
103     class ArgumentDecoder;
104     class Connection;
105 }
106
107 namespace WebCore {
108     class GraphicsContext;
109     class Frame;
110     class FrameView;
111     class HTMLPlugInElement;
112     class KeyboardEvent;
113     class Page;
114     class PrintContext;
115     class Range;
116     class ResourceResponse;
117     class ResourceRequest;
118     class SharedBuffer;
119     class VisibleSelection;
120     struct KeypressCommand;
121 }
122
123 namespace WebKit {
124
125 class DrawingArea;
126 class InjectedBundleBackForwardList;
127 class NotificationPermissionRequestManager;
128 class PageOverlay;
129 class PluginView;
130 class SessionState;
131 class WebColorChooser;
132 class WebContextMenu;
133 class WebContextMenuItemData;
134 class WebEvent;
135 class WebFrame;
136 class WebFullScreenManager;
137 class WebImage;
138 class WebInspector;
139 class WebInspectorClient;
140 class WebKeyboardEvent;
141 class WebMouseEvent;
142 class WebNotificationClient;
143 class WebOpenPanelResultListener;
144 class WebPageGroupProxy;
145 class WebPopupMenu;
146 class WebWheelEvent;
147 struct AttributedString;
148 struct EditorState;
149 struct PrintInfo;
150 struct WebPageCreationParameters;
151 struct WebPreferencesStore;
152
153 #if ENABLE(GESTURE_EVENTS)
154 class WebGestureEvent;
155 #endif
156
157 #if ENABLE(TOUCH_EVENTS)
158 class WebTouchEvent;
159 #endif
160
161 class WebPage : public APIObject, public CoreIPC::MessageReceiver, public CoreIPC::MessageSender<WebPage> {
162 public:
163     static const Type APIType = TypeBundlePage;
164
165     static PassRefPtr<WebPage> create(uint64_t pageID, const WebPageCreationParameters&);
166     virtual ~WebPage();
167
168     // Used by MessageSender.
169     CoreIPC::Connection* connection() const;
170     uint64_t destinationID() const { return pageID(); }
171
172     void close();
173
174     static WebPage* fromCorePage(WebCore::Page*);
175
176     WebCore::Page* corePage() const { return m_page.get(); }
177     uint64_t pageID() const { return m_pageID; }
178
179     void setSize(const WebCore::IntSize&);
180     const WebCore::IntSize& size() const { return m_viewSize; }
181     WebCore::IntRect bounds() const { return WebCore::IntRect(WebCore::IntPoint(), size()); }
182     
183     InjectedBundleBackForwardList* backForwardList();
184     DrawingArea* drawingArea() const { return m_drawingArea.get(); }
185
186     WebPageGroupProxy* pageGroup() const { return m_pageGroup.get(); }
187
188     void scrollMainFrameIfNotAtMaxScrollPosition(const WebCore::IntSize& scrollOffset);
189
190     void scrollBy(uint32_t scrollDirection, uint32_t scrollGranularity);
191
192     void centerSelectionInVisibleArea();
193
194 #if ENABLE(INSPECTOR)
195     WebInspector* inspector();
196 #endif
197
198 #if ENABLE(FULLSCREEN_API)
199     WebFullScreenManager* fullScreenManager();
200 #endif
201
202     // -- Called by the DrawingArea.
203     // FIXME: We could genericize these into a DrawingArea client interface. Would that be beneficial?
204     void drawRect(WebCore::GraphicsContext&, const WebCore::IntRect&);
205     void drawPageOverlay(WebCore::GraphicsContext&, const WebCore::IntRect&);
206     void layoutIfNeeded();
207
208     // -- Called from WebCore clients.
209 #if PLATFORM(MAC)
210     bool handleEditingKeyboardEvent(WebCore::KeyboardEvent*, bool saveCommands);
211 #elif !PLATFORM(GTK)
212     bool handleEditingKeyboardEvent(WebCore::KeyboardEvent*);
213 #endif
214
215     void didStartPageTransition();
216     void didCompletePageTransition();
217     void show();
218     String userAgent() const { return m_userAgent; }
219     WebCore::IntRect windowResizerRect() const;
220     WebCore::KeyboardUIMode keyboardUIMode();
221
222     WebUndoStep* webUndoStep(uint64_t);
223     void addWebUndoStep(uint64_t, WebUndoStep*);
224     void removeWebEditCommand(uint64_t);
225     bool isInRedo() const { return m_isInRedo; }
226
227     void setActivePopupMenu(WebPopupMenu*);
228
229 #if ENABLE(INPUT_TYPE_COLOR)
230     WebColorChooser* activeColorChooser() const { return m_activeColorChooser; }
231     void setActiveColorChooser(WebColorChooser*);
232     void didChooseColor(const WebCore::Color&);
233     void didEndColorChooser();
234 #endif
235
236     WebOpenPanelResultListener* activeOpenPanelResultListener() const { return m_activeOpenPanelResultListener.get(); }
237     void setActiveOpenPanelResultListener(PassRefPtr<WebOpenPanelResultListener>);
238
239     void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) OVERRIDE;
240     void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&) OVERRIDE;
241
242     // -- InjectedBundle methods
243 #if ENABLE(CONTEXT_MENUS)
244     void initializeInjectedBundleContextMenuClient(WKBundlePageContextMenuClient*);
245 #endif
246     void initializeInjectedBundleEditorClient(WKBundlePageEditorClient*);
247     void initializeInjectedBundleFormClient(WKBundlePageFormClient*);
248     void initializeInjectedBundleLoaderClient(WKBundlePageLoaderClient*);
249     void initializeInjectedBundlePolicyClient(WKBundlePagePolicyClient*);
250     void initializeInjectedBundleResourceLoadClient(WKBundlePageResourceLoadClient*);
251     void initializeInjectedBundleUIClient(WKBundlePageUIClient*);
252 #if ENABLE(FULLSCREEN_API)
253     void initializeInjectedBundleFullScreenClient(WKBundlePageFullScreenClient*);
254 #endif
255     void initializeInjectedBundleDiagnosticLoggingClient(WKBundlePageDiagnosticLoggingClient*);
256
257 #if ENABLE(CONTEXT_MENUS)
258     InjectedBundlePageContextMenuClient& injectedBundleContextMenuClient() { return m_contextMenuClient; }
259 #endif
260     InjectedBundlePageEditorClient& injectedBundleEditorClient() { return m_editorClient; }
261     InjectedBundlePageFormClient& injectedBundleFormClient() { return m_formClient; }
262     InjectedBundlePageLoaderClient& injectedBundleLoaderClient() { return m_loaderClient; }
263     InjectedBundlePagePolicyClient& injectedBundlePolicyClient() { return m_policyClient; }
264     InjectedBundlePageResourceLoadClient& injectedBundleResourceLoadClient() { return m_resourceLoadClient; }
265     InjectedBundlePageUIClient& injectedBundleUIClient() { return m_uiClient; }
266     InjectedBundlePageDiagnosticLoggingClient& injectedBundleDiagnosticLoggingClient() { return m_logDiagnosticMessageClient; }
267 #if ENABLE(FULLSCREEN_API)
268     InjectedBundlePageFullScreenClient& injectedBundleFullScreenClient() { return m_fullScreenClient; }
269 #endif
270
271     void setUnderlayPage(PassRefPtr<WebPage> underlayPage) { m_underlayPage = underlayPage; }
272
273     bool findStringFromInjectedBundle(const String&, FindOptions);
274
275     WebFrame* mainWebFrame() const { return m_mainFrame.get(); }
276
277     WebCore::Frame* mainFrame() const; // May return 0.
278     WebCore::FrameView* mainFrameView() const; // May return 0.
279
280 #if ENABLE(NETSCAPE_PLUGIN_API)
281     PassRefPtr<Plugin> createPlugin(WebFrame*, WebCore::HTMLPlugInElement*, const Plugin::Parameters&);
282 #endif
283
284     EditorState editorState() const;
285
286     String renderTreeExternalRepresentation() const;
287     uint64_t renderTreeSize() const;
288
289     void setTracksRepaints(bool);
290     bool isTrackingRepaints() const;
291     void resetTrackedRepaints();
292     PassRefPtr<ImmutableArray> trackedRepaintRects();
293
294     void executeEditingCommand(const String& commandName, const String& argument);
295     bool isEditingCommandEnabled(const String& commandName);
296     void clearMainFrameName();
297     void sendClose();
298
299     double textZoomFactor() const;
300     void setTextZoomFactor(double);
301     double pageZoomFactor() const;
302     void setPageZoomFactor(double);
303     void setPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor);
304     void windowScreenDidChange(uint64_t);
305     void setViewMode(WebCore::Page::ViewMode);
306
307     void scalePage(double scale, const WebCore::IntPoint& origin);
308     double pageScaleFactor() const;
309
310     void setUseFixedLayout(bool);
311     bool useFixedLayout() const { return m_useFixedLayout; }
312     void setFixedLayoutSize(const WebCore::IntSize&);
313
314     void listenForLayoutMilestones(uint32_t /* LayoutMilestones */);
315
316     void setSuppressScrollbarAnimations(bool);
317
318     void setRubberBandsAtBottom(bool);
319     void setRubberBandsAtTop(bool);
320
321     void setPaginationMode(uint32_t /* WebCore::Pagination::Mode */);
322     void setPaginationBehavesLikeColumns(bool);
323     void setPageLength(double);
324     void setGapBetweenPages(double);
325
326     void postInjectedBundleMessage(const String& messageName, CoreIPC::MessageDecoder&);
327
328     bool drawsBackground() const { return m_drawsBackground; }
329     bool drawsTransparentBackground() const { return m_drawsTransparentBackground; }
330
331     void stopLoading();
332     void stopLoadingFrame(uint64_t frameID);
333     void setDefersLoading(bool deferLoading);
334
335 #if USE(ACCELERATED_COMPOSITING)
336     void enterAcceleratedCompositingMode(WebCore::GraphicsLayer*);
337     void exitAcceleratedCompositingMode();
338 #endif
339
340     void addPluginView(PluginView*);
341     void removePluginView(PluginView*);
342
343 #if PLATFORM(MAC)
344     LayerHostingMode layerHostingMode() const { return m_layerHostingMode; }
345     void setLayerHostingMode(LayerHostingMode);
346
347     bool windowIsVisible() const { return m_windowIsVisible; }
348     void updatePluginsActiveAndFocusedState();
349     const WebCore::IntRect& windowFrameInScreenCoordinates() const { return m_windowFrameInScreenCoordinates; }
350     const WebCore::IntRect& viewFrameInWindowCoordinates() const { return m_viewFrameInWindowCoordinates; }
351 #endif
352
353     bool windowIsFocused() const;
354     bool windowAndWebPageAreFocused() const;
355     void installPageOverlay(PassRefPtr<PageOverlay>, bool shouldFadeIn = false);
356     void uninstallPageOverlay(PageOverlay*, bool shouldFadeOut = false);
357     bool hasPageOverlay() const { return m_pageOverlay; }
358     WebCore::IntPoint screenToWindow(const WebCore::IntPoint&);
359     WebCore::IntRect windowToScreen(const WebCore::IntRect&);
360
361     PassRefPtr<WebImage> scaledSnapshotWithOptions(const WebCore::IntRect&, double scaleFactor, SnapshotOptions);
362
363     static const WebEvent* currentEvent();
364
365     FindController& findController() { return m_findController; }
366 #if ENABLE(TOUCH_EVENTS) && PLATFORM(QT)
367     TapHighlightController& tapHighlightController() { return m_tapHighlightController; }
368 #endif
369
370 #if ENABLE(GEOLOCATION)
371     GeolocationPermissionRequestManager& geolocationPermissionRequestManager() { return m_geolocationPermissionRequestManager; }
372 #endif
373
374     NotificationPermissionRequestManager* notificationPermissionRequestManager();
375
376     void pageDidScroll();
377 #if USE(TILED_BACKING_STORE)
378     void pageDidRequestScroll(const WebCore::IntPoint&);
379     void setFixedVisibleContentRect(const WebCore::IntRect&);
380     void resizeToContentsIfNeeded();
381     void sendViewportAttributesChanged();
382     void setViewportSize(const WebCore::IntSize&);
383     WebCore::IntSize viewportSize() const { return m_viewportSize; }
384 #endif
385
386 #if ENABLE(CONTEXT_MENUS)
387     WebContextMenu* contextMenu();
388 #endif
389     
390     bool hasLocalDataForURL(const WebCore::KURL&);
391     String cachedResponseMIMETypeForURL(const WebCore::KURL&);
392     String cachedSuggestedFilenameForURL(const WebCore::KURL&);
393     PassRefPtr<WebCore::SharedBuffer> cachedResponseDataForURL(const WebCore::KURL&);
394
395     static bool canHandleRequest(const WebCore::ResourceRequest&);
396
397     class SandboxExtensionTracker {
398     public:
399         ~SandboxExtensionTracker();
400
401         void invalidate();
402
403         void beginLoad(WebFrame*, const SandboxExtension::Handle& handle);
404         void willPerformLoadDragDestinationAction(PassRefPtr<SandboxExtension> pendingDropSandboxExtension);
405         void didStartProvisionalLoad(WebFrame*);
406         void didCommitProvisionalLoad(WebFrame*);
407         void didFailProvisionalLoad(WebFrame*);
408
409     private:
410         void setPendingProvisionalSandboxExtension(PassRefPtr<SandboxExtension>);
411
412         RefPtr<SandboxExtension> m_pendingProvisionalSandboxExtension;
413         RefPtr<SandboxExtension> m_provisionalSandboxExtension;
414         RefPtr<SandboxExtension> m_committedSandboxExtension;
415     };
416
417     SandboxExtensionTracker& sandboxExtensionTracker() { return m_sandboxExtensionTracker; }
418
419 #if PLATFORM(EFL)
420     void setThemePath(const String&);
421 #endif
422
423 #if USE(TILED_BACKING_STORE)
424     void commitPageTransitionViewport();
425 #endif
426
427 #if PLATFORM(QT) || PLATFORM(GTK)
428     void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd);
429     void confirmComposition(const String& text, int64_t selectionStart, int64_t selectionLength);
430     void cancelComposition();
431 #endif
432
433 #if PLATFORM(MAC)
434     void registerUIProcessAccessibilityTokens(const CoreIPC::DataReference& elemenToken, const CoreIPC::DataReference& windowToken);
435     WKAccessibilityWebPageObject* accessibilityRemoteObject();
436     WebCore::IntPoint accessibilityPosition() const { return m_accessibilityPosition; }    
437     
438     void sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String& textInput);
439
440     void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, EditorState& newState);
441     void confirmComposition(EditorState& newState);
442     void cancelComposition(EditorState& newState);
443     void insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, bool& handled, EditorState& newState);
444     void getMarkedRange(uint64_t& location, uint64_t& length);
445     void getSelectedRange(uint64_t& location, uint64_t& length);
446     void getAttributedSubstringFromRange(uint64_t location, uint64_t length, AttributedString&);
447     void characterIndexForPoint(const WebCore::IntPoint point, uint64_t& result);
448     void firstRectForCharacterRange(uint64_t location, uint64_t length, WebCore::IntRect& resultRect);
449     void executeKeypressCommands(const Vector<WebCore::KeypressCommand>&, bool& handled, EditorState& newState);
450     void readSelectionFromPasteboard(const WTF::String& pasteboardName, bool& result);
451     void getStringSelectionForPasteboard(WTF::String& stringValue);
452     void getDataSelectionForPasteboard(const WTF::String pasteboardType, SharedMemory::Handle& handle, uint64_t& size);
453     void shouldDelayWindowOrderingEvent(const WebKit::WebMouseEvent&, bool& result);
454     void acceptsFirstMouse(int eventNumber, const WebKit::WebMouseEvent&, bool& result);
455     bool performNonEditingBehaviorForSelector(const String&);
456     void insertDictatedText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, const Vector<WebCore::DictationAlternative>& dictationAlternativeLocations, bool& handled, EditorState& newState);
457 #elif PLATFORM(EFL)
458     void confirmComposition(const String& compositionString);
459     void setComposition(const WTF::String& compositionString, const WTF::Vector<WebCore::CompositionUnderline>& underlines, uint64_t cursorPosition);
460     void cancelComposition();
461 #elif PLATFORM(GTK)
462 #if USE(TEXTURE_MAPPER_GL)
463     void setAcceleratedCompositingWindowId(int64_t nativeWindowHandle);
464 #endif
465 #endif
466
467 #if HAVE(ACCESSIBILITY) && (PLATFORM(GTK) || PLATFORM(EFL))
468     void updateAccessibilityTree();
469 #endif
470
471     void setCompositionForTesting(const String& compositionString, uint64_t from, uint64_t length);
472     bool hasCompositionForTesting();
473     void confirmCompositionForTesting(const String& compositionString);
474
475     // FIXME: This a dummy message, to avoid breaking the build for platforms that don't require
476     // any synchronous messages, and should be removed when <rdar://problem/8775115> is fixed.
477     void dummy(bool&);
478
479 #if PLATFORM(MAC)
480     void performDictionaryLookupForSelection(DictionaryPopupInfo::Type, WebCore::Frame*, const WebCore::VisibleSelection&);
481
482     bool isSpeaking();
483     void speak(const String&);
484     void stopSpeaking();
485
486     bool isSmartInsertDeleteEnabled() const { return m_isSmartInsertDeleteEnabled; }
487 #endif
488
489     void replaceSelectionWithText(WebCore::Frame*, const String&);
490     void clearSelection();
491
492 #if ENABLE(DRAG_SUPPORT)
493 #if PLATFORM(QT) || PLATFORM(GTK)
494     void performDragControllerAction(uint64_t action, WebCore::DragData);
495 #else
496     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&);
497 #endif
498     void dragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t operation);
499
500     void willPerformLoadDragDestinationAction();
501     void mayPerformUploadDragDestinationAction();
502 #endif // ENABLE(DRAG_SUPPORT)
503
504     void beginPrinting(uint64_t frameID, const PrintInfo&);
505     void endPrinting();
506     void computePagesForPrinting(uint64_t frameID, const PrintInfo&, uint64_t callbackID);
507 #if PLATFORM(MAC)
508     void drawRectToImage(uint64_t frameID, const PrintInfo&, const WebCore::IntRect&, const WebCore::IntSize&, uint64_t callbackID);
509     void drawPagesToPDF(uint64_t frameID, const PrintInfo&, uint32_t first, uint32_t count, uint64_t callbackID);
510 #elif PLATFORM(GTK)
511     void drawPagesForPrinting(uint64_t frameID, const PrintInfo&, uint64_t callbackID);
512 #endif
513
514     void setMediaVolume(float);
515     void setMayStartMediaWhenInWindow(bool);
516
517     bool mainFrameHasCustomRepresentation() const;
518
519     void didChangeScrollOffsetForMainFrame();
520
521     void mainFrameDidLayout();
522
523     bool canRunBeforeUnloadConfirmPanel() const { return m_canRunBeforeUnloadConfirmPanel; }
524     void setCanRunBeforeUnloadConfirmPanel(bool canRunBeforeUnloadConfirmPanel) { m_canRunBeforeUnloadConfirmPanel = canRunBeforeUnloadConfirmPanel; }
525
526     bool canRunModal() const { return m_canRunModal; }
527     void setCanRunModal(bool canRunModal) { m_canRunModal = canRunModal; }
528
529     void runModal();
530
531     void setDeviceScaleFactor(float);
532     float deviceScaleFactor() const;
533
534     void setMemoryCacheMessagesEnabled(bool);
535
536     void forceRepaintWithoutCallback();
537
538     void unmarkAllMisspellings();
539     void unmarkAllBadGrammar();
540 #if PLATFORM(MAC)
541     void handleAlternativeTextUIResult(const String&);
542 #endif
543
544     // For testing purpose.
545     void simulateMouseDown(int button, WebCore::IntPoint, int clickCount, WKEventModifiers, double time);
546     void simulateMouseUp(int button, WebCore::IntPoint, int clickCount, WKEventModifiers, double time);
547     void simulateMouseMotion(WebCore::IntPoint, double time);
548
549 #if ENABLE(CONTEXT_MENUS)
550     void contextMenuShowing() { m_isShowingContextMenu = true; }
551 #endif
552
553 #if PLATFORM(QT)
554     void registerApplicationScheme(const String& scheme);
555     void applicationSchemeReply(const QtNetworkReplyData&);
556     void receivedApplicationSchemeRequest(const QNetworkRequest&, QtNetworkReply*);
557     void setUserScripts(const Vector<String>&);
558 #endif
559     void wheelEvent(const WebWheelEvent&);
560 #if ENABLE(GESTURE_EVENTS)
561     void gestureEvent(const WebGestureEvent&);
562 #endif
563
564     void numWheelEventHandlersChanged(unsigned);
565     void recomputeShortCircuitHorizontalWheelEventsState();
566
567     bool willGoToBackForwardItemCallbackEnabled() const { return m_willGoToBackForwardItemCallbackEnabled; }
568
569 #if ENABLE(PAGE_VISIBILITY_API) || ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
570     void setVisibilityState(uint32_t /* WebCore::PageVisibilityState */, bool isInitialState);
571 #endif
572
573 #if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL)
574     uint64_t nativeWindowHandle() { return m_nativeWindowHandle; }
575 #endif
576
577     bool shouldUseCustomRepresentationForResponse(const WebCore::ResourceResponse&);
578     bool canPluginHandleResponse(const WebCore::ResourceResponse& response);
579
580     bool asynchronousPluginInitializationEnabled() const { return m_asynchronousPluginInitializationEnabled; }
581     void setAsynchronousPluginInitializationEnabled(bool enabled) { m_asynchronousPluginInitializationEnabled = enabled; }
582     bool asynchronousPluginInitializationEnabledForAllPlugins() const { return m_asynchronousPluginInitializationEnabledForAllPlugins; }
583     void setAsynchronousPluginInitializationEnabledForAllPlugins(bool enabled) { m_asynchronousPluginInitializationEnabledForAllPlugins = enabled; }
584     bool artificialPluginInitializationDelayEnabled() const { return m_artificialPluginInitializationDelayEnabled; }
585     void setArtificialPluginInitializationDelayEnabled(bool enabled) { m_artificialPluginInitializationDelayEnabled = enabled; }
586     void setTabToLinksEnabled(bool enabled) { m_tabToLinks = enabled; }
587     bool tabToLinksEnabled() const { return m_tabToLinks; }
588
589     bool scrollingPerformanceLoggingEnabled() const { return m_scrollingPerformanceLoggingEnabled; }
590     void setScrollingPerformanceLoggingEnabled(bool);
591
592 #if PLATFORM(MAC)
593     bool pdfPluginEnabled() const { return m_pdfPluginEnabled; }
594     void setPDFPluginEnabled(bool enabled) { m_pdfPluginEnabled = enabled; }
595 #endif
596
597 #if PLATFORM(MAC)
598     static HashSet<String, CaseFoldingHash> pdfAndPostScriptMIMETypes();
599 #endif
600
601     void savePDFToFileInDownloadsFolder(const String& suggestedFilename, const String& originatingURLString, const uint8_t* data, unsigned long size);
602 #if PLATFORM(MAC)
603     void savePDFToTemporaryFolderAndOpenWithNativeApplication(const String& suggestedFilename, const String& originatingURLString, const uint8_t* data, unsigned long size, const String& pdfUUID);
604 #endif
605
606     bool mainFrameIsScrollable() const { return m_mainFrameIsScrollable; }
607
608     void setMinimumLayoutWidth(double);
609     double minimumLayoutWidth() const { return m_minimumLayoutWidth; }
610
611 private:
612     WebPage(uint64_t pageID, const WebPageCreationParameters&);
613
614     virtual Type type() const { return APIType; }
615
616     void platformInitialize();
617
618     void didReceiveWebPageMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&);
619     void didReceiveSyncWebPageMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&);
620
621 #if !PLATFORM(MAC)
622     static const char* interpretKeyEvent(const WebCore::KeyboardEvent*);
623 #endif
624     bool performDefaultBehaviorForKeyEvent(const WebKeyboardEvent&);
625
626 #if PLATFORM(MAC)
627     bool executeKeypressCommandsInternal(const Vector<WebCore::KeypressCommand>&, WebCore::KeyboardEvent*);
628 #endif
629
630     String sourceForFrame(WebFrame*);
631
632     void loadData(PassRefPtr<WebCore::SharedBuffer>, const String& MIMEType, const String& encodingName, const WebCore::KURL& baseURL, const WebCore::KURL& failingURL);
633
634     bool platformHasLocalDataForURL(const WebCore::KURL&);
635
636     // Actions
637     void tryClose();
638     void loadURL(const String&, const SandboxExtension::Handle&);
639     void loadURLRequest(const WebCore::ResourceRequest&, const SandboxExtension::Handle&);
640     void loadHTMLString(const String& htmlString, const String& baseURL);
641     void loadAlternateHTMLString(const String& htmlString, const String& baseURL, const String& unreachableURL);
642     void loadPlainTextString(const String&);
643     void loadWebArchiveData(const CoreIPC::DataReference&);
644     void linkClicked(const String& url, const WebMouseEvent&);
645     void reload(bool reloadFromOrigin, const SandboxExtension::Handle&);
646     void goForward(uint64_t);
647     void goBack(uint64_t);
648     void goToBackForwardItem(uint64_t);
649     void tryRestoreScrollPosition();
650     void setActive(bool);
651     void setFocused(bool);
652     void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&);
653     void setWindowResizerSize(const WebCore::IntSize&);
654     void setIsInWindow(bool);
655     void validateCommand(const String&, uint64_t);
656     void executeEditCommand(const String&);
657
658     void mouseEvent(const WebMouseEvent&);
659     void mouseEventSyncForTesting(const WebMouseEvent&, bool&);
660     void wheelEventSyncForTesting(const WebWheelEvent&, bool&);
661     void keyEvent(const WebKeyboardEvent&);
662     void keyEventSyncForTesting(const WebKeyboardEvent&, bool&);
663 #if ENABLE(TOUCH_EVENTS)
664     void touchEvent(const WebTouchEvent&);
665     void touchEventSyncForTesting(const WebTouchEvent&, bool& handled);
666 #if PLATFORM(QT)
667     void highlightPotentialActivation(const WebCore::IntPoint&, const WebCore::IntSize& area);
668 #endif
669 #endif
670 #if ENABLE(CONTEXT_MENUS)
671     void contextMenuHidden() { m_isShowingContextMenu = false; }
672 #endif
673
674     static void scroll(WebCore::Page*, WebCore::ScrollDirection, WebCore::ScrollGranularity);
675     static void logicalScroll(WebCore::Page*, WebCore::ScrollLogicalDirection, WebCore::ScrollGranularity);
676
677     uint64_t restoreSession(const SessionState&);
678     void restoreSessionAndNavigateToCurrentItem(const SessionState&);
679
680     void didRemoveBackForwardItem(uint64_t);
681
682     void setWillGoToBackForwardItemCallbackEnabled(bool enabled) { m_willGoToBackForwardItemCallbackEnabled = enabled; }
683     
684     void setDrawsBackground(bool);
685     void setDrawsTransparentBackground(bool);
686
687     void viewWillStartLiveResize();
688     void viewWillEndLiveResize();
689
690     void getContentsAsString(uint64_t callbackID);
691 #if ENABLE(MHTML)
692     void getContentsAsMHTMLData(uint64_t callbackID, bool useBinaryEncoding);
693 #endif
694     void getMainResourceDataOfFrame(uint64_t frameID, uint64_t callbackID);
695     void getResourceDataFromFrame(uint64_t frameID, const String& resourceURL, uint64_t callbackID);
696     void getRenderTreeExternalRepresentation(uint64_t callbackID);
697     void getSelectionOrContentsAsString(uint64_t callbackID);
698     void getSelectionAsWebArchiveData(uint64_t callbackID);
699     void getSourceForFrame(uint64_t frameID, uint64_t callbackID);
700     void getWebArchiveOfFrame(uint64_t frameID, uint64_t callbackID);
701     void runJavaScriptInMainFrame(const String&, uint64_t callbackID);
702     void forceRepaint(uint64_t callbackID);
703
704     void preferencesDidChange(const WebPreferencesStore&);
705     void platformPreferencesDidChange(const WebPreferencesStore&);
706     void updatePreferences(const WebPreferencesStore&);
707
708     void didReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, uint32_t policyAction, uint64_t downloadID);
709     void setUserAgent(const String&);
710     void setCustomTextEncodingName(const String&);
711     void suspendActiveDOMObjectsAndAnimations();
712     void resumeActiveDOMObjectsAndAnimations();
713
714 #if PLATFORM(MAC)
715     void performDictionaryLookupAtLocation(const WebCore::FloatPoint&);
716     void performDictionaryLookupForRange(DictionaryPopupInfo::Type, WebCore::Frame*, WebCore::Range*, NSDictionary *options);
717
718     void setWindowIsVisible(bool windowIsVisible);
719     void windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates, const WebCore::IntPoint& accessibilityViewCoordinates);
720
721     RetainPtr<PDFDocument> pdfDocumentForPrintingFrame(WebCore::Frame*);
722     void computePagesForPrintingPDFDocument(uint64_t frameID, const PrintInfo&, Vector<WebCore::IntRect>& resultPageRects);
723     void drawPDFDocument(CGContextRef, PDFDocument *, const PrintInfo&, const WebCore::IntRect&);
724     void drawPagesToPDFFromPDFDocument(CGContextRef, PDFDocument *, const PrintInfo&, uint32_t first, uint32_t count);
725 #endif
726
727     void viewExposedRectChanged(const WebCore::IntRect& exposedRect);
728     void setMainFrameIsScrollable(bool);
729
730     void unapplyEditCommand(uint64_t commandID);
731     void reapplyEditCommand(uint64_t commandID);
732     void didRemoveEditCommand(uint64_t commandID);
733
734     void findString(const String&, uint32_t findOptions, uint32_t maxMatchCount);
735     void findStringMatches(const String&, uint32_t findOptions, uint32_t maxMatchCount);
736     void getImageForFindMatch(uint32_t matchIndex);
737     void selectFindMatch(uint32_t matchIndex);
738     void hideFindUI();
739     void countStringMatches(const String&, uint32_t findOptions, uint32_t maxMatchCount);
740
741 #if PLATFORM(QT)
742     void findZoomableAreaForPoint(const WebCore::IntPoint&, const WebCore::IntSize& area);
743 #endif
744
745     void didChangeSelectedIndexForActivePopupMenu(int32_t newIndex);
746     void setTextForActivePopupMenu(int32_t index);
747
748 #if PLATFORM(GTK)
749     void failedToShowPopupMenu();
750 #endif
751 #if PLATFORM(QT)
752     void hidePopupMenu();
753     void selectedIndex(int32_t newIndex);
754 #endif
755
756     void didChooseFilesForOpenPanel(const Vector<String>&);
757     void didCancelForOpenPanel();
758 #if ENABLE(WEB_PROCESS_SANDBOX)
759     void extendSandboxForFileFromOpenPanel(const SandboxExtension::Handle&);
760 #endif
761
762     void didReceiveGeolocationPermissionDecision(uint64_t geolocationID, bool allowed);
763
764     void didReceiveNotificationPermissionDecision(uint64_t notificationID, bool allowed);
765
766     void advanceToNextMisspelling(bool startBeforeSelection);
767     void changeSpellingToWord(const String& word);
768 #if USE(APPKIT)
769     void uppercaseWord();
770     void lowercaseWord();
771     void capitalizeWord();
772 #endif
773
774 #if PLATFORM(MAC)
775     void setSmartInsertDeleteEnabled(bool isSmartInsertDeleteEnabled) { m_isSmartInsertDeleteEnabled = isSmartInsertDeleteEnabled; }
776 #endif
777
778 #if ENABLE(CONTEXT_MENUS)
779     void didSelectItemFromActiveContextMenu(const WebContextMenuItemData&);
780 #endif
781
782     void changeSelectedIndex(int32_t index);
783     void setCanStartMediaTimerFired();
784
785     bool canHandleUserEvents() const;
786
787     void setMainFrameInViewSourceMode(bool);
788
789     static bool platformCanHandleRequest(const WebCore::ResourceRequest&);
790
791     OwnPtr<WebCore::Page> m_page;
792     RefPtr<WebFrame> m_mainFrame;
793     RefPtr<InjectedBundleBackForwardList> m_backForwardList;
794
795     RefPtr<WebPageGroupProxy> m_pageGroup;
796
797     String m_userAgent;
798
799     WebCore::IntSize m_viewSize;
800     OwnPtr<DrawingArea> m_drawingArea;
801
802     HashSet<PluginView*> m_pluginViews;
803
804     bool m_useFixedLayout;
805
806     bool m_drawsBackground;
807     bool m_drawsTransparentBackground;
808
809     bool m_isInRedo;
810     bool m_isClosed;
811
812     bool m_tabToLinks;
813     
814     bool m_asynchronousPluginInitializationEnabled;
815     bool m_asynchronousPluginInitializationEnabledForAllPlugins;
816     bool m_artificialPluginInitializationDelayEnabled;
817
818     bool m_scrollingPerformanceLoggingEnabled;
819
820     bool m_mainFrameIsScrollable;
821
822 #if PLATFORM(MAC)
823     bool m_pdfPluginEnabled;
824
825     // Whether the containing window is visible or not.
826     bool m_windowIsVisible;
827
828     // Whether smart insert/delete is enabled or not.
829     bool m_isSmartInsertDeleteEnabled;
830
831     // The frame of the containing window in screen coordinates.
832     WebCore::IntRect m_windowFrameInScreenCoordinates;
833
834     // The frame of the view in window coordinates.
835     WebCore::IntRect m_viewFrameInWindowCoordinates;
836
837     // The accessibility position of the view.
838     WebCore::IntPoint m_accessibilityPosition;
839     
840     // The layer hosting mode.
841     LayerHostingMode m_layerHostingMode;
842
843     RetainPtr<WKAccessibilityWebPageObject> m_mockAccessibilityElement;
844
845     WebCore::KeyboardEvent* m_keyboardEventBeingInterpreted;
846
847 #elif HAVE(ACCESSIBILITY) && (PLATFORM(GTK) || PLATFORM(EFL))
848     GRefPtr<WebPageAccessibilityObject> m_accessibilityObject;
849
850 #if USE(TEXTURE_MAPPER_GL)
851     // Our view's window in the UI process.
852     uint64_t m_nativeWindowHandle;
853 #endif
854 #endif
855     
856     WebCore::RunLoop::Timer<WebPage> m_setCanStartMediaTimer;
857     bool m_mayStartMediaWhenInWindow;
858
859     HashMap<uint64_t, RefPtr<WebUndoStep> > m_undoStepMap;
860
861     WebCore::IntSize m_windowResizerSize;
862
863 #if ENABLE(CONTEXT_MENUS)
864     InjectedBundlePageContextMenuClient m_contextMenuClient;
865 #endif
866     InjectedBundlePageEditorClient m_editorClient;
867     InjectedBundlePageFormClient m_formClient;
868     InjectedBundlePageLoaderClient m_loaderClient;
869     InjectedBundlePagePolicyClient m_policyClient;
870     InjectedBundlePageResourceLoadClient m_resourceLoadClient;
871     InjectedBundlePageUIClient m_uiClient;
872 #if ENABLE(FULLSCREEN_API)
873     InjectedBundlePageFullScreenClient m_fullScreenClient;
874 #endif
875     InjectedBundlePageDiagnosticLoggingClient m_logDiagnosticMessageClient;
876
877 #if USE(TILED_BACKING_STORE)
878     WebCore::IntSize m_viewportSize;
879 #endif
880
881     FindController m_findController;
882 #if ENABLE(TOUCH_EVENTS) && PLATFORM(QT)
883     TapHighlightController m_tapHighlightController;
884 #endif
885     RefPtr<PageOverlay> m_pageOverlay;
886
887     RefPtr<WebPage> m_underlayPage;
888
889 #if ENABLE(INSPECTOR)
890     RefPtr<WebInspector> m_inspector;
891 #endif
892 #if ENABLE(FULLSCREEN_API)
893     RefPtr<WebFullScreenManager> m_fullScreenManager;
894 #endif
895     RefPtr<WebPopupMenu> m_activePopupMenu;
896 #if ENABLE(CONTEXT_MENUS)
897     RefPtr<WebContextMenu> m_contextMenu;
898 #endif
899 #if ENABLE(INPUT_TYPE_COLOR)
900     WebColorChooser* m_activeColorChooser;
901 #endif
902     RefPtr<WebOpenPanelResultListener> m_activeOpenPanelResultListener;
903     RefPtr<NotificationPermissionRequestManager> m_notificationPermissionRequestManager;
904
905 #if ENABLE(GEOLOCATION)
906     GeolocationPermissionRequestManager m_geolocationPermissionRequestManager;
907 #endif
908
909     OwnPtr<WebCore::PrintContext> m_printContext;
910 #if PLATFORM(GTK)
911     RefPtr<WebPrintOperationGtk> m_printOperation;
912 #endif
913
914     SandboxExtensionTracker m_sandboxExtensionTracker;
915     uint64_t m_pageID;
916
917     RefPtr<SandboxExtension> m_pendingDropSandboxExtension;
918     Vector<RefPtr<SandboxExtension> > m_pendingDropExtensionsForFileUpload;
919
920     bool m_canRunBeforeUnloadConfirmPanel;
921
922     bool m_canRunModal;
923     bool m_isRunningModal;
924
925     bool m_cachedMainFrameIsPinnedToLeftSide;
926     bool m_cachedMainFrameIsPinnedToRightSide;
927     bool m_cachedMainFrameIsPinnedToTopSide;
928     bool m_cachedMainFrameIsPinnedToBottomSide;
929     bool m_canShortCircuitHorizontalWheelEvents;
930     unsigned m_numWheelEventHandlers;
931
932     unsigned m_cachedPageCount;
933
934     double m_minimumLayoutWidth;
935
936 #if ENABLE(CONTEXT_MENUS)
937     bool m_isShowingContextMenu;
938 #endif
939     
940     bool m_willGoToBackForwardItemCallbackEnabled;
941
942 #if PLATFORM(QT)
943     HashMap<String, QtNetworkReply*> m_applicationSchemeReplies;
944 #endif
945 #if ENABLE(PAGE_VISIBILITY_API)
946     WebCore::PageVisibilityState m_visibilityState;
947 #endif
948     WebInspectorClient* m_inspectorClient;
949
950     HashSet<String, CaseFoldingHash> m_mimeTypesWithCustomRepresentations;
951     WebCore::Color m_backgroundColor;
952 };
953
954 } // namespace WebKit
955
956 #endif // WebPage_h