[Release] Webkit-EFL Ver. 2.0_beta_118996_0.6.24
[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 initializeScale();
102     void updateScale();
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 setCursorPosition(int preeditPosition = 0);
115     bool getInputMethodState();
116     bool initializeInputMethod();
117     void terminateInputMethod();
118
119     void imContextPreeditChanged();
120     void imContextCommitted(char*);
121
122     void handleInputMethodKeydown();
123     void handleInputMethodMousePress();
124     Ecore_IMF_Context* getIMFContext() { return m_inputMethod; }
125 #endif
126
127     void setViewFocused(bool focused) { m_viewFocused = focused; }
128     void setViewWindowActive(bool active) { m_viewWindowActive = active; }
129     void updateFormNavigation(int length, int offset);
130
131 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
132 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
133     DrawingAreaProxy* drawingArea() const { return m_page->drawingArea(); }
134 #endif
135     virtual void pageDidRequestScroll(const WebCore::IntPoint&);
136     float scaleFactor() { return m_scaleFactor; }
137     WebCore::IntPoint scrollPosition() { return m_visibleContentRect.location(); }
138     void adjustVisibleContentRect(WebCore::IntRect&, float);
139     void setVisibleContentRect(const WebCore::IntPoint&, float, const WebCore::FloatPoint&);
140     void displayViewport();
141     void drawContents();
142     void scaleImage(double, WebCore::IntPoint, bool adjustToBoundary = false);
143     void scaleContents(double, const WebCore::IntPoint&);
144     WebCore::IntRect visibleContentRect() { return m_visibleContentRect; }
145
146 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
147     void updateScrollbar(const WebCore::IntPoint& scrollPosition);
148     void frameRectChanged();
149 #endif
150 #else
151     float scaleFactor() { return page()->pageScaleFactor(); }
152     WebCore::IntPoint scrollPosition() { return page()->scrollPosition(); }
153 #endif // #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
154
155 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
156     bool isTextSelectionEnable();
157     void setIsTextSelectionEnable(bool isTextSelectionEnable);
158     bool isTextSelectionDowned();
159     bool isTextSelectionMode();
160     void setIsTextSelectionMode(bool isTextSelectionMode);
161     void updateTextSelectionHandlesAndContextMenu(bool isShow);
162     void textSelectionDown(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside = false);
163     void textSelectionMove(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside = false);
164     void textSelectionUp(const WebCore::IntPoint& point);
165 #endif
166
167 #if ENABLE(TIZEN_WEBKIT_PASTEBOARD)
168     void writeDataToClipboardWithType(const String&, WebCore::Pasteboard::PasteboardDataType);
169     void pasteWithClipboard();
170 #endif
171
172     //FIXME: These are for supporting suspend/resume API. so they should be moved to ewk_XXX.
173     void suspendIfNeeded();
174     void resumeIfNeeded();
175
176     void suspendPainting();
177     void suspendJavaScriptAndResource();
178     void resumePainting();
179     void resumeJavaScriptAndResource();
180
181 #if ENABLE(TIZEN_NPAPI)
182     void suspendPlugin();
183     void resumePlugin();
184 #endif
185
186 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
187     void setIsVisible(bool isVisible);
188 #endif
189
190 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
191     bool scrollBy(WebCore::IntSize);
192     void scrollTo(WebCore::IntPoint);
193 #endif
194
195     void setIsScrollableNodeFocused(const bool b) { m_isScrollableNodeFocused = b; }
196     bool isScrollableNodeFocused() const { return m_isScrollableNodeFocused; }
197 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
198     void findScrollableNode(WebCore::IntPoint&);
199 #endif
200
201 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
202     bool isContextMenuVisible() { return m_isContextMenuVisible; }
203     void setIsContextMenuVisible(bool isVisible) { m_isContextMenuVisible = isVisible; }
204 #endif
205     void didRenderFrame();
206 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
207     void setBackgroundColor(double red, double green, double blue, double alpha);
208 #endif
209 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
210     void didGetTextStyleStateForSelection(int underlineState, int italicState, int boldState);
211 #endif
212
213     virtual void didFindZoomableArea(const WebCore::IntPoint&, const WebCore::IntRect&);
214 #endif // #if OS(TIZEN)
215
216 private:
217     PageClientImpl(WebContext*, WebPageGroup*, Evas_Object*);
218
219 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
220     void createScrollbarIfNeeded(bool horizontalBar, bool verticalBar);
221 #endif
222
223     // PageClient
224     virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy();
225     virtual void setViewNeedsDisplay(const WebCore::IntRect&);
226     virtual void displayView();
227     virtual void scrollView(const WebCore::IntRect&, const WebCore::IntSize&);
228     virtual WebCore::IntSize viewSize();
229     virtual bool isViewWindowActive() { return m_viewWindowActive; }
230     virtual bool isViewFocused() { return m_viewFocused; }
231     virtual bool isViewVisible();
232     virtual bool isViewInWindow();
233
234     virtual void processDidCrash();
235     virtual void didRelaunchProcess();
236     virtual void pageClosed();
237
238     virtual void toolTipChanged(const String&, const String&);
239
240     virtual void setCursor(const WebCore::Cursor&);
241     virtual void setCursorHiddenUntilMouseMoves(bool);
242     virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&);
243
244     virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo);
245     virtual void clearAllEditCommands();
246     virtual bool canUndoRedo(WebPageProxy::UndoOrRedo);
247     virtual void executeUndoRedo(WebPageProxy::UndoOrRedo);
248     virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&);
249     virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&);
250     virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&);
251     virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&);
252
253     virtual void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool);
254 #if ENABLE(TOUCH_EVENTS)
255     virtual void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled);
256 #endif
257
258     virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*);
259     virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*);
260
261 #if ENABLE(INPUT_TYPE_COLOR)
262     virtual PassRefPtr<WebColorChooserProxy> createColorChooserProxy(WebPageProxy*, const WebCore::Color& initialColor);
263 #endif
264
265     virtual void setFindIndicator(PassRefPtr<FindIndicator>, bool, bool);
266 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
267     void initializeAcceleratedCompositingMode();
268     void finalizeAcceleratedCompositingMode();
269     virtual void enterAcceleratedCompositingMode(const LayerTreeContext&);
270     virtual void exitAcceleratedCompositingMode();
271     void setTargetSurface();
272     virtual void updateAcceleratedCompositingMode(const LayerTreeContext&);
273     virtual void updateLayoutAndScaleIfNeeded();
274 #endif
275
276     virtual void didChangeScrollbarsForMainFrame() const;
277
278 #if OS(TIZEN)
279 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
280     virtual void updateTextSelection();
281 #endif
282
283     virtual void didStartProgress();
284     virtual void didFirstVisuallyNonEmptyLayoutForMainFrame();
285     virtual void didFinishLoadForMainFrame();
286     virtual void didFinishProgress();
287     virtual void didChangeContentsSize(const WebCore::IntSize);
288     virtual void setRequestedScaleFactor(double);
289     virtual void pageScaleFactorDidChange();
290 #if ENABLE(TOUCH_EVENTS) && ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
291     virtual void cancelTouchEvent();
292 #endif
293 #endif
294
295     virtual void didCommitLoadForMainFrame(bool);
296     virtual void didFinishLoadingDataForCustomRepresentation(const String&, const CoreIPC::DataReference&);
297     virtual double customRepresentationZoomFactor();
298     virtual void setCustomRepresentationZoomFactor(double);
299
300     virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>&);
301     virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned);
302     virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned);
303
304 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
305     virtual void registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title);
306 #endif
307 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
308     virtual void registerContentHandler(const String& mimeType, const String& baseURL, const String& url, const String& title);
309 #endif
310
311 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
312     virtual bool getStandaloneStatus();
313 #endif
314
315 #if ENABLE(TIZEN_VIBRATION)
316     virtual void vibrate(const unsigned long& time);
317     virtual void cancelVibration();
318 #endif
319 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
320     virtual bool lockOrientation(int willLockOrientation);
321     virtual void unlockOrientation();
322 #endif
323
324 private:
325     RefPtr<WebPageProxy> m_page;
326     Evas_Object* m_viewWidget;
327 #if OS(TIZEN)
328     ViewportConstraints m_viewportConstraints;
329     double m_requestedScaleFactor;
330
331     bool m_viewFocused;
332     bool m_viewWindowActive;
333
334     bool m_preventNextCompositionCommit;
335     enum LayoutAndScaleState {
336         BeforeCommitLoad = 0,
337         DidCommitLoaded,
338         DidFirstVisuallyNonEmptyLayout,
339         DidFirstFrameRendered
340     };
341     LayoutAndScaleState m_layoutAndScaleState;
342     bool m_areFirstLayoutAndScaleInitialized;
343
344     Ecore_IMF_Context* m_inputMethod;
345     bool m_mousePressed;
346     WebCore::IntRect m_focusedNodeRect;
347
348 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
349     WebCore::IntRect m_visibleContentRect;
350     float m_scaleFactor;
351
352     WebCore::IntRect m_visibleContentRectForDrawContents;
353     float m_scaleFactorForDrawContents;
354 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
355     Evas_GL* m_evasGL;
356     Evas_GL_API* m_evasGlApi;
357     Evas_GL_Context* m_context;
358     Evas_GL_Surface* m_surface;
359     Evas_GL_Config* m_config;
360 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
361     int m_angle;
362 #endif
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_WEBKIT2_TILED_AC)
386     WebCore::Color m_bgColor;
387 #endif
388
389     Vector<RefPtr<WebKit::WebEditCommandProxy> > m_undoCommands;
390     Vector<RefPtr<WebKit::WebEditCommandProxy> > m_redoCommands;
391
392 #endif // #if OS(TIZEN)
393 };
394
395 } // namespace WebKit
396
397 #endif // PageClientImpl_h