[WK2] Change how to check the state of keypad
[framework/web/webkit-efl.git] / Source / WebKit2 / UIProcess / API / efl / PageClientImpl.h
1 /*
2  * Copyright (C) 2011 Samsung Electronics
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 PageClientImpl_h
27 #define PageClientImpl_h
28
29 #include "PageClient.h"
30 #include <Evas.h>
31
32 #if OS(TIZEN)
33 #include "WebEditCommandProxy.h"
34 #include <WebCore/ViewportArguments.h>
35
36 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
37 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
38 #include "DrawingAreaProxyImpl.h"
39 #include <WebCore/Color.h>
40 #endif
41 #endif
42 #if ENABLE(TIZEN_ISF_PORT)
43 #include "EditorState.h"
44 #endif
45 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
46 #include "TextSelection.h"
47 #endif
48 #endif // #if OS(TIZEN)
49
50 namespace WebKit {
51
52 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
53 class MainFrameScrollbarEfl;
54 #endif
55
56 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
57 class TextSelection;
58 #endif
59
60 class PageClientImpl : public PageClient {
61 public:
62     static PassOwnPtr<PageClientImpl> create(WebContext* context, WebPageGroup* pageGroup, Evas_Object* viewWidget)
63     {
64         return adoptPtr(new PageClientImpl(context, pageGroup, viewWidget));
65     }
66     ~PageClientImpl();
67
68     Evas_Object* viewWidget() const { return m_viewWidget; }
69
70     WebPageProxy* page() const { return m_page.get(); }
71
72 #if OS(TIZEN)
73     struct ViewportConstraints {
74         ViewportConstraints()
75             : initialScale(1.0)
76             , minimumScale(0.25)
77             , maximumScale(5.0)
78             , userScalable(true)
79             , layoutSize(WebCore::IntSize())
80 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
81             , devicePixelRatio(1.0)
82 #endif
83         {
84         }
85         double initialScale;
86         double minimumScale;
87         double maximumScale;
88         bool userScalable;
89         WebCore::IntSize layoutSize;
90 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
91         double devicePixelRatio;
92 #endif
93     };
94
95     ViewportConstraints viewportConstraints() { return m_viewportConstraints; }
96     ViewportConstraints computeViewportConstraints(const WebCore::ViewportAttributes&);
97     double adjustScaleWithViewport(double);
98 #if USE(TILED_BACKING_STORE) && ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
99     void updateViewportSize(const WebCore::IntSize& viewportSize);
100 #endif
101     void initializeLayoutAndScale();
102     void updateLayoutAndScale(bool fitToContentWidth = false);
103
104     void setFocusedNodeRect(const WebCore::IntRect&);
105     WebCore::IntRect focusedNodeRect() { return m_focusedNodeRect; };
106
107 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
108     void setInputMethodState(bool active, const AtomicString& inputType, const String& inputValue);
109 #else
110     void setInputMethodState(bool active);
111 #endif
112 #if ENABLE(TIZEN_ISF_PORT)
113     void handleInputMethodMouseRelease();
114     void handleInputMethodState();
115     void setCursorPosition(int preeditPosition = 0);
116     bool getInputMethodState();
117     bool initializeInputMethod();
118     bool isShowImeState() { return m_inputMethodState; }
119     void setImeState(bool state) { m_inputMethodState = state; }
120
121     void imContextPreeditChanged();
122     void imContextCommitted(char*);
123
124     void handleInputMethodKeydown();
125     void handleInputMethodMousePress();
126     Ecore_IMF_Context* getIMFContext() { return m_inputMethod; }
127     void handleInputMethodForFocusedNode();
128 #endif
129
130     void setViewFocused(bool focused) { m_viewFocused = focused; }
131     void setViewWindowActive(bool active) { m_viewWindowActive = active; }
132     void updateFormNavigation(int length, int offset);
133
134 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
135 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
136     DrawingAreaProxy* drawingArea() const { return m_page->drawingArea(); }
137 #endif
138     virtual void pageDidRequestScroll(const WebCore::IntPoint&);
139     float scaleFactor() { return m_scaleFactor; }
140     WebCore::IntPoint scrollPosition() { return m_visibleContentRect.location(); }
141     void adjustVisibleContentRect(WebCore::IntRect&, float);
142     void setVisibleContentRect(const WebCore::IntPoint&, float, const WebCore::FloatPoint&);
143     void displayViewport();
144     void drawContents();
145     void scaleImage(double, WebCore::IntPoint, bool adjustToBoundary = false);
146     void scaleContents(double, const WebCore::IntPoint&);
147     WebCore::IntRect visibleContentRect() { return m_visibleContentRect; }
148
149 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
150     void updateScrollbar(const WebCore::IntPoint& scrollPosition);
151     void frameRectChanged();
152 #endif
153 #else
154     float scaleFactor() { return page()->pageScaleFactor(); }
155     WebCore::IntPoint scrollPosition() { return page()->scrollPosition(); }
156 #endif // #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
157
158 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
159     bool isTextSelectionEnable();
160     void setIsTextSelectionEnable(bool isTextSelectionEnable);
161     bool isTextSelectionDowned();
162     bool isTextSelectionMode();
163     void setIsTextSelectionMode(bool isTextSelectionMode);
164     void updateTextSelectionHandlesAndContextMenu(bool isShow);
165     void textSelectionDown(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside = false);
166     void textSelectionMove(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside = false);
167     void textSelectionUp(const WebCore::IntPoint& point);
168 #endif
169
170 #if ENABLE(TIZEN_WEBKIT_PASTEBOARD)
171     void writeDataToClipboardWithType(const String&, WebCore::Pasteboard::PasteboardDataType);
172     void pasteWithClipboard();
173 #endif
174
175     //FIXME: These are for supporting suspend/resume API. so they should be moved to ewk_XXX.
176     void suspendIfNeeded();
177     void resumeIfNeeded();
178
179     void suspendPainting();
180     void suspendJavaScriptAndResource();
181     void resumePainting();
182     void resumeJavaScriptAndResource();
183
184 #if ENABLE(TIZEN_NPAPI)
185     void suspendPlugin();
186     void resumePlugin();
187 #endif
188
189 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
190     void setIsVisible(bool isVisible);
191 #endif
192
193 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
194     bool scrollBy(WebCore::IntSize);
195     void scrollTo(WebCore::IntPoint);
196 #endif
197
198     void setIsScrollableNodeFocused(const bool b) { m_isScrollableNodeFocused = b; }
199     bool isScrollableNodeFocused() const { return m_isScrollableNodeFocused; }
200 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
201     void findScrollableNode(WebCore::IntPoint&);
202 #endif
203
204 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
205     bool isContextMenuVisible() { return m_isContextMenuVisible; }
206     void setIsContextMenuVisible(bool isVisible) { m_isContextMenuVisible = isVisible; }
207 #endif
208     void didRenderFrame();
209 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
210     void setBackgroundColor(double red, double green, double blue, double alpha);
211 #endif
212 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
213     void didGetTextStyleStateForSelection(int underlineState, int italicState, int boldState);
214 #endif
215
216 #endif // #if OS(TIZEN)
217
218 private:
219     PageClientImpl(WebContext*, WebPageGroup*, Evas_Object*);
220
221 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
222     void createScrollbarIfNeeded(bool horizontalBar, bool verticalBar);
223 #endif
224
225     // PageClient
226     virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy();
227     virtual void setViewNeedsDisplay(const WebCore::IntRect&);
228     virtual void displayView();
229     virtual void scrollView(const WebCore::IntRect&, const WebCore::IntSize&);
230     virtual WebCore::IntSize viewSize();
231     virtual bool isViewWindowActive() { return m_viewWindowActive; }
232     virtual bool isViewFocused() { return m_viewFocused; }
233     virtual bool isViewVisible();
234     virtual bool isViewInWindow();
235
236     virtual void processDidCrash();
237     virtual void didRelaunchProcess();
238     virtual void pageClosed();
239
240     virtual void toolTipChanged(const String&, const String&);
241
242     virtual void setCursor(const WebCore::Cursor&);
243     virtual void setCursorHiddenUntilMouseMoves(bool);
244     virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&);
245
246     virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo);
247     virtual void clearAllEditCommands();
248     virtual bool canUndoRedo(WebPageProxy::UndoOrRedo);
249     virtual void executeUndoRedo(WebPageProxy::UndoOrRedo);
250     virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&);
251     virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&);
252     virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&);
253     virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&);
254
255     virtual void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool);
256 #if ENABLE(TOUCH_EVENTS)
257     virtual void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled);
258 #endif
259
260     virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*);
261     virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*);
262
263 #if ENABLE(INPUT_TYPE_COLOR)
264     virtual PassRefPtr<WebColorChooserProxy> createColorChooserProxy(WebPageProxy*, const WebCore::Color& initialColor);
265 #endif
266
267     virtual void setFindIndicator(PassRefPtr<FindIndicator>, bool, bool);
268 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
269     void initializeAcceleratedCompositingMode();
270     void finalizeAcceleratedCompositingMode();
271     virtual void enterAcceleratedCompositingMode(const LayerTreeContext&);
272     virtual void exitAcceleratedCompositingMode();
273     void setTargetSurface();
274     virtual void updateAcceleratedCompositingMode(const LayerTreeContext&);
275     virtual void updateLayoutAndScaleIfNeeded();
276 #endif
277
278     virtual void didChangeScrollbarsForMainFrame() const;
279
280 #if OS(TIZEN)
281 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
282     virtual void updateTextSelection();
283 #endif
284
285     virtual void didStartProgress();
286     virtual void didFirstVisuallyNonEmptyLayoutForMainFrame();
287     virtual void didFinishLoadForMainFrame();
288     virtual void didFinishProgress();
289     virtual void didChangeContentsSize(const WebCore::IntSize);
290     virtual void setRequestedScaleFactor(double);
291     virtual void pageScaleFactorDidChange();
292 #if ENABLE(TOUCH_EVENTS) && ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
293     virtual void cancelTouchEvent();
294 #endif
295 #endif
296
297     virtual void didCommitLoadForMainFrame(bool);
298     virtual void didFinishLoadingDataForCustomRepresentation(const String&, const CoreIPC::DataReference&);
299     virtual double customRepresentationZoomFactor();
300     virtual void setCustomRepresentationZoomFactor(double);
301
302     virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>&);
303     virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned);
304     virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned);
305
306 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
307     virtual void registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title);
308 #endif
309 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
310     virtual void registerContentHandler(const String& mimeType, const String& baseURL, const String& url, const String& title);
311 #endif
312
313 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
314     virtual bool getStandaloneStatus();
315 #endif
316
317 #if ENABLE(TIZEN_VIBRATION)
318     virtual void vibrate(const unsigned long& time);
319     virtual void cancelVibration();
320 #endif
321 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
322     virtual bool lockOrientation(int willLockOrientation);
323     virtual void unlockOrientation();
324 #endif
325
326 private:
327     RefPtr<WebPageProxy> m_page;
328     Evas_Object* m_viewWidget;
329 #if OS(TIZEN)
330     ViewportConstraints m_viewportConstraints;
331     double m_requestedScaleFactor;
332
333     bool m_viewFocused;
334     bool m_viewWindowActive;
335
336     bool m_preventNextCompositionCommit;
337     enum LayoutAndScaleState {
338         BeforeCommitLoad = 0,
339         DidCommitLoaded,
340         DidFirstVisuallyNonEmptyLayout,
341         DidFirstFrameRendered
342     };
343     LayoutAndScaleState m_layoutAndScaleState;
344     bool m_areFirstLayoutAndScaleInitialized;
345
346     Ecore_IMF_Context* m_inputMethod;
347     bool m_inputMethodState;
348     bool m_mousePressed;
349     WebCore::IntRect m_focusedNodeRect;
350
351 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
352     WebCore::IntRect m_visibleContentRect;
353     float m_scaleFactor;
354
355     WebCore::IntRect m_visibleContentRectForDrawContents;
356     float m_scaleFactorForDrawContents;
357 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
358     Evas_GL* m_evasGL;
359     Evas_GL_API* m_evasGlApi;
360     Evas_GL_Context* m_context;
361     Evas_GL_Surface* m_surface;
362     Evas_GL_Config* m_config;
363     bool m_isAcceleratedCompositingModeInitialized;
364 #endif
365 #endif
366
367 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
368     RefPtr<MainFrameScrollbarEfl> m_horizontalScrollbar;
369     RefPtr<MainFrameScrollbarEfl> m_verticalScrollbar;
370 #endif
371 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
372     OwnPtr<TextSelection> m_textSelection;
373 #endif
374     bool m_suspendPainting;
375     bool m_suspendResource;
376     bool m_suspendRequested;
377     bool m_isVisible;
378
379     bool m_isScrollableNodeFocused;
380
381 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
382     bool m_isContextMenuVisible;
383 #endif
384
385 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
386     String m_inputValue;
387     String m_inputType;
388 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
389
390 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
391     WebCore::Color m_bgColor;
392 #endif
393
394     Vector<RefPtr<WebKit::WebEditCommandProxy> > m_undoCommands;
395     Vector<RefPtr<WebKit::WebEditCommandProxy> > m_redoCommands;
396
397 #endif // #if OS(TIZEN)
398 };
399
400 } // namespace WebKit
401
402 #endif // PageClientImpl_h