From: deepak.m1 Date: Fri, 6 Sep 2013 07:07:59 +0000 (+0900) Subject: Fix for Context menu overlapping overlap with the selection handles issue in Email... X-Git-Tag: 2.2.1_release~103 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e47576cbaf100582601942d380ed36b91c6ff6aa;p=framework%2Fweb%2Fwebkit-efl.git Fix for Context menu overlapping overlap with the selection handles issue in Email & Webpages. [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 --- diff --git a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp index 2407650..754a381 100755 --- a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp +++ b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp @@ -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) diff --git a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h index 8ce4e06..41802e5 100755 --- a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h +++ b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h @@ -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 diff --git a/Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.cpp b/Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.cpp index 0638634..9464db1 100755 --- a/Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.cpp @@ -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) diff --git a/Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.h b/Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.h index 5ed18ab..5f1c859 100755 --- a/Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.h +++ b/Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.h @@ -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 diff --git a/Source/WebKit2/UIProcess/tizen/WebContextMenuProxyTizen.cpp b/Source/WebKit2/UIProcess/tizen/WebContextMenuProxyTizen.cpp index c61db8d..19752f0 100755 --- a/Source/WebKit2/UIProcess/tizen/WebContextMenuProxyTizen.cpp +++ b/Source/WebKit2/UIProcess/tizen/WebContextMenuProxyTizen.cpp @@ -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