Commit 8a702487 authored by Jinsong Fan's avatar Jinsong Fan Committed by Commit Bot

Fix the context menu is overlaid on the touch handles

There two cases of the bug:
1. When the touch handles are on the same line, or one of them is
invisible, the RectBetweenBounds becomes a line, and not union the
handle rect, cause the context menu covers the touch handles.

2. Long press on any text, the showSelectionMenu is coming before
concluding the selection. While the handles remain hidden for the
duration of a longpress drag, including the time between a longpress
and the start of drag motion. So, the handle rect is empty and cause
the context menu covers the touch handles.

The CL removes the empty check of RectBetweenBounds, so it always
union the handle rect to fix case 1. For case 2, leave it to Ajith's
CL to fix(http://crrev/c/995653).

Bug: 1013477
Test: manual
Change-Id: Ie4fbe0669b28d1a0e7ac0894d2ba07569b63dd05
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1857838
Commit-Queue: Jinsong Fan <fanjinsong@sogou-inc.com>
Reviewed-by: default avatarMohsen Izadi <mohsen@chromium.org>
Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709760}
parent 7294eccd
......@@ -131,10 +131,11 @@ std::unique_ptr<ui::TouchSelectionController> CreateSelectionController(
}
gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) {
// When the touch handles are on the same line, or one of them is invisible,
// the rect may become a line, and still need to union the handle rect to
// avoid the context menu covering the touch handle. See detailed comments in
// TouchSelectionController::GetRectBetweenBounds().
gfx::RectF rect = controller.GetRectBetweenBounds();
if (rect.IsEmpty())
return rect;
rect.Union(controller.GetStartHandleRect());
rect.Union(controller.GetEndHandleRect());
return rect;
......
......@@ -253,13 +253,21 @@ gfx::RectF TouchSelectionController::GetRectBetweenBounds() const {
if (active_status_ == INACTIVE)
return gfx::RectF();
if (start_.visible() && !end_.visible())
if (start_.visible() && !end_.visible()) {
// This BoundingRect is actually a line unless the selection is rotated.
return gfx::BoundingRect(start_.edge_top(), start_.edge_bottom());
}
if (end_.visible() && !start_.visible())
if (end_.visible() && !start_.visible()) {
// This BoundingRect is actually a line unless the selection is rotated.
return gfx::BoundingRect(end_.edge_top(), end_.edge_bottom());
}
// If both handles are visible, or both are invisible, use the entire rect.
// Specifically, if both handles are on the same horizontal line for
// writing-mode: vertical-*, or both are on the same vertical line for
// writing-mode: horizontal, the entire rect is actually a line unless the
// selection is rotated.
return RectFBetweenSelectionBounds(start_, end_);
}
......
......@@ -115,8 +115,9 @@ class UI_TOUCH_SELECTION_EXPORT TouchSelectionController
bool Animate(base::TimeTicks animate_time);
// Returns the rect between the two active selection bounds. If just one of
// the bounds is visible, the rect is simply the (one-dimensional) rect of
// that bound. If no selection is active, an empty rect will be returned.
// the bounds is visible, or both bounds are visible and on the same line,
// the rect is simply a one-dimensional rect of that bound. If no selection
// is active, an empty rect will be returned.
gfx::RectF GetRectBetweenBounds() const;
// Returns the visible rect of specified touch handle. For an active insertion
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment