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)
#endif
void requestToShowTextSelectionHandlesAndContextMenu();
void initTextSelectionHandlesMouseDownedStatus();
- void changeContextMenuPosition(WebCore::IntPoint& point);
+ bool changeContextMenuPosition(WebCore::IntPoint& point, WebCore::IntPoint);
void selectWordAutomatically(const WebCore::IntPoint& point);
#endif
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)
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)
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
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