Text selection is updated by timer when webview's geometry is changed.
authorYuni Jeong <yhnet.jung@samsung.com>
Wed, 31 Jul 2013 14:15:08 +0000 (23:15 +0900)
committerTaeyun An <ty.an@samsung.com>
Thu, 10 Oct 2013 07:51:06 +0000 (16:51 +0900)
[Title] Text selection is updated by timer when webview's geometry is changed.
[Issue#] P130730-4510
[Problem] When text selection is working and screen is rotated in Email composer,
          webview is not scrolled smoothly.
[Cause] Whenever webview is scrolled, webview's geometry is changed.
        And whenever webview's geometry is changed, text selection is updated immediately.
        So, function to show context menu is called too many during scrolling.
[Solution] Added timer for updating text selection.
           - When webview's geometry is chagned, text selection is updated by timer.

Change-Id: I1cfdcf0145d6de08a95a0d17535dc50210faad95

Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.cpp

index 7198e61..c9e3cca 100755 (executable)
@@ -1032,7 +1032,10 @@ static void _ewk_view_smart_calculate(Evas_Object* ewkView)
         impl->pageClient->frameRectChanged();
 #endif
 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
-        impl->pageClient->updateTextSelectionHandlesAndContextMenu(true);
+        if (impl->pageClient->isTextSelectionMode()) {
+            impl->pageClient->updateTextSelectionHandlesAndContextMenu(false);
+            impl->pageClient->requestToShowTextSelectionHandlesAndContextMenu();
+        }
 #endif
 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
         if (impl->focusRing())
index d961829..138368d 100755 (executable)
@@ -208,8 +208,8 @@ void TextSelection::updateHandlers()
     if (!m_viewImpl->page()->getSelectionHandlers(leftRect, rightRect, selectionDirection))
         return;
 
-    m_lastLeftHandleRect = leftRect;
-    m_lastRightHandleRect = rightRect;
+    m_lastLeftHandleRect = m_viewImpl->transformToScene().mapRect(leftRect);
+    m_lastRightHandleRect = m_viewImpl->transformToScene().mapRect(rightRect);
 
     AffineTransform toEvasTransform = m_viewImpl->transformToScene();
     WebCore::IntPoint leftEvasPoint ;
@@ -551,6 +551,9 @@ void TextSelection::updateHandlesAndContextMenu(bool isShow, bool isScrolling)
         if (m_viewImpl->gestureClient->isGestureWorking())
             return;
 
+        if (m_showTimer)
+            return;
+
         updateHandlers();
         showContextMenu();
     } else {
@@ -777,6 +780,12 @@ bool TextSelection::isAutomaticClearEnabled()
 
 void TextSelection::requestToShow()
 {
+    EditorState editorState = m_viewImpl->page()->editorState();
+    if (!editorState.selectionIsRange && editorState.isContentEditable) {
+        setIsTextSelectionMode(false);
+        return;
+    }
+
     if (m_showTimer)
         ecore_timer_del(m_showTimer);
     m_showTimer = ecore_timer_loop_add((double)200.0/1000.0, showTimerCallback, this);
@@ -795,6 +804,8 @@ void TextSelection::showHandlesAndContextMenu()
     WebCore::IntRect leftRect, rightRect;
     int selectionDirection = LToR;
     if (m_viewImpl->page()->getSelectionHandlers(leftRect, rightRect, selectionDirection)) {
+        leftRect = m_viewImpl->transformToScene().mapRect(leftRect);
+        rightRect = m_viewImpl->transformToScene().mapRect(rightRect);
         if ((leftRect == m_lastLeftHandleRect) && (rightRect == m_lastRightHandleRect)) {
             if (m_showTimer) {
                 ecore_timer_del(m_showTimer);