Hide context menu after specific time interval
authorprathmesh.m <prathmesh.m@samsung.com>
Fri, 21 Jun 2013 09:49:51 +0000 (15:19 +0530)
committerYuni Jeong <yhnet.jung@samsung.com>
Fri, 12 Jul 2013 07:30:06 +0000 (16:30 +0900)
[Title] Hide context menu after specific time interval
[Issue#] P130619-4131
[Problem] Context menu is overlapping other options which are
   becoming unusable
[Cause] Context menu remains persistant after it is shown
[Solution] Context menu will display and hide after specific time interval

Change-Id: Ib671635673dd07018cac992679553b6ce0f032aa

Source/WebKit2/UIProcess/tizen/WebContextMenuProxyTizen.cpp
Source/WebKit2/UIProcess/tizen/WebContextMenuProxyTizen.h [changed mode: 0644->0755]

index 98d1000..ec9830b 100755 (executable)
@@ -64,6 +64,9 @@ WebContextMenuProxyTizen::WebContextMenuProxyTizen(Evas_Object* webView, WebPage
     , m_webView(webView)
     , m_items()
 #endif
+#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
+    , m_contextShowTimer(0)
+#endif
 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_TEXT_SELECTION_MODE)
     , m_positionForSelection()
 #endif
@@ -180,13 +183,26 @@ void WebContextMenuProxyTizen::createEflMenu(const Vector<WebContextMenuItemData
     }
 }
 
-static void contextMenuPopupDismissedCallback(void* data, Evas_Object* obj, void* eventInfo)
+#if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
+void WebContextMenuProxyTizen::contextMenuPopupDismissedCallback(void* data, Evas_Object* obj, void* eventInfo)
 {
+    WebContextMenuProxyTizen* menuProxy = static_cast<WebContextMenuProxyTizen*>(data);
+    if (menuProxy) {
 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
-    static_cast<PageClientImpl*>(data)->hideFocusRing();
+        menuProxy->m_pageClientImpl->hideFocusRing();
+#endif
+        menuProxy->m_pageClientImpl->setIsContextMenuVisible(false);
+
+#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
+        if (menuProxy->m_contextShowTimer) {
+            ecore_timer_del(menuProxy->m_contextShowTimer);
+            menuProxy->m_contextShowTimer = 0;
+        }
 #endif
-    static_cast<PageClientImpl*>(data)->setIsContextMenuVisible(false);
+    }
 }
+#endif
+
 #else
 void WebContextMenuProxyTizen::createEflMenu()
 {
@@ -194,6 +210,33 @@ void WebContextMenuProxyTizen::createEflMenu()
 }
 #endif
 
+#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
+Eina_Bool WebContextMenuProxyTizen::contextMenuTimerCallback(void* data)
+{
+    WebContextMenuProxyTizen *contextMenuProxy = static_cast<WebContextMenuProxyTizen*>(data);
+    if (contextMenuProxy) {
+        if (contextMenuProxy->m_popup)
+            evas_object_hide(contextMenuProxy->m_popup);
+
+        contextMenuProxy->m_pageClientImpl->setIsContextMenuVisible(false);
+#if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
+        contextMenuProxy->m_pageClientImpl->hideFocusRing();
+#endif
+    }
+     return ECORE_CALLBACK_CANCEL;
+}
+
+void WebContextMenuProxyTizen::startContextMenuTimer()
+{
+    double contextMenuDispTime = 3.0;
+    if (m_contextShowTimer) {
+        ecore_timer_del(m_contextShowTimer);
+        m_contextShowTimer = 0;
+    }
+    m_contextShowTimer = ecore_timer_add(contextMenuDispTime, contextMenuTimerCallback, this);
+}
+#endif // TIZEN_WEBKIT2_TEXT_SELECTION
+
 void WebContextMenuProxyTizen::showContextMenu(const WebCore::IntPoint& position, const Vector<WebContextMenuItemData>& items)
 {
 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_TEXT_SELECTION_MODE)
@@ -243,13 +286,20 @@ void WebContextMenuProxyTizen::showContextMenu(const WebCore::IntPoint& position
         evas_object_move(m_popup, popupPosition.x(), popupPosition.y());
         evas_object_show(m_popup);
 
-        evas_object_smart_callback_add(m_popup, "dismissed", contextMenuPopupDismissedCallback, m_pageClientImpl);
+        evas_object_smart_callback_add(m_popup, "dismissed", contextMenuPopupDismissedCallback, this);
+
 
         m_pageClientImpl->setIsContextMenuVisible(true);
 #if ENABLE(TOUCH_EVENTS) && ENABLE(TIZEN_GESTURE)
         // Cancel touch event when ContextMenu is shown.
         EwkViewImpl::fromEvasObject(m_webView)->feedTouchEventsByType(EWK_TOUCH_CANCEL);
 #endif
+
+#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
+        // Start the timer at the end
+        if (m_isContextMenuForTextSelection)
+            startContextMenuTimer();
+#endif
     }
 #else
     createEflMenu();
@@ -263,6 +313,12 @@ void WebContextMenuProxyTizen::hideContextMenu()
     if (m_popup)
         evas_object_hide(m_popup);
     m_pageClientImpl->setIsContextMenuVisible(false);
+#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
+    if (m_contextShowTimer) {
+        ecore_timer_del(m_contextShowTimer);
+        m_contextShowTimer = 0;
+    }
+#endif
 #else
     notImplemented();
 #endif
old mode 100644 (file)
new mode 100755 (executable)
index cd7bdd5..03de7b7
@@ -54,6 +54,12 @@ private:
     WebContextMenuProxyTizen(Evas_Object*, WebPageProxy*, PageClientImpl*);
 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
     static void contextMenuItemSelectedCallback(void* data, Evas_Object* obj, void* eventInfo);
+    static void contextMenuPopupDismissedCallback(void* data, Evas_Object* obj, void* eventInfo);
+
+#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
+    static Eina_Bool contextMenuTimerCallback(void *data);
+    void startContextMenuTimer();
+#endif
     void createEflMenu(const Vector<WebContextMenuItemData>&);
 #else
     void createEflMenu();
@@ -74,6 +80,7 @@ private:
 
 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
     bool m_isContextMenuForTextSelection;
+    Ecore_Timer* m_contextShowTimer;
 #endif
 };