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