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