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;
157 Evas_Object* ewkView;
160 typedef struct Ewk_View_Callback_Context Ewk_View_Callback_Context;
165 explicit EwkViewImpl(Evas_Object* view);
168 static EwkViewImpl* fromEvasObject(const Evas_Object* view);
170 inline Evas_Object* view() { return m_view; }
172 inline WebKit::WebPageProxy* page() { return pageProxy.get(); }
173 Ewk_Context* ewkContext() { return context.get(); }
174 Ewk_Settings* settings() { return m_settings.get(); }
176 WebCore::IntSize size() const;
177 bool isFocused() const;
178 bool isVisible() const;
180 const char* url() const { return m_url; }
181 const char* faviconURL() const { return m_faviconURL; }
182 const char* title() const;
183 WebKit::InputMethodContextEfl* inputMethodContext();
185 const char* themePath() const;
186 void setThemePath(const char* theme);
187 const char* customTextEncodingName() const;
188 void setCustomTextEncodingName(const char* encoding);
190 bool mouseEventsEnabled() const { return m_mouseEventsEnabled; }
191 void setMouseEventsEnabled(bool enabled);
192 #if ENABLE(TOUCH_EVENTS)
193 bool touchEventsEnabled() const { return m_touchEventsEnabled; }
194 void setTouchEventsEnabled(bool enabled);
197 void setCursor(const WebCore::Cursor& cursor);
198 void redrawRegion(const WebCore::IntRect& rect);
199 void setImageData(void* imageData, const WebCore::IntSize& size);
201 #if ENABLE(INPUT_TYPE_COLOR)
202 bool setColorPickerColor(const WebCore::Color& color);
205 static void addToPageViewMap(const Evas_Object* ewkView);
206 static void removeFromPageViewMap(const Evas_Object* ewkView);
207 static const Evas_Object* viewFromPageViewMap(const WKPageRef);
209 #if ENABLE(FULLSCREEN_API)
210 void enterFullScreen();
211 void exitFullScreen();
214 #if USE(ACCELERATED_COMPOSITING)
215 bool createGLSurface(const WebCore::IntSize& viewSize);
216 bool enterAcceleratedCompositingMode();
217 bool exitAcceleratedCompositingMode();
220 #if ENABLE(INPUT_TYPE_COLOR)
221 void requestColorPicker(int r, int g, int b, int a, WKColorPickerResultListenerRef listener);
222 void dismissColorPicker();
225 WKPageRef createNewPage();
228 #if ENABLE(TIZEN_MULTIPLE_SELECT)
229 void requestPopupMenu(WebKit::WebPopupMenuProxyEfl*, const WebCore::IntRect&, WebCore::TextDirection, double pageScaleFactor, const Vector<WebKit::WebPopupItem>& items, int32_t selectedIndex, bool);
231 void requestPopupMenu(WebKit::WebPopupMenuProxyEfl*, const WebCore::IntRect&, WebCore::TextDirection, double pageScaleFactor, const Vector<WebKit::WebPopupItem>& items, int32_t selectedIndex);
233 void updateTextInputState();
235 void requestJSAlertPopup(const WKEinaSharedString& message);
236 bool requestJSConfirmPopup(const WKEinaSharedString& message);
237 WKEinaSharedString requestJSPromptPopup(const WKEinaSharedString& message, const WKEinaSharedString& defaultValue);
239 void informDownloadJobCancelled(Ewk_Download_Job* download);
240 void informDownloadJobFailed(Ewk_Download_Job* download, Ewk_Error* error);
241 void informDownloadJobFinished(Ewk_Download_Job* download);
242 void informDownloadJobRequested(Ewk_Download_Job* download);
244 void informNewFormSubmissionRequest(Ewk_Form_Submission_Request* request);
245 void informLoadError(Ewk_Error* error);
246 void informLoadFinished();
247 void informLoadProgress(double progress);
248 void informProvisionalLoadFailed(Ewk_Error* error);
249 #if USE(TILED_BACKING_STORE)
250 void informLoadCommitted();
252 void informProvisionalLoadRedirect();
253 void informProvisionalLoadStarted();
255 void informResourceLoadStarted(Ewk_Resource* resource, Ewk_Url_Request* request);
256 void informResourceLoadResponse(Ewk_Resource* resource, Ewk_Url_Response* response);
257 void informResourceLoadFailed(Ewk_Resource* resource, Ewk_Error* error);
258 void informResourceLoadFinished(Ewk_Resource* resource);
259 void informResourceRequestSent(Ewk_Resource* resource, Ewk_Url_Request* request, Ewk_Url_Response* redirectResponse);
261 void informNavigationPolicyDecision(Ewk_Navigation_Policy_Decision* decision);
262 void informNewWindowPolicyDecision(Ewk_Navigation_Policy_Decision* decision);
263 void informBackForwardListChange();
265 void informTitleChange(const String& title);
266 void informTooltipTextChange(const String& text);
267 void informTextFound(unsigned matchCount);
268 void informIconChange();
269 void informWebProcessCrashed();
270 void informContentsSizeChange(const WebCore::IntSize& size);
271 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);
272 void informURLChange();
274 #if ENABLE(WEB_INTENTS)
275 void informIntentRequest(Ewk_Intent* ewkIntent);
277 #if ENABLE(WEB_INTENTS_TAG)
278 void informIntentServiceRegistration(Ewk_Intent_Service* ewkIntentService);
282 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
283 WebCore::AffineTransform transformFromView() const;
284 WebCore::AffineTransform transformToView() const;
286 WebCore::AffineTransform transformToScene() const;
287 WebCore::AffineTransform transformFromScene() const;
288 WebCore::AffineTransform transformToScreen() const;
290 #if ENABLE(TIZEN_WEBKIT2_SEPERATE_LOAD_PROGRESS)
291 void informLoadProgressStarted();
292 void informLoadProgressFinished();
295 #if ENABLE(TIZEN_DATALIST_ELEMENT)
296 void deleteDataList();
299 #if USE(TILED_BACKING_STORE)
300 void setScaleFactor(float scaleFactor) { m_scaleFactor = scaleFactor; }
301 float scaleFactor() const { return m_scaleFactor; }
303 void setScrollPosition(WebCore::IntPoint position) { m_scrollPosition = position; }
304 const WebCore::IntPoint scrollPosition() const { return m_scrollPosition; }
307 #if ENABLE(TOUCH_EVENTS) && ENABLE(TIZEN_GESTURE)
308 void feedCancelTouchEvents();
312 // FIXME: Make members private for encapsulation.
313 OwnPtr<WebKit::PageClientImpl> pageClient;
314 #if ENABLE(WAIT_UPVERSION)
315 #if USE(TILED_BACKING_STORE)
316 OwnPtr<WebKit::PageViewportControllerClientEfl> pageViewportControllerClient;
317 OwnPtr<WebKit::PageViewportController> pageViewportController;
320 RefPtr<WebKit::WebPageProxy> pageProxy;
321 OwnPtr<WebKit::PageLoadClientEfl> pageLoadClient;
322 OwnPtr<WebKit::PagePolicyClientEfl> pagePolicyClient;
323 OwnPtr<WebKit::PageUIClientEfl> pageUIClient;
324 OwnPtr<WebKit::ResourceLoadClientEfl> resourceLoadClient;
325 OwnPtr<WebKit::FindClientEfl> findClient;
326 OwnPtr<WebKit::FormClientEfl> formClient;
328 OwnPtr<Ewk_Back_Forward_List> backForwardList;
329 RefPtr<Ewk_Context> context;
331 WebKit::WebPopupMenuProxyEfl* popupMenuProxy;
332 Eina_List* popupMenuItems;
334 #if USE(ACCELERATED_COMPOSITING)
336 Evas_GL_Context* evasGlContext;
337 Evas_GL_Surface* evasGlSurface;
341 #if ENABLE(TIZEN_ORIENTATION_EVENTS)
345 JSGlobalContextRef javascriptGlobalContext;
347 WKEinaSharedString userAgent;
349 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
350 WKEinaSharedString webAppIconURL;
351 Eina_List* webAppIconURLs;
354 OwnPtr<Ewk_View_Callback_Context> alertContext;
355 OwnPtr<Ewk_View_Callback_Context> confirmContext;
356 OwnPtr<Ewk_View_Callback_Context> promptContext;
358 #if ENABLE(TIZEN_SUPPORT_BEFORE_UNLOAD_CONFIRM_PANEL)
359 OwnPtr<Ewk_View_Callback_Context> beforeUnloadConfirmPanelContext;
362 OwnPtr<Ewk_View_Callback_Context> openpanelContext;
363 OwnPtr<WebKit::JavaScriptPopup> javascriptPopup;
364 bool isWaitingForJavaScriptPopupReply;
365 OwnPtr<WebKit::OpenPanel> openPanel;
367 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
368 OwnPtr<WebKit::InputPicker> inputPicker;
369 WKEinaSharedString inputValue;
372 Ewk_Auth_Challenge* authChallenge;
373 Ewk_Policy_Decision* policyDecision;
374 WKOpenPanelResultListenerRef openPanelListener;
376 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
377 Ewk_Certificate_Policy_Decision* certificatePolicyDecision;
380 #if ENABLE(TIZEN_MEDIA_STREAM)
381 Eina_List* userMediaPermissionRequests;
384 #if ENABLE(TIZEN_GEOLOCATION)
385 Ewk_Geolocation* geolocation;
386 Eina_List* geolocationPermissionRequests;
389 bool suspendRequested;
390 bool suspendedPainting;
391 bool suspendedResources;
393 #if ENABLE(TIZEN_NOTIFICATIONS)
394 Eina_List* notifications;
395 Eina_List* notificationPermissionRequests;
398 #if ENABLE(TIZEN_SQL_DATABASE)
399 Ewk_Context_Exceeded_Quota* exceededDatabaseQuota;
402 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
403 Ewk_Popup_Picker* popupPicker;
407 bool isHorizontalEdge;
409 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
410 OwnPtr<FocusRing> focusRing;
413 #if ENABLE(TIZEN_GESTURE)
414 OwnPtr<WebKit::GestureRecognizer> gestureRecognizer;
415 OwnPtr<WebKit::GestureClient> gestureClient;
416 #if ENABLE(TOUCH_EVENTS)
417 Evas_Coord_Point touchDownPoint;
418 bool exceedTouchMoveThreshold;
419 bool wasHandledTouchStart;
420 bool wasHandledTouchMove;
422 bool holdHorizontalPanning;
423 bool holdVerticalPanning;
424 #endif // #if ENABLE(TIZEN_GESTURE)
426 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
427 bool mainFrameScrollbarVisibility;
430 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
431 Ecore_Animator* compositionAnimator;
434 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
435 WKEinaSharedString selectedText;
438 #if ENABLE(TIZEN_DATALIST_ELEMENT)
442 #if ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT_INTERNAL)
444 Ewk_Orientation_Lock_Cb callback;
449 #if ENABLE(TIZEN_WEBKIT2_CREATE_VIEW_WITH_CREATED_PAGE_GROUP_WITH_IDENTIFIER)
450 RefPtr<WebKit::WebPageGroup> pageGroup;
452 #endif // #if OS(TIZEN)
455 inline Ewk_View_Smart_Data* smartData() const;
456 void displayTimerFired(WebCore::Timer<EwkViewImpl>*);
458 static void onMouseDown(void* data, Evas*, Evas_Object*, void* eventInfo);
459 static void onMouseUp(void* data, Evas*, Evas_Object*, void* eventInfo);
460 static void onMouseMove(void* data, Evas*, Evas_Object*, void* eventInfo);
461 #if ENABLE(TOUCH_EVENTS)
462 void feedTouchEvents(Ewk_Touch_Event_Type type);
463 static void onTouchDown(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */);
464 static void onTouchUp(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */);
465 static void onTouchMove(void* /* data */, Evas* /* canvas */, Evas_Object* ewkView, void* /* eventInfo */);
469 OwnPtr<Ewk_Settings> m_settings;
470 RefPtr<Evas_Object> m_cursorObject;
471 WKEinaSharedString m_cursorGroup;
472 WKEinaSharedString m_faviconURL;
473 WKEinaSharedString m_url;
474 mutable WKEinaSharedString m_title;
475 WKEinaSharedString m_theme;
476 mutable WKEinaSharedString m_customEncoding;
477 bool m_mouseEventsEnabled;
478 #if ENABLE(TOUCH_EVENTS)
479 bool m_touchEventsEnabled;
481 WKRetainPtr<WKColorPickerResultListenerRef> m_colorPickerResultListener;
482 WebCore::Timer<EwkViewImpl> m_displayTimer;
483 WTF::Vector <WebCore::IntRect> m_dirtyRects;
484 OwnPtr<WebKit::InputMethodContextEfl> m_inputMethodContext;
486 typedef HashMap<WKPageRef, const Evas_Object*> PageViewMap;
487 static PageViewMap pageViewMap;
490 #if USE(TILED_BACKING_STORE)
492 WebCore::IntPoint m_scrollPosition;
497 #endif // EwkViewImpl_h