Text Selection Handlers not updated with the correct position
[framework/web/webkit-efl.git] / Source / WebKit2 / UIProcess / API / efl / tizen / TextSelectionHandle.cpp
index dfed306..47a35ae 100644 (file)
@@ -78,21 +78,37 @@ TextSelectionHandle::~TextSelectionHandle()
 void TextSelectionHandle::move(const IntPoint& point, const IntRect& selectionRect)
 {
     IntPoint movePoint = point;
+    const int reverseMargin = 32;
     int x, y, deviceWidth, deviceHeight;
+    int handleHeight;
+
+    edje_object_part_geometry_get(m_icon, "handle", 0, 0, 0, &handleHeight);
     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;
+
+    if ((m_isLeft && (movePoint.x() <= reverseMargin)) || (!m_isLeft && (movePoint.x() >= deviceWidth - reverseMargin))) {
+        if ((movePoint.y() + handleHeight) > (y + deviceHeight)) {
+            movePoint.setY(movePoint.y() - selectionRect.height());
+            edje_object_signal_emit(m_icon, "elm,state,top,reversed", "elm");
+            m_isTop = true;
+        } else {
+            edje_object_signal_emit(m_icon, "elm,state,bottom,reversed", "elm");
+            m_isTop = false;
+        }
+    }
+    else {
+        if ((movePoint.y() + handleHeight) > (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()
@@ -108,6 +124,9 @@ void TextSelectionHandle::hide()
 #if ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
 const IntRect TextSelectionHandle::getHandleRect()
 {
+    if (!evas_object_visible_get(m_icon))
+        return IntRect();
+
     int x, y;
     evas_object_geometry_get(m_icon, &x, &y, 0, 0);
 
@@ -149,6 +168,9 @@ void TextSelectionHandle::mouseUp()
     edje_object_signal_emit(m_icon, "mouse,up,1", "handle");
 #endif
 
+    if (m_textSelection->isEnabled())
+        setIsMouseDowned(false);
+
     m_textSelection->handleMouseUp(this, m_mousePosition);
 }