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