#include <stdio.h>
+#if ENABLE(TIZEN_HW_MORE_BACK_KEY)
+#include <dlfcn.h>
+#include <efl_assist.h>
+extern void* EflAssistHandle;
+#endif
+
using namespace WebCore;
namespace WebKit {
, 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
menuProxy->m_popup = 0;
}
+#if ENABLE(TIZEN_HW_MORE_BACK_KEY)
+static void contextMenuHwBackKeyCallback(void* data, Evas_Object* obj, void* eventInfo)
+{
+ elm_ctxpopup_dismiss(obj);
+}
+#endif
+
void WebContextMenuProxyTizen::createEflMenu(const Vector<WebContextMenuItemData>& items)
{
if (m_popup)
if (!m_popup)
return;
+#if ENABLE(TIZEN_HW_MORE_BACK_KEY)
+ if (EflAssistHandle) {
+ void (*webkit_ea_object_event_callback_add)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *);
+ webkit_ea_object_event_callback_add = (void (*)(Evas_Object *, Ea_Callback_Type , Ea_Event_Cb func, void *))dlsym(EflAssistHandle, "ea_object_event_callback_add");
+ (*webkit_ea_object_event_callback_add)(m_popup, EA_CALLBACK_BACK, contextMenuHwBackKeyCallback, 0);
+ }
+#endif
+
m_items = items;
evas_object_data_set(m_popup, "WebContextMenuProxyTizen", this);
elm_object_tree_focus_allow_set(m_popup, false);
int clipboardItemSize = ClipboardHelper::numberOfItems();
TIZEN_LOGI("clipboardItemSize : %d", clipboardItemSize);
#endif
+
+#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
+ m_isContextMenuForTextSelection = false;
+#endif
+
for (size_t i = 0; i < size; i++) {
#if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
if ((m_items.at(i).action() == ContextMenuItemTagPaste || m_items.at(i).action() == ContextMenuItemTagClipboard) && !clipboardItemSize)
continue;
#endif
+#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
+ if (m_items.at(i).action() == ContextMenuItemTagCopy || m_items.at(i).action() == ContextMenuItemTagSelectAll
+ || m_items.at(i).action() == ContextMenuItemTagSelectWord || m_items.at(i).action() == ContextMenuItemTagPaste)
+ m_isContextMenuForTextSelection = true;
+#endif
+
#if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_ICON_TYPE_SUPPORT)
if (!m_items.at(i).title().isEmpty() || !m_items.at(i).iconFile().isEmpty()) {
Evas_Object* icon = 0;
}
}
-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
- static_cast<PageClientImpl*>(data)->setIsContextMenuVisible(false);
+ 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
+ }
}
+#endif
+
#else
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)
#endif
#if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
- if (items.isEmpty())
+ if (items.isEmpty()) {
+#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
+ if (m_pageClientImpl->isTextSelectionMode())
+ m_pageClientImpl->setIsTextSelectionMode(false);
+#endif
return;
+ }
createEflMenu(items);
+#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
+ if (m_isContextMenuForTextSelection && !evas_object_focus_get(m_webView))
+ return;
+#endif
+
if (m_popup) {
int webViewX, webViewY;
evas_object_geometry_get(m_webView, &webViewX, &webViewY, 0, 0);
popupPosition.setY(popupPosition.y() + webViewY);
#if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
- if (m_pageClientImpl->isTextSelectionMode()) {
+ if (m_isContextMenuForTextSelection) {
+ if (!m_pageClientImpl->isTextSelectionMode())
+ m_pageClientImpl->setIsTextSelectionMode(true);
elm_object_style_set(m_popup,"copypaste");
elm_ctxpopup_horizontal_set(m_popup, EINA_TRUE);
elm_ctxpopup_direction_priority_set(m_popup, ELM_CTXPOPUP_DIRECTION_UP, ELM_CTXPOPUP_DIRECTION_UP, ELM_CTXPOPUP_DIRECTION_UP, ELM_CTXPOPUP_DIRECTION_UP);
-
- m_pageClientImpl->changeContextMenuPosition(popupPosition);
}
#endif
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();
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