| Index: ui/views/selection_controller.cc
|
| diff --git a/ui/views/selection_controller.cc b/ui/views/selection_controller.cc
|
| index 9aecd741641e8b825b17651a434375dbfde501de..fdf9924bd0819bbbd5e7155e351e7c33c03d910f 100644
|
| --- a/ui/views/selection_controller.cc
|
| +++ b/ui/views/selection_controller.cc
|
| @@ -27,8 +27,10 @@ SelectionController::SelectionController(SelectionControllerDelegate* delegate)
|
| DCHECK(delegate);
|
| }
|
|
|
| -bool SelectionController::OnMousePressed(const ui::MouseEvent& event,
|
| - bool handled) {
|
| +bool SelectionController::OnMousePressed(
|
| + const ui::MouseEvent& event,
|
| + bool handled,
|
| + InitialFocusStateOnMousePress initial_focus_state) {
|
| gfx::RenderText* render_text = GetRenderText();
|
| DCHECK(render_text);
|
|
|
| @@ -61,23 +63,22 @@ bool SelectionController::OnMousePressed(const ui::MouseEvent& event,
|
| break;
|
| case 2:
|
| // Select all the text on a triple click.
|
| - delegate_->OnBeforePointerAction();
|
| - render_text->SelectAll(false);
|
| - delegate_->OnAfterPointerAction(false, true);
|
| + SelectAll();
|
| break;
|
| default:
|
| NOTREACHED();
|
| }
|
| }
|
|
|
| - // TODO(crbug.com/676296): Right clicking an unfocused text view should select
|
| - // all its text on Mac.
|
| - const bool select_word_on_right_click =
|
| - event.IsOnlyRightMouseButton() &&
|
| - PlatformStyle::kSelectWordOnRightClick &&
|
| - !render_text->IsPointInSelection(event.location());
|
| - if (select_word_on_right_click)
|
| - SelectWord(event.location());
|
| + if (event.IsOnlyRightMouseButton()) {
|
| + if (PlatformStyle::kSelectAllOnRightClickWhenUnfocused &&
|
| + initial_focus_state == InitialFocusStateOnMousePress::UNFOCUSED) {
|
| + SelectAll();
|
| + } else if (PlatformStyle::kSelectWordOnRightClick &&
|
| + !render_text->IsPointInSelection(event.location())) {
|
| + SelectWord(event.location());
|
| + }
|
| + }
|
|
|
| if (handles_selection_clipboard_ && event.IsOnlyMiddleMouseButton()) {
|
| if (render_text->IsPointInSelection(event.location())) {
|
| @@ -186,6 +187,14 @@ void SelectionController::SelectWord(const gfx::Point& point) {
|
| delegate_->OnAfterPointerAction(false, true);
|
| }
|
|
|
| +void SelectionController::SelectAll() {
|
| + gfx::RenderText* render_text = GetRenderText();
|
| + DCHECK(render_text);
|
| + delegate_->OnBeforePointerAction();
|
| + render_text->SelectAll(false);
|
| + delegate_->OnAfterPointerAction(false, true);
|
| +}
|
| +
|
| gfx::RenderText* SelectionController::GetRenderText() {
|
| return delegate_->GetRenderTextForSelectionController();
|
| }
|
|
|