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 void didChangeScrollAndScale(const WebCore::IntPoint&, float);
328 #if ENABLE(TIZEN_FOCUS_UI)
329 static void pages(Vector<RefPtr<WebKit::WebPageProxy> >&);
331 #endif // #if OS(TIZEN)
333 // FIXME: Make members private for encapsulation.
334 OwnPtr<WebKit::PageClientImpl> pageClient;
335 #if ENABLE(WAIT_UPVERSION)
336 #if USE(TILED_BACKING_STORE)
337 OwnPtr<WebKit::PageViewportControllerClientEfl> pageViewportControllerClient;
338 OwnPtr<WebKit::PageViewportController> pageViewportController;
341 RefPtr<WebKit::WebPageProxy> pageProxy;
342 OwnPtr<WebKit::PageLoadClientEfl> pageLoadClient;
343 OwnPtr<WebKit::PagePolicyClientEfl> pagePolicyClient;
344 OwnPtr<WebKit::PageUIClientEfl> pageUIClient;
345 OwnPtr<WebKit::ResourceLoadClientEfl> resourceLoadClient;
346 OwnPtr<WebKit::FindClientEfl> findClient;
347 OwnPtr<WebKit::FormClientEfl> formClient;
349 OwnPtr<Ewk_Back_Forward_List> backForwardList;
350 RefPtr<Ewk_Context> context;
352 WebKit::WebPopupMenuProxyEfl* popupMenuProxy;
353 Eina_List* popupMenuItems;
355 #if USE(ACCELERATED_COMPOSITING)
357 Evas_GL_Context* evasGlContext;
358 Evas_GL_Surface* evasGlSurface;
362 #if ENABLE(TIZEN_ORIENTATION_EVENTS)
366 JSGlobalContextRef javascriptGlobalContext;
368 WKEinaSharedString userAgent;
370 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
371 WKEinaSharedString webAppIconURL;
372 Eina_List* webAppIconURLs;
375 OwnPtr<Ewk_View_Callback_Context> alertContext;
376 OwnPtr<Ewk_View_Callback_Context> confirmContext;
377 OwnPtr<Ewk_View_Callback_Context> promptContext;
379 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
380 OwnPtr<Ewk_View_Callback_Context> beforeUnloadConfirmPanelContext;
383 OwnPtr<Ewk_View_Callback_Context> openpanelContext;
384 OwnPtr<WebKit::JavaScriptPopup> javascriptPopup;
385 bool isWaitingForJavaScriptPopupReply;
386 OwnPtr<WebKit::OpenPanel> openPanel;
388 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
389 OwnPtr<WebKit::InputPicker> inputPicker;
390 WKEinaSharedString inputValue;
393 Ewk_Auth_Challenge* authChallenge;
394 Ewk_Policy_Decision* policyDecision;
395 WKOpenPanelResultListenerRef openPanelListener;
397 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
398 Ewk_Certificate_Policy_Decision* certificatePolicyDecision;
401 #if ENABLE(TIZEN_MEDIA_STREAM)
402 Eina_List* userMediaPermissionRequests;
405 #if ENABLE(TIZEN_GEOLOCATION)
406 Ewk_Geolocation* geolocation;
407 Eina_List* geolocationPermissionRequests;
410 bool suspendRequested;
411 bool suspendedPainting;
412 bool suspendedResources;
414 #if ENABLE(TIZEN_NOTIFICATIONS)
415 Eina_List* notifications;
416 Eina_List* notificationPermissionRequests;
419 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
420 Ewk_Popup_Picker* popupPicker;
424 bool isHorizontalEdge;
426 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
427 OwnPtr<FocusRing> focusRing;
430 #if ENABLE(TIZEN_GESTURE)
431 OwnPtr<WebKit::GestureRecognizer> gestureRecognizer;
432 OwnPtr<WebKit::GestureClient> gestureClient;
433 #if ENABLE(TOUCH_EVENTS)
434 Evas_Coord_Point touchDownPoint;
435 bool exceedTouchMoveThreshold;
436 bool wasHandledTouchStart;
437 bool wasHandledTouchMove;
439 bool holdHorizontalPanning;
440 bool holdVerticalPanning;
441 #endif // #if ENABLE(TIZEN_GESTURE)
443 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
444 bool mainFrameScrollbarVisibility;
447 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
448 Ecore_Animator* compositionAnimator;
451 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
452 WKEinaSharedString selectedText;
455 #if ENABLE(TIZEN_DATALIST_ELEMENT)
459 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
461 Ewk_Orientation_Lock_Cb callback;
466 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
467 RefPtr<WebKit::WebPageGroup> pageGroup;
470 #if ENABLE(TIZEN_APPLICATION_CACHE)
471 OwnPtr<Ewk_View_Callback_Context> applicationCachePermissionContext;
472 Ewk_Security_Origin* applicationCachePermissionOrigin;
473 bool isWaitingForApplicationCachePermission;
475 #if ENABLE(TIZEN_INDEXED_DATABASE)
476 OwnPtr<Ewk_View_Callback_Context> exceededIndexedDatabaseQuotaContext;
478 #if ENABLE(TIZEN_SQL_DATABASE)
479 OwnPtr<Ewk_View_Callback_Context> exceededDatabaseQuotaContext;
481 #if ENABLE(TIZEN_FILE_SYSTEM)
482 OwnPtr<Ewk_View_Callback_Context> exceededLocalFileSystemQuotaContext;
484 Ewk_Security_Origin* exceededQuotaOrigin;
485 bool isWaitingForExceededQuotaPopupReply;
486 #endif // #if OS(TIZEN)
489 inline Ewk_View_Smart_Data* smartData() const;
490 void displayTimerFired(WebCore::Timer<EwkViewImpl>*);
492 static void onMouseDown(void* data, Evas*, Evas_Object*, void* eventInfo);
493 static void onMouseUp(void* data, Evas*, Evas_Object*, void* eventInfo);
494 static void onMouseMove(void* data, Evas*, Evas_Object*, void* eventInfo);
495 #if ENABLE(TOUCH_EVENTS)
496 void feedTouchEvents(Ewk_Touch_Event_Type type);
497 static void onTouchDown(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */);
498 static void onTouchUp(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */);
499 static void onTouchMove(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */);
503 OwnPtr<Ewk_Settings> m_settings;
504 RefPtr<Evas_Object> m_cursorObject;
505 WKEinaSharedString m_cursorGroup;
506 WKEinaSharedString m_faviconURL;
507 WKEinaSharedString m_url;
508 mutable WKEinaSharedString m_title;
509 WKEinaSharedString m_theme;
510 mutable WKEinaSharedString m_customEncoding;
511 bool m_mouseEventsEnabled;
512 #if ENABLE(TOUCH_EVENTS)
513 bool m_touchEventsEnabled;
515 WKRetainPtr<WKColorPickerResultListenerRef> m_colorPickerResultListener;
516 WebCore::Timer<EwkViewImpl> m_displayTimer;
517 WTF::Vector <WebCore::IntRect> m_dirtyRects;
518 OwnPtr<WebKit::InputMethodContextEfl> m_inputMethodContext;
520 typedef HashMap<WKPageRef, const Evas_Object*> PageViewMap;
521 static PageViewMap pageViewMap;
524 #if USE(TILED_BACKING_STORE)
526 WebCore::IntPoint m_scrollPosition;
531 #endif // EwkViewImpl_h