Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(680)

Unified Diff: ui/views/touchui/touch_selection_controller_impl.cc

Issue 12388011: Two fixes to touch selection: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/textfield/native_textfield_views.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/touchui/touch_selection_controller_impl.cc
diff --git a/ui/views/touchui/touch_selection_controller_impl.cc b/ui/views/touchui/touch_selection_controller_impl.cc
index 7819d449141ec6d6c921769e9fab1b654377638a..e5ded39fa06c0f5a12da60883cc0e65366c12bb9 100644
--- a/ui/views/touchui/touch_selection_controller_impl.cc
+++ b/ui/views/touchui/touch_selection_controller_impl.cc
@@ -297,6 +297,7 @@ void TouchSelectionControllerImpl::ExecuteCommand(int command_id) {
void TouchSelectionControllerImpl::OpenContextMenu() {
gfx::Point anchor = context_menu_->anchor_point();
+ anchor.Offset(0, kContextMenuVerticalOffset);
HideContextMenu();
client_view_->OpenContextMenu(anchor);
}
@@ -325,19 +326,23 @@ void TouchSelectionControllerImpl::ContextMenuTimerFired() {
client_view_->GetSelectionEndPoints(&r1, &r2);
// if selection is completely inside the view, we display the context menu
- // in the middle of the end points on the top. Else, we show the menu on the
- // top border of the view in the center.
+ // in the middle of the end points on the top. Else, we show it above the
+ // visible handle. If no handle is visible, we do not show the menu.
gfx::Point menu_pos;
gfx::Rect client_bounds = client_view_->GetBounds();
if (client_bounds.Contains(r1.origin()) &&
client_bounds.Contains(r2.origin())) {
menu_pos.set_x((r1.origin().x() + r2.origin().x()) / 2);
- menu_pos.set_y(std::min(r1.y(), r2.y()) - kContextMenuVerticalOffset);
+ menu_pos.set_y(std::min(r1.y(), r2.y()));
+ } else if (client_bounds.Contains(r1.origin())) {
+ menu_pos = r1.origin();
+ } else if (client_bounds.Contains(r2.origin())) {
+ menu_pos = r2.origin();
} else {
- menu_pos.set_x(client_bounds.x() + client_bounds.width() / 2);
- menu_pos.set_y(client_bounds.y());
+ return;
}
+ menu_pos.Offset(0, -kContextMenuVerticalOffset);
client_view_->ConvertPointToScreen(&menu_pos);
DCHECK(!context_menu_);
« no previous file with comments | « ui/views/controls/textfield/native_textfield_views.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698