Commit 697c453e authored by Yuichiro Hanada's avatar Yuichiro Hanada Committed by Commit Bot

Use GetSelectedText() to check whether any text is selected or not.

Bug: 901439, 908762
Test: content_browsertests
Change-Id: Id8730f01db6781d7983ebbc1402176203e0b146a
Reviewed-on: https://chromium-review.googlesource.com/c/1347634Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Commit-Queue: Yuichiro Hanada <yhanada@chromium.org>
Cr-Commit-Position: refs/heads/master@{#613366}
parent 95f6901b
...@@ -431,9 +431,7 @@ bool TouchSelectionControllerClientAura::IsCommandIdEnabled( ...@@ -431,9 +431,7 @@ bool TouchSelectionControllerClientAura::IsCommandIdEnabled(
int command_id) const { int command_id) const {
bool editable = rwhva_->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE; bool editable = rwhva_->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE;
bool readable = rwhva_->GetTextInputType() != ui::TEXT_INPUT_TYPE_PASSWORD; bool readable = rwhva_->GetTextInputType() != ui::TEXT_INPUT_TYPE_PASSWORD;
gfx::Range selection_range; bool has_selection = !rwhva_->GetSelectedText().empty();
rwhva_->GetSelectionRange(&selection_range);
bool has_selection = !selection_range.is_empty();
switch (command_id) { switch (command_id) {
case IDS_APP_CUT: case IDS_APP_CUT:
return editable && readable && has_selection; return editable && readable && has_selection;
......
...@@ -138,9 +138,7 @@ bool TouchSelectionControllerClientChildFrame::IsCommandIdEnabled( ...@@ -138,9 +138,7 @@ bool TouchSelectionControllerClientChildFrame::IsCommandIdEnabled(
bool editable = rwhv_->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE; bool editable = rwhv_->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE;
bool readable = rwhv_->GetTextInputType() != ui::TEXT_INPUT_TYPE_PASSWORD; bool readable = rwhv_->GetTextInputType() != ui::TEXT_INPUT_TYPE_PASSWORD;
gfx::Range selection_range; bool has_selection = !rwhv_->GetSelectedText().empty();
bool has_selection =
rwhv_->GetSelectionRange(&selection_range) && !selection_range.is_empty();
switch (command_id) { switch (command_id) {
case IDS_APP_CUT: case IDS_APP_CUT:
return editable && readable && has_selection; return editable && readable && has_selection;
......
...@@ -1077,22 +1077,6 @@ void RenderWidgetHostViewChildFrame::ResetCompositorFrameSinkSupport() { ...@@ -1077,22 +1077,6 @@ void RenderWidgetHostViewChildFrame::ResetCompositorFrameSinkSupport() {
support_.reset(); support_.reset();
} }
bool RenderWidgetHostViewChildFrame::GetSelectionRange(
gfx::Range* range) const {
if (!text_input_manager_ || !GetFocusedWidget())
return false;
const TextInputManager::TextSelection* selection =
text_input_manager_->GetTextSelection(GetFocusedWidget()->GetView());
if (!selection)
return false;
range->set_start(selection->range().start());
range->set_end(selection->range().end());
return true;
}
ui::TextInputType RenderWidgetHostViewChildFrame::GetTextInputType() const { ui::TextInputType RenderWidgetHostViewChildFrame::GetTextInputType() const {
if (!text_input_manager_) if (!text_input_manager_)
return ui::TEXT_INPUT_TYPE_NONE; return ui::TEXT_INPUT_TYPE_NONE;
......
...@@ -234,7 +234,6 @@ class CONTENT_EXPORT RenderWidgetHostViewChildFrame ...@@ -234,7 +234,6 @@ class CONTENT_EXPORT RenderWidgetHostViewChildFrame
void UpdateRenderThrottlingStatus(); void UpdateRenderThrottlingStatus();
ui::TextInputType GetTextInputType() const; ui::TextInputType GetTextInputType() const;
bool GetSelectionRange(gfx::Range* range) const;
RenderWidgetHostViewBase* GetRootRenderWidgetHostView() const; RenderWidgetHostViewBase* GetRootRenderWidgetHostView() const;
......
...@@ -138,7 +138,8 @@ class CONTENT_EXPORT RenderWidgetHostView { ...@@ -138,7 +138,8 @@ class CONTENT_EXPORT RenderWidgetHostView {
// Retrieve the bounds of the View, in screen coordinates. // Retrieve the bounds of the View, in screen coordinates.
virtual gfx::Rect GetViewBounds() const = 0; virtual gfx::Rect GetViewBounds() const = 0;
// Returns the currently selected text. // Returns the currently selected text in both of editable text fields and
// non-editable texts.
virtual base::string16 GetSelectedText() = 0; virtual base::string16 GetSelectedText() = 0;
// This only returns non-null on platforms that implement touch // This only returns non-null on platforms that implement touch
......
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