Resizing Cappuccino is very laggy on WebKit since Safari 5.1
[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/TextChecking.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 HAVE(ACCESSIBILITY) && (PLATFORM(GTK) || PLATFORM(EFL))
81 #include "WebPageAccessibilityObject.h"
82 #include <wtf/gobject/GRefPtr.h>
83 #endif
84
85 #if PLATFORM(GTK)
86 #include "ArgumentCodersGtk.h"
87 #include "WebPrintOperationGtk.h"
88 #endif
89
90 #if ENABLE(TOUCH_EVENTS)
91 #include <WebCore/PlatformTouchEvent.h>
92 #endif
93
94 #if PLATFORM(MAC)
95 #include "DictionaryPopupInfo.h"
96 #include "LayerHostingContext.h"
97 #include <wtf/RetainPtr.h>
98 OBJC_CLASS NSDictionary;
99 OBJC_CLASS NSObject;
100 OBJC_CLASS WKAccessibilityWebPageObject;
101 #endif
102
103 namespace CoreIPC {
104     class ArgumentDecoder;
105     class Connection;
106 }
107
108 namespace WebCore {
109     class GraphicsContext;
110     class Frame;
111     class FrameView;
112     class HTMLPlugInElement;
113     class KeyboardEvent;
114     class Page;
115     class PrintContext;
116     class Range;
117     class ResourceResponse;
118     class ResourceRequest;
119     class SharedBuffer;
120     class TextCheckingRequest;
121     class VisibleSelection;
122     struct KeypressCommand;
123     struct TextCheckingResult;
124 }
125
126 namespace WebKit {
127
128 class DrawingArea;
129 class InjectedBundleBackForwardList;
130 class NotificationPermissionRequestManager;
131 class PageOverlay;
132 class PluginView;
133 class SessionState;
134 class WebColorChooser;
135 class WebContextMenu;
136 class WebContextMenuItemData;
137 class WebEvent;
138 class WebFrame;
139 class WebFullScreenManager;
140 class WebImage;
141 class WebInspector;
142 class WebInspectorClient;
143 class WebKeyboardEvent;
144 class WebMouseEvent;
145 class WebNotificationClient;
146 class WebOpenPanelResultListener;
147 class WebPageGroupProxy;
148 class WebPopupMenu;
149 class WebWheelEvent;
150 struct AttributedString;
151 struct EditorState;
152 struct PrintInfo;
153 struct WebPageCreationParameters;
154 struct WebPreferencesStore;
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::MessageReceiver, 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     static WebPage* fromCorePage(WebCore::Page*);
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::MessageDecoder&) OVERRIDE;
243     void didReceiveSyncMessage(CoreIPC::Connection*, 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     void sendSetWindowFrame(const WebCore::FloatRect&);
303
304     double textZoomFactor() const;
305     void setTextZoomFactor(double);
306     double pageZoomFactor() const;
307     void setPageZoomFactor(double);
308     void setPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor);
309     void windowScreenDidChange(uint64_t);
310     void setViewMode(WebCore::Page::ViewMode);
311
312     void scalePage(double scale, const WebCore::IntPoint& origin);
313     double pageScaleFactor() const;
314
315     void setUseFixedLayout(bool);
316     bool useFixedLayout() const { return m_useFixedLayout; }
317     void setFixedLayoutSize(const WebCore::IntSize&);
318
319     void listenForLayoutMilestones(uint32_t /* LayoutMilestones */);
320
321     void setSuppressScrollbarAnimations(bool);
322
323     void setRubberBandsAtBottom(bool);
324     void setRubberBandsAtTop(bool);
325
326     void setPaginationMode(uint32_t /* WebCore::Pagination::Mode */);
327     void setPaginationBehavesLikeColumns(bool);
328     void setPageLength(double);
329     void setGapBetweenPages(double);
330
331     void postInjectedBundleMessage(const String& messageName, CoreIPC::MessageDecoder&);
332
333     bool drawsBackground() const { return m_drawsBackground; }
334     bool drawsTransparentBackground() const { return m_drawsTransparentBackground; }
335
336     void setUnderlayColor(const WebCore::Color& color) { m_underlayColor = color; }
337     WebCore::Color underlayColor() const { return m_underlayColor; }
338
339     void stopLoading();
340     void stopLoadingFrame(uint64_t frameID);
341     void setDefersLoading(bool deferLoading);
342
343 #if USE(ACCELERATED_COMPOSITING)
344     void enterAcceleratedCompositingMode(WebCore::GraphicsLayer*);
345     void exitAcceleratedCompositingMode();
346 #endif
347
348     void addPluginView(PluginView*);
349     void removePluginView(PluginView*);
350
351 #if PLATFORM(MAC)
352     LayerHostingMode layerHostingMode() const { return m_layerHostingMode; }
353     void setLayerHostingMode(LayerHostingMode);
354
355     bool windowIsVisible() const { return m_windowIsVisible; }
356     void updatePluginsActiveAndFocusedState();
357     const WebCore::FloatRect& windowFrameInScreenCoordinates() const { return m_windowFrameInScreenCoordinates; }
358     const WebCore::FloatRect& viewFrameInWindowCoordinates() const { return m_viewFrameInWindowCoordinates; }
359
360     bool hasCachedWindowFrame() const { return m_hasCachedWindowFrame; }
361
362     void setTopOverhangImage(PassRefPtr<WebImage>);
363     void setBottomOverhangImage(PassRefPtr<WebImage>);
364 #endif
365
366     bool windowIsFocused() const;
367     bool windowAndWebPageAreFocused() const;
368     void installPageOverlay(PassRefPtr<PageOverlay>, bool shouldFadeIn = false);
369     void uninstallPageOverlay(PageOverlay*, bool shouldFadeOut = false);
370     bool hasPageOverlay() const { return m_pageOverlay; }
371     WebCore::IntPoint screenToWindow(const WebCore::IntPoint&);
372     WebCore::IntRect windowToScreen(const WebCore::IntRect&);
373
374     PassRefPtr<WebImage> scaledSnapshotWithOptions(const WebCore::IntRect&, double scaleFactor, SnapshotOptions);
375
376     static const WebEvent* currentEvent();
377
378     FindController& findController() { return m_findController; }
379 #if ENABLE(TOUCH_EVENTS) && PLATFORM(QT)
380     TapHighlightController& tapHighlightController() { return m_tapHighlightController; }
381 #endif
382
383 #if ENABLE(GEOLOCATION)
384     GeolocationPermissionRequestManager& geolocationPermissionRequestManager() { return m_geolocationPermissionRequestManager; }
385 #endif
386
387     NotificationPermissionRequestManager* notificationPermissionRequestManager();
388
389     void pageDidScroll();
390 #if USE(TILED_BACKING_STORE)
391     void pageDidRequestScroll(const WebCore::IntPoint&);
392     void setFixedVisibleContentRect(const WebCore::IntRect&);
393     void sendViewportAttributesChanged();
394 #endif
395
396 #if ENABLE(CONTEXT_MENUS)
397     WebContextMenu* contextMenu();
398 #endif
399     
400     bool hasLocalDataForURL(const WebCore::KURL&);
401     String cachedResponseMIMETypeForURL(const WebCore::KURL&);
402     String cachedSuggestedFilenameForURL(const WebCore::KURL&);
403     PassRefPtr<WebCore::SharedBuffer> cachedResponseDataForURL(const WebCore::KURL&);
404
405     static bool canHandleRequest(const WebCore::ResourceRequest&);
406
407     class SandboxExtensionTracker {
408     public:
409         ~SandboxExtensionTracker();
410
411         void invalidate();
412
413         void beginLoad(WebFrame*, const SandboxExtension::Handle& handle);
414         void willPerformLoadDragDestinationAction(PassRefPtr<SandboxExtension> pendingDropSandboxExtension);
415         void didStartProvisionalLoad(WebFrame*);
416         void didCommitProvisionalLoad(WebFrame*);
417         void didFailProvisionalLoad(WebFrame*);
418
419     private:
420         void setPendingProvisionalSandboxExtension(PassRefPtr<SandboxExtension>);
421
422         RefPtr<SandboxExtension> m_pendingProvisionalSandboxExtension;
423         RefPtr<SandboxExtension> m_provisionalSandboxExtension;
424         RefPtr<SandboxExtension> m_committedSandboxExtension;
425     };
426
427     SandboxExtensionTracker& sandboxExtensionTracker() { return m_sandboxExtensionTracker; }
428
429 #if PLATFORM(EFL)
430     void setThemePath(const String&);
431 #endif
432
433 #if USE(TILED_BACKING_STORE)
434     void commitPageTransitionViewport();
435 #endif
436
437 #if PLATFORM(QT) || PLATFORM(GTK)
438     void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd);
439     void confirmComposition(const String& text, int64_t selectionStart, int64_t selectionLength);
440     void cancelComposition();
441 #endif
442
443     void didChangeSelection();
444
445 #if PLATFORM(MAC)
446     void registerUIProcessAccessibilityTokens(const CoreIPC::DataReference& elemenToken, const CoreIPC::DataReference& windowToken);
447     WKAccessibilityWebPageObject* accessibilityRemoteObject();
448     const WebCore::FloatPoint& accessibilityPosition() const { return m_accessibilityPosition; }
449     
450     void sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String& textInput);
451
452     void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, EditorState& newState);
453     void confirmComposition(EditorState& newState);
454     void cancelComposition(EditorState& newState);
455     void insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, bool& handled, EditorState& newState);
456     void getMarkedRange(uint64_t& location, uint64_t& length);
457     void getSelectedRange(uint64_t& location, uint64_t& length);
458     void getAttributedSubstringFromRange(uint64_t location, uint64_t length, AttributedString&);
459     void characterIndexForPoint(const WebCore::IntPoint point, uint64_t& result);
460     void firstRectForCharacterRange(uint64_t location, uint64_t length, WebCore::IntRect& resultRect);
461     void executeKeypressCommands(const Vector<WebCore::KeypressCommand>&, bool& handled, EditorState& newState);
462     void readSelectionFromPasteboard(const WTF::String& pasteboardName, bool& result);
463     void getStringSelectionForPasteboard(WTF::String& stringValue);
464     void getDataSelectionForPasteboard(const WTF::String pasteboardType, SharedMemory::Handle& handle, uint64_t& size);
465     void shouldDelayWindowOrderingEvent(const WebKit::WebMouseEvent&, bool& result);
466     void acceptsFirstMouse(int eventNumber, const WebKit::WebMouseEvent&, bool& result);
467     bool performNonEditingBehaviorForSelector(const String&);
468     void insertDictatedText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, const Vector<WebCore::DictationAlternative>& dictationAlternativeLocations, bool& handled, EditorState& newState);
469 #elif PLATFORM(EFL)
470     void confirmComposition(const String& compositionString);
471     void setComposition(const WTF::String& compositionString, const WTF::Vector<WebCore::CompositionUnderline>& underlines, uint64_t cursorPosition);
472     void cancelComposition();
473 #elif PLATFORM(GTK)
474 #if USE(TEXTURE_MAPPER_GL)
475     void setAcceleratedCompositingWindowId(int64_t nativeWindowHandle);
476 #endif
477 #endif
478
479 #if HAVE(ACCESSIBILITY) && (PLATFORM(GTK) || PLATFORM(EFL))
480     void updateAccessibilityTree();
481 #endif
482
483     void setCompositionForTesting(const String& compositionString, uint64_t from, uint64_t length);
484     bool hasCompositionForTesting();
485     void confirmCompositionForTesting(const String& compositionString);
486
487     // FIXME: This a dummy message, to avoid breaking the build for platforms that don't require
488     // any synchronous messages, and should be removed when <rdar://problem/8775115> is fixed.
489     void dummy(bool&);
490
491 #if PLATFORM(MAC)
492     void performDictionaryLookupForSelection(DictionaryPopupInfo::Type, WebCore::Frame*, const WebCore::VisibleSelection&);
493
494     bool isSpeaking();
495     void speak(const String&);
496     void stopSpeaking();
497
498 #endif
499
500     bool isSmartInsertDeleteEnabled();
501     void setSmartInsertDeleteEnabled(bool);
502
503     void replaceSelectionWithText(WebCore::Frame*, const String&);
504     void clearSelection();
505
506 #if ENABLE(DRAG_SUPPORT)
507 #if PLATFORM(QT) || PLATFORM(GTK)
508     void performDragControllerAction(uint64_t action, WebCore::DragData);
509 #else
510     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&);
511 #endif
512     void dragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t operation);
513
514     void willPerformLoadDragDestinationAction();
515     void mayPerformUploadDragDestinationAction();
516 #endif // ENABLE(DRAG_SUPPORT)
517
518     void beginPrinting(uint64_t frameID, const PrintInfo&);
519     void endPrinting();
520     void computePagesForPrinting(uint64_t frameID, const PrintInfo&, uint64_t callbackID);
521 #if PLATFORM(MAC)
522     void drawRectToImage(uint64_t frameID, const PrintInfo&, const WebCore::IntRect&, const WebCore::IntSize&, uint64_t callbackID);
523     void drawPagesToPDF(uint64_t frameID, const PrintInfo&, uint32_t first, uint32_t count, uint64_t callbackID);
524 #elif PLATFORM(GTK)
525     void drawPagesForPrinting(uint64_t frameID, const PrintInfo&, uint64_t callbackID);
526 #endif
527
528     void setMediaVolume(float);
529     void setMayStartMediaWhenInWindow(bool);
530
531     bool mainFrameHasCustomRepresentation() const;
532
533     void didChangeScrollOffsetForMainFrame();
534
535     void mainFrameDidLayout();
536
537     bool canRunBeforeUnloadConfirmPanel() const { return m_canRunBeforeUnloadConfirmPanel; }
538     void setCanRunBeforeUnloadConfirmPanel(bool canRunBeforeUnloadConfirmPanel) { m_canRunBeforeUnloadConfirmPanel = canRunBeforeUnloadConfirmPanel; }
539
540     bool canRunModal() const { return m_canRunModal; }
541     void setCanRunModal(bool canRunModal) { m_canRunModal = canRunModal; }
542
543     void runModal();
544
545     void setDeviceScaleFactor(float);
546     float deviceScaleFactor() const;
547
548     void setMemoryCacheMessagesEnabled(bool);
549
550     void forceRepaintWithoutCallback();
551
552     void unmarkAllMisspellings();
553     void unmarkAllBadGrammar();
554 #if PLATFORM(MAC)
555     void handleAlternativeTextUIResult(const String&);
556 #endif
557
558     // For testing purpose.
559     void simulateMouseDown(int button, WebCore::IntPoint, int clickCount, WKEventModifiers, double time);
560     void simulateMouseUp(int button, WebCore::IntPoint, int clickCount, WKEventModifiers, double time);
561     void simulateMouseMotion(WebCore::IntPoint, double time);
562
563 #if ENABLE(CONTEXT_MENUS)
564     void contextMenuShowing() { m_isShowingContextMenu = true; }
565 #endif
566
567 #if PLATFORM(QT)
568     void registerApplicationScheme(const String& scheme);
569     void applicationSchemeReply(const QtNetworkReplyData&);
570     void receivedApplicationSchemeRequest(const QNetworkRequest&, QtNetworkReply*);
571     void setUserScripts(const Vector<String>&);
572 #endif
573     void wheelEvent(const WebWheelEvent&);
574 #if ENABLE(GESTURE_EVENTS)
575     void gestureEvent(const WebGestureEvent&);
576 #endif
577
578     void numWheelEventHandlersChanged(unsigned);
579     void recomputeShortCircuitHorizontalWheelEventsState();
580
581     bool willGoToBackForwardItemCallbackEnabled() const { return m_willGoToBackForwardItemCallbackEnabled; }
582
583 #if ENABLE(PAGE_VISIBILITY_API) || ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
584     void setVisibilityState(uint32_t /* WebCore::PageVisibilityState */, bool isInitialState);
585 #endif
586
587 #if PLATFORM(GTK) && USE(TEXTURE_MAPPER_GL)
588     uint64_t nativeWindowHandle() { return m_nativeWindowHandle; }
589 #endif
590
591     bool shouldUseCustomRepresentationForResponse(const WebCore::ResourceResponse&);
592     bool canPluginHandleResponse(const WebCore::ResourceResponse& response);
593
594     bool asynchronousPluginInitializationEnabled() const { return m_asynchronousPluginInitializationEnabled; }
595     void setAsynchronousPluginInitializationEnabled(bool enabled) { m_asynchronousPluginInitializationEnabled = enabled; }
596     bool asynchronousPluginInitializationEnabledForAllPlugins() const { return m_asynchronousPluginInitializationEnabledForAllPlugins; }
597     void setAsynchronousPluginInitializationEnabledForAllPlugins(bool enabled) { m_asynchronousPluginInitializationEnabledForAllPlugins = enabled; }
598     bool artificialPluginInitializationDelayEnabled() const { return m_artificialPluginInitializationDelayEnabled; }
599     void setArtificialPluginInitializationDelayEnabled(bool enabled) { m_artificialPluginInitializationDelayEnabled = enabled; }
600     void setTabToLinksEnabled(bool enabled) { m_tabToLinks = enabled; }
601     bool tabToLinksEnabled() const { return m_tabToLinks; }
602
603     bool scrollingPerformanceLoggingEnabled() const { return m_scrollingPerformanceLoggingEnabled; }
604     void setScrollingPerformanceLoggingEnabled(bool);
605
606 #if PLATFORM(MAC)
607     bool pdfPluginEnabled() const { return m_pdfPluginEnabled; }
608     void setPDFPluginEnabled(bool enabled) { m_pdfPluginEnabled = enabled; }
609 #endif
610
611 #if PLATFORM(MAC)
612     static HashSet<String, CaseFoldingHash> pdfAndPostScriptMIMETypes();
613 #endif
614
615     void savePDFToFileInDownloadsFolder(const String& suggestedFilename, const String& originatingURLString, const uint8_t* data, unsigned long size);
616 #if PLATFORM(MAC)
617     void savePDFToTemporaryFolderAndOpenWithNativeApplication(const String& suggestedFilename, const String& originatingURLString, const uint8_t* data, unsigned long size, const String& pdfUUID);
618 #endif
619
620     bool mainFrameIsScrollable() const { return m_mainFrameIsScrollable; }
621
622     void setMinimumLayoutWidth(double);
623     double minimumLayoutWidth() const { return m_minimumLayoutWidth; }
624
625     bool canShowMIMEType(const String& MIMEType) const;
626
627     void addTextCheckingRequest(uint64_t requestID, PassRefPtr<WebCore::TextCheckingRequest>);
628     void didFinishCheckingText(uint64_t requestID, const Vector<WebCore::TextCheckingResult>&);
629     void didCancelCheckingText(uint64_t requestID);
630
631 private:
632     WebPage(uint64_t pageID, const WebPageCreationParameters&);
633
634     virtual Type type() const { return APIType; }
635
636     void platformInitialize();
637
638     void didReceiveWebPageMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&);
639     void didReceiveSyncWebPageMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&);
640
641 #if !PLATFORM(MAC)
642     static const char* interpretKeyEvent(const WebCore::KeyboardEvent*);
643 #endif
644     bool performDefaultBehaviorForKeyEvent(const WebKeyboardEvent&);
645
646 #if PLATFORM(MAC)
647     bool executeKeypressCommandsInternal(const Vector<WebCore::KeypressCommand>&, WebCore::KeyboardEvent*);
648 #endif
649
650     String sourceForFrame(WebFrame*);
651
652     void loadData(PassRefPtr<WebCore::SharedBuffer>, const String& MIMEType, const String& encodingName, const WebCore::KURL& baseURL, const WebCore::KURL& failingURL);
653
654     bool platformHasLocalDataForURL(const WebCore::KURL&);
655
656     // Actions
657     void tryClose();
658     void loadURL(const String&, const SandboxExtension::Handle&);
659     void loadURLRequest(const WebCore::ResourceRequest&, const SandboxExtension::Handle&);
660     void loadHTMLString(const String& htmlString, const String& baseURL);
661     void loadAlternateHTMLString(const String& htmlString, const String& baseURL, const String& unreachableURL);
662     void loadPlainTextString(const String&);
663     void loadWebArchiveData(const CoreIPC::DataReference&);
664     void linkClicked(const String& url, const WebMouseEvent&);
665     void reload(bool reloadFromOrigin, const SandboxExtension::Handle&);
666     void goForward(uint64_t);
667     void goBack(uint64_t);
668     void goToBackForwardItem(uint64_t);
669     void tryRestoreScrollPosition();
670     void setActive(bool);
671     void setFocused(bool);
672     void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&);
673     void setWindowResizerSize(const WebCore::IntSize&);
674     void setIsInWindow(bool);
675     void validateCommand(const String&, uint64_t);
676     void executeEditCommand(const String&);
677
678     void mouseEvent(const WebMouseEvent&);
679     void mouseEventSyncForTesting(const WebMouseEvent&, bool&);
680     void wheelEventSyncForTesting(const WebWheelEvent&, bool&);
681     void keyEvent(const WebKeyboardEvent&);
682     void keyEventSyncForTesting(const WebKeyboardEvent&, bool&);
683 #if ENABLE(TOUCH_EVENTS)
684     void touchEvent(const WebTouchEvent&);
685     void touchEventSyncForTesting(const WebTouchEvent&, bool& handled);
686 #if PLATFORM(QT)
687     void highlightPotentialActivation(const WebCore::IntPoint&, const WebCore::IntSize& area);
688 #endif
689 #endif
690 #if ENABLE(CONTEXT_MENUS)
691     void contextMenuHidden() { m_isShowingContextMenu = false; }
692 #endif
693
694     static void scroll(WebCore::Page*, WebCore::ScrollDirection, WebCore::ScrollGranularity);
695     static void logicalScroll(WebCore::Page*, WebCore::ScrollLogicalDirection, WebCore::ScrollGranularity);
696
697     uint64_t restoreSession(const SessionState&);
698     void restoreSessionAndNavigateToCurrentItem(const SessionState&);
699
700     void didRemoveBackForwardItem(uint64_t);
701
702     void setWillGoToBackForwardItemCallbackEnabled(bool enabled) { m_willGoToBackForwardItemCallbackEnabled = enabled; }
703     
704     void setDrawsBackground(bool);
705     void setDrawsTransparentBackground(bool);
706
707     void viewWillStartLiveResize();
708     void viewWillEndLiveResize();
709
710     void getContentsAsString(uint64_t callbackID);
711 #if ENABLE(MHTML)
712     void getContentsAsMHTMLData(uint64_t callbackID, bool useBinaryEncoding);
713 #endif
714     void getMainResourceDataOfFrame(uint64_t frameID, uint64_t callbackID);
715     void getResourceDataFromFrame(uint64_t frameID, const String& resourceURL, uint64_t callbackID);
716     void getRenderTreeExternalRepresentation(uint64_t callbackID);
717     void getSelectionOrContentsAsString(uint64_t callbackID);
718     void getSelectionAsWebArchiveData(uint64_t callbackID);
719     void getSourceForFrame(uint64_t frameID, uint64_t callbackID);
720     void getWebArchiveOfFrame(uint64_t frameID, uint64_t callbackID);
721     void runJavaScriptInMainFrame(const String&, uint64_t callbackID);
722     void forceRepaint(uint64_t callbackID);
723
724     void preferencesDidChange(const WebPreferencesStore&);
725     void platformPreferencesDidChange(const WebPreferencesStore&);
726     void updatePreferences(const WebPreferencesStore&);
727
728     void didReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, uint32_t policyAction, uint64_t downloadID);
729     void setUserAgent(const String&);
730     void setCustomTextEncodingName(const String&);
731     void suspendActiveDOMObjectsAndAnimations();
732     void resumeActiveDOMObjectsAndAnimations();
733
734 #if PLATFORM(MAC)
735     void performDictionaryLookupAtLocation(const WebCore::FloatPoint&);
736     void performDictionaryLookupForRange(DictionaryPopupInfo::Type, WebCore::Frame*, WebCore::Range*, NSDictionary *options);
737
738     void setWindowIsVisible(bool windowIsVisible);
739     void windowAndViewFramesChanged(const WebCore::FloatRect& windowFrameInScreenCoordinates, const WebCore::FloatRect& viewFrameInWindowCoordinates, const WebCore::FloatPoint& accessibilityViewCoordinates);
740
741     RetainPtr<PDFDocument> pdfDocumentForPrintingFrame(WebCore::Frame*);
742     void computePagesForPrintingPDFDocument(uint64_t frameID, const PrintInfo&, Vector<WebCore::IntRect>& resultPageRects);
743     void drawPDFDocument(CGContextRef, PDFDocument *, const PrintInfo&, const WebCore::IntRect&);
744     void drawPagesToPDFFromPDFDocument(CGContextRef, PDFDocument *, const PrintInfo&, uint32_t first, uint32_t count);
745 #endif
746
747     void viewExposedRectChanged(const WebCore::FloatRect& exposedRect);
748     void setMainFrameIsScrollable(bool);
749
750     void unapplyEditCommand(uint64_t commandID);
751     void reapplyEditCommand(uint64_t commandID);
752     void didRemoveEditCommand(uint64_t commandID);
753
754     void findString(const String&, uint32_t findOptions, uint32_t maxMatchCount);
755     void findStringMatches(const String&, uint32_t findOptions, uint32_t maxMatchCount);
756     void getImageForFindMatch(uint32_t matchIndex);
757     void selectFindMatch(uint32_t matchIndex);
758     void hideFindUI();
759     void countStringMatches(const String&, uint32_t findOptions, uint32_t maxMatchCount);
760
761 #if PLATFORM(QT)
762     void findZoomableAreaForPoint(const WebCore::IntPoint&, const WebCore::IntSize& area);
763 #endif
764
765     void didChangeSelectedIndexForActivePopupMenu(int32_t newIndex);
766     void setTextForActivePopupMenu(int32_t index);
767
768 #if PLATFORM(GTK)
769     void failedToShowPopupMenu();
770 #endif
771 #if PLATFORM(QT)
772     void hidePopupMenu();
773     void selectedIndex(int32_t newIndex);
774 #endif
775
776     void didChooseFilesForOpenPanel(const Vector<String>&);
777     void didCancelForOpenPanel();
778 #if ENABLE(WEB_PROCESS_SANDBOX)
779     void extendSandboxForFileFromOpenPanel(const SandboxExtension::Handle&);
780 #endif
781
782     void didReceiveGeolocationPermissionDecision(uint64_t geolocationID, bool allowed);
783
784     void didReceiveNotificationPermissionDecision(uint64_t notificationID, bool allowed);
785
786     void advanceToNextMisspelling(bool startBeforeSelection);
787     void changeSpellingToWord(const String& word);
788 #if USE(APPKIT)
789     void uppercaseWord();
790     void lowercaseWord();
791     void capitalizeWord();
792 #endif
793
794 #if ENABLE(CONTEXT_MENUS)
795     void didSelectItemFromActiveContextMenu(const WebContextMenuItemData&);
796 #endif
797
798     void changeSelectedIndex(int32_t index);
799     void setCanStartMediaTimerFired();
800
801     bool canHandleUserEvents() const;
802
803     void setMainFrameInViewSourceMode(bool);
804
805     static bool platformCanHandleRequest(const WebCore::ResourceRequest&);
806
807     static PluginView* focusedPluginViewForFrame(WebCore::Frame*);
808     static PluginView* pluginViewForFrame(WebCore::Frame*);
809
810     OwnPtr<WebCore::Page> m_page;
811     RefPtr<WebFrame> m_mainFrame;
812     RefPtr<InjectedBundleBackForwardList> m_backForwardList;
813
814     RefPtr<WebPageGroupProxy> m_pageGroup;
815
816     String m_userAgent;
817
818     WebCore::IntSize m_viewSize;
819     OwnPtr<DrawingArea> m_drawingArea;
820
821     HashSet<PluginView*> m_pluginViews;
822
823     HashMap<uint64_t, RefPtr<WebCore::TextCheckingRequest> > m_pendingTextCheckingRequestMap;
824
825     bool m_useFixedLayout;
826
827     bool m_drawsBackground;
828     bool m_drawsTransparentBackground;
829
830     WebCore::Color m_underlayColor;
831
832     bool m_isInRedo;
833     bool m_isClosed;
834
835     bool m_tabToLinks;
836     
837     bool m_asynchronousPluginInitializationEnabled;
838     bool m_asynchronousPluginInitializationEnabledForAllPlugins;
839     bool m_artificialPluginInitializationDelayEnabled;
840
841     bool m_scrollingPerformanceLoggingEnabled;
842
843     bool m_mainFrameIsScrollable;
844
845 #if PLATFORM(MAC)
846     bool m_pdfPluginEnabled;
847
848     bool m_hasCachedWindowFrame;
849
850     // Whether the containing window is visible or not.
851     bool m_windowIsVisible;
852
853     // The frame of the containing window in screen coordinates.
854     WebCore::FloatRect m_windowFrameInScreenCoordinates;
855
856     // The frame of the view in window coordinates.
857     WebCore::FloatRect m_viewFrameInWindowCoordinates;
858
859     // The accessibility position of the view.
860     WebCore::FloatPoint m_accessibilityPosition;
861     
862     // The layer hosting mode.
863     LayerHostingMode m_layerHostingMode;
864
865     RetainPtr<WKAccessibilityWebPageObject> m_mockAccessibilityElement;
866
867     WebCore::KeyboardEvent* m_keyboardEventBeingInterpreted;
868
869 #elif HAVE(ACCESSIBILITY) && (PLATFORM(GTK) || PLATFORM(EFL))
870     GRefPtr<WebPageAccessibilityObject> m_accessibilityObject;
871
872 #if USE(TEXTURE_MAPPER_GL)
873     // Our view's window in the UI process.
874     uint64_t m_nativeWindowHandle;
875 #endif
876 #endif
877     
878     WebCore::RunLoop::Timer<WebPage> m_setCanStartMediaTimer;
879     bool m_mayStartMediaWhenInWindow;
880
881     HashMap<uint64_t, RefPtr<WebUndoStep> > m_undoStepMap;
882
883     WebCore::IntSize m_windowResizerSize;
884
885 #if ENABLE(CONTEXT_MENUS)
886     InjectedBundlePageContextMenuClient m_contextMenuClient;
887 #endif
888     InjectedBundlePageEditorClient m_editorClient;
889     InjectedBundlePageFormClient m_formClient;
890     InjectedBundlePageLoaderClient m_loaderClient;
891     InjectedBundlePagePolicyClient m_policyClient;
892     InjectedBundlePageResourceLoadClient m_resourceLoadClient;
893     InjectedBundlePageUIClient m_uiClient;
894 #if ENABLE(FULLSCREEN_API)
895     InjectedBundlePageFullScreenClient m_fullScreenClient;
896 #endif
897     InjectedBundlePageDiagnosticLoggingClient m_logDiagnosticMessageClient;
898
899     FindController m_findController;
900 #if ENABLE(TOUCH_EVENTS) && PLATFORM(QT)
901     TapHighlightController m_tapHighlightController;
902 #endif
903     RefPtr<PageOverlay> m_pageOverlay;
904
905     RefPtr<WebPage> m_underlayPage;
906
907 #if ENABLE(INSPECTOR)
908     RefPtr<WebInspector> m_inspector;
909 #endif
910 #if ENABLE(FULLSCREEN_API)
911     RefPtr<WebFullScreenManager> m_fullScreenManager;
912 #endif
913     RefPtr<WebPopupMenu> m_activePopupMenu;
914 #if ENABLE(CONTEXT_MENUS)
915     RefPtr<WebContextMenu> m_contextMenu;
916 #endif
917 #if ENABLE(INPUT_TYPE_COLOR)
918     WebColorChooser* m_activeColorChooser;
919 #endif
920     RefPtr<WebOpenPanelResultListener> m_activeOpenPanelResultListener;
921     RefPtr<NotificationPermissionRequestManager> m_notificationPermissionRequestManager;
922
923 #if ENABLE(GEOLOCATION)
924     GeolocationPermissionRequestManager m_geolocationPermissionRequestManager;
925 #endif
926
927     OwnPtr<WebCore::PrintContext> m_printContext;
928 #if PLATFORM(GTK)
929     RefPtr<WebPrintOperationGtk> m_printOperation;
930 #endif
931
932     SandboxExtensionTracker m_sandboxExtensionTracker;
933     uint64_t m_pageID;
934
935     RefPtr<SandboxExtension> m_pendingDropSandboxExtension;
936     Vector<RefPtr<SandboxExtension> > m_pendingDropExtensionsForFileUpload;
937
938     bool m_canRunBeforeUnloadConfirmPanel;
939
940     bool m_canRunModal;
941     bool m_isRunningModal;
942
943     bool m_cachedMainFrameIsPinnedToLeftSide;
944     bool m_cachedMainFrameIsPinnedToRightSide;
945     bool m_cachedMainFrameIsPinnedToTopSide;
946     bool m_cachedMainFrameIsPinnedToBottomSide;
947     bool m_canShortCircuitHorizontalWheelEvents;
948     unsigned m_numWheelEventHandlers;
949
950     unsigned m_cachedPageCount;
951
952     double m_minimumLayoutWidth;
953
954 #if ENABLE(CONTEXT_MENUS)
955     bool m_isShowingContextMenu;
956 #endif
957     
958     bool m_willGoToBackForwardItemCallbackEnabled;
959
960 #if PLATFORM(QT)
961     HashMap<String, QtNetworkReply*> m_applicationSchemeReplies;
962 #endif
963 #if ENABLE(PAGE_VISIBILITY_API)
964     WebCore::PageVisibilityState m_visibilityState;
965 #endif
966     WebInspectorClient* m_inspectorClient;
967
968     HashSet<String, CaseFoldingHash> m_mimeTypesWithCustomRepresentations;
969     WebCore::Color m_backgroundColor;
970 };
971
972 } // namespace WebKit
973
974 #endif // WebPage_h