| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/renderer_host/input/touch_selection_controller_client_
child_frame.h" | 5 #include "content/browser/renderer_host/input/touch_selection_controller_client_
child_frame.h" |
| 6 | 6 |
| 7 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" | 7 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
| 8 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 8 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 9 #include "content/browser/renderer_host/render_widget_host_impl.h" | 9 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 10 #include "content/common/content_switches_internal.h" | 10 #include "content/common/content_switches_internal.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 std::unique_ptr<ui::TouchHandleDrawable> | 118 std::unique_ptr<ui::TouchHandleDrawable> |
| 119 TouchSelectionControllerClientChildFrame::CreateDrawable() { | 119 TouchSelectionControllerClientChildFrame::CreateDrawable() { |
| 120 NOTREACHED(); | 120 NOTREACHED(); |
| 121 return std::unique_ptr<ui::TouchHandleDrawable>(); | 121 return std::unique_ptr<ui::TouchHandleDrawable>(); |
| 122 } | 122 } |
| 123 | 123 |
| 124 bool TouchSelectionControllerClientChildFrame::IsCommandIdEnabled( | 124 bool TouchSelectionControllerClientChildFrame::IsCommandIdEnabled( |
| 125 int command_id) const { | 125 int command_id) const { |
| 126 bool editable = rwhv_->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE; | 126 bool editable = rwhv_->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE; |
| 127 bool readable = rwhv_->GetTextInputType() != ui::TEXT_INPUT_TYPE_PASSWORD; | 127 bool readable = rwhv_->GetTextInputType() != ui::TEXT_INPUT_TYPE_PASSWORD; |
| 128 // TODO(wjmaclean): The test for has_selection should be changed to | 128 |
| 129 // | 129 gfx::Range selection_range; |
| 130 // rwhv_->GetSelectionRange(&selection_range); | 130 bool has_selection = |
| 131 // bool has_selection = !selection_range.is_empty(); | 131 rwhv_->GetSelectionRange(&selection_range) && !selection_range.is_empty(); |
| 132 // | |
| 133 // like in TouchSelectionControllerClientAura. Unfortunately this fails here | |
| 134 // due to https://crbug.com/723790, which means that the first text | |
| 135 // selected in an oopif subframe when it acquires focus will fail to send | |
| 136 // a FrameHostMsg_SelectionChanged, meaning the TextInputManager won't | |
| 137 // know about the new selection. | |
| 138 bool has_selection = selection_start_.type() != gfx::SelectionBound::EMPTY && | |
| 139 selection_end_.type() != gfx::SelectionBound::EMPTY && | |
| 140 selection_start_ != selection_end_; | |
| 141 switch (command_id) { | 132 switch (command_id) { |
| 142 case IDS_APP_CUT: | 133 case IDS_APP_CUT: |
| 143 return editable && readable && has_selection; | 134 return editable && readable && has_selection; |
| 144 case IDS_APP_COPY: | 135 case IDS_APP_COPY: |
| 145 return readable && has_selection; | 136 return readable && has_selection; |
| 146 case IDS_APP_PASTE: { | 137 case IDS_APP_PASTE: { |
| 147 base::string16 result; | 138 base::string16 result; |
| 148 ui::Clipboard::GetForCurrentThread()->ReadText( | 139 ui::Clipboard::GetForCurrentThread()->ReadText( |
| 149 ui::CLIPBOARD_TYPE_COPY_PASTE, &result); | 140 ui::CLIPBOARD_TYPE_COPY_PASTE, &result); |
| 150 return editable && !result.empty(); | 141 return editable && !result.empty(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 gfx::ToRoundedPoint(anchor_point))); | 184 gfx::ToRoundedPoint(anchor_point))); |
| 194 | 185 |
| 195 // Hide selection handles after getting rect-between-bounds from touch | 186 // Hide selection handles after getting rect-between-bounds from touch |
| 196 // selection controller; otherwise, rect would be empty and the above | 187 // selection controller; otherwise, rect would be empty and the above |
| 197 // calculations would be invalid. | 188 // calculations would be invalid. |
| 198 manager_->GetTouchSelectionController() | 189 manager_->GetTouchSelectionController() |
| 199 ->HideAndDisallowShowingAutomatically(); | 190 ->HideAndDisallowShowingAutomatically(); |
| 200 } | 191 } |
| 201 | 192 |
| 202 } // namespace content | 193 } // namespace content |
| OLD | NEW |