2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FWebCtrl_Web.cpp
20 * @brief The file contains the definition of _Web class.
22 * The file contains the definition of _Web class.
25 #include <Elementary.h>
27 #include <FBaseByteBuffer.h>
28 #include <FBaseColLinkedListT.h>
29 #include <FBaseSysLog.h>
30 #include <FBaseColIListT.h>
31 #include <FGrpFloatPoint.h>
32 #include <FGrpPoint.h>
33 #include <FGrpBitmap.h>
34 #include <FGrpCanvas.h>
35 #include <FGrpFloatRectangle.h>
36 #include <FSysVibrator.h>
37 #include <FWebCtrlWebSetting.h>
38 #include <FGrp_CoordinateSystem.h>
39 #include <FSys_VibratorImpl.h>
40 #include <FUiAnim_EflNode.h>
41 #include <FUiAnim_VisualElement.h>
42 #include <FUiAnim_VisualElementImpl.h>
43 #include <FUi_CoordinateSystemUtils.h>
44 #include <FUi_AccessibilityContainer.h>
45 #include <FUi_AccessibilityElement.h>
46 #include <FUi_UiEventManager.h>
47 #include <FUi_IAccessibilityFocusHandler.h>
48 #include <FUi_IAccessibilityListener.h>
50 #include <FUi_TouchManager.h>
51 #include "FWebCtrl_EflWebkit.h"
52 #include "FWebCtrl_GestureState.h"
53 #include "FWebCtrl_Web.h"
54 #include "FWebCtrl_WebSettingImpl.h"
55 #include "FWebCtrl_Utility.h"
58 using namespace Tizen::Base;
59 using namespace Tizen::Base::Collection;
60 using namespace Tizen::Graphics;
61 using namespace Tizen::Ui;
62 using namespace Tizen::Ui::Animations;
69 class _WebAccessibilityListener
70 : public Tizen::Ui::_IAccessibilityListener
73 _WebAccessibilityListener(Evas_Object* pView);
75 virtual ~_WebAccessibilityListener(void);
77 virtual bool OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element);
79 virtual bool OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element);
81 virtual bool OnAccessibilityReadingElement(const _AccessibilityContainer& control, const _AccessibilityElement& element);
83 virtual bool OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element);
85 virtual bool OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element);
87 virtual bool OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element);
89 virtual bool OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element);
91 virtual bool OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element);
93 virtual bool OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element);
100 _WebAccessibilityListener::_WebAccessibilityListener(Evas_Object* pView)
106 _WebAccessibilityListener::~_WebAccessibilityListener(void)
112 _WebAccessibilityListener::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element)
119 _WebAccessibilityListener::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element)
126 _WebAccessibilityListener::OnAccessibilityReadingElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
133 _WebAccessibilityListener::OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
140 _WebAccessibilityListener::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element)
147 _WebAccessibilityListener::OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element)
149 Ewk_View_Smart_Data* pSmartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(__pView));
150 SysAssertf(pSmartData, "Failed to get webkit smart data.");
152 Elm_Access_Action_Info* pActionInfo = new Elm_Access_Action_Info();
153 SysTryReturn(NID_WEB_CTRL, pActionInfo, false, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
157 pActionInfo->action_type = ELM_ACCESS_ACTION_UNHIGHLIGHT;
159 result = pSmartData->api->screen_reader_action_execute(pSmartData, pActionInfo);
167 _WebAccessibilityListener::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element)
169 Ewk_View_Smart_Data* pSmartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(__pView));
170 SysAssertf(pSmartData, "Failed to get webkit smart data.");
172 Elm_Access_Action_Info* pActionInfo = new Elm_Access_Action_Info();
173 SysTryReturn(NID_WEB_CTRL, pActionInfo, false, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
177 pActionInfo->action_type = ELM_ACCESS_ACTION_ACTIVATE;
179 result = pSmartData->api->screen_reader_action_execute(pSmartData, pActionInfo);
187 _WebAccessibilityListener::OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
194 _WebAccessibilityListener::OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
200 class _WebAccessibilityFocusHandler
201 : public Tizen::Ui::_IAccessibilityFocusHandler
204 _WebAccessibilityFocusHandler(Evas_Object* pView);
206 virtual ~_WebAccessibilityFocusHandler(void);
208 virtual bool OnMoveFocus(Tizen::Ui::_AccessibilityFocusDirection direction);
210 virtual bool OnMoveFocus(const Tizen::Graphics::Point& point);
213 Evas_Object* __pView;
217 _WebAccessibilityFocusHandler::_WebAccessibilityFocusHandler(Evas_Object* pView)
223 _WebAccessibilityFocusHandler::~_WebAccessibilityFocusHandler(void)
229 _WebAccessibilityFocusHandler::OnMoveFocus(Tizen::Ui::_AccessibilityFocusDirection direction)
231 Ewk_View_Smart_Data* pSmartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(__pView));
232 SysAssertf(pSmartData, "Failed to get webkit smart data.");
234 Elm_Access_Action_Info* pActionInfo = new Elm_Access_Action_Info();
235 SysTryReturn(NID_WEB_CTRL, pActionInfo, false, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
239 if (direction == Tizen::Ui::_ACCESSIBILITY_FOCUS_DIRECTION_PREVIOUS)
241 pActionInfo->action_type = ELM_ACCESS_ACTION_HIGHLIGHT;
243 pActionInfo->action_by = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
245 result = pSmartData->api->screen_reader_action_execute(pSmartData, pActionInfo);
247 else if (direction == Tizen::Ui::_ACCESSIBILITY_FOCUS_DIRECTION_NEXT)
249 pActionInfo->action_type = ELM_ACCESS_ACTION_HIGHLIGHT;
251 pActionInfo->action_by = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
253 result = pSmartData->api->screen_reader_action_execute(pSmartData, pActionInfo);
262 _WebAccessibilityFocusHandler::OnMoveFocus(const Tizen::Graphics::Point& point)
264 Ewk_View_Smart_Data* pSmartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(__pView));
265 SysAssertf(pSmartData, "Failed to get webkit smart data.");
267 Elm_Access_Action_Info* pActionInfo = new Elm_Access_Action_Info();
268 SysTryReturn(NID_WEB_CTRL, pActionInfo, false, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
272 pActionInfo->action_type = ELM_ACCESS_ACTION_READ;
273 pActionInfo->x = point.x;
274 pActionInfo->y = point.y;
276 result = pSmartData->api->screen_reader_action_execute(pSmartData, pActionInfo);
286 namespace Tizen { namespace Web { namespace Controls
291 OnEdgeLeft(void* pUserData, Evas_Object* pView, void* pEventInfo)
293 _Web* pCore = reinterpret_cast< _Web* >(pUserData);
294 SysAssertf(pCore, "Failed to request");
296 pCore->SetEdgeReachedEvent(WEB_EDGE_LEFT);
301 OnEdgeRight(void* pUserData, Evas_Object* pView, void* pEventInfo)
303 _Web* pCore = reinterpret_cast< _Web* >(pUserData);
304 SysAssertf(pCore, "Failed to request");
306 pCore->SetEdgeReachedEvent(WEB_EDGE_RIGHT);
311 OnEdgeTop(void* pUserData, Evas_Object* pView, void* pEventInfo)
313 _Web* pCore = reinterpret_cast< _Web* >(pUserData);
314 SysAssertf(pCore, "Failed to request");
316 pCore->SetEdgeReachedEvent(WEB_EDGE_TOP);
321 OnEdgeBottom(void* pUserData, Evas_Object* pView, void* pEventInfo)
323 _Web* pCore = reinterpret_cast< _Web* >(pUserData);
324 SysAssertf(pCore, "Failed to request");
326 pCore->SetEdgeReachedEvent(WEB_EDGE_BOTTOM);
331 : __pGestureHandler(null)
333 , __pWebSetting(null)
334 , __pGestureFlick(null)
335 , __pGestureLongPress(null)
336 , __pGesturePinch(null)
337 , __pGestureDoubleTap(null)
338 , __pTouchEventInfoList(null)
339 , __pTapGestureHandler(null)
340 , __pPanningGestureHandler(null)
341 , __pFlickGestureHandler(null)
342 , __pPinchGestureHandler(null)
343 , __gestureType(WEB_GESTURE_TYPE_TAP)
344 , __edgeType(WEB_EDGE_NONE)
346 , __pTextElement(null)
347 , __previousTouchedPosition(0.0f, 0.0f)
348 , __isFullScreenEntered(false)
350 SetBackgroundColor(Color(0, 0, 0, 0));
356 RemoveGestureListener();
361 _Web::CreateWebN(void)
363 result r = E_SUCCESS;
365 std::unique_ptr<_Web> pWeb(new (std::nothrow) _Web());
366 SysTryReturn(NID_WEB_CTRL, pWeb.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
368 pWeb->__pWebSetting = std::unique_ptr<WebSetting>(new (std::nothrow) WebSetting());
369 SysTryReturn(NID_WEB_CTRL, pWeb->__pWebSetting.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
371 pWeb->AcquireHandle();
372 pWeb->SetMultiTouchEnabled(true);
373 pWeb->SetTouchPressThreshold(0.08);
375 r = pWeb->AddGestureListeners();
376 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
378 r = pWeb->InitializeGestureStates();
379 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
381 return pWeb.release();
386 _Web::CreateWebkitEvasObject(void)
388 result r = E_SUCCESS;
390 std::unique_ptr<_EflWebkit> pEflWebkit(new (std::nothrow) _EflWebkit());
391 SysTryReturnResult(NID_WEB_CTRL, pEflWebkit.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
393 _VisualElement* pVe = GetVisualElement();
394 r = pEflWebkit->Construct(GetAbsoluteBounds(), *pVe, this);
395 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
397 _VisualElementImpl* pVeImpl = _VisualElementImpl::GetInstance(*pVe);
398 pVeImpl->SetCaptureProvider(this);
400 __pEflWebkit = std::move(pEflWebkit);
402 Evas_Object* pView = GetWebNativeNode();
403 evas_object_smart_callback_add(pView, "edge,left", OnEdgeLeft, this);
404 evas_object_smart_callback_add(pView, "edge,right", OnEdgeRight, this);
405 evas_object_smart_callback_add(pView, "edge,top", OnEdgeTop, this);
406 evas_object_smart_callback_add(pView, "edge,bottom", OnEdgeBottom, this);
413 _Web::InitializeGestureStates(void)
415 __pPinchGestureHandler = std::unique_ptr<_PinchGestureState>(new (std::nothrow) _PinchGestureState(this));
416 SysTryReturnResult(NID_WEB_CTRL, __pPinchGestureHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
418 __pTapGestureHandler = std::unique_ptr<_TapGestureState>(new (std::nothrow) _TapGestureState(this));
419 SysTryReturnResult(NID_WEB_CTRL, __pTapGestureHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
421 __pPanningGestureHandler = std::unique_ptr<_PanningGestureState>(new (std::nothrow) _PanningGestureState(this));
422 SysTryReturnResult(NID_WEB_CTRL, __pPanningGestureHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
424 __pFlickGestureHandler = std::unique_ptr<_FlickGestureState>(new (std::nothrow) _FlickGestureState(this));
425 SysTryReturnResult(NID_WEB_CTRL, __pFlickGestureHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
427 __pGestureHandler = __pTapGestureHandler.get();
434 _Web::AddGestureListeners(void)
436 result r = E_SUCCESS;
438 std::unique_ptr<_TouchFlickGestureDetector> pGestureFlick(new (std::nothrow) _TouchFlickGestureDetector());
439 SysTryReturnResult(NID_WEB_CTRL, pGestureFlick.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
441 r = pGestureFlick->AddGestureListener(*this);
442 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
444 r = AddGestureDetector(*pGestureFlick.get());
445 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
447 __pGestureFlick = std::move(pGestureFlick);
449 std::unique_ptr<_TouchLongPressGestureDetector> pGestureLongPress(new (std::nothrow) _TouchLongPressGestureDetector());
450 SysTryReturnResult(NID_WEB_CTRL, pGestureLongPress.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
452 r = pGestureLongPress->AddGestureListener(*this);
453 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
455 r = AddGestureDetector(*pGestureLongPress.get());
456 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
458 __pGestureLongPress = std::move(pGestureLongPress);
460 std::unique_ptr<_TouchTapGestureDetector> pGestureDoubleTap(new (std::nothrow) _TouchTapGestureDetector());
461 SysTryReturnResult(NID_WEB_CTRL, pGestureDoubleTap.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
463 r = pGestureDoubleTap->AddGestureListener(*this);
464 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
466 r = AddGestureDetector(*pGestureDoubleTap.get());
467 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
469 __pGestureDoubleTap = std::move(pGestureDoubleTap);
471 std::unique_ptr<_TouchPinchGestureDetector> pGesturePinch(new (std::nothrow) _TouchPinchGestureDetector());
472 SysTryReturnResult(NID_WEB_CTRL, pGesturePinch.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
474 r = pGesturePinch->AddGestureListener(*this);
475 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
477 r = AddGestureDetector(*pGesturePinch.get());
478 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
480 __pGesturePinch = std::move(pGesturePinch);
487 _Web::RemoveGestureListener(void)
489 if (__pGestureFlick.get())
491 __pGestureFlick->RemoveGestureListener(*this);
492 RemoveGestureDetector(*__pGestureFlick);
495 if (__pGestureLongPress.get())
497 __pGestureLongPress->RemoveGestureListener(*this);
498 RemoveGestureDetector(*__pGestureLongPress);
501 if (__pGestureDoubleTap.get())
503 __pGestureDoubleTap->RemoveGestureListener(*this);
504 RemoveGestureDetector(*__pGestureDoubleTap);
507 if (__pGesturePinch.get())
509 __pGesturePinch->RemoveGestureListener(*this);
510 RemoveGestureDetector(*__pGesturePinch);
513 Evas_Object* pView = GetWebNativeNode();
516 evas_object_smart_callback_del(pView, "edge,left", OnEdgeLeft);
517 evas_object_smart_callback_del(pView, "edge,right", OnEdgeRight);
518 evas_object_smart_callback_del(pView, "edge,top", OnEdgeTop);
519 evas_object_smart_callback_del(pView, "edge,bottom", OnEdgeBottom);
525 _Web::InitializeWebNativeNode(void)
527 result r = E_SUCCESS;
529 r = CreateWebkitEvasObject();
530 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
532 SetNativeObjectFocusable(false);
534 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
535 SysTryReturn(NID_WEB_CTRL, pContainer, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(E_SYSTEM));
537 __pTextElement = new (std::nothrow) _AccessibilityElement(true);
538 SysTryReturn(NID_WEB_CTRL, __pTextElement, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
540 __pTextElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBoundsF().width, GetBoundsF().height));
541 __pTextElement->SetLabel(L"Web control");
543 pContainer->AddElement(*__pTextElement);
544 pContainer->Activate(true);
546 _WebAccessibilityListener* pListener = new (std::nothrow) _WebAccessibilityListener(GetWebNativeNode());
547 SysTryReturn(NID_WEB_CTRL, pListener, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
549 pContainer->AddListener(*dynamic_cast<_IAccessibilityListener*>(pListener));
551 _WebAccessibilityFocusHandler* pFocusHandler = new (std::nothrow) _WebAccessibilityFocusHandler(GetWebNativeNode());
552 SysTryReturn(NID_WEB_CTRL, pFocusHandler, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
554 pContainer->SetFocusHandler(dynamic_cast<_IAccessibilityFocusHandler*>(pFocusHandler));
561 _Web::GetAbsoluteCoordinate(Point relativePoint)
563 return _CoordinateSystemUtils::Transform(ConvertToScreenPosition(relativePoint));
568 _Web::GetAbsoluteCoordinate(FloatPoint relativePoint)
570 return _CoordinateSystemUtils::Transform(ConvertToScreenPosition(relativePoint));
575 _Web::GetRelativeCoordinate(Point absolutePoint)
577 return ConvertToControlPosition(_CoordinateSystemUtils::InverseTransform(absolutePoint));
582 _Web::GetRelativeCoordinate(FloatPoint absolutePoint)
584 return ConvertToControlPosition(_CoordinateSystemUtils::InverseTransform(absolutePoint));
589 _Web::GetWebNativeNode(void)
591 if (__pEflWebkit.get())
593 return __pEflWebkit->GetWebEvasObject();
601 _Web::GetSetting(void) const
603 return __pWebSetting.get();
608 _Web::OnAttaching(const _Control* pParent)
610 if (__pEflWebkit.get())
612 evas_object_show(__pEflWebkit->GetWebEvasObject());
613 evas_object_focus_set(__pEflWebkit->GetWebEvasObject(), EINA_TRUE);
621 _Web::OnBoundsChanging(const Rectangle& bounds)
623 Rectangle absoluteBounds = GetAbsoluteBounds();
624 Rectangle webBounds = GetBounds();
625 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetTransformer();
626 SysTryReturnResult(NID_WEB_CTRL, pXformer, E_SYSTEM, "[%s] A system error has been occurred. Failed to get coordinate transformer.", GetErrorMessage(E_SYSTEM));
628 if (__pEflWebkit.get())
630 evas_object_move(__pEflWebkit->GetWebEvasObject(), pXformer->TransformHorizontal(absoluteBounds.x - webBounds.x + bounds.x), pXformer->TransformVertical(absoluteBounds.y - webBounds.y + bounds.y));
631 evas_object_resize(__pEflWebkit->GetWebEvasObject(), pXformer->TransformHorizontal(bounds.width), pXformer->TransformVertical(bounds.height));
639 _Web::ChangeGesture(_WebGestureType type)
643 case WEB_GESTURE_TYPE_TAP:
644 __pGestureHandler = __pTapGestureHandler.get();
645 __gestureType = WEB_GESTURE_TYPE_TAP;
648 case WEB_GESTURE_TYPE_PANNING:
649 __pGestureHandler = __pPanningGestureHandler.get();
650 __gestureType = WEB_GESTURE_TYPE_PANNING;
653 case WEB_GESTURE_TYPE_FLICK:
654 __pGestureHandler = __pFlickGestureHandler.get();
655 __gestureType = WEB_GESTURE_TYPE_FLICK;
658 case WEB_GESTURE_TYPE_PINCH:
659 __pGestureHandler = __pPinchGestureHandler.get();
660 __gestureType = WEB_GESTURE_TYPE_PINCH;
670 _Web::SetEdgeReachedEvent(_WebEdgeType type)
677 __edgeType &= ~WEB_EDGE_RIGHT;
681 __edgeType &= ~WEB_EDGE_LEFT;
685 __edgeType &= ~WEB_EDGE_BOTTOM;
688 case WEB_EDGE_BOTTOM:
689 __edgeType &= ~WEB_EDGE_TOP;
699 _Web::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo)
701 evas_object_focus_set(GetWebNativeNode(), EINA_TRUE);
703 if (__pEflWebkit.get())
705 __edgeType = WEB_EDGE_NONE;
706 __previousTouchedPosition = touchInfo.GetCurrentPosition();
708 SendTouchEventForJavaScript(touchInfo);
710 return __pGestureHandler->OnTouchPressed(source, touchInfo);
718 _Web::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo)
720 if (__pEflWebkit.get())
722 if (__gestureType == WEB_GESTURE_TYPE_TAP)
724 __pPanningGestureHandler->InitializeTextSelectionStatus();
727 SendTouchEventForJavaScript(touchInfo);
729 __pGestureHandler->OnTouchMoved(source, touchInfo);
731 float scrollDistanceX = __previousTouchedPosition.x - touchInfo.GetCurrentPosition().x;
732 float scrollDistanceY = __previousTouchedPosition.y - touchInfo.GetCurrentPosition().y;
733 __previousTouchedPosition = touchInfo.GetCurrentPosition();
735 if (__edgeType != WEB_EDGE_NONE && __gestureType == WEB_GESTURE_TYPE_PANNING)
737 if (_Abs(scrollDistanceY) < _Abs(scrollDistanceX))
739 if (__edgeType & WEB_EDGE_LEFT)
741 if (scrollDistanceX < 0)
743 __edgeType &= ~WEB_EDGE_RIGHT;
749 __edgeType &= ~WEB_EDGE_LEFT;
752 else if (__edgeType & WEB_EDGE_RIGHT)
754 if (scrollDistanceX > 0)
756 __edgeType &= ~WEB_EDGE_LEFT;
762 __edgeType &= ~WEB_EDGE_RIGHT;
766 else if (_Abs(scrollDistanceY) > _Abs(scrollDistanceX))
768 if (__edgeType & WEB_EDGE_TOP)
770 if (scrollDistanceY < 0)
772 __edgeType &= ~WEB_EDGE_BOTTOM;
778 __edgeType &= ~WEB_EDGE_TOP;
781 else if (__edgeType & WEB_EDGE_BOTTOM)
783 if (scrollDistanceY > 0)
785 __edgeType &= ~WEB_EDGE_TOP;
791 __edgeType &= ~WEB_EDGE_BOTTOM;
805 _Web::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo)
809 if (__pEflWebkit.get())
811 SendTouchEventForJavaScript(touchInfo);
813 return __pGestureHandler->OnTouchReleased(source, touchInfo);
821 _Web::OnTouchCanceled(const _Control& source, const _TouchInfo& touchInfo)
823 if (__pEflWebkit.get())
825 SendTouchEventForJavaScript(touchInfo);
827 return __pGestureHandler->OnTouchCanceled(source, touchInfo);
835 _Web::OnTouchPressHandled(const _Control& control)
841 _Web::OnTouchReleaseHandled(const _Control& control)
847 _Web::OnTouchMoveHandled(const _Control& control)
853 _Web::OnTouchCancelHandled(const _Control& control)
859 _Web::OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture)
861 if (__pEflWebkit.get() && __gestureType == WEB_GESTURE_TYPE_TAP)
863 return __pTapGestureHandler->OnLongPressGestureDetected(gesture);
871 _Web::OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture)
878 _Web::OnTapGestureDetected(_TouchTapGestureDetector& gesture)
880 if (__pEflWebkit.get())
882 return __pTapGestureHandler->OnTapGestureDetected(gesture);
890 _Web::OnTapGestureCanceled(_TouchTapGestureDetector& gesture)
897 _Web::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture)
899 if (__pEflWebkit.get() && _WebSettingImpl::GetInstance(__pWebSetting.get())->IsScrollEnabled())
901 return __pFlickGestureHandler->OnFlickGestureDetected(gesture);
909 _Web::OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture)
916 _Web::OnPinchGestureStarted(Tizen::Ui::_TouchPinchGestureDetector& gesture)
918 if (__pEflWebkit.get())
920 return __pPinchGestureHandler->OnPinchGestureStarted(gesture);
928 _Web::OnPinchGestureChanged(Tizen::Ui::_TouchPinchGestureDetector& gesture)
930 if (__pEflWebkit.get() && __gestureType == WEB_GESTURE_TYPE_PINCH)
932 return __pPinchGestureHandler->OnPinchGestureChanged(gesture);
940 _Web::OnPinchGestureFinished(Tizen::Ui::_TouchPinchGestureDetector& gesture)
942 if (__pEflWebkit.get() && __gestureType == WEB_GESTURE_TYPE_PINCH)
944 return __pPinchGestureHandler->OnPinchGestureFinished(gesture);
952 _Web::OnPinchGestureCanceled(Tizen::Ui::_TouchPinchGestureDetector& gesture)
959 _Web::OnCanvasRequestedN(const FloatRectangle& bounds)
961 SysTryReturn(NID_WEB_CTRL, bounds.width >= 0.0f && bounds.height >= 0.0f, null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Canvas size is out of range. size = (%f, %f)", bounds.width, bounds.height);
962 if (bounds.width == 0.0f || bounds.height == 0.0f)
964 FloatDimension size(GetSizeF());
965 SysTryReturn(NID_WEB_CTRL, bounds.x >= 0.0f && bounds.y >= 0.0f && bounds.x <= size.width && bounds.y <= size.height, null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Bounds is out of range.");
968 result r = E_SUCCESS;
970 Rectangle absBounds(_CoordinateSystemUtils::ConvertToInteger(_CoordinateSystemUtils::Transform(bounds)));
973 EINA_RECTANGLE_SET(&rect, absBounds.x, absBounds.y, absBounds.width, absBounds.height);
975 Evas_Object* pWebFrame = GetWebNativeNode();
976 Evas_Object* pScreenShot = ewk_view_screenshot_contents_get(pWebFrame, rect, 1.0f, evas_object_evas_get(pWebFrame));
978 std::unique_ptr<Canvas> pCanvas(new (std::nothrow) Canvas());
979 SysTryReturn(NID_WEB_CTRL, pCanvas.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
983 BufferInfo bufferInfo;
985 r = _Utility::GetPixelBufferFromEvasObject(pScreenShot, bufferInfo);
986 evas_object_del(pScreenShot);
987 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] propagating", GetErrorMessage(r));
989 r = pCanvas->Construct(bufferInfo);
990 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] propagating", GetErrorMessage(r));
994 r = pCanvas->Construct(bounds);
995 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] propagating", GetErrorMessage(r));
998 return pCanvas.release();
1003 _Web::OnCapturedBitmapRequestedN(void)
1005 result r = E_SUCCESS;
1007 BufferInfo bufferInfo;
1008 SysTryReturn(NID_WEB_CTRL, OnCaptureAcquire(bufferInfo), null, E_SYSTEM, "[%s] A system error has been occurred. Failed to get snapshot of Web control", GetErrorMessage(E_SYSTEM));
1011 int bufferSize = bufferInfo.bitsPerPixel * bufferInfo.width * bufferInfo.height;
1013 r = buffer.Construct(reinterpret_cast < byte* >(bufferInfo.pPixels), 0, bufferSize, bufferSize);
1014 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] propagating", GetErrorMessage(r));
1016 std::unique_ptr<Bitmap> pBitmap(new (std::nothrow) Bitmap());
1017 SysTryReturn(NID_WEB_CTRL, pBitmap.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1019 r = pBitmap->Construct(buffer, Dimension(bufferInfo.width, bufferInfo.height), BITMAP_PIXEL_FORMAT_ARGB8888);
1020 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] propagating", GetErrorMessage(r));
1022 return pBitmap.release();
1027 _Web::OnCaptureAcquire(BufferInfo& output)
1029 result r = E_SUCCESS;
1031 FloatPoint position(GetPositionF());
1032 FloatDimension size(GetSizeF());
1034 Dimension absSize(_CoordinateSystemUtils::ConvertToInteger(_CoordinateSystemUtils::Transform(size)));
1036 Eina_Rectangle rect;
1037 EINA_RECTANGLE_SET(&rect, 0, 0, absSize.width, absSize.height);
1039 Evas_Object* pWebFrame = GetWebNativeNode();
1040 Evas_Object* pScreenShot = ewk_view_screenshot_contents_get(pWebFrame, rect, 1.0f, evas_object_evas_get(pWebFrame));
1041 SysTryReturn(NID_WEB_CTRL, pScreenShot, false, E_SYSTEM, "[%s] A system error has been occurred. Failed to get snapshot of Web control", GetErrorMessage(E_SYSTEM));
1043 r = _Utility::GetPixelBufferFromEvasObject(pScreenShot, output);
1044 evas_object_del(pScreenShot);
1045 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] propagating", GetErrorMessage(r));
1052 _Web::SendTouchEventForJavaScript(const _TouchInfo& touchInfo)
1054 result r = E_SUCCESS;
1056 _TouchManager* pTouchManager = _TouchManager::GetInstance();
1057 SysAssertf(pTouchManager, "Failed to get touch manager.");
1059 std::unique_ptr<IListT<_FingerInfo*> > pTouchList(pTouchManager->GetMultiFingerInfoListN());
1060 SysTryReturnVoidResult(NID_WEB_CTRL, pTouchList.get(), GetLastResult(), "[%s] Failed to get touch list.", GetErrorMessage(GetLastResult()));
1062 std::unique_ptr<IBidirectionalEnumeratorT<_FingerInfo*> > pTouchListEnum(pTouchList->GetBidirectionalEnumeratorN());
1063 SysAssertf(pTouchListEnum.get() != null, "Failed to get enumerator of touch list.");
1065 Eina_List* pPointList = null;
1066 _FingerInfo* pFingerInfo = null;
1067 while(pTouchListEnum->MoveNext() == E_SUCCESS)
1069 r = pTouchListEnum->GetCurrent(pFingerInfo);
1070 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1072 _TouchStatus state = pFingerInfo->GetStatus();
1073 if(state == _TOUCH_PRESSED || state == _TOUCH_MOVED || state == _TOUCH_RELEASED || state == _TOUCH_CANCELED)
1075 Point integerPoint(_CoordinateSystemUtils::ConvertToInteger(GetAbsoluteCoordinate(pFingerInfo->GetPoint())));
1077 Ewk_Touch_Point* pPoint = static_cast<Ewk_Touch_Point*>(calloc(1, sizeof(Ewk_Touch_Point)));
1078 pPoint->id = pFingerInfo->GetPointId();
1079 pPoint->x = integerPoint.x;
1080 pPoint->y = integerPoint.y;
1081 pPoint->state = GetEvasTouchState((TouchStatus)pFingerInfo->GetStatus());
1082 SysSecureLog(NID_WEB_CTRL, "The current value of id is %lu, x is %d, y is %d, state is %d", pPoint->id, pPoint->x, pPoint->y, pPoint->state);
1084 pPointList = eina_list_append(pPointList, pPoint);
1088 ewk_view_feed_touch_event(__pEflWebkit->GetWebEvasObject(), GetEwkTouchEvent(touchInfo.GetTouchStatus()), pPointList, null);
1091 EINA_LIST_FREE(pPointList, pData)
1096 Ewk_Touch_Event_Type
1097 _Web::GetEwkTouchEvent(_TouchStatus touchStatus)
1099 Ewk_Touch_Event_Type ewkTouchEvent = EWK_TOUCH_CANCEL;
1101 switch (touchStatus)
1103 case _TOUCH_PRESSED :
1104 ewkTouchEvent = EWK_TOUCH_START;
1107 ewkTouchEvent = EWK_TOUCH_MOVE;
1109 case _TOUCH_RELEASED :
1110 ewkTouchEvent = EWK_TOUCH_END;
1112 case _TOUCH_CANCELED :
1115 ewkTouchEvent = EWK_TOUCH_CANCEL;
1119 return ewkTouchEvent;
1123 Evas_Touch_Point_State
1124 _Web::GetEvasTouchState(TouchStatus touchStatus)
1126 Evas_Touch_Point_State evasTouchState = EVAS_TOUCH_POINT_CANCEL;
1128 switch (touchStatus)
1130 case TOUCH_PRESSED :
1131 evasTouchState = EVAS_TOUCH_POINT_DOWN;
1134 evasTouchState = EVAS_TOUCH_POINT_MOVE;
1136 case TOUCH_RELEASED :
1137 evasTouchState = EVAS_TOUCH_POINT_UP;
1139 case TOUCH_CANCELED :
1142 evasTouchState = EVAS_TOUCH_POINT_CANCEL;
1143 //todo : mapping EVAS_TOUCH_POINT_STILL, /**< Touch point is not moved af
1147 return evasTouchState;
1152 _Web::SetFullScreenEntered(bool isFullScreenEntered)
1154 __isFullScreenEntered = isFullScreenEntered;
1159 _Web::SetFocusEnd(bool focus)
1166 _Web::IsFocusEnd(void)
1173 _Web::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
1175 Ecore_X_Window rootWindow = ecore_x_window_root_first_get();
1176 Ecore_X_Atom keyboardExist = ecore_x_atom_get("X External Keyboard Exist");
1177 unsigned int keyboardNumber = 0;
1178 int ret = ecore_x_window_prop_card32_get(rootWindow, keyboardExist, &keyboardNumber, 1);
1179 if (keyboardNumber == 0)
1184 _KeyCode keyCode = keyInfo.GetKeyCode();
1186 if (IsFocusEnd() == true)
1189 evas_object_focus_set(GetWebNativeNode(), EINA_FALSE);
1197 evas_object_focus_set(GetWebNativeNode(), EINA_FALSE);
1204 evas_object_focus_set(GetWebNativeNode(), EINA_TRUE);
1211 _Web::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
1213 if (__isFullScreenEntered)
1215 if (keyInfo.GetKeyCode() == _KEY_ESC || keyInfo.GetKeyCode() == _KEY_BACK)
1217 __isFullScreenEntered = false;
1219 ewk_view_fullscreen_exit(GetWebNativeNode());
1230 _Web::OnDrawFocus(void)
1235 }}} // Tizen::Web::Controls