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.
24 #include <Elementary.h>
26 #include <FBaseByteBuffer.h>
27 #include <FBaseColLinkedListT.h>
28 #include <FBaseSysLog.h>
29 #include <FBaseColIListT.h>
30 #include <FGrpFloatPoint.h>
31 #include <FGrpPoint.h>
32 #include <FGrpBitmap.h>
33 #include <FGrpCanvas.h>
34 #include <FGrpFloatRectangle.h>
35 #include <FSysVibrator.h>
36 #include <FWebCtrlWebSetting.h>
37 #include <FGrp_CoordinateSystem.h>
38 #include <FSys_VibratorImpl.h>
39 #include <FUiAnim_EflNode.h>
40 #include <FUiAnim_VisualElement.h>
41 #include <FUiAnim_VisualElementImpl.h>
42 #include <FUi_CoordinateSystemUtils.h>
43 #include <FUi_AccessibilityContainer.h>
44 #include <FUi_AccessibilityElement.h>
45 #include <FUi_IAccessibilityFocusHandler.h>
46 #include <FUi_IAccessibilityListener.h>
48 #include <FUi_TouchManager.h>
49 #include "FWebCtrl_EflWebkit.h"
50 #include "FWebCtrl_GestureState.h"
51 #include "FWebCtrl_Web.h"
52 #include "FWebCtrl_WebSettingImpl.h"
53 #include "FWebCtrl_Utility.h"
56 using namespace Tizen::Base;
57 using namespace Tizen::Base::Collection;
58 using namespace Tizen::Graphics;
59 using namespace Tizen::Ui;
60 using namespace Tizen::Ui::Animations;
67 class _WebAccessibilityListener
68 : public Tizen::Ui::_IAccessibilityListener
71 _WebAccessibilityListener(Evas_Object* pView);
73 virtual ~_WebAccessibilityListener(void);
75 virtual bool OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element);
77 virtual bool OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element);
79 virtual bool OnAccessibilityReadingElement(const _AccessibilityContainer& control, const _AccessibilityElement& element);
81 virtual bool OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element);
83 virtual bool OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element);
85 virtual bool OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element);
87 virtual bool OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element);
89 virtual bool OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element);
91 virtual bool OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element);
98 _WebAccessibilityListener::_WebAccessibilityListener(Evas_Object* pView)
104 _WebAccessibilityListener::~_WebAccessibilityListener(void)
110 _WebAccessibilityListener::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element)
117 _WebAccessibilityListener::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element)
124 _WebAccessibilityListener::OnAccessibilityReadingElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
131 _WebAccessibilityListener::OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
138 _WebAccessibilityListener::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element)
145 _WebAccessibilityListener::OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element)
147 Ewk_View_Smart_Data* pSmartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(__pView));
148 SysAssertf(pSmartData, "Failed to get webkit smart data.");
150 Elm_Access_Action_Info* pActionInfo = new Elm_Access_Action_Info();
151 SysTryReturn(NID_WEB_CTRL, pActionInfo, false, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
155 pActionInfo->action_type = ELM_ACCESS_ACTION_UNHIGHLIGHT;
157 result = pSmartData->api->screen_reader_action_execute(pSmartData, pActionInfo);
165 _WebAccessibilityListener::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element)
167 Ewk_View_Smart_Data* pSmartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(__pView));
168 SysAssertf(pSmartData, "Failed to get webkit smart data.");
170 Elm_Access_Action_Info* pActionInfo = new Elm_Access_Action_Info();
171 SysTryReturn(NID_WEB_CTRL, pActionInfo, false, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
175 pActionInfo->action_type = ELM_ACCESS_ACTION_ACTIVATE;
177 result = pSmartData->api->screen_reader_action_execute(pSmartData, pActionInfo);
185 _WebAccessibilityListener::OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
192 _WebAccessibilityListener::OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
198 class _WebAccessibilityFocusHandler
199 : public Tizen::Ui::_IAccessibilityFocusHandler
202 _WebAccessibilityFocusHandler(Evas_Object* pView);
204 virtual ~_WebAccessibilityFocusHandler(void);
206 virtual bool OnMoveFocus(Tizen::Ui::_AccessibilityFocusDirection direction);
208 virtual bool OnMoveFocus(const Tizen::Graphics::Point& point);
211 Evas_Object* __pView;
215 _WebAccessibilityFocusHandler::_WebAccessibilityFocusHandler(Evas_Object* pView)
221 _WebAccessibilityFocusHandler::~_WebAccessibilityFocusHandler(void)
227 _WebAccessibilityFocusHandler::OnMoveFocus(Tizen::Ui::_AccessibilityFocusDirection direction)
229 Ewk_View_Smart_Data* pSmartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(__pView));
230 SysAssertf(pSmartData, "Failed to get webkit smart data.");
232 Elm_Access_Action_Info* pActionInfo = new Elm_Access_Action_Info();
233 SysTryReturn(NID_WEB_CTRL, pActionInfo, false, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
237 if (direction == Tizen::Ui::_ACCESSIBILITY_FOCUS_DIRECTION_PREVIOUS)
239 pActionInfo->action_type = ELM_ACCESS_ACTION_HIGHLIGHT;
241 pActionInfo->action_by = ELM_ACCESS_ACTION_HIGHLIGHT_PREV;
243 result = pSmartData->api->screen_reader_action_execute(pSmartData, pActionInfo);
245 else if (direction == Tizen::Ui::_ACCESSIBILITY_FOCUS_DIRECTION_NEXT)
247 pActionInfo->action_type = ELM_ACCESS_ACTION_HIGHLIGHT;
249 pActionInfo->action_by = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT;
251 result = pSmartData->api->screen_reader_action_execute(pSmartData, pActionInfo);
260 _WebAccessibilityFocusHandler::OnMoveFocus(const Tizen::Graphics::Point& point)
262 Ewk_View_Smart_Data* pSmartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(__pView));
263 SysAssertf(pSmartData, "Failed to get webkit smart data.");
265 Elm_Access_Action_Info* pActionInfo = new Elm_Access_Action_Info();
266 SysTryReturn(NID_WEB_CTRL, pActionInfo, false, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
270 pActionInfo->action_type = ELM_ACCESS_ACTION_READ;
271 pActionInfo->x = point.x;
272 pActionInfo->y = point.y;
274 result = pSmartData->api->screen_reader_action_execute(pSmartData, pActionInfo);
284 namespace Tizen { namespace Web { namespace Controls
289 OnEdgeLeft(void* pUserData, Evas_Object* pView, void* pEventInfo)
291 _Web* pCore = reinterpret_cast< _Web* >(pUserData);
292 SysAssertf(pCore, "Failed to request");
294 pCore->SetEdgeReachedEvent(WEB_EDGE_LEFT);
299 OnEdgeRight(void* pUserData, Evas_Object* pView, void* pEventInfo)
301 _Web* pCore = reinterpret_cast< _Web* >(pUserData);
302 SysAssertf(pCore, "Failed to request");
304 pCore->SetEdgeReachedEvent(WEB_EDGE_RIGHT);
309 OnEdgeTop(void* pUserData, Evas_Object* pView, void* pEventInfo)
311 _Web* pCore = reinterpret_cast< _Web* >(pUserData);
312 SysAssertf(pCore, "Failed to request");
314 pCore->SetEdgeReachedEvent(WEB_EDGE_TOP);
319 OnEdgeBottom(void* pUserData, Evas_Object* pView, void* pEventInfo)
321 _Web* pCore = reinterpret_cast< _Web* >(pUserData);
322 SysAssertf(pCore, "Failed to request");
324 pCore->SetEdgeReachedEvent(WEB_EDGE_BOTTOM);
329 : __pGestureHandler(null)
331 , __pWebSetting(null)
332 , __pGestureFlick(null)
333 , __pGestureLongPress(null)
334 , __pGesturePinch(null)
335 , __pGestureDoubleTap(null)
336 , __pTouchEventInfoList(null)
337 , __pTapGestureHandler(null)
338 , __pPanningGestureHandler(null)
339 , __pFlickGestureHandler(null)
340 , __pPinchGestureHandler(null)
341 , __gestureType(WEB_GESTURE_TYPE_TAP)
342 , __edgeType(WEB_EDGE_NONE)
344 , __pTextElement(null)
345 , __previousTouchedPosition(0.0f, 0.0f)
347 SetBackgroundColor(Color(0, 0, 0, 0));
353 RemoveGestureListener();
358 _Web::CreateWebN(void)
360 result r = E_SUCCESS;
362 std::unique_ptr<_Web> pWeb(new (std::nothrow) _Web());
363 SysTryReturn(NID_WEB_CTRL, pWeb.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
365 pWeb->__pWebSetting = std::unique_ptr<WebSetting>(new (std::nothrow) WebSetting());
366 SysTryReturn(NID_WEB_CTRL, pWeb->__pWebSetting.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
368 pWeb->AcquireHandle();
369 pWeb->SetMultiTouchEnabled(true);
370 pWeb->SetTouchPressThreshold(0.08);
372 r = pWeb->AddGestureListeners();
373 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
375 r = pWeb->InitializeGestureStates();
376 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
378 return pWeb.release();
383 _Web::CreateWebkitEvasObject(void)
385 result r = E_SUCCESS;
387 std::unique_ptr<_EflWebkit> pEflWebkit(new (std::nothrow) _EflWebkit());
388 SysTryReturnResult(NID_WEB_CTRL, pEflWebkit.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
390 _VisualElement* pVe = GetVisualElement();
391 r = pEflWebkit->Construct(GetAbsoluteBounds(), *pVe, this);
392 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
394 _VisualElementImpl* pVeImpl = _VisualElementImpl::GetInstance(*pVe);
395 pVeImpl->SetCaptureProvider(this);
397 __pEflWebkit = std::move(pEflWebkit);
399 Evas_Object* pView = GetWebNativeNode();
400 evas_object_smart_callback_add(pView, "edge,left", OnEdgeLeft, this);
401 evas_object_smart_callback_add(pView, "edge,right", OnEdgeRight, this);
402 evas_object_smart_callback_add(pView, "edge,top", OnEdgeTop, this);
403 evas_object_smart_callback_add(pView, "edge,bottom", OnEdgeBottom, this);
410 _Web::InitializeGestureStates(void)
412 __pPinchGestureHandler = std::unique_ptr<_PinchGestureState>(new (std::nothrow) _PinchGestureState(this));
413 SysTryReturnResult(NID_WEB_CTRL, __pPinchGestureHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
415 __pTapGestureHandler = std::unique_ptr<_TapGestureState>(new (std::nothrow) _TapGestureState(this));
416 SysTryReturnResult(NID_WEB_CTRL, __pTapGestureHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
418 __pPanningGestureHandler = std::unique_ptr<_PanningGestureState>(new (std::nothrow) _PanningGestureState(this));
419 SysTryReturnResult(NID_WEB_CTRL, __pPanningGestureHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
421 __pFlickGestureHandler = std::unique_ptr<_FlickGestureState>(new (std::nothrow) _FlickGestureState(this));
422 SysTryReturnResult(NID_WEB_CTRL, __pFlickGestureHandler.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
424 __pGestureHandler = __pTapGestureHandler.get();
431 _Web::AddGestureListeners(void)
433 result r = E_SUCCESS;
435 std::unique_ptr<_TouchFlickGestureDetector> pGestureFlick(new (std::nothrow) _TouchFlickGestureDetector());
436 SysTryReturnResult(NID_WEB_CTRL, pGestureFlick.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
438 r = pGestureFlick->AddGestureListener(*this);
439 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
441 r = AddGestureDetector(*pGestureFlick.get());
442 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
444 __pGestureFlick = std::move(pGestureFlick);
446 std::unique_ptr<_TouchLongPressGestureDetector> pGestureLongPress(new (std::nothrow) _TouchLongPressGestureDetector());
447 SysTryReturnResult(NID_WEB_CTRL, pGestureLongPress.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
449 r = pGestureLongPress->AddGestureListener(*this);
450 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
452 r = AddGestureDetector(*pGestureLongPress.get());
453 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
455 __pGestureLongPress = std::move(pGestureLongPress);
457 std::unique_ptr<_TouchTapGestureDetector> pGestureDoubleTap(new (std::nothrow) _TouchTapGestureDetector());
458 SysTryReturnResult(NID_WEB_CTRL, pGestureDoubleTap.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
460 r = pGestureDoubleTap->AddGestureListener(*this);
461 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
463 r = AddGestureDetector(*pGestureDoubleTap.get());
464 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
466 __pGestureDoubleTap = std::move(pGestureDoubleTap);
468 std::unique_ptr<_TouchPinchGestureDetector> pGesturePinch(new (std::nothrow) _TouchPinchGestureDetector());
469 SysTryReturnResult(NID_WEB_CTRL, pGesturePinch.get(), E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
471 r = pGesturePinch->AddGestureListener(*this);
472 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
474 r = AddGestureDetector(*pGesturePinch.get());
475 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
477 __pGesturePinch = std::move(pGesturePinch);
484 _Web::RemoveGestureListener(void)
486 if (__pGestureFlick.get())
488 __pGestureFlick->RemoveGestureListener(*this);
489 RemoveGestureDetector(*__pGestureFlick);
492 if (__pGestureLongPress.get())
494 __pGestureLongPress->RemoveGestureListener(*this);
495 RemoveGestureDetector(*__pGestureLongPress);
498 if (__pGestureDoubleTap.get())
500 __pGestureDoubleTap->RemoveGestureListener(*this);
501 RemoveGestureDetector(*__pGestureDoubleTap);
504 if (__pGesturePinch.get())
506 __pGesturePinch->RemoveGestureListener(*this);
507 RemoveGestureDetector(*__pGesturePinch);
510 Evas_Object* pView = GetWebNativeNode();
513 evas_object_smart_callback_del(pView, "edge,left", OnEdgeLeft);
514 evas_object_smart_callback_del(pView, "edge,right", OnEdgeRight);
515 evas_object_smart_callback_del(pView, "edge,top", OnEdgeTop);
516 evas_object_smart_callback_del(pView, "edge,bottom", OnEdgeBottom);
522 _Web::InitializeWebNativeNode(void)
524 result r = E_SUCCESS;
526 r = CreateWebkitEvasObject();
527 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
529 SetNativeObjectFocusable(false);
531 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
532 SysTryReturn(NID_WEB_CTRL, pContainer, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(E_SYSTEM));
534 __pTextElement = new (std::nothrow) _AccessibilityElement(true);
535 SysTryReturn(NID_WEB_CTRL, __pTextElement, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
537 __pTextElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBoundsF().width, GetBoundsF().height));
538 __pTextElement->SetLabel(L"Web control");
540 pContainer->AddElement(*__pTextElement);
541 pContainer->Activate(true);
543 _WebAccessibilityListener* pListener = new (std::nothrow) _WebAccessibilityListener(GetWebNativeNode());
544 SysTryReturn(NID_WEB_CTRL, pListener, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
546 pContainer->AddListener(*dynamic_cast<_IAccessibilityListener*>(pListener));
548 _WebAccessibilityFocusHandler* pFocusHandler = new (std::nothrow) _WebAccessibilityFocusHandler(GetWebNativeNode());
549 SysTryReturn(NID_WEB_CTRL, pFocusHandler, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
551 pContainer->SetFocusHandler(dynamic_cast<_IAccessibilityFocusHandler*>(pFocusHandler));
558 _Web::GetAbsoluteCoordinate(Point relativePoint)
560 return _CoordinateSystemUtils::Transform(ConvertToScreenPosition(relativePoint));
565 _Web::GetAbsoluteCoordinate(FloatPoint relativePoint)
567 return _CoordinateSystemUtils::Transform(ConvertToScreenPosition(relativePoint));
572 _Web::GetRelativeCoordinate(Point absolutePoint)
574 return ConvertToControlPosition(_CoordinateSystemUtils::InverseTransform(absolutePoint));
579 _Web::GetRelativeCoordinate(FloatPoint absolutePoint)
581 return ConvertToControlPosition(_CoordinateSystemUtils::InverseTransform(absolutePoint));
586 _Web::GetWebNativeNode(void)
588 if (__pEflWebkit.get())
590 return __pEflWebkit->GetWebEvasObject();
598 _Web::GetSetting(void) const
600 return __pWebSetting.get();
605 _Web::OnAttaching(const _Control* pParent)
607 if (__pEflWebkit.get())
609 evas_object_show(__pEflWebkit->GetWebEvasObject());
610 evas_object_focus_set(__pEflWebkit->GetWebEvasObject(), EINA_TRUE);
618 _Web::OnBoundsChanging(const Rectangle& bounds)
620 Rectangle absoluteBounds = GetAbsoluteBounds();
621 Rectangle webBounds = GetBounds();
622 _ICoordinateSystemTransformer* pXformer = _CoordinateSystem::GetInstance()->GetTransformer();
623 SysTryReturnResult(NID_WEB_CTRL, pXformer, E_SYSTEM, "[%s] A system error has been occurred. Failed to get coordinate transformer.", GetErrorMessage(E_SYSTEM));
625 if (__pEflWebkit.get())
627 evas_object_move(__pEflWebkit->GetWebEvasObject(), pXformer->TransformHorizontal(absoluteBounds.x - webBounds.x + bounds.x), pXformer->TransformVertical(absoluteBounds.y - webBounds.y + bounds.y));
628 evas_object_resize(__pEflWebkit->GetWebEvasObject(), pXformer->TransformHorizontal(bounds.width), pXformer->TransformVertical(bounds.height));
636 _Web::ChangeGesture(_WebGestureType type)
640 case WEB_GESTURE_TYPE_TAP:
641 __pGestureHandler = __pTapGestureHandler.get();
642 __gestureType = WEB_GESTURE_TYPE_TAP;
645 case WEB_GESTURE_TYPE_PANNING:
646 __pGestureHandler = __pPanningGestureHandler.get();
647 __gestureType = WEB_GESTURE_TYPE_PANNING;
650 case WEB_GESTURE_TYPE_FLICK:
651 __pGestureHandler = __pFlickGestureHandler.get();
652 __gestureType = WEB_GESTURE_TYPE_FLICK;
655 case WEB_GESTURE_TYPE_PINCH:
656 __pGestureHandler = __pPinchGestureHandler.get();
657 __gestureType = WEB_GESTURE_TYPE_PINCH;
667 _Web::SetEdgeReachedEvent(_WebEdgeType type)
674 __edgeType &= ~WEB_EDGE_RIGHT;
678 __edgeType &= ~WEB_EDGE_LEFT;
682 __edgeType &= ~WEB_EDGE_BOTTOM;
685 case WEB_EDGE_BOTTOM:
686 __edgeType &= ~WEB_EDGE_TOP;
696 _Web::SetFocusEnd(bool focus)
703 _Web::IsFocusEnd(void)
710 _Web::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
712 _KeyCode keyCode = keyInfo.GetKeyCode();
713 Evas* pEvas = evas_object_evas_get(GetWebNativeNode());
715 if (IsFocusEnd() == true)
718 evas_object_focus_set(GetWebNativeNode(), EINA_FALSE);
726 evas_object_focus_set(GetWebNativeNode(), EINA_FALSE);
733 evas_object_focus_set(GetWebNativeNode(), EINA_TRUE);
740 _Web::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
747 _Web::OnDrawFocus(void)
753 _Web::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo)
755 if (__pEflWebkit.get())
757 __edgeType = WEB_EDGE_NONE;
758 __previousTouchedPosition = touchInfo.GetCurrentPosition();
760 SendTouchEventForJavaScript(touchInfo);
762 return __pGestureHandler->OnTouchPressed(source, touchInfo);
770 _Web::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo)
772 if (__pEflWebkit.get())
774 if (__gestureType == WEB_GESTURE_TYPE_TAP)
776 __pPanningGestureHandler->InitializeTextSelectionStatus();
779 SendTouchEventForJavaScript(touchInfo);
781 __pGestureHandler->OnTouchMoved(source, touchInfo);
783 float scrollDistanceX = __previousTouchedPosition.x - touchInfo.GetCurrentPosition().x;
784 float scrollDistanceY = __previousTouchedPosition.y - touchInfo.GetCurrentPosition().y;
785 __previousTouchedPosition = touchInfo.GetCurrentPosition();
787 if (__edgeType != WEB_EDGE_NONE && __gestureType == WEB_GESTURE_TYPE_PANNING)
789 if (_Abs(scrollDistanceY) < _Abs(scrollDistanceX))
791 if (__edgeType & WEB_EDGE_LEFT)
793 if (scrollDistanceX < 0)
795 __edgeType &= ~WEB_EDGE_RIGHT;
801 __edgeType &= ~WEB_EDGE_LEFT;
804 else if (__edgeType & WEB_EDGE_RIGHT)
806 if (scrollDistanceX > 0)
808 __edgeType &= ~WEB_EDGE_LEFT;
814 __edgeType &= ~WEB_EDGE_RIGHT;
818 else if (_Abs(scrollDistanceY) > _Abs(scrollDistanceX))
820 if (__edgeType & WEB_EDGE_TOP)
822 if (scrollDistanceY < 0)
824 __edgeType &= ~WEB_EDGE_BOTTOM;
830 __edgeType &= ~WEB_EDGE_TOP;
833 else if (__edgeType & WEB_EDGE_BOTTOM)
835 if (scrollDistanceY > 0)
837 __edgeType &= ~WEB_EDGE_TOP;
843 __edgeType &= ~WEB_EDGE_BOTTOM;
857 _Web::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo)
861 if (__pEflWebkit.get())
863 SendTouchEventForJavaScript(touchInfo);
865 return __pGestureHandler->OnTouchReleased(source, touchInfo);
873 _Web::OnTouchCanceled(const _Control& source, const _TouchInfo& touchInfo)
875 if (__pEflWebkit.get())
877 SendTouchEventForJavaScript(touchInfo);
879 return __pGestureHandler->OnTouchCanceled(source, touchInfo);
887 _Web::OnTouchPressHandled(const _Control& control)
893 _Web::OnTouchReleaseHandled(const _Control& control)
899 _Web::OnTouchMoveHandled(const _Control& control)
905 _Web::OnTouchCancelHandled(const _Control& control)
911 _Web::OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture)
913 if (__pEflWebkit.get() && __gestureType == WEB_GESTURE_TYPE_TAP)
915 return __pTapGestureHandler->OnLongPressGestureDetected(gesture);
923 _Web::OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture)
930 _Web::OnTapGestureDetected(_TouchTapGestureDetector& gesture)
932 if (__pEflWebkit.get())
934 return __pTapGestureHandler->OnTapGestureDetected(gesture);
942 _Web::OnTapGestureCanceled(_TouchTapGestureDetector& gesture)
949 _Web::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture)
951 if (__pEflWebkit.get() && _WebSettingImpl::GetInstance(__pWebSetting.get())->IsScrollEnabled())
953 return __pFlickGestureHandler->OnFlickGestureDetected(gesture);
961 _Web::OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture)
968 _Web::OnPinchGestureStarted(Tizen::Ui::_TouchPinchGestureDetector& gesture)
970 if (__pEflWebkit.get())
972 return __pPinchGestureHandler->OnPinchGestureStarted(gesture);
980 _Web::OnPinchGestureChanged(Tizen::Ui::_TouchPinchGestureDetector& gesture)
982 if (__pEflWebkit.get() && __gestureType == WEB_GESTURE_TYPE_PINCH)
984 return __pPinchGestureHandler->OnPinchGestureChanged(gesture);
992 _Web::OnPinchGestureFinished(Tizen::Ui::_TouchPinchGestureDetector& gesture)
994 if (__pEflWebkit.get() && __gestureType == WEB_GESTURE_TYPE_PINCH)
996 return __pPinchGestureHandler->OnPinchGestureFinished(gesture);
1004 _Web::OnPinchGestureCanceled(Tizen::Ui::_TouchPinchGestureDetector& gesture)
1011 _Web::OnCanvasRequestedN(const FloatRectangle& bounds)
1013 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);
1014 if (bounds.width == 0.0f || bounds.height == 0.0f)
1016 FloatDimension size(GetSizeF());
1017 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.");
1020 result r = E_SUCCESS;
1022 Rectangle absBounds(_CoordinateSystemUtils::ConvertToInteger(_CoordinateSystemUtils::Transform(bounds)));
1024 Eina_Rectangle rect;
1025 EINA_RECTANGLE_SET(&rect, absBounds.x, absBounds.y, absBounds.width, absBounds.height);
1027 Evas_Object* pWebFrame = GetWebNativeNode();
1028 Evas_Object* pScreenShot = ewk_view_screenshot_contents_get(pWebFrame, rect, 1.0f, evas_object_evas_get(pWebFrame));
1030 std::unique_ptr<Canvas> pCanvas(new (std::nothrow) Canvas());
1031 SysTryReturn(NID_WEB_CTRL, pCanvas.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1035 BufferInfo bufferInfo;
1037 r = _Utility::GetPixelBufferFromEvasObject(pScreenShot, bufferInfo);
1038 evas_object_del(pScreenShot);
1039 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] propagating", GetErrorMessage(r));
1041 r = pCanvas->Construct(bufferInfo);
1042 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] propagating", GetErrorMessage(r));
1046 r = pCanvas->Construct(bounds);
1047 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] propagating", GetErrorMessage(r));
1050 return pCanvas.release();
1055 _Web::OnCapturedBitmapRequestedN(void)
1057 result r = E_SUCCESS;
1059 BufferInfo bufferInfo;
1060 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));
1063 int bufferSize = bufferInfo.bitsPerPixel * bufferInfo.width * bufferInfo.height;
1065 r = buffer.Construct(reinterpret_cast < byte* >(bufferInfo.pPixels), 0, bufferSize, bufferSize);
1066 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] propagating", GetErrorMessage(r));
1068 std::unique_ptr<Bitmap> pBitmap(new (std::nothrow) Bitmap());
1069 SysTryReturn(NID_WEB_CTRL, pBitmap.get(), null, E_OUT_OF_MEMORY, "[%s] Memory Allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
1071 r = pBitmap->Construct(buffer, Dimension(bufferInfo.width, bufferInfo.height), BITMAP_PIXEL_FORMAT_ARGB8888);
1072 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, null, r, "[%s] propagating", GetErrorMessage(r));
1074 return pBitmap.release();
1079 _Web::OnCaptureAcquire(BufferInfo& output)
1081 result r = E_SUCCESS;
1083 FloatPoint position(GetPositionF());
1084 FloatDimension size(GetSizeF());
1086 Dimension absSize(_CoordinateSystemUtils::ConvertToInteger(_CoordinateSystemUtils::Transform(size)));
1088 Eina_Rectangle rect;
1089 EINA_RECTANGLE_SET(&rect, 0, 0, absSize.width, absSize.height);
1091 Evas_Object* pWebFrame = GetWebNativeNode();
1092 Evas_Object* pScreenShot = ewk_view_screenshot_contents_get(pWebFrame, rect, 1.0f, evas_object_evas_get(pWebFrame));
1093 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));
1095 r = _Utility::GetPixelBufferFromEvasObject(pScreenShot, output);
1096 evas_object_del(pScreenShot);
1097 SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, false, r, "[%s] propagating", GetErrorMessage(r));
1104 _Web::SendTouchEventForJavaScript(const _TouchInfo& touchInfo)
1106 result r = E_SUCCESS;
1108 _TouchManager* pTouchManager = _TouchManager::GetInstance();
1109 SysAssertf(pTouchManager, "Failed to get touch manager.");
1111 std::unique_ptr<IListT<_FingerInfo*> > pTouchList(pTouchManager->GetMultiFingerInfoListN());
1112 SysTryReturnVoidResult(NID_WEB_CTRL, pTouchList.get(), GetLastResult(), "[%s] Failed to get touch list.", GetErrorMessage(GetLastResult()));
1114 std::unique_ptr<IBidirectionalEnumeratorT<_FingerInfo*> > pTouchListEnum(pTouchList->GetBidirectionalEnumeratorN());
1115 SysAssertf(pTouchListEnum.get() != null, "Failed to get enumerator of touch list.");
1117 Eina_List* pPointList = null;
1118 _FingerInfo* pFingerInfo = null;
1119 while(pTouchListEnum->MoveNext() == E_SUCCESS)
1121 r = pTouchListEnum->GetCurrent(pFingerInfo);
1122 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1124 _TouchStatus state = pFingerInfo->GetStatus();
1125 if(state == _TOUCH_PRESSED || state == _TOUCH_MOVED || state == _TOUCH_RELEASED || state == _TOUCH_CANCELED)
1127 Point integerPoint(_CoordinateSystemUtils::ConvertToInteger(GetAbsoluteCoordinate(pFingerInfo->GetPoint())));
1129 Ewk_Touch_Point* pPoint = static_cast<Ewk_Touch_Point*>(calloc(1, sizeof(Ewk_Touch_Point)));
1130 pPoint->id = pFingerInfo->GetPointId();
1131 pPoint->x = integerPoint.x;
1132 pPoint->y = integerPoint.y;
1133 pPoint->state = GetEvasTouchState((TouchStatus)pFingerInfo->GetStatus());
1134 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);
1136 pPointList = eina_list_append(pPointList, pPoint);
1140 ewk_view_feed_touch_event(__pEflWebkit->GetWebEvasObject(), GetEwkTouchEvent(touchInfo.GetTouchStatus()), pPointList, null);
1143 EINA_LIST_FREE(pPointList, pData)
1148 Ewk_Touch_Event_Type
1149 _Web::GetEwkTouchEvent(_TouchStatus touchStatus)
1151 Ewk_Touch_Event_Type ewkTouchEvent = EWK_TOUCH_CANCEL;
1153 switch (touchStatus)
1155 case _TOUCH_PRESSED :
1156 ewkTouchEvent = EWK_TOUCH_START;
1159 ewkTouchEvent = EWK_TOUCH_MOVE;
1161 case _TOUCH_RELEASED :
1162 ewkTouchEvent = EWK_TOUCH_END;
1164 case _TOUCH_CANCELED :
1167 ewkTouchEvent = EWK_TOUCH_CANCEL;
1171 return ewkTouchEvent;
1175 Evas_Touch_Point_State
1176 _Web::GetEvasTouchState(TouchStatus touchStatus)
1178 Evas_Touch_Point_State evasTouchState = EVAS_TOUCH_POINT_CANCEL;
1180 switch (touchStatus)
1182 case TOUCH_PRESSED :
1183 evasTouchState = EVAS_TOUCH_POINT_DOWN;
1186 evasTouchState = EVAS_TOUCH_POINT_MOVE;
1188 case TOUCH_RELEASED :
1189 evasTouchState = EVAS_TOUCH_POINT_UP;
1191 case TOUCH_CANCELED :
1194 evasTouchState = EVAS_TOUCH_POINT_CANCEL;
1195 //todo : mapping EVAS_TOUCH_POINT_STILL, /**< Touch point is not moved af
1199 return evasTouchState;
1203 }}} // Tizen::Web::Controls