Fix for Context menu overlapping overlap with the selection handles issue in Email...
authordeepak.m1 <deepak.m1@samsung.com>
Fri, 6 Sep 2013 07:07:59 +0000 (16:07 +0900)
committerTaeyun An <ty.an@samsung.com>
Thu, 10 Oct 2013 08:03:13 +0000 (17:03 +0900)
[Version]    common
[Title]      Context menu should not overlap with the selection handles.
[BinType]    N/A
[Customer]   HQ
[Issue#]     P130918-01691
[Problem]    Context menu should not overlap with the selection handles.
[Cause]      Context menu,  Position points decide the Position of the Context menu, and based on the context menu priority it will apprear.
[Solution]   Condition added so that when the chances of overlap then context menu will come below the right slection handler,As selection can be multiple lines.
[Team]       WebCoreSupport
[Developer]  deepak.m1@samsung.com
[Request]    N/A
[Horizontal expansion] N/A
[SCMRequest] NA

Change-Id: Ie88424a35a64e64905fdd56fd2227389a0f34d2d

Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp
Source/WebKit2/UIProcess/API/efl/PageClientImpl.h
Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.cpp
Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.h
Source/WebKit2/UIProcess/tizen/WebContextMenuProxyTizen.cpp

index 2407650..754a381 100755 (executable)
@@ -1204,9 +1204,9 @@ void PageClientImpl::initTextSelectionHandlesMouseDownedStatus()
     m_textSelection->initHandlesMouseDownedStatus();
 }
 
-void PageClientImpl::changeContextMenuPosition(IntPoint& point)
+bool PageClientImpl::changeContextMenuPosition(IntPoint& point,WebCore::IntPoint webViewPoint)
 {
-    m_textSelection->changeContextMenuPosition(point);
+    return m_textSelection->changeContextMenuPosition(point, webViewPoint);
 }
 
 void PageClientImpl::selectWordAutomatically(const IntPoint& point)
index 8ce4e06..41802e5 100755 (executable)
@@ -186,7 +186,7 @@ public:
 #endif
     void requestToShowTextSelectionHandlesAndContextMenu();
     void initTextSelectionHandlesMouseDownedStatus();
-    void changeContextMenuPosition(WebCore::IntPoint& point);
+    bool changeContextMenuPosition(WebCore::IntPoint& point, WebCore::IntPoint);
     void selectWordAutomatically(const WebCore::IntPoint& point);
 #endif
 
index 0638634..9464db1 100755 (executable)
@@ -39,6 +39,9 @@ using namespace WebCore;
 
 namespace WebKit {
 
+const int menuHeight = 140;// The Height fo the context menu.
+const int menuPadding = 50;// This is padding for deciding when to modify context menu position.
+const int spacePadding = 24;// This is for making context menu closer to the handles.
 const int zIndexDefault = -999;
 
 TextSelection::TextSelection(EwkViewImpl* viewImpl)
@@ -858,12 +861,30 @@ void TextSelection::initHandlesMouseDownedStatus()
     m_rightHandle->setIsMouseDowned(false);
 }
 
-void TextSelection::changeContextMenuPosition(WebCore::IntPoint& position)
+bool TextSelection::changeContextMenuPosition(WebCore::IntPoint& position, WebCore::IntPoint webViewPoint)
 {
     if (m_leftHandle->isTop()) {
         IntRect handleRect = m_leftHandle->getHandleRect();
         position.setY(position.y() - handleRect.height());
+        return false;
+    } else if (!m_rightHandle->isTop()) {
+        WebCore::IntRect emptyRect(0, 0, 0, 0);
+        IntRect leftHandleRect = m_leftHandle->getHandleRect();
+        IntRect rightHandleRect = m_rightHandle->getHandleRect();
+
+        // The Width of the context menu is menuHeight so comapairing current position with the viewport point plus menuHeight.
+        // If position is less than this value then set new position for the contextmenu.
+        if ((position.y() <= (webViewPoint.y() + menuHeight)) || ((position.y() - (webViewPoint.y() + menuHeight)) <= menuPadding)) {
+            if ( leftHandleRect == emptyRect && rightHandleRect == emptyRect) {
+                position.setY(position.y() + spacePadding);// This value is chosen based on the how much close the context menu arrow should come to word.
+                return true;
+            } else {
+                position.setY(m_rightHandle->getHandleRect().maxY() - spacePadding);
+                return true;
+            }
+        }
     }
+    return false;
 }
 
 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
index 5ed18ab..5f1c859 100755 (executable)
@@ -93,7 +93,7 @@ public:
     void requestToShow();
     void initHandlesMouseDownedStatus();
 
-    void changeContextMenuPosition(WebCore::IntPoint& position);
+    bool changeContextMenuPosition(WebCore::IntPoint& position,WebCore::IntPoint);
     void selectWordAutomatically(const WebCore::IntPoint& point);
 
     friend class PageClientImpl; // to allow hideHandlers() call while zooming
index c61db8d..19752f0 100755 (executable)
@@ -254,9 +254,11 @@ void WebContextMenuProxyTizen::showContextMenu(const WebCore::IntPoint& position
 
         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_LEFT, ELM_CTXPOPUP_DIRECTION_RIGHT, ELM_CTXPOPUP_DIRECTION_DOWN);
+        elm_ctxpopup_direction_priority_set(m_popup, ELM_CTXPOPUP_DIRECTION_UP, ELM_CTXPOPUP_DIRECTION_DOWN, ELM_CTXPOPUP_DIRECTION_LEFT, ELM_CTXPOPUP_DIRECTION_RIGHT);
 
-        m_pageClientImpl->changeContextMenuPosition(popupPosition);
+        IntPoint webViewPoint(webViewX,webViewY);
+        if (m_pageClientImpl->changeContextMenuPosition(popupPosition, webViewPoint))
+            elm_ctxpopup_direction_priority_set(m_popup, ELM_CTXPOPUP_DIRECTION_DOWN, ELM_CTXPOPUP_DIRECTION_DOWN, ELM_CTXPOPUP_DIRECTION_DOWN, ELM_CTXPOPUP_DIRECTION_DOWN);
     }
 #endif