2 * Copyright (C) 2011 Samsung Electronics
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
26 #ifndef PageClientImpl_h
27 #define PageClientImpl_h
29 #include "PageClient.h"
33 #include "WebEditCommandProxy.h"
34 #include <WebCore/ViewportArguments.h>
36 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
37 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
38 #include "DrawingAreaProxyImpl.h"
39 #include <WebCore/Color.h>
42 #if ENABLE(TIZEN_ISF_PORT)
43 #include "EditorState.h"
45 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
46 #include "TextSelection.h"
48 #endif // #if OS(TIZEN)
52 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
53 class MainFrameScrollbarEfl;
56 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
60 class PageClientImpl : public PageClient {
62 static PassOwnPtr<PageClientImpl> create(WebContext* context, WebPageGroup* pageGroup, Evas_Object* viewWidget)
64 return adoptPtr(new PageClientImpl(context, pageGroup, viewWidget));
68 Evas_Object* viewWidget() const { return m_viewWidget; }
70 WebPageProxy* page() const { return m_page.get(); }
73 struct ViewportConstraints {
79 , layoutSize(WebCore::IntSize())
80 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
81 , devicePixelRatio(1.0)
89 WebCore::IntSize layoutSize;
90 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
91 double devicePixelRatio;
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);
101 void initializeScale();
104 void setFocusedNodeRect(const WebCore::IntRect&);
105 WebCore::IntRect focusedNodeRect() { return m_focusedNodeRect; };
107 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
108 void setInputMethodState(bool active, const AtomicString& inputType, const String& inputValue);
110 void setInputMethodState(bool active);
112 #if ENABLE(TIZEN_ISF_PORT)
113 void handleInputMethodMouseRelease();
114 void setCursorPosition(int preeditPosition = 0);
115 bool getInputMethodState();
116 bool initializeInputMethod();
117 void terminateInputMethod();
119 void imContextPreeditChanged();
120 void imContextCommitted(char*);
122 void handleInputMethodKeydown();
123 void handleInputMethodMousePress();
124 Ecore_IMF_Context* getIMFContext() { return m_inputMethod; }
127 void setViewFocused(bool focused) { m_viewFocused = focused; }
128 void setViewWindowActive(bool active) { m_viewWindowActive = active; }
129 void updateFormNavigation(int length, int offset);
131 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
132 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
133 DrawingAreaProxy* drawingArea() const { return m_page->drawingArea(); }
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();
142 void scaleImage(double, WebCore::IntPoint, bool adjustToBoundary = false);
143 void scaleContents(double, const WebCore::IntPoint&);
144 WebCore::IntRect visibleContentRect() { return m_visibleContentRect; }
146 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
147 void updateScrollbar(const WebCore::IntPoint& scrollPosition);
148 void frameRectChanged();
151 float scaleFactor() { return page()->pageScaleFactor(); }
152 WebCore::IntPoint scrollPosition() { return page()->scrollPosition(); }
153 #endif // #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
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);
167 #if ENABLE(TIZEN_WEBKIT_PASTEBOARD)
168 void writeDataToClipboardWithType(const String&, WebCore::Pasteboard::PasteboardDataType);
169 void pasteWithClipboard();
172 //FIXME: These are for supporting suspend/resume API. so they should be moved to ewk_XXX.
173 void suspendIfNeeded();
174 void resumeIfNeeded();
176 void suspendPainting();
177 void suspendJavaScriptAndResource();
178 void resumePainting();
179 void resumeJavaScriptAndResource();
181 #if ENABLE(TIZEN_NPAPI)
182 void suspendPlugin();
186 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
187 void setIsVisible(bool isVisible);
190 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
191 bool scrollBy(WebCore::IntSize);
192 void scrollTo(WebCore::IntPoint);
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&);
201 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
202 bool isContextMenuVisible() { return m_isContextMenuVisible; }
203 void setIsContextMenuVisible(bool isVisible) { m_isContextMenuVisible = isVisible; }
205 void didRenderFrame();
206 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
207 void setBackgroundColor(double red, double green, double blue, double alpha);
209 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
210 void didGetTextStyleStateForSelection(int underlineState, int italicState, int boldState);
213 virtual void didFindZoomableArea(const WebCore::IntPoint&, const WebCore::IntRect&);
214 #endif // #if OS(TIZEN)
217 PageClientImpl(WebContext*, WebPageGroup*, Evas_Object*);
219 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
220 void createScrollbarIfNeeded(bool horizontalBar, bool verticalBar);
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();
234 virtual void processDidCrash();
235 virtual void didRelaunchProcess();
236 virtual void pageClosed();
238 virtual void toolTipChanged(const String&, const String&);
240 virtual void setCursor(const WebCore::Cursor&);
241 virtual void setCursorHiddenUntilMouseMoves(bool);
242 virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&);
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&);
253 virtual void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool);
254 #if ENABLE(TOUCH_EVENTS)
255 virtual void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled);
258 virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*);
259 virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*);
261 #if ENABLE(INPUT_TYPE_COLOR)
262 virtual PassRefPtr<WebColorChooserProxy> createColorChooserProxy(WebPageProxy*, const WebCore::Color& initialColor);
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();
276 virtual void didChangeScrollbarsForMainFrame() const;
279 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
280 virtual void updateTextSelection();
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();
295 virtual void didCommitLoadForMainFrame(bool);
296 virtual void didFinishLoadingDataForCustomRepresentation(const String&, const CoreIPC::DataReference&);
297 virtual double customRepresentationZoomFactor();
298 virtual void setCustomRepresentationZoomFactor(double);
300 virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>&);
301 virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned);
302 virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned);
304 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
305 virtual void registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title);
307 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
308 virtual void registerContentHandler(const String& mimeType, const String& baseURL, const String& url, const String& title);
311 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
312 virtual bool getStandaloneStatus();
315 #if ENABLE(TIZEN_VIBRATION)
316 virtual void vibrate(const unsigned long& time);
317 virtual void cancelVibration();
319 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
320 virtual bool lockOrientation(int willLockOrientation);
321 virtual void unlockOrientation();
325 RefPtr<WebPageProxy> m_page;
326 Evas_Object* m_viewWidget;
328 ViewportConstraints m_viewportConstraints;
329 double m_requestedScaleFactor;
332 bool m_viewWindowActive;
334 bool m_preventNextCompositionCommit;
335 enum LayoutAndScaleState {
336 BeforeCommitLoad = 0,
338 DidFirstVisuallyNonEmptyLayout,
339 DidFirstFrameRendered
341 LayoutAndScaleState m_layoutAndScaleState;
342 bool m_areFirstLayoutAndScaleInitialized;
344 Ecore_IMF_Context* m_inputMethod;
346 WebCore::IntRect m_focusedNodeRect;
348 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
349 WebCore::IntRect m_visibleContentRect;
352 WebCore::IntRect m_visibleContentRectForDrawContents;
353 float m_scaleFactorForDrawContents;
354 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
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)
363 bool m_isAcceleratedCompositingModeInitialized;
367 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
368 RefPtr<MainFrameScrollbarEfl> m_horizontalScrollbar;
369 RefPtr<MainFrameScrollbarEfl> m_verticalScrollbar;
371 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
372 OwnPtr<TextSelection> m_textSelection;
374 bool m_suspendPainting;
375 bool m_suspendResource;
376 bool m_suspendRequested;
379 bool m_isScrollableNodeFocused;
381 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
382 bool m_isContextMenuVisible;
385 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
386 WebCore::Color m_bgColor;
389 Vector<RefPtr<WebKit::WebEditCommandProxy> > m_undoCommands;
390 Vector<RefPtr<WebKit::WebEditCommandProxy> > m_redoCommands;
392 #endif // #if OS(TIZEN)
395 } // namespace WebKit
397 #endif // PageClientImpl_h