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