Implemented scolling of page with extending selection
authorprathmesh.m <prathmesh.m@samsung.com>
Thu, 6 Jun 2013 06:46:35 +0000 (12:16 +0530)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Mon, 26 Aug 2013 09:58:28 +0000 (09:58 +0000)
[Title] Implemented scrolling of page with selection
[Issue#] P130603-0415
[Problem] Extending the selection(right and left) beyond
         the visible area, page is not getting scrolled.
[Cause] No implementation present
[Solution] Added implementation for scrolling of the page
          when selection is extended beyond the visible area

Change-Id: I33e1083042b22c30a144ac5807153a2af8a43be3

Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.cpp
Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.h [changed mode: 0644->0755]

index 588801a..ee5330b 100755 (executable)
@@ -48,6 +48,7 @@ TextSelection::TextSelection(EwkViewImpl* viewImpl)
       , m_selectedHandle(0)
 #endif
       , m_handleMovingDirection(HandleMovingDirectionNormal)
+      , m_isSelectionInScrollingMode(false)
 {
     ASSERT(viewWidget);
 
@@ -359,8 +360,36 @@ void TextSelection::hideContextMenu()
     m_viewImpl->page()->hideContextMenu();
 }
 
+void TextSelection::scrollContentWithSelectionIfRequired(const IntPoint& evasPoint)
+{
+    EditorState editorState = m_viewImpl->page()->editorState();
+    if (editorState.isContentEditable)
+        return;
+
+    setSelectionScrollingStatus(true);
+    IntRect unscaledVisibleContentRect = m_viewImpl->pageClient->visibleContentRect();
+    const int scrollClipValue = 50;
+    if (evasPoint.y() >= (unscaledVisibleContentRect.height() - scrollClipValue))
+        m_viewImpl->pageClient->scrollBy(IntSize(0, m_rightHandle->getHandleRect().height()));
+    else if (evasPoint.y() <= scrollClipValue) {
+        IntSize scrollSize(0, m_rightHandle->getHandleRect().height());
+        scrollSize.scale(-1);
+        m_viewImpl->pageClient->scrollBy(scrollSize);
+    }
+
+    if (evasPoint.x() >= (unscaledVisibleContentRect.width() - scrollClipValue))
+        m_viewImpl->pageClient->scrollBy(IntSize(m_rightHandle->getHandleRect().width(),0));
+    else if (evasPoint.x() <= scrollClipValue) {
+        IntSize scrollSize(m_rightHandle->getHandleRect().width(), 0);
+        scrollSize.scale(-1);
+        m_viewImpl->pageClient->scrollBy(scrollSize);
+    }
+    setSelectionScrollingStatus(false);
+}
+
 void TextSelection::setLeftSelectionToEvasPoint(const IntPoint& evasPoint)
 {
+    scrollContentWithSelectionIfRequired(evasPoint);
     int result = m_viewImpl->page()->setLeftSelection(m_viewImpl->transformFromScene().mapPoint(evasPoint), m_handleMovingDirection);
     if (result)
         m_handleMovingDirection = result;
@@ -369,6 +398,7 @@ void TextSelection::setLeftSelectionToEvasPoint(const IntPoint& evasPoint)
 
 void TextSelection::setRightSelectionToEvasPoint(const IntPoint& evasPoint)
 {
+    scrollContentWithSelectionIfRequired(evasPoint);
     int result = m_viewImpl->page()->setRightSelection(m_viewImpl->transformFromScene().mapPoint(evasPoint), m_handleMovingDirection);
     if (result)
         m_handleMovingDirection = result;
@@ -431,6 +461,9 @@ bool TextSelection::isMagnifierVisible()
 
 void TextSelection::updateHandlesAndContextMenu(bool isShow, bool isScrolling)
 {
+    if (getSelectionScrollingStatus())
+        return;
+
     if (isTextSelectionDowned() && !isScrolling) {
         showMagnifier();
         return;
old mode 100644 (file)
new mode 100755 (executable)
index dcfbb1f..d937298
@@ -117,6 +117,9 @@ private:
 
     static Eina_Bool showTimerCallback(void* data);
     void showHandlesAndContextMenu();
+    void scrollContentWithSelectionIfRequired(const WebCore::IntPoint& evasPoint);
+    int getSelectionScrollingStatus() { return m_isSelectionInScrollingMode; }
+    void setSelectionScrollingStatus(bool status) { m_isSelectionInScrollingMode = status; }
 
 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
     void informTextStyleState();
@@ -137,6 +140,7 @@ private:
     TextSelectionHandle* m_selectedHandle;
 #endif
     int m_handleMovingDirection;
+    bool m_isSelectionInScrollingMode;
 };
 
 } // namespace WebKit