Align the SelectionControllEfl selects text to TouchSelectionController
authorAntonio Gomes <a1.gomes@samsung.com>
Wed, 19 Aug 2015 15:34:32 +0000 (11:34 -0400)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
TouchSelectionController is the upstream class that handles
touch based text selection logic for Aura and Android.
We are on our way towards being able to use it, but
we still need to eliminate some hit-testing ping-pong
messages that SelectionControllerEfl relies on in order
to figure out the text selection context.

In the meanwhile, patch aligns our SelectionControllerEfl
logic with regards to how text selection is changed
upon user movements of selection handles.

Previously, every time the handle is dragged WCI::SelectionRange
was called. That required us to have control of which
handle comes first (see SelectionDataEfl::is_anchor_first_).

Patch changes that by doing the following:
- On mouse down, we set the selection range.
- On mouse move, we just adjust the selection 'extent' accordingly.

For reference, this is the logic in TouchSelectionController, as
one can see [1] and [2].

[1] http://bit.ly/1K6NmYj
[2] http://bit.ly/1UTzAve

Original beta/m42 patches:
- http://165.213.202.130/gerrit/#/c/85429/ , reviewed by
Janusz Majnert, Arnaud Renevier.
- http://165.213.202.130/gerrit/#/c/85705/ , reviewed by
Janusz Majnert, Arnaud Renevier.

Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=6663

Reviewed by: Janusz Majnert, arno renevier

Change-Id: Ifba5ed44d335f25b15bc1975d3f54c2f9243dce6
Signed-off-by: Antonio Gomes <a1.gomes@samsung.com>
tizen_src/chromium_impl/content/browser/selection/selection_controller_efl.cc

index 2fbe86a..13d0a43 100644 (file)
@@ -416,6 +416,31 @@ void SelectionControllerEfl::OnMouseDown(
   magnifier_->UpdateLocation(magnifier_point);
   magnifier_->Move(magnifier_point);
   magnifier_->Show();
+
+  if (handle == input_handle_) {
+    ShowHandleAndContextMenuIfRequired();
+    return;
+  }
+
+  // When moving the handle we want to move only the extent point.
+  // Before doing so, we must make sure that the base point is set correctly.
+  float device_scale_factor =
+      gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().device_scale_factor();
+  gfx::Point base, extent;
+  if (handle == start_handle_) {
+    base.set_x(end_handle_->GetBasePosition().x() / device_scale_factor);
+    base.set_y(end_handle_->GetBasePosition().y() / device_scale_factor);
+    extent.set_x(start_handle_->GetBasePosition().x() / device_scale_factor);
+    extent.set_y(start_handle_->GetBasePosition().y() / device_scale_factor);
+  } else {
+    base.set_x(start_handle_->GetBasePosition().x() / device_scale_factor);
+    base.set_y(start_handle_->GetBasePosition().y() / device_scale_factor);
+    extent.set_x(end_handle_->GetBasePosition().x() / device_scale_factor);
+    extent.set_y(end_handle_->GetBasePosition().y() / device_scale_factor);
+  }
+  WebContentsImpl* wci = static_cast<WebContentsImpl*>(&web_contents_);
+  wci->SelectRange(base, extent);
+
   ShowHandleAndContextMenuIfRequired();
 }
 
@@ -443,15 +468,13 @@ void SelectionControllerEfl::OnMouseMove(const gfx::Point& touch_point,
     }
     case SelectionHandleEfl::HANDLE_TYPE_LEFT:
     case SelectionHandleEfl::HANDLE_TYPE_RIGHT: {
-      gfx::Point start_point, end_point;
       float device_scale_factor =
           gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().device_scale_factor();
-      start_point.set_x(start_handle_->GetBasePosition().x() / device_scale_factor);
-      start_point.set_y(start_handle_->GetBasePosition().y() / device_scale_factor);
-      end_point.set_x(end_handle_->GetBasePosition().x() / device_scale_factor);
-      end_point.set_y(end_handle_->GetBasePosition().y() / device_scale_factor);
+      gfx::Point extent;
+      extent.set_x(handle->GetBasePosition().x() / device_scale_factor);
+      extent.set_y(handle->GetBasePosition().y() / device_scale_factor);
       WebContentsImpl* wci = static_cast<WebContentsImpl*>(&web_contents_);
-      wci->SelectRange(start_point, end_point);
+      wci->MoveRangeSelectionExtent(extent);
       return;
     }
   }