Do not adjust focused input node if node is visible now.
authorEunmi Lee <eunmi15.lee@samsung.com>
Fri, 5 Apr 2013 04:53:00 +0000 (13:53 +0900)
committerGerrit Code Review <gerrit2@kim11>
Fri, 5 Apr 2013 05:38:14 +0000 (14:38 +0900)
[Title] Do not adjust focused input node if node is visible now.
[Issue#] DCM-1155
[Problem] The focused input node is adjusted to the wrong position when IME is shown in the Web Application.
[Cause] The viewport is resized but contents is not resized right after showing IME
        and unchanged size of contents is used to adjust focused node, so calculated position is wrong.
[Solution] Do not adjust focused input node if node is visible now in order to prevent wrong case of Web Applicaiton.
           We should find the better solution later.

Change-Id: I385cb7f0aa8c9a177dc0a8f228596712c2a6913d

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

index b86f6dc..efd814c 100755 (executable)
@@ -2462,7 +2462,6 @@ bool ewk_view_focused_node_adjust(Evas_Object* ewkView, Eina_Bool adjustForExter
         return false;
 #endif
 
-    IntSize visibleSize(smartData->view.w, smartData->view.h);
     // caret position can be outside of visible rect.
     // we need to consider it.
     IntRect selectionRect = impl->pageProxy->getSelectionRect(true);
@@ -2477,13 +2476,17 @@ bool ewk_view_focused_node_adjust(Evas_Object* ewkView, Eina_Bool adjustForExter
     if (selectionRect.isEmpty())
         return false;
 
-    // set paddings
-    IntPoint scrollPosition(selectionRect.x() - visibleSize.width() / 3, selectionRect.y() - visibleSize.height() / 3);
-    // If both input field's position x and selection rect can be displayed together,
-    // adjust scroll position to input field's position x.
-    if (!focusedNodeRect.isEmpty()
-        && selectionRect.x() - focusedNodeRect.x() < visibleSize.width() * 4 / 5)
-        scrollPosition.setX(focusedNodeRect.x());
+    IntRect visibleRect = impl->pageClient->visibleContentRect();
+    IntPoint scrollPosition = visibleRect.location();
+    // Do not adjust scroll position if selection rect (caret) is visible after scaling.
+    if (!visibleRect.contains(selectionRect)) {
+        // set paddings
+        scrollPosition = IntPoint(selectionRect.x() - visibleRect.width() / 3, selectionRect.y() - visibleRect.height() / 3);
+        // If both input field's position x and selection rect can be displayed together,
+        // adjust scroll position to input field's position x.
+        if (!focusedNodeRect.isEmpty() && selectionRect.x() - focusedNodeRect.x() < visibleRect.width() * 4 / 5)
+            scrollPosition.setX(focusedNodeRect.x());
+    }
 
 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
     impl->pageClient->setVisibleContentRect(IntRect(scrollPosition, impl->size()), newScaleFactor);