From c7a1301ce8c032ce5e42262f626c50339e13f84c Mon Sep 17 00:00:00 2001 From: Yuni Jeong Date: Wed, 12 Jun 2013 22:28:27 +0900 Subject: [PATCH] Changed the handle type from "bottom" to "top" when the handle go to the bottom of the visible webview area. [Title] Changed the handle type from "bottom" to "top" when the handle go to the bottom of the visible webview area. [Issue#] N_SE-40983 [Problem] If the handle go to the bottom of visible webview area, the handle is not selected well. [Cause] The handle is truncated on the visible webview area. [Solution] When the handle go to the bottom of the visible webview area, changed the handle type from "bottom" to "top". Change-Id: I7557c7a1a02e169629d220966335bbc554321d53 --- .../WebKit2/UIProcess/API/efl/PageClientImpl.cpp | 5 ++++ Source/WebKit2/UIProcess/API/efl/PageClientImpl.h | 2 +- .../UIProcess/API/efl/tizen/TextSelection.cpp | 17 ++++++++---- .../UIProcess/API/efl/tizen/TextSelection.h | 2 ++ .../API/efl/tizen/TextSelectionHandle.cpp | 30 +++++++++++++++++----- .../UIProcess/API/efl/tizen/TextSelectionHandle.h | 5 +++- .../UIProcess/tizen/WebContextMenuProxyTizen.cpp | 9 ++++--- 7 files changed, 53 insertions(+), 17 deletions(-) diff --git a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp index 7f54413..895bf23 100755 --- a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp +++ b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp @@ -1117,6 +1117,11 @@ void PageClientImpl::initTextSelectionHandlesMouseDownedStatus() { m_textSelection->initHandlesMouseDownedStatus(); } + +void PageClientImpl::changeContextMenuPosition(IntPoint& point) +{ + m_textSelection->changeContextMenuPosition(point); +} #endif #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE) diff --git a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h index 99c2b6d..e0ddf58 100755 --- a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h +++ b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h @@ -180,7 +180,7 @@ public: #endif void requestToShowTextSelectionHandlesAndContextMenu(); void initTextSelectionHandlesMouseDownedStatus(); - + void changeContextMenuPosition(WebCore::IntPoint& point); #endif #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE) diff --git a/Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.cpp b/Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.cpp index 306e1ae..84efac3 100644 --- a/Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.cpp @@ -196,20 +196,20 @@ void TextSelection::updateHandlers() evas_object_geometry_get(m_viewImpl->view(), &webViewX, &webViewY, &webViewWidth, &webViewHeight); if ((editorLeftEvasPoint.x() <= leftEvasPoint.x() && editorLeftEvasPoint.y() <= leftEvasPoint.y()) && (webViewX <= leftEvasPoint.x() && webViewY <= leftEvasPoint.y())) { - m_leftHandle->move(leftEvasPoint); - m_leftHandle->show(); + m_leftHandle->move(leftEvasPoint, m_viewImpl->transformToScene().mapRect(leftRect)); + m_leftHandle->show(); } if ((editorRightEvasPoint.x() >= rightEvasPoint.x() && editorRightEvasPoint.y() >= rightEvasPoint.y()) && ((webViewX + webViewWidth) >= rightEvasPoint.x() && (webViewY <= rightEvasPoint.y() && (webViewY + webViewHeight) >= rightEvasPoint.y()))) { - m_rightHandle->move(rightEvasPoint); + m_rightHandle->move(rightEvasPoint, m_viewImpl->transformToScene().mapRect(rightRect)); m_rightHandle->show(); } } else { - m_leftHandle->move(leftEvasPoint); + m_leftHandle->move(leftEvasPoint, m_viewImpl->transformToScene().mapRect(leftRect)); m_leftHandle->show(); - m_rightHandle->move(rightEvasPoint); + m_rightHandle->move(rightEvasPoint, m_viewImpl->transformToScene().mapRect(rightRect)); m_rightHandle->show(); } } @@ -697,6 +697,13 @@ void TextSelection::initHandlesMouseDownedStatus() m_rightHandle->setIsMouseDowned(false); } +void TextSelection::changeContextMenuPosition(WebCore::IntPoint& position) +{ + if (m_leftHandle->isTop()) { + IntRect handleRect = m_leftHandle->getHandleRect(); + position.setY(position.y() - handleRect.height()); + } +} } // namespace WebKit #endif // TIZEN_WEBKIT2_TEXT_SELECTION diff --git a/Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.h b/Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.h index e1eb1b7..ec90e1a 100644 --- a/Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.h +++ b/Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.h @@ -82,6 +82,8 @@ public: void requestToShow(); void initHandlesMouseDownedStatus(); + void changeContextMenuPosition(WebCore::IntPoint& position); + friend class PageClientImpl; // to allow hideHandlers() call while zooming private: TextSelection(EwkViewImpl*); diff --git a/Source/WebKit2/UIProcess/API/efl/tizen/TextSelectionHandle.cpp b/Source/WebKit2/UIProcess/API/efl/tizen/TextSelectionHandle.cpp index 2a82a53..dfed306 100644 --- a/Source/WebKit2/UIProcess/API/efl/tizen/TextSelectionHandle.cpp +++ b/Source/WebKit2/UIProcess/API/efl/tizen/TextSelectionHandle.cpp @@ -37,10 +37,12 @@ namespace WebKit { Ecore_Job* TextSelectionHandle::s_job = 0; TextSelectionHandle::TextSelectionHandle(Evas_Object* object, const char* themePath, const char* part, bool isLeft, TextSelection* textSelection) - : m_isLeft(isLeft), - m_textSelection(textSelection), - m_position(IntPoint(0, 0)), - m_isMouseDowned(false) + : m_isLeft(isLeft) + , m_widget(object) + , m_textSelection(textSelection) + , m_position(IntPoint(0, 0)) + , m_isMouseDowned(false) + , m_isTop(false) { Evas* evas = evas_object_evas_get(object); m_icon = edje_object_add(evas); @@ -73,10 +75,24 @@ TextSelectionHandle::~TextSelectionHandle() } } -void TextSelectionHandle::move(const IntPoint& point) +void TextSelectionHandle::move(const IntPoint& point, const IntRect& selectionRect) { - evas_object_move(m_icon, point.x(), point.y()); - m_position = point; + IntPoint movePoint = point; + int x, y, deviceWidth, deviceHeight; + evas_object_geometry_get(m_widget, &x, &y, &deviceWidth, &deviceHeight); + IntRect handleRect = getHandleRect(); + + if ((movePoint.y() + handleRect.height()) > (y + deviceHeight)) { + movePoint.setY(movePoint.y() - selectionRect.height()); + edje_object_signal_emit(m_icon, "elm,state,top", "elm"); + m_isTop = true; + } else { + edje_object_signal_emit(m_icon, "elm,state,bottom", "elm"); + m_isTop = false; + } + + evas_object_move(m_icon, movePoint.x(), movePoint.y()); + m_position = movePoint; } void TextSelectionHandle::show() diff --git a/Source/WebKit2/UIProcess/API/efl/tizen/TextSelectionHandle.h b/Source/WebKit2/UIProcess/API/efl/tizen/TextSelectionHandle.h index 51d6614..8499a89 100755 --- a/Source/WebKit2/UIProcess/API/efl/tizen/TextSelectionHandle.h +++ b/Source/WebKit2/UIProcess/API/efl/tizen/TextSelectionHandle.h @@ -44,7 +44,7 @@ public: TextSelectionHandle(Evas_Object* object, const char* path, const char* part, bool isLeft, TextSelection* textSelection); ~TextSelectionHandle(); - void move(const WebCore::IntPoint& point); + void move(const WebCore::IntPoint& point, const WebCore::IntRect& selectionRect); void show(); void hide(); bool isLeft() const { return m_isLeft; } @@ -56,6 +56,7 @@ public: #if ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP) const WebCore::IntRect getHandleRect(); #endif + bool isTop() const { return m_isTop; } void mouseDown(const WebCore::IntPoint& point); void mouseMove(const WebCore::IntPoint& point); @@ -73,6 +74,7 @@ private: private: Evas_Object* m_icon; + Evas_Object* m_widget; WebCore::IntPoint m_mousePosition; static Ecore_Job* s_job; bool m_isLeft; @@ -81,6 +83,7 @@ private: WebCore::IntPoint m_firstDownMousePosition; WebCore::IntPoint m_basePositionForMove; bool m_isMouseDowned; + bool m_isTop; }; } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/tizen/WebContextMenuProxyTizen.cpp b/Source/WebKit2/UIProcess/tizen/WebContextMenuProxyTizen.cpp index 4168fdb..2a47512 100755 --- a/Source/WebKit2/UIProcess/tizen/WebContextMenuProxyTizen.cpp +++ b/Source/WebKit2/UIProcess/tizen/WebContextMenuProxyTizen.cpp @@ -185,17 +185,20 @@ void WebContextMenuProxyTizen::showContextMenu(const WebCore::IntPoint& position popupPosition.move(-scrollPosition.x(), -scrollPosition.y()); } #endif + popupPosition.setX(popupPosition.x() + webViewX); + popupPosition.setY(popupPosition.y() + webViewY); #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION) - - if ( m_pageClientImpl->isTextSelectionMode()) { + if (m_pageClientImpl->isTextSelectionMode()) { 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() + webViewX, popupPosition.y() + webViewY); + 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); -- 2.7.4