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 initializeLayoutAndScale();
102 void updateLayoutAndScale(bool fitToContentWidth = false);
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 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; }
121 void imContextPreeditChanged();
122 void imContextCommitted(char*);
124 void handleInputMethodKeydown();
125 void handleInputMethodMousePress();
126 Ecore_IMF_Context* getIMFContext() { return m_inputMethod; }
127 void handleInputMethodForFocusedNode();
130 void setViewFocused(bool focused) { m_viewFocused = focused; }
131 void setViewWindowActive(bool active) { m_viewWindowActive = active; }
132 void updateFormNavigation(int length, int offset);
134 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
135 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
136 DrawingAreaProxy* drawingArea() const { return m_page->drawingArea(); }
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();
145 void scaleImage(double, WebCore::IntPoint, bool adjustToBoundary = false);
146 void scaleContents(double, const WebCore::IntPoint&);
147 WebCore::IntRect visibleContentRect() { return m_visibleContentRect; }
149 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
150 void updateScrollbar(const WebCore::IntPoint& scrollPosition);
151 void frameRectChanged();
154 float scaleFactor() { return page()->pageScaleFactor(); }
155 WebCore::IntPoint scrollPosition() { return page()->scrollPosition(); }
156 #endif // #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
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);
170 #if ENABLE(TIZEN_WEBKIT_PASTEBOARD)
171 void writeDataToClipboardWithType(const String&, WebCore::Pasteboard::PasteboardDataType);
172 void pasteWithClipboard();
175 //FIXME: These are for supporting suspend/resume API. so they should be moved to ewk_XXX.
176 void suspendIfNeeded();
177 void resumeIfNeeded();
179 void suspendPainting();
180 void suspendJavaScriptAndResource();
181 void resumePainting();
182 void resumeJavaScriptAndResource();
184 #if ENABLE(TIZEN_NPAPI)
185 void suspendPlugin();
189 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
190 void setIsVisible(bool isVisible);
193 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
194 bool scrollBy(WebCore::IntSize);
195 void scrollTo(WebCore::IntPoint);
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&);
204 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
205 bool isContextMenuVisible() { return m_isContextMenuVisible; }
206 void setIsContextMenuVisible(bool isVisible) { m_isContextMenuVisible = isVisible; }
208 void didRenderFrame();
209 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
210 void setBackgroundColor(double red, double green, double blue, double alpha);
212 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
213 void didGetTextStyleStateForSelection(int underlineState, int italicState, int boldState);
216 #endif // #if OS(TIZEN)
219 PageClientImpl(WebContext*, WebPageGroup*, Evas_Object*);
221 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
222 void createScrollbarIfNeeded(bool horizontalBar, bool verticalBar);
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();
236 virtual void processDidCrash();
237 virtual void didRelaunchProcess();
238 virtual void pageClosed();
240 virtual void toolTipChanged(const String&, const String&);
242 virtual void setCursor(const WebCore::Cursor&);
243 virtual void setCursorHiddenUntilMouseMoves(bool);
244 virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&);
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&);
255 virtual void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool);
256 #if ENABLE(TOUCH_EVENTS)
257 virtual void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled);
260 virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*);
261 virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*);
263 #if ENABLE(INPUT_TYPE_COLOR)
264 virtual PassRefPtr<WebColorChooserProxy> createColorChooserProxy(WebPageProxy*, const WebCore::Color& initialColor);
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();
278 virtual void didChangeScrollbarsForMainFrame() const;
281 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
282 virtual void updateTextSelection();
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();
297 virtual void didCommitLoadForMainFrame(bool);
298 virtual void didFinishLoadingDataForCustomRepresentation(const String&, const CoreIPC::DataReference&);
299 virtual double customRepresentationZoomFactor();
300 virtual void setCustomRepresentationZoomFactor(double);
302 virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>&);
303 virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned);
304 virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned);
306 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
307 virtual void registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title);
309 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
310 virtual void registerContentHandler(const String& mimeType, const String& baseURL, const String& url, const String& title);
313 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
314 virtual bool getStandaloneStatus();
317 #if ENABLE(TIZEN_VIBRATION)
318 virtual void vibrate(const unsigned long& time);
319 virtual void cancelVibration();
321 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
322 virtual bool lockOrientation(int willLockOrientation);
323 virtual void unlockOrientation();
327 RefPtr<WebPageProxy> m_page;
328 Evas_Object* m_viewWidget;
330 ViewportConstraints m_viewportConstraints;
331 double m_requestedScaleFactor;
334 bool m_viewWindowActive;
336 bool m_preventNextCompositionCommit;
337 enum LayoutAndScaleState {
338 BeforeCommitLoad = 0,
340 DidFirstVisuallyNonEmptyLayout,
341 DidFirstFrameRendered
343 LayoutAndScaleState m_layoutAndScaleState;
344 bool m_areFirstLayoutAndScaleInitialized;
346 Ecore_IMF_Context* m_inputMethod;
347 bool m_inputMethodState;
349 WebCore::IntRect m_focusedNodeRect;
351 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
352 WebCore::IntRect m_visibleContentRect;
355 WebCore::IntRect m_visibleContentRectForDrawContents;
356 float m_scaleFactorForDrawContents;
357 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
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;
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_INPUT_TAG_EXTENSION)
388 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
390 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
391 WebCore::Color m_bgColor;
394 Vector<RefPtr<WebKit::WebEditCommandProxy> > m_undoCommands;
395 Vector<RefPtr<WebKit::WebEditCommandProxy> > m_redoCommands;
397 #endif // #if OS(TIZEN)
400 } // namespace WebKit
402 #endif // PageClientImpl_h