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_WEBKIT2_INPUT_FIELD_ZOOM)
57 #include "InputFieldZoom.h"
60 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
61 #include "InputPicker.h"
64 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
65 #include "FocusRing.h"
68 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
69 #include "ewk_popup_picker.h"
73 #define EWK_VIEW_IMPL_GET(smartData, impl) \
74 EwkViewImpl* impl = smartData->priv
76 #define EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, ...) \
78 EINA_LOG_CRIT("smart data is null"); \
81 EWK_VIEW_IMPL_GET(smartData, impl); \
84 EINA_LOG_CRIT("no private data for object %p (%s)", \
85 smartData->self, evas_object_type_get(smartData->self)); \
93 class InputMethodContextEfl;
95 class PageLoadClientEfl;
96 class PagePolicyClientEfl;
97 class PageUIClientEfl;
98 class PageViewportControllerClientEfl;
99 class PageViewportController;
100 class ResourceLoadClientEfl;
103 class WebPopupMenuProxyEfl;
113 class Ewk_Back_Forward_List;
115 class Ewk_Download_Job;
117 class Ewk_Form_Submission_Request;
119 class Ewk_Intent_Service;
120 class Ewk_Navigation_Policy_Decision;
123 class Ewk_Url_Request;
124 class Ewk_Url_Response;
126 typedef struct Ewk_View_Smart_Data Ewk_View_Smart_Data;
130 class AffineTransform;
133 // FIXME: we have to include ewk_view.h instead of typedef,
134 // because there are "circular include" in the local code unlike open source,
135 // so we can not do typedef again here.
136 //typedef struct Ewk_View_Smart_Data Ewk_View_Smart_Data;
137 #include "ewk_view.h"
139 struct Ewk_View_Callback_Context {
141 Ewk_Web_App_Capable_Get_Callback webAppCapableCallback;
142 Ewk_Web_App_Icon_URL_Get_Callback webAppIconURLCallback;
143 Ewk_Web_App_Icon_URLs_Get_Callback webAppIconURLsCallback;
144 #if ENABLE(TIZEN_WEB_STORAGE) && ENABLE(TIZEN_WEBKIT2_NUMBER_TYPE_SUPPORT)
145 Ewk_Web_Storage_Quota_Get_Callback webStorageQuotaCallback;
147 Ewk_View_Script_Execute_Callback scriptExecuteCallback;
148 Ewk_View_Plain_Text_Get_Callback plainTextGetCallback;
149 #if ENABLE(TIZEN_SUPPORT_MHTML)
150 Ewk_View_MHTML_Data_Get_Callback mhtmlDataGetCallback;
152 Ewk_View_JavaScript_Alert_Callback javascriptAlertCallback;
153 Ewk_View_JavaScript_Confirm_Callback javascriptConfirmCallback;
154 Ewk_View_JavaScript_Prompt_Callback javascriptPromptCallback;
155 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
156 Ewk_View_Before_Unload_Confirm_Panel_Callback beforeUnloadConfirmPanelCallback;
158 Ewk_View_Open_Panel_Callback openPanelCallback;
159 #if ENABLE(TIZEN_APPLICATION_CACHE)
160 Ewk_View_Applicacion_Cache_Permission_Callback applicationCachePermissionCallback;
162 #if ENABLE(TIZEN_INDEXED_DATABASE)
163 Ewk_View_Exceeded_Indexed_Database_Quota_Callback exceededIndexedDatabaseQuotaCallback;
165 #if ENABLE(TIZEN_SQL_DATABASE)
166 Ewk_View_Exceeded_Database_Quota_Callback exceededDatabaseQuotaCallback;
168 #if ENABLE(TIZEN_FILE_SYSTEM)
169 Ewk_View_Exceeded_Local_File_System_Quota_Callback exceededLocalFileSystemQuotaCallback;
173 Evas_Object* ewkView;
176 typedef struct Ewk_View_Callback_Context Ewk_View_Callback_Context;
181 explicit EwkViewImpl(Evas_Object* view);
184 static EwkViewImpl* fromEvasObject(const Evas_Object* view);
186 inline Evas_Object* view() { return m_view; }
188 inline WebKit::WebPageProxy* page() { return pageProxy.get(); }
189 Ewk_Context* ewkContext() { return context.get(); }
190 Ewk_Settings* settings() { return m_settings.get(); }
192 WebCore::IntSize size() const;
193 bool isFocused() const;
194 bool isVisible() const;
196 const char* url() const { return m_url; }
198 #if ENABLE(TIZEN_WEBKIT2_SUSPEND_LOADING_URL)
199 const char* suspendedURL() { return m_suspendedURL; }
200 void setSuspendedURL(const char* url) { m_suspendedURL = url; }
203 const char* faviconURL() const { return m_faviconURL; }
204 const char* title() const;
205 WebKit::InputMethodContextEfl* inputMethodContext();
207 const char* themePath() const;
208 void setThemePath(const char* theme);
209 const char* customTextEncodingName() const;
210 void setCustomTextEncodingName(const char* encoding);
212 bool mouseEventsEnabled() const { return m_mouseEventsEnabled; }
213 void setMouseEventsEnabled(bool enabled);
214 #if ENABLE(TOUCH_EVENTS)
215 bool touchEventsEnabled() const { return m_touchEventsEnabled; }
216 void setTouchEventsEnabled(bool enabled);
219 void setCursor(const WebCore::Cursor& cursor);
220 void redrawRegion(const WebCore::IntRect& rect);
221 void setImageData(void* imageData, const WebCore::IntSize& size);
223 #if ENABLE(INPUT_TYPE_COLOR)
224 bool setColorPickerColor(const WebCore::Color& color);
227 static void addToPageViewMap(const Evas_Object* ewkView);
228 static void removeFromPageViewMap(const Evas_Object* ewkView);
229 static const Evas_Object* viewFromPageViewMap(const WKPageRef);
231 #if ENABLE(FULLSCREEN_API)
232 void enterFullScreen();
233 void exitFullScreen();
236 #if USE(ACCELERATED_COMPOSITING)
237 bool createGLSurface(const WebCore::IntSize& viewSize);
238 bool enterAcceleratedCompositingMode();
239 bool exitAcceleratedCompositingMode();
242 #if ENABLE(INPUT_TYPE_COLOR)
243 void requestColorPicker(int r, int g, int b, int a, WKColorPickerResultListenerRef listener);
244 void dismissColorPicker();
247 WKPageRef createNewPage();
250 #if ENABLE(TIZEN_MULTIPLE_SELECT)
251 void requestPopupMenu(WebKit::WebPopupMenuProxyEfl*, const WebCore::IntRect&, WebCore::TextDirection, double pageScaleFactor, const Vector<WebKit::WebPopupItem>& items, int32_t selectedIndex, bool);
253 void requestPopupMenu(WebKit::WebPopupMenuProxyEfl*, const WebCore::IntRect&, WebCore::TextDirection, double pageScaleFactor, const Vector<WebKit::WebPopupItem>& items, int32_t selectedIndex);
255 void updateTextInputState();
257 void requestJSAlertPopup(const WKEinaSharedString& message);
258 bool requestJSConfirmPopup(const WKEinaSharedString& message);
259 WKEinaSharedString requestJSPromptPopup(const WKEinaSharedString& message, const WKEinaSharedString& defaultValue);
261 void informDownloadJobCancelled(Ewk_Download_Job* download);
262 void informDownloadJobFailed(Ewk_Download_Job* download, Ewk_Error* error);
263 void informDownloadJobFinished(Ewk_Download_Job* download);
264 void informDownloadJobRequested(Ewk_Download_Job* download);
266 void informNewFormSubmissionRequest(Ewk_Form_Submission_Request* request);
267 void informLoadError(Ewk_Error* error);
268 void informLoadFinished();
269 void informLoadProgress(double progress);
270 void informProvisionalLoadFailed(Ewk_Error* error);
271 #if USE(TILED_BACKING_STORE)
272 void informLoadCommitted();
274 void informProvisionalLoadRedirect();
275 void informProvisionalLoadStarted();
277 void informResourceLoadStarted(Ewk_Resource* resource, Ewk_Url_Request* request);
278 void informResourceLoadResponse(Ewk_Resource* resource, Ewk_Url_Response* response);
279 void informResourceLoadFailed(Ewk_Resource* resource, Ewk_Error* error);
280 void informResourceLoadFinished(Ewk_Resource* resource);
281 void informResourceRequestSent(Ewk_Resource* resource, Ewk_Url_Request* request, Ewk_Url_Response* redirectResponse);
283 void informNavigationPolicyDecision(Ewk_Navigation_Policy_Decision* decision);
284 void informNewWindowPolicyDecision(Ewk_Navigation_Policy_Decision* decision);
285 void informBackForwardListChange();
287 void informTitleChange(const String& title);
288 void informTooltipTextChange(const String& text);
289 void informTextFound(unsigned matchCount);
290 void informIconChange();
291 void informWebProcessCrashed();
292 void informContentsSizeChange(const WebCore::IntSize& size);
293 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);
294 void informURLChange();
296 #if ENABLE(WEB_INTENTS)
297 void informIntentRequest(Ewk_Intent* ewkIntent);
299 #if ENABLE(WEB_INTENTS_TAG)
300 void informIntentServiceRegistration(Ewk_Intent_Service* ewkIntentService);
304 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
305 WebCore::AffineTransform transformFromView() const;
306 WebCore::AffineTransform transformToView() const;
308 WebCore::AffineTransform transformToScene() const;
309 WebCore::AffineTransform transformFromScene() const;
310 WebCore::AffineTransform transformToScreen() const;
312 #if ENABLE(TIZEN_WEBKIT2_SEPERATE_LOAD_PROGRESS)
313 void informLoadProgressStarted();
314 void informLoadProgressFinished();
317 #if ENABLE(TIZEN_DATALIST_ELEMENT)
318 void deleteDataList();
321 #if ENABLE(TIZEN_GEOLOCATION)
322 bool isValidLocationService();
325 #if USE(TILED_BACKING_STORE)
326 void setScaleFactor(float scaleFactor) { m_scaleFactor = scaleFactor; }
327 float scaleFactor() const { return m_scaleFactor; }
329 void setScrollPosition(WebCore::IntPoint position) { m_scrollPosition = position; }
330 const WebCore::IntPoint scrollPosition() const { return m_scrollPosition; }
333 #if ENABLE(TIZEN_GESTURE)
334 #if ENABLE(TOUCH_EVENTS)
335 void feedTouchEventsByType(Ewk_Touch_Event_Type);
337 void setDoubleTapEnabled(bool);
340 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
341 FocusRing* focusRing() { return m_focusRing.get(); }
344 #if ENABLE(TIZEN_FOCUS_UI)
345 static void pages(Vector<RefPtr<WebKit::WebPageProxy> >&);
347 #endif // #if OS(TIZEN)
349 // FIXME: Make members private for encapsulation.
350 OwnPtr<WebKit::PageClientImpl> pageClient;
351 #if ENABLE(WAIT_UPVERSION)
352 #if USE(TILED_BACKING_STORE)
353 OwnPtr<WebKit::PageViewportControllerClientEfl> pageViewportControllerClient;
354 OwnPtr<WebKit::PageViewportController> pageViewportController;
357 RefPtr<WebKit::WebPageProxy> pageProxy;
358 OwnPtr<WebKit::PageLoadClientEfl> pageLoadClient;
359 OwnPtr<WebKit::PagePolicyClientEfl> pagePolicyClient;
360 OwnPtr<WebKit::PageUIClientEfl> pageUIClient;
361 OwnPtr<WebKit::ResourceLoadClientEfl> resourceLoadClient;
362 OwnPtr<WebKit::FindClientEfl> findClient;
363 OwnPtr<WebKit::FormClientEfl> formClient;
365 OwnPtr<Ewk_Back_Forward_List> backForwardList;
366 RefPtr<Ewk_Context> context;
368 WebKit::WebPopupMenuProxyEfl* popupMenuProxy;
369 Eina_List* popupMenuItems;
371 #if USE(ACCELERATED_COMPOSITING)
373 Evas_GL_Context* evasGlContext;
374 Evas_GL_Surface* evasGlSurface;
378 #if ENABLE(TIZEN_ORIENTATION_EVENTS)
382 JSGlobalContextRef javascriptGlobalContext;
384 WKEinaSharedString userAgent;
387 WKEinaSharedString applicationName;
390 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
391 WKEinaSharedString webAppIconURL;
392 Eina_List* webAppIconURLs;
395 OwnPtr<Ewk_View_Callback_Context> alertContext;
396 OwnPtr<Ewk_View_Callback_Context> confirmContext;
397 OwnPtr<Ewk_View_Callback_Context> promptContext;
399 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
400 OwnPtr<Ewk_View_Callback_Context> beforeUnloadConfirmPanelContext;
403 OwnPtr<Ewk_View_Callback_Context> openpanelContext;
404 OwnPtr<WebKit::JavaScriptPopup> javascriptPopup;
405 bool isWaitingForJavaScriptPopupReply;
406 OwnPtr<WebKit::OpenPanel> openPanel;
408 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
409 OwnPtr<WebKit::InputPicker> inputPicker;
410 WKEinaSharedString inputValue;
413 Ewk_Auth_Challenge* authChallenge;
414 Ewk_Policy_Decision* policyDecision;
415 WKOpenPanelResultListenerRef openPanelListener;
417 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
418 Ewk_Certificate_Policy_Decision* certificatePolicyDecision;
421 #if ENABLE(TIZEN_MEDIA_STREAM)
422 Eina_List* userMediaPermissionRequests;
425 #if ENABLE(TIZEN_GEOLOCATION)
426 Eina_List* geolocationPermissionRequests;
429 bool suspendRequested;
430 bool suspendedPainting;
431 bool suspendedResources;
433 #if ENABLE(TIZEN_NOTIFICATIONS)
434 Eina_List* notifications;
435 Eina_List* notificationPermissionRequests;
438 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
439 Ewk_Popup_Picker* popupPicker;
443 bool isHorizontalEdge;
445 #if ENABLE(TIZEN_GESTURE)
446 OwnPtr<WebKit::GestureRecognizer> gestureRecognizer;
447 OwnPtr<WebKit::GestureClient> gestureClient;
448 #if ENABLE(TOUCH_EVENTS)
449 Evas_Coord_Point touchDownPoint;
450 bool exceedTouchMoveThreshold;
451 bool wasHandledTouchStart;
452 bool wasHandledTouchMove;
454 bool holdHorizontalPanning;
455 bool holdVerticalPanning;
456 #endif // #if ENABLE(TIZEN_GESTURE)
458 #if ENABLE(TIZEN_WEBKIT2_INPUT_FIELD_ZOOM)
459 OwnPtr<WebKit::InputFieldZoom> inputFieldZoom;
462 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
463 bool mainFrameScrollbarVisibility;
466 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
467 Ecore_Animator* compositionAnimator;
470 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
471 WKEinaSharedString selectedText;
474 #if ENABLE(TIZEN_DATALIST_ELEMENT)
478 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
480 Ewk_Orientation_Lock_Cb callback;
485 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
486 RefPtr<WebKit::WebPageGroup> pageGroup;
489 #if ENABLE(TIZEN_APPLICATION_CACHE)
490 OwnPtr<Ewk_View_Callback_Context> applicationCachePermissionContext;
491 Ewk_Security_Origin* applicationCachePermissionOrigin;
492 bool isWaitingForApplicationCachePermission;
494 #if ENABLE(TIZEN_INDEXED_DATABASE)
495 OwnPtr<Ewk_View_Callback_Context> exceededIndexedDatabaseQuotaContext;
497 #if ENABLE(TIZEN_SQL_DATABASE)
498 OwnPtr<Ewk_View_Callback_Context> exceededDatabaseQuotaContext;
500 #if ENABLE(TIZEN_FILE_SYSTEM)
501 OwnPtr<Ewk_View_Callback_Context> exceededLocalFileSystemQuotaContext;
503 Ewk_Security_Origin* exceededQuotaOrigin;
504 bool isWaitingForExceededQuotaPopupReply;
505 #endif // #if OS(TIZEN)
508 inline Ewk_View_Smart_Data* smartData() const;
509 void displayTimerFired(WebCore::Timer<EwkViewImpl>*);
511 static void onMouseDown(void* data, Evas*, Evas_Object*, void* eventInfo);
512 static void onMouseUp(void* data, Evas*, Evas_Object*, void* eventInfo);
513 static void onMouseMove(void* data, Evas*, Evas_Object*, void* eventInfo);
514 #if ENABLE(TOUCH_EVENTS)
515 void feedTouchEvents(Ewk_Touch_Event_Type type);
516 static void onTouchDown(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */);
517 static void onTouchUp(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */);
518 static void onTouchMove(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */);
522 OwnPtr<Ewk_Settings> m_settings;
523 RefPtr<Evas_Object> m_cursorObject;
524 WKEinaSharedString m_cursorGroup;
525 WKEinaSharedString m_faviconURL;
526 WKEinaSharedString m_url;
528 #if ENABLE(TIZEN_WEBKIT2_SUSPEND_LOADING_URL)
529 WKEinaSharedString m_suspendedURL;
532 mutable WKEinaSharedString m_title;
533 WKEinaSharedString m_theme;
534 mutable WKEinaSharedString m_customEncoding;
535 bool m_mouseEventsEnabled;
536 #if ENABLE(TOUCH_EVENTS)
537 bool m_touchEventsEnabled;
539 WKRetainPtr<WKColorPickerResultListenerRef> m_colorPickerResultListener;
540 WebCore::Timer<EwkViewImpl> m_displayTimer;
541 WTF::Vector <WebCore::IntRect> m_dirtyRects;
542 OwnPtr<WebKit::InputMethodContextEfl> m_inputMethodContext;
544 typedef HashMap<WKPageRef, const Evas_Object*> PageViewMap;
545 static PageViewMap pageViewMap;
548 #if USE(TILED_BACKING_STORE)
550 WebCore::IntPoint m_scrollPosition;
553 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
554 OwnPtr<FocusRing> m_focusRing;
559 #endif // EwkViewImpl_h