2 Copyright (C) 2011 Samsung Electronics
3 Copyright (C) 2012 Intel Corporation. All rights reserved.
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
24 #include "RefPtrEfl.h"
25 #include "WKEinaSharedString.h"
26 #include "WKRetainPtr.h"
28 #include <WebCore/TextDirection.h>
29 #include <WebCore/Timer.h>
30 #include <WebKit2/WKBase.h>
31 #include <wtf/HashMap.h>
32 #include <wtf/OwnPtr.h>
33 #include <wtf/RefPtr.h>
34 #include <wtf/text/WTFString.h>
36 #if ENABLE(TOUCH_EVENTS)
37 #include "ewk_touch.h"
40 #if USE(ACCELERATED_COMPOSITING)
45 #include "JavaScriptPopup.h"
46 #include "OpenPanel.h"
47 #include "ewk_auth_challenge_private.h"
48 #include <JavaScriptCore/JSRetainPtr.h>
49 #include <WebCore/IntPoint.h>
51 #if ENABLE(TIZEN_GESTURE)
52 #include "GestureRecognizer.h"
53 #include "GestureClient.h"
56 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
57 #include "InputPicker.h"
60 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
61 #include "FocusRing.h"
64 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
65 #include "ewk_popup_picker.h"
69 #define EWK_VIEW_IMPL_GET(smartData, impl) \
70 EwkViewImpl* impl = smartData->priv
72 #define EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, ...) \
74 EINA_LOG_CRIT("smart data is null"); \
77 EWK_VIEW_IMPL_GET(smartData, impl); \
80 EINA_LOG_CRIT("no private data for object %p (%s)", \
81 smartData->self, evas_object_type_get(smartData->self)); \
89 class InputMethodContextEfl;
91 class PageLoadClientEfl;
92 class PagePolicyClientEfl;
93 class PageUIClientEfl;
94 class PageViewportControllerClientEfl;
95 class PageViewportController;
96 class ResourceLoadClientEfl;
99 class WebPopupMenuProxyEfl;
109 class Ewk_Back_Forward_List;
111 class Ewk_Download_Job;
113 class Ewk_Form_Submission_Request;
115 class Ewk_Intent_Service;
116 class Ewk_Navigation_Policy_Decision;
119 class Ewk_Url_Request;
120 class Ewk_Url_Response;
122 typedef struct Ewk_View_Smart_Data Ewk_View_Smart_Data;
126 class AffineTransform;
129 // FIXME: we have to include ewk_view.h instead of typedef,
130 // because there are "circular include" in the local code unlike open source,
131 // so we can not do typedef again here.
132 //typedef struct Ewk_View_Smart_Data Ewk_View_Smart_Data;
133 #include "ewk_view.h"
135 struct Ewk_View_Callback_Context {
137 Ewk_Web_App_Capable_Get_Callback webAppCapableCallback;
138 Ewk_Web_App_Icon_URL_Get_Callback webAppIconURLCallback;
139 Ewk_Web_App_Icon_URLs_Get_Callback webAppIconURLsCallback;
140 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
141 Ewk_Web_Storage_Quota_Get_Callback webStorageQuotaCallback;
143 Ewk_View_Script_Execute_Callback scriptExecuteCallback;
144 Ewk_View_Plain_Text_Get_Callback plainTextGetCallback;
145 #if ENABLE(TIZEN_SUPPORT_MHTML)
146 Ewk_View_MHTML_Data_Get_Callback mhtmlDataGetCallback;
148 Ewk_View_JavaScript_Alert_Callback javascriptAlertCallback;
149 Ewk_View_JavaScript_Confirm_Callback javascriptConfirmCallback;
150 Ewk_View_JavaScript_Prompt_Callback javascriptPromptCallback;
151 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
152 Ewk_View_Before_Unload_Confirm_Panel_Callback beforeUnloadConfirmPanelCallback;
154 Ewk_View_Open_Panel_Callback openPanelCallback;
155 #if ENABLE(TIZEN_APPLICATION_CACHE)
156 Ewk_View_Applicacion_Cache_Permission_Callback applicationCachePermissionCallback;
158 #if ENABLE(TIZEN_INDEXED_DATABASE)
159 Ewk_View_Exceeded_Indexed_Database_Quota_Callback exceededIndexedDatabaseQuotaCallback;
161 #if ENABLE(TIZEN_SQL_DATABASE)
162 Ewk_View_Exceeded_Database_Quota_Callback exceededDatabaseQuotaCallback;
164 #if ENABLE(TIZEN_FILE_SYSTEM)
165 Ewk_View_Exceeded_Local_File_System_Quota_Callback exceededLocalFileSystemQuotaCallback;
169 Evas_Object* ewkView;
172 typedef struct Ewk_View_Callback_Context Ewk_View_Callback_Context;
177 explicit EwkViewImpl(Evas_Object* view);
180 static EwkViewImpl* fromEvasObject(const Evas_Object* view);
182 inline Evas_Object* view() { return m_view; }
184 inline WebKit::WebPageProxy* page() { return pageProxy.get(); }
185 Ewk_Context* ewkContext() { return context.get(); }
186 Ewk_Settings* settings() { return m_settings.get(); }
188 WebCore::IntSize size() const;
189 bool isFocused() const;
190 bool isVisible() const;
192 const char* url() const { return m_url; }
193 const char* faviconURL() const { return m_faviconURL; }
194 const char* title() const;
195 WebKit::InputMethodContextEfl* inputMethodContext();
197 const char* themePath() const;
198 void setThemePath(const char* theme);
199 const char* customTextEncodingName() const;
200 void setCustomTextEncodingName(const char* encoding);
202 bool mouseEventsEnabled() const { return m_mouseEventsEnabled; }
203 void setMouseEventsEnabled(bool enabled);
204 #if ENABLE(TOUCH_EVENTS)
205 bool touchEventsEnabled() const { return m_touchEventsEnabled; }
206 void setTouchEventsEnabled(bool enabled);
209 void setCursor(const WebCore::Cursor& cursor);
210 void redrawRegion(const WebCore::IntRect& rect);
211 void setImageData(void* imageData, const WebCore::IntSize& size);
213 #if ENABLE(INPUT_TYPE_COLOR)
214 bool setColorPickerColor(const WebCore::Color& color);
217 static void addToPageViewMap(const Evas_Object* ewkView);
218 static void removeFromPageViewMap(const Evas_Object* ewkView);
219 static const Evas_Object* viewFromPageViewMap(const WKPageRef);
221 #if ENABLE(FULLSCREEN_API)
222 void enterFullScreen();
223 void exitFullScreen();
226 #if USE(ACCELERATED_COMPOSITING)
227 bool createGLSurface(const WebCore::IntSize& viewSize);
228 bool enterAcceleratedCompositingMode();
229 bool exitAcceleratedCompositingMode();
232 #if ENABLE(INPUT_TYPE_COLOR)
233 void requestColorPicker(int r, int g, int b, int a, WKColorPickerResultListenerRef listener);
234 void dismissColorPicker();
237 WKPageRef createNewPage();
240 #if ENABLE(TIZEN_MULTIPLE_SELECT)
241 void requestPopupMenu(WebKit::WebPopupMenuProxyEfl*, const WebCore::IntRect&, WebCore::TextDirection, double pageScaleFactor, const Vector<WebKit::WebPopupItem>& items, int32_t selectedIndex, bool);
243 void requestPopupMenu(WebKit::WebPopupMenuProxyEfl*, const WebCore::IntRect&, WebCore::TextDirection, double pageScaleFactor, const Vector<WebKit::WebPopupItem>& items, int32_t selectedIndex);
245 void updateTextInputState();
247 void requestJSAlertPopup(const WKEinaSharedString& message);
248 bool requestJSConfirmPopup(const WKEinaSharedString& message);
249 WKEinaSharedString requestJSPromptPopup(const WKEinaSharedString& message, const WKEinaSharedString& defaultValue);
251 void informDownloadJobCancelled(Ewk_Download_Job* download);
252 void informDownloadJobFailed(Ewk_Download_Job* download, Ewk_Error* error);
253 void informDownloadJobFinished(Ewk_Download_Job* download);
254 void informDownloadJobRequested(Ewk_Download_Job* download);
256 void informNewFormSubmissionRequest(Ewk_Form_Submission_Request* request);
257 void informLoadError(Ewk_Error* error);
258 void informLoadFinished();
259 void informLoadProgress(double progress);
260 void informProvisionalLoadFailed(Ewk_Error* error);
261 #if USE(TILED_BACKING_STORE)
262 void informLoadCommitted();
264 void informProvisionalLoadRedirect();
265 void informProvisionalLoadStarted();
267 void informResourceLoadStarted(Ewk_Resource* resource, Ewk_Url_Request* request);
268 void informResourceLoadResponse(Ewk_Resource* resource, Ewk_Url_Response* response);
269 void informResourceLoadFailed(Ewk_Resource* resource, Ewk_Error* error);
270 void informResourceLoadFinished(Ewk_Resource* resource);
271 void informResourceRequestSent(Ewk_Resource* resource, Ewk_Url_Request* request, Ewk_Url_Response* redirectResponse);
273 void informNavigationPolicyDecision(Ewk_Navigation_Policy_Decision* decision);
274 void informNewWindowPolicyDecision(Ewk_Navigation_Policy_Decision* decision);
275 void informBackForwardListChange();
277 void informTitleChange(const String& title);
278 void informTooltipTextChange(const String& text);
279 void informTextFound(unsigned matchCount);
280 void informIconChange();
281 void informWebProcessCrashed();
282 void informContentsSizeChange(const WebCore::IntSize& size);
283 unsigned long long informDatabaseQuotaReached(const String& databaseName, const String& displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage);
284 void informURLChange();
286 #if ENABLE(WEB_INTENTS)
287 void informIntentRequest(Ewk_Intent* ewkIntent);
289 #if ENABLE(WEB_INTENTS_TAG)
290 void informIntentServiceRegistration(Ewk_Intent_Service* ewkIntentService);
294 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
295 WebCore::AffineTransform transformFromView() const;
296 WebCore::AffineTransform transformToView() const;
298 WebCore::AffineTransform transformToScene() const;
299 WebCore::AffineTransform transformFromScene() const;
300 WebCore::AffineTransform transformToScreen() const;
302 #if ENABLE(TIZEN_WEBKIT2_SEPERATE_LOAD_PROGRESS)
303 void informLoadProgressStarted();
304 void informLoadProgressFinished();
307 #if ENABLE(TIZEN_DATALIST_ELEMENT)
308 void deleteDataList();
311 #if USE(TILED_BACKING_STORE)
312 void setScaleFactor(float scaleFactor) { m_scaleFactor = scaleFactor; }
313 float scaleFactor() const { return m_scaleFactor; }
315 void setScrollPosition(WebCore::IntPoint position) { m_scrollPosition = position; }
316 const WebCore::IntPoint scrollPosition() const { return m_scrollPosition; }
319 #if ENABLE(TIZEN_GESTURE)
320 #if ENABLE(TOUCH_EVENTS)
321 void feedTouchEventsByType(Ewk_Touch_Event_Type);
323 void setDoubleTapEnabled(bool);
326 #endif // #if OS(TIZEN)
328 // FIXME: Make members private for encapsulation.
329 OwnPtr<WebKit::PageClientImpl> pageClient;
330 #if ENABLE(WAIT_UPVERSION)
331 #if USE(TILED_BACKING_STORE)
332 OwnPtr<WebKit::PageViewportControllerClientEfl> pageViewportControllerClient;
333 OwnPtr<WebKit::PageViewportController> pageViewportController;
336 RefPtr<WebKit::WebPageProxy> pageProxy;
337 OwnPtr<WebKit::PageLoadClientEfl> pageLoadClient;
338 OwnPtr<WebKit::PagePolicyClientEfl> pagePolicyClient;
339 OwnPtr<WebKit::PageUIClientEfl> pageUIClient;
340 OwnPtr<WebKit::ResourceLoadClientEfl> resourceLoadClient;
341 OwnPtr<WebKit::FindClientEfl> findClient;
342 OwnPtr<WebKit::FormClientEfl> formClient;
344 OwnPtr<Ewk_Back_Forward_List> backForwardList;
345 RefPtr<Ewk_Context> context;
347 WebKit::WebPopupMenuProxyEfl* popupMenuProxy;
348 Eina_List* popupMenuItems;
350 #if USE(ACCELERATED_COMPOSITING)
352 Evas_GL_Context* evasGlContext;
353 Evas_GL_Surface* evasGlSurface;
357 #if ENABLE(TIZEN_ORIENTATION_EVENTS)
361 JSGlobalContextRef javascriptGlobalContext;
363 WKEinaSharedString userAgent;
365 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
366 WKEinaSharedString webAppIconURL;
367 Eina_List* webAppIconURLs;
370 OwnPtr<Ewk_View_Callback_Context> alertContext;
371 OwnPtr<Ewk_View_Callback_Context> confirmContext;
372 OwnPtr<Ewk_View_Callback_Context> promptContext;
374 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
375 OwnPtr<Ewk_View_Callback_Context> beforeUnloadConfirmPanelContext;
378 OwnPtr<Ewk_View_Callback_Context> openpanelContext;
379 OwnPtr<WebKit::JavaScriptPopup> javascriptPopup;
380 bool isWaitingForJavaScriptPopupReply;
381 OwnPtr<WebKit::OpenPanel> openPanel;
383 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
384 OwnPtr<WebKit::InputPicker> inputPicker;
385 WKEinaSharedString inputValue;
388 Ewk_Auth_Challenge* authChallenge;
389 Ewk_Policy_Decision* policyDecision;
390 WKOpenPanelResultListenerRef openPanelListener;
392 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
393 Ewk_Certificate_Policy_Decision* certificatePolicyDecision;
396 #if ENABLE(TIZEN_MEDIA_STREAM)
397 Eina_List* userMediaPermissionRequests;
400 #if ENABLE(TIZEN_GEOLOCATION)
401 Ewk_Geolocation* geolocation;
402 Eina_List* geolocationPermissionRequests;
405 bool suspendRequested;
406 bool suspendedPainting;
407 bool suspendedResources;
409 #if ENABLE(TIZEN_NOTIFICATIONS)
410 Eina_List* notifications;
411 Eina_List* notificationPermissionRequests;
414 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
415 Ewk_Popup_Picker* popupPicker;
419 bool isHorizontalEdge;
421 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
422 OwnPtr<FocusRing> focusRing;
425 #if ENABLE(TIZEN_GESTURE)
426 OwnPtr<WebKit::GestureRecognizer> gestureRecognizer;
427 OwnPtr<WebKit::GestureClient> gestureClient;
428 #if ENABLE(TOUCH_EVENTS)
429 Evas_Coord_Point touchDownPoint;
430 bool exceedTouchMoveThreshold;
431 bool wasHandledTouchStart;
432 bool wasHandledTouchMove;
434 bool holdHorizontalPanning;
435 bool holdVerticalPanning;
436 #endif // #if ENABLE(TIZEN_GESTURE)
438 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
439 bool mainFrameScrollbarVisibility;
442 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
443 Ecore_Animator* compositionAnimator;
446 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
447 WKEinaSharedString selectedText;
450 #if ENABLE(TIZEN_DATALIST_ELEMENT)
454 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
456 Ewk_Orientation_Lock_Cb callback;
461 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
462 RefPtr<WebKit::WebPageGroup> pageGroup;
465 #if ENABLE(TIZEN_APPLICATION_CACHE)
466 OwnPtr<Ewk_View_Callback_Context> applicationCachePermissionContext;
467 Ewk_Security_Origin* applicationCachePermissionOrigin;
468 bool isWaitingForApplicationCachePermission;
470 #if ENABLE(TIZEN_INDEXED_DATABASE)
471 OwnPtr<Ewk_View_Callback_Context> exceededIndexedDatabaseQuotaContext;
473 #if ENABLE(TIZEN_SQL_DATABASE)
474 OwnPtr<Ewk_View_Callback_Context> exceededDatabaseQuotaContext;
476 #if ENABLE(TIZEN_FILE_SYSTEM)
477 OwnPtr<Ewk_View_Callback_Context> exceededLocalFileSystemQuotaContext;
479 Ewk_Security_Origin* exceededQuotaOrigin;
480 bool isWaitingForExceededQuotaPopupReply;
481 #endif // #if OS(TIZEN)
484 inline Ewk_View_Smart_Data* smartData() const;
485 void displayTimerFired(WebCore::Timer<EwkViewImpl>*);
487 static void onMouseDown(void* data, Evas*, Evas_Object*, void* eventInfo);
488 static void onMouseUp(void* data, Evas*, Evas_Object*, void* eventInfo);
489 static void onMouseMove(void* data, Evas*, Evas_Object*, void* eventInfo);
490 #if ENABLE(TOUCH_EVENTS)
491 void feedTouchEvents(Ewk_Touch_Event_Type type);
492 static void onTouchDown(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */);
493 static void onTouchUp(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */);
494 static void onTouchMove(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */);
498 OwnPtr<Ewk_Settings> m_settings;
499 RefPtr<Evas_Object> m_cursorObject;
500 WKEinaSharedString m_cursorGroup;
501 WKEinaSharedString m_faviconURL;
502 WKEinaSharedString m_url;
503 mutable WKEinaSharedString m_title;
504 WKEinaSharedString m_theme;
505 mutable WKEinaSharedString m_customEncoding;
506 bool m_mouseEventsEnabled;
507 #if ENABLE(TOUCH_EVENTS)
508 bool m_touchEventsEnabled;
510 WKRetainPtr<WKColorPickerResultListenerRef> m_colorPickerResultListener;
511 WebCore::Timer<EwkViewImpl> m_displayTimer;
512 WTF::Vector <WebCore::IntRect> m_dirtyRects;
513 OwnPtr<WebKit::InputMethodContextEfl> m_inputMethodContext;
515 typedef HashMap<WKPageRef, const Evas_Object*> PageViewMap;
516 static PageViewMap pageViewMap;
519 #if USE(TILED_BACKING_STORE)
521 WebCore::IntPoint m_scrollPosition;
526 #endif // EwkViewImpl_h