diff --git a/chrome/browser/chromeos/arc/input_method_manager/input_connection_impl.cc b/chrome/browser/chromeos/arc/input_method_manager/input_connection_impl.cc index 1142470cd782b7..ce72993c8fe64e 100644 --- a/chrome/browser/chromeos/arc/input_method_manager/input_connection_impl.cc +++ b/chrome/browser/chromeos/arc/input_method_manager/input_connection_impl.cc @@ -86,7 +86,7 @@ mojom::TextInputStatePtr InputConnectionImpl::GetTextInputState( gfx::Range text_range, selection_range; base::string16 text; client->GetTextRange(&text_range); - client->GetSelectionRange(&selection_range); + client->GetEditableSelectionRange(&selection_range); client->GetTextFromRange(text_range, &text); return mojom::TextInputStatePtr( @@ -147,7 +147,7 @@ void InputConnectionImpl::FinishComposingText() { ui::TextInputClient* client = GetTextInputClient(); gfx::Range selection_range, composition_range; - client->GetSelectionRange(&selection_range); + client->GetEditableSelectionRange(&selection_range); client->GetCompositionTextRange(&composition_range); std::string error; @@ -183,7 +183,7 @@ void InputConnectionImpl::SetComposingText( ui::TextInputClient* client = GetTextInputClient(); gfx::Range selection_range; - client->GetSelectionRange(&selection_range); + client->GetEditableSelectionRange(&selection_range); if (text.empty() && selection_range.start() == static_cast(selection_start) && selection_range.end() == static_cast(selection_end)) { @@ -214,7 +214,7 @@ void InputConnectionImpl::SetSelection(const gfx::Range& new_selection_range) { ui::TextInputClient* client = GetTextInputClient(); gfx::Range selection_range; - client->GetSelectionRange(&selection_range); + client->GetEditableSelectionRange(&selection_range); if (new_selection_range == selection_range) { // This SetSelection call is no-op. // Return the current state immediately. @@ -222,7 +222,7 @@ void InputConnectionImpl::SetSelection(const gfx::Range& new_selection_range) { } StartStateUpdateTimer(); - client->SetSelectionRange(new_selection_range); + client->SetEditableSelectionRange(new_selection_range); } void InputConnectionImpl::StartStateUpdateTimer() { diff --git a/chrome/browser/chromeos/input_method/textinput_test_helper.cc b/chrome/browser/chromeos/input_method/textinput_test_helper.cc index cae24c76291966..b2cfba3c1cac40 100644 --- a/chrome/browser/chromeos/input_method/textinput_test_helper.cc +++ b/chrome/browser/chromeos/input_method/textinput_test_helper.cc @@ -97,7 +97,7 @@ void TextInputTestHelper::OnCaretBoundsChanged( if (!GetTextInputClient()->GetTextRange(&text_range) || !GetTextInputClient()->GetTextFromRange(text_range, &surrounding_text_) || - !GetTextInputClient()->GetSelectionRange(&selection_range_)) + !GetTextInputClient()->GetEditableSelectionRange(&selection_range_)) return; } if (waiting_type_ == WAIT_ON_CARET_BOUNDS_CHANGED) diff --git a/chrome/browser/ui/views/ime_driver/remote_text_input_client.cc b/chrome/browser/ui/views/ime_driver/remote_text_input_client.cc index 5d8845ca3aa956..0ff96ed4663fc0 100644 --- a/chrome/browser/ui/views/ime_driver/remote_text_input_client.cc +++ b/chrome/browser/ui/views/ime_driver/remote_text_input_client.cc @@ -120,13 +120,13 @@ bool RemoteTextInputClient::GetCompositionTextRange(gfx::Range* range) const { return false; } -bool RemoteTextInputClient::GetSelectionRange(gfx::Range* range) const { +bool RemoteTextInputClient::GetEditableSelectionRange(gfx::Range* range) const { // TODO(moshayedi): crbug.com/631527. NOTIMPLEMENTED_LOG_ONCE(); return false; } -bool RemoteTextInputClient::SetSelectionRange(const gfx::Range& range) { +bool RemoteTextInputClient::SetEditableSelectionRange(const gfx::Range& range) { // TODO(moshayedi): crbug.com/631527. NOTIMPLEMENTED_LOG_ONCE(); return false; diff --git a/chrome/browser/ui/views/ime_driver/remote_text_input_client.h b/chrome/browser/ui/views/ime_driver/remote_text_input_client.h index 157308aff94b4c..6bcd332d208797 100644 --- a/chrome/browser/ui/views/ime_driver/remote_text_input_client.h +++ b/chrome/browser/ui/views/ime_driver/remote_text_input_client.h @@ -50,8 +50,8 @@ class RemoteTextInputClient : public ui::TextInputClient, FocusReason GetFocusReason() const override; bool GetTextRange(gfx::Range* range) const override; bool GetCompositionTextRange(gfx::Range* range) const override; - bool GetSelectionRange(gfx::Range* range) const override; - bool SetSelectionRange(const gfx::Range& range) override; + bool GetEditableSelectionRange(gfx::Range* range) const override; + bool SetEditableSelectionRange(const gfx::Range& range) override; bool DeleteRange(const gfx::Range& range) override; bool GetTextFromRange(const gfx::Range& range, base::string16* text) const override; diff --git a/components/arc/ime/arc_ime_service.cc b/components/arc/ime/arc_ime_service.cc index 7181aa6cfc0685..18a58f439a8321 100644 --- a/components/arc/ime/arc_ime_service.cc +++ b/components/arc/ime/arc_ime_service.cc @@ -442,7 +442,7 @@ bool ArcImeService::GetTextRange(gfx::Range* range) const { return true; } -bool ArcImeService::GetSelectionRange(gfx::Range* range) const { +bool ArcImeService::GetEditableSelectionRange(gfx::Range* range) const { if (!selection_range_.IsValid()) return false; *range = selection_range_; @@ -502,7 +502,7 @@ bool ArcImeService::GetCompositionTextRange(gfx::Range* range) const { return false; } -bool ArcImeService::SetSelectionRange(const gfx::Range& range) { +bool ArcImeService::SetEditableSelectionRange(const gfx::Range& range) { return false; } diff --git a/components/arc/ime/arc_ime_service.h b/components/arc/ime/arc_ime_service.h index 695df6ee708ae9..23297e1deac97c 100644 --- a/components/arc/ime/arc_ime_service.h +++ b/components/arc/ime/arc_ime_service.h @@ -113,7 +113,7 @@ class ArcImeService : public KeyedService, ui::TextInputType GetTextInputType() const override; gfx::Rect GetCaretBounds() const override; bool GetTextRange(gfx::Range* range) const override; - bool GetSelectionRange(gfx::Range* range) const override; + bool GetEditableSelectionRange(gfx::Range* range) const override; bool GetTextFromRange(const gfx::Range& range, base::string16* text) const override; @@ -129,7 +129,7 @@ class ArcImeService : public KeyedService, bool HasCompositionText() const override; FocusReason GetFocusReason() const override; bool GetCompositionTextRange(gfx::Range* range) const override; - bool SetSelectionRange(const gfx::Range& range) override; + bool SetEditableSelectionRange(const gfx::Range& range) override; bool DeleteRange(const gfx::Range& range) override; void OnInputMethodChanged() override {} bool ChangeTextDirectionAndLayoutAlignment( diff --git a/components/arc/ime/arc_ime_service_unittest.cc b/components/arc/ime/arc_ime_service_unittest.cc index 549b3725caf804..c044f65a711828 100644 --- a/components/arc/ime/arc_ime_service_unittest.cc +++ b/components/arc/ime/arc_ime_service_unittest.cc @@ -348,7 +348,7 @@ TEST_F(ArcImeServiceTest, GetTextFromRange) { instance_->GetTextFromRange(text_range, &temp_str); EXPECT_EQ(text_in_range, temp_str); - instance_->GetSelectionRange(&temp); + instance_->GetEditableSelectionRange(&temp); EXPECT_EQ(selection_range, temp); } diff --git a/components/exo/text_input.cc b/components/exo/text_input.cc index ad34380ed6874a..f2534c4c42bdc1 100644 --- a/components/exo/text_input.cc +++ b/components/exo/text_input.cc @@ -172,12 +172,12 @@ bool TextInput::GetCompositionTextRange(gfx::Range* range) const { return false; } -bool TextInput::GetSelectionRange(gfx::Range* range) const { +bool TextInput::GetEditableSelectionRange(gfx::Range* range) const { NOTIMPLEMENTED_LOG_ONCE(); return false; } -bool TextInput::SetSelectionRange(const gfx::Range& range) { +bool TextInput::SetEditableSelectionRange(const gfx::Range& range) { NOTIMPLEMENTED_LOG_ONCE(); return false; } diff --git a/components/exo/text_input.h b/components/exo/text_input.h index 96c6f444aebe63..4a47440954da80 100644 --- a/components/exo/text_input.h +++ b/components/exo/text_input.h @@ -114,8 +114,8 @@ class TextInput : public ui::TextInputClient, ui::TextInputClient::FocusReason GetFocusReason() const override; bool GetTextRange(gfx::Range* range) const override; bool GetCompositionTextRange(gfx::Range* range) const override; - bool GetSelectionRange(gfx::Range* range) const override; - bool SetSelectionRange(const gfx::Range& range) override; + bool GetEditableSelectionRange(gfx::Range* range) const override; + bool SetEditableSelectionRange(const gfx::Range& range) override; bool DeleteRange(const gfx::Range& range) override; bool GetTextFromRange(const gfx::Range& range, base::string16* text) const override; diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index caa00cebf350fa..642e95614d6c87 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -1409,7 +1409,9 @@ bool RenderWidgetHostViewAura::GetCompositionTextRange( return false; } -bool RenderWidgetHostViewAura::GetSelectionRange(gfx::Range* range) const { +bool RenderWidgetHostViewAura::GetEditableSelectionRange( + gfx::Range* range) const { + // TODO(yhanada, crbug.com/908762): Return only selections in a text field. if (!text_input_manager_ || !GetFocusedWidget()) return false; @@ -1423,7 +1425,8 @@ bool RenderWidgetHostViewAura::GetSelectionRange(gfx::Range* range) const { return true; } -bool RenderWidgetHostViewAura::SetSelectionRange(const gfx::Range& range) { +bool RenderWidgetHostViewAura::SetEditableSelectionRange( + const gfx::Range& range) { // TODO(suzhe): implement this method when fixing http://crbug.com/55130. NOTIMPLEMENTED_LOG_ONCE(); return false; diff --git a/content/browser/renderer_host/render_widget_host_view_aura.h b/content/browser/renderer_host/render_widget_host_view_aura.h index e719fb13dda6b9..1be2dec6b9bc5a 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.h +++ b/content/browser/renderer_host/render_widget_host_view_aura.h @@ -229,8 +229,8 @@ class CONTENT_EXPORT RenderWidgetHostViewAura ui::TextInputClient::FocusReason GetFocusReason() const override; bool GetTextRange(gfx::Range* range) const override; bool GetCompositionTextRange(gfx::Range* range) const override; - bool GetSelectionRange(gfx::Range* range) const override; - bool SetSelectionRange(const gfx::Range& range) override; + bool GetEditableSelectionRange(gfx::Range* range) const override; + bool SetEditableSelectionRange(const gfx::Range& range) override; bool DeleteRange(const gfx::Range& range) override; bool GetTextFromRange(const gfx::Range& range, base::string16* text) const override; diff --git a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc index 3d0644ad389962..76285987609d48 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc @@ -6453,7 +6453,7 @@ TEST_F(InputMethodStateAuraTest, GetTextRange) { } // This test is for selection range. -TEST_F(InputMethodStateAuraTest, GetSelectionRange) { +TEST_F(InputMethodStateAuraTest, GetEditableSelectionRange) { base::string16 text; gfx::Range expected_range(0U, 1U); @@ -6464,7 +6464,8 @@ TEST_F(InputMethodStateAuraTest, GetSelectionRange) { gfx::Range range_from_client; // This method always returns true. - EXPECT_TRUE(text_input_client()->GetSelectionRange(&range_from_client)); + EXPECT_TRUE( + text_input_client()->GetEditableSelectionRange(&range_from_client)); EXPECT_EQ(expected_range, range_from_client); // Changing range to make sure that the next view has a different text diff --git a/ui/base/ime/dummy_text_input_client.cc b/ui/base/ime/dummy_text_input_client.cc index 3299270a52cb41..34dfc79db8e4a9 100644 --- a/ui/base/ime/dummy_text_input_client.cc +++ b/ui/base/ime/dummy_text_input_client.cc @@ -92,11 +92,11 @@ bool DummyTextInputClient::GetCompositionTextRange(gfx::Range* range) const { return false; } -bool DummyTextInputClient::GetSelectionRange(gfx::Range* range) const { +bool DummyTextInputClient::GetEditableSelectionRange(gfx::Range* range) const { return false; } -bool DummyTextInputClient::SetSelectionRange(const gfx::Range& range) { +bool DummyTextInputClient::SetEditableSelectionRange(const gfx::Range& range) { selection_history_.push_back(range); return false; } diff --git a/ui/base/ime/dummy_text_input_client.h b/ui/base/ime/dummy_text_input_client.h index acc72b866e537b..e313b0356db27d 100644 --- a/ui/base/ime/dummy_text_input_client.h +++ b/ui/base/ime/dummy_text_input_client.h @@ -40,8 +40,8 @@ class DummyTextInputClient : public TextInputClient { ui::TextInputClient::FocusReason GetFocusReason() const override; bool GetTextRange(gfx::Range* range) const override; bool GetCompositionTextRange(gfx::Range* range) const override; - bool GetSelectionRange(gfx::Range* range) const override; - bool SetSelectionRange(const gfx::Range& range) override; + bool GetEditableSelectionRange(gfx::Range* range) const override; + bool SetEditableSelectionRange(const gfx::Range& range) override; bool DeleteRange(const gfx::Range& range) override; bool GetTextFromRange(const gfx::Range& range, base::string16* text) const override; diff --git a/ui/base/ime/input_method_auralinux.cc b/ui/base/ime/input_method_auralinux.cc index f7343b30c07639..9a793126005cff 100644 --- a/ui/base/ime/input_method_auralinux.cc +++ b/ui/base/ime/input_method_auralinux.cc @@ -281,7 +281,7 @@ void InputMethodAuraLinux::OnCaretBoundsChanged(const TextInputClient* client) { base::string16 text; if (client->GetTextRange(&text_range) && client->GetTextFromRange(text_range, &text) && - client->GetSelectionRange(&selection_range)) { + client->GetEditableSelectionRange(&selection_range)) { context_->SetSurroundingText(text, selection_range); } diff --git a/ui/base/ime/input_method_auralinux_unittest.cc b/ui/base/ime/input_method_auralinux_unittest.cc index 2496391504e167..cc67ef7d7e49e8 100644 --- a/ui/base/ime/input_method_auralinux_unittest.cc +++ b/ui/base/ime/input_method_auralinux_unittest.cc @@ -252,7 +252,7 @@ class TextInputClientForTesting : public DummyTextInputClient { *range = text_range; return true; } - bool GetSelectionRange(gfx::Range* range) const override { + bool GetEditableSelectionRange(gfx::Range* range) const override { *range = selection_range; return true; } diff --git a/ui/base/ime/input_method_base.cc b/ui/base/ime/input_method_base.cc index 76f14cac5afc24..fc96c61b538ee7 100644 --- a/ui/base/ime/input_method_base.cc +++ b/ui/base/ime/input_method_base.cc @@ -259,7 +259,7 @@ SurroundingTextInfo InputMethodBase::GetSurroundingTextInfo() { TextInputClient* client = GetTextInputClient(); if (!client->GetTextRange(&text_range) || !client->GetTextFromRange(text_range, &info.surrounding_text) || - !client->GetSelectionRange(&info.selection_range)) { + !client->GetEditableSelectionRange(&info.selection_range)) { return SurroundingTextInfo(); } return info; diff --git a/ui/base/ime/input_method_chromeos.cc b/ui/base/ime/input_method_chromeos.cc index 918bd6eca9a70c..79a9f5a6f72d4d 100644 --- a/ui/base/ime/input_method_chromeos.cc +++ b/ui/base/ime/input_method_chromeos.cc @@ -240,7 +240,7 @@ void InputMethodChromeOS::OnCaretBoundsChanged(const TextInputClient* client) { base::string16 surrounding_text; if (!client->GetTextRange(&text_range) || !client->GetTextFromRange(text_range, &surrounding_text) || - !client->GetSelectionRange(&selection_range)) { + !client->GetEditableSelectionRange(&selection_range)) { previous_surrounding_text_.clear(); previous_selection_range_ = gfx::Range::InvalidRange(); return; diff --git a/ui/base/ime/input_method_chromeos_unittest.cc b/ui/base/ime/input_method_chromeos_unittest.cc index 5b4a72a861f2b8..3ab3975bd2c5a4 100644 --- a/ui/base/ime/input_method_chromeos_unittest.cc +++ b/ui/base/ime/input_method_chromeos_unittest.cc @@ -275,7 +275,7 @@ class InputMethodChromeOSTest : public internal::InputMethodDelegate, *range = text_range_; return true; } - bool GetSelectionRange(gfx::Range* range) const override { + bool GetEditableSelectionRange(gfx::Range* range) const override { *range = selection_range_; return true; } diff --git a/ui/base/ime/input_method_win_base.cc b/ui/base/ime/input_method_win_base.cc index 333607e76eae5b..6b7c3bef62aec0 100644 --- a/ui/base/ime/input_method_win_base.cc +++ b/ui/base/ime/input_method_win_base.cc @@ -350,7 +350,8 @@ LRESULT InputMethodWinBase::OnDocumentFeed(RECONVERTSTRING* reconv) { result = client->GetCompositionTextRange(&target_range); if (!result || target_range.is_empty()) { - if (!client->GetSelectionRange(&target_range) || !target_range.IsValid()) { + if (!client->GetEditableSelectionRange(&target_range) || + !target_range.IsValid()) { return 0; } } @@ -411,7 +412,7 @@ LRESULT InputMethodWinBase::OnReconvertString(RECONVERTSTRING* reconv) { return 0; gfx::Range selection_range; - if (!client->GetSelectionRange(&selection_range) || + if (!client->GetEditableSelectionRange(&selection_range) || selection_range.is_empty()) { return 0; } diff --git a/ui/base/ime/text_input_client.h b/ui/base/ime/text_input_client.h index c475c432dcfa20..4bcaf18c841042 100644 --- a/ui/base/ime/text_input_client.h +++ b/ui/base/ime/text_input_client.h @@ -127,23 +127,25 @@ class UI_BASE_IME_EXPORT TextInputClient { // Returns false if the information cannot be retrieved right now. virtual bool GetCompositionTextRange(gfx::Range* range) const = 0; - // Retrieves the UTF-16 based character range of current selection. - // Returns false if the information cannot be retrieved right now. - virtual bool GetSelectionRange(gfx::Range* range) const = 0; + // Retrieves the UTF-16 based character range of current selection in the text + // input. Returns false if the information cannot be retrieved right now. + // Returns false if the selected text is outside of the text input (== the + // text input is not focused) + virtual bool GetEditableSelectionRange(gfx::Range* range) const = 0; // Selects the given UTF-16 based character range. Current composition text // will be confirmed before selecting the range. // Returns false if the operation is not supported. - virtual bool SetSelectionRange(const gfx::Range& range) = 0; + virtual bool SetEditableSelectionRange(const gfx::Range& range) = 0; // Deletes contents in the given UTF-16 based character range. Current // composition text will be confirmed before deleting the range. // The input caret will be moved to the place where the range gets deleted. // ExtendSelectionAndDelete should be used instead as far as you are deleting // characters around current caret. This function with the range based on - // GetSelectionRange has a race condition due to asynchronous IPCs between - // browser and renderer. - // Returns false if the operation is not supported. + // GetEditableSelectionRange has a race condition due to asynchronous IPCs + // between browser and renderer. Returns false if the operation is not + // supported. virtual bool DeleteRange(const gfx::Range& range) = 0; // Retrieves the text content in a given UTF-16 based character range. @@ -168,9 +170,9 @@ class UI_BASE_IME_EXPORT TextInputClient { // Deletes the current selection plus the specified number of characters // before and after the selection or caret. This function should be used - // instead of calling DeleteRange with GetSelectionRange, because - // GetSelectionRange may not be the latest value due to asynchronous of IPC - // between browser and renderer. + // instead of calling DeleteRange with GetEditableSelectionRange, because + // GetEditableSelectionRange may not be the latest value due to asynchronous + // of IPC between browser and renderer. virtual void ExtendSelectionAndDelete(size_t before, size_t after) = 0; // Ensure the caret is not in |rect|. |rect| is in screen coordinates in diff --git a/ui/base/ime/win/tsf_text_store_unittest.cc b/ui/base/ime/win/tsf_text_store_unittest.cc index a65641e1a55314..ed22f583e4eb5c 100644 --- a/ui/base/ime/win/tsf_text_store_unittest.cc +++ b/ui/base/ime/win/tsf_text_store_unittest.cc @@ -47,8 +47,8 @@ class MockTextInputClient : public TextInputClient { MOCK_METHOD0(ShouldDoLearning, bool()); MOCK_CONST_METHOD1(GetTextRange, bool(gfx::Range*)); MOCK_CONST_METHOD1(GetCompositionTextRange, bool(gfx::Range*)); - MOCK_CONST_METHOD1(GetSelectionRange, bool(gfx::Range*)); - MOCK_METHOD1(SetSelectionRange, bool(const gfx::Range&)); + MOCK_CONST_METHOD1(GetEditableSelectionRange, bool(gfx::Range*)); + MOCK_METHOD1(SetEditableSelectionRange, bool(const gfx::Range&)); MOCK_METHOD1(DeleteRange, bool(const gfx::Range&)); MOCK_CONST_METHOD2(GetTextFromRange, bool(const gfx::Range&, base::string16*)); diff --git a/ui/views/cocoa/bridged_native_widget_unittest.mm b/ui/views/cocoa/bridged_native_widget_unittest.mm index 8f1941096bcbe8..5c729fcde948dc 100644 --- a/ui/views/cocoa/bridged_native_widget_unittest.mm +++ b/ui/views/cocoa/bridged_native_widget_unittest.mm @@ -591,7 +591,7 @@ bool AcceleratorPressed(const ui::Accelerator& accelerator) override { void BridgedNativeWidgetTest::SetSelectionRange(NSRange range) { ui::TextInputClient* client = [ns_view_ textInputClient]; - client->SetSelectionRange(gfx::Range(range)); + client->SetEditableSelectionRange(gfx::Range(range)); [dummy_text_view_ setSelectedRange:range]; } @@ -607,7 +607,7 @@ bool AcceleratorPressed(const ui::Accelerator& accelerator) override { // Although a gfx::Range is directed, the underlying model will not choose an // affinity until the cursor is moved. - client->SetSelectionRange(range); + client->SetEditableSelectionRange(range); // Set the range without an affinity. The first @selector sent to the text // field determines the affinity. Note that Range::ToNSRange() may discard diff --git a/ui/views/controls/prefix_selector.cc b/ui/views/controls/prefix_selector.cc index 98aab8c61c7f02..fe8decc9a68684 100644 --- a/ui/views/controls/prefix_selector.cc +++ b/ui/views/controls/prefix_selector.cc @@ -112,12 +112,12 @@ bool PrefixSelector::GetCompositionTextRange(gfx::Range* range) const { return false; } -bool PrefixSelector::GetSelectionRange(gfx::Range* range) const { +bool PrefixSelector::GetEditableSelectionRange(gfx::Range* range) const { *range = gfx::Range(); return false; } -bool PrefixSelector::SetSelectionRange(const gfx::Range& range) { +bool PrefixSelector::SetEditableSelectionRange(const gfx::Range& range) { return false; } diff --git a/ui/views/controls/prefix_selector.h b/ui/views/controls/prefix_selector.h index 801c9112b73916..de9caa39616fef 100644 --- a/ui/views/controls/prefix_selector.h +++ b/ui/views/controls/prefix_selector.h @@ -55,8 +55,8 @@ class VIEWS_EXPORT PrefixSelector : public ui::TextInputClient { FocusReason GetFocusReason() const override; bool GetTextRange(gfx::Range* range) const override; bool GetCompositionTextRange(gfx::Range* range) const override; - bool GetSelectionRange(gfx::Range* range) const override; - bool SetSelectionRange(const gfx::Range& range) override; + bool GetEditableSelectionRange(gfx::Range* range) const override; + bool SetEditableSelectionRange(const gfx::Range& range) override; bool DeleteRange(const gfx::Range& range) override; bool GetTextFromRange(const gfx::Range& range, base::string16* text) const override; diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc index 2ff60335add8f6..90968d5c75dc9a 100644 --- a/ui/views/controls/textfield/textfield.cc +++ b/ui/views/controls/textfield/textfield.cc @@ -1046,7 +1046,7 @@ bool Textfield::HandleAccessibleAction(const ui::AXActionData& action_data) { return false; // TODO(nektar): Check that the focus_node_id matches the ID of this node. const gfx::Range range(action_data.anchor_offset, action_data.focus_offset); - return SetSelectionRange(range); + return SetEditableSelectionRange(range); } // Remaining actions cannot be performed on readonly fields. @@ -1590,14 +1590,14 @@ bool Textfield::GetCompositionTextRange(gfx::Range* range) const { return true; } -bool Textfield::GetSelectionRange(gfx::Range* range) const { +bool Textfield::GetEditableSelectionRange(gfx::Range* range) const { if (!ImeEditingAllowed()) return false; *range = GetRenderText()->selection(); return true; } -bool Textfield::SetSelectionRange(const gfx::Range& range) { +bool Textfield::SetEditableSelectionRange(const gfx::Range& range) { if (!ImeEditingAllowed() || !range.IsValid()) return false; OnBeforeUserAction(); diff --git a/ui/views/controls/textfield/textfield.h b/ui/views/controls/textfield/textfield.h index f5d0914d43eb65..38b565590a642b 100644 --- a/ui/views/controls/textfield/textfield.h +++ b/ui/views/controls/textfield/textfield.h @@ -349,8 +349,8 @@ class VIEWS_EXPORT Textfield : public View, FocusReason GetFocusReason() const override; bool GetTextRange(gfx::Range* range) const override; bool GetCompositionTextRange(gfx::Range* range) const override; - bool GetSelectionRange(gfx::Range* range) const override; - bool SetSelectionRange(const gfx::Range& range) override; + bool GetEditableSelectionRange(gfx::Range* range) const override; + bool SetEditableSelectionRange(const gfx::Range& range) override; bool DeleteRange(const gfx::Range& range) override; bool GetTextFromRange(const gfx::Range& range, base::string16* text) const override; diff --git a/ui/views/controls/textfield/textfield_unittest.cc b/ui/views/controls/textfield/textfield_unittest.cc index 879ebf11a8386e..7b3f7fd6c62cfb 100644 --- a/ui/views/controls/textfield/textfield_unittest.cc +++ b/ui/views/controls/textfield/textfield_unittest.cc @@ -970,7 +970,7 @@ TEST_F(TextfieldTest, WordSelection) { textfield_->SetText(ASCIIToUTF16("12 34567 89")); // Place the cursor after "5". - textfield_->SetSelectionRange(gfx::Range(6)); + textfield_->SetEditableSelectionRange(gfx::Range(6)); // Select word towards right. SendWordEvent(ui::VKEY_RIGHT, true); @@ -1013,7 +1013,7 @@ TEST_F(TextfieldTest, LineSelection) { textfield_->SetText(ASCIIToUTF16("12 34567 89")); // Place the cursor after "5". - textfield_->SetSelectionRange(gfx::Range(6)); + textfield_->SetEditableSelectionRange(gfx::Range(6)); // Select line towards right. SendEndEvent(true); @@ -1042,7 +1042,7 @@ TEST_F(TextfieldTest, LineSelection) { TEST_F(TextfieldTest, MoveUpDownAndModifySelection) { InitTextfield(); textfield_->SetText(ASCIIToUTF16("12 34567 89")); - textfield_->SetSelectionRange(gfx::Range(6)); + textfield_->SetEditableSelectionRange(gfx::Range(6)); // Up/Down keys won't be handled except on Mac where they map to move // commands. @@ -1066,7 +1066,7 @@ TEST_F(TextfieldTest, MoveUpDownAndModifySelection) { #endif textfield_->clear(); - textfield_->SetSelectionRange(gfx::Range(6)); + textfield_->SetEditableSelectionRange(gfx::Range(6)); // Shift+[Up/Down] should select the text to the beginning and end of the // line, respectively. @@ -1090,7 +1090,7 @@ TEST_F(TextfieldTest, MovePageUpDownAndModifySelection) { // enabled on Mac. #if defined(OS_MACOSX) textfield_->SetText(ASCIIToUTF16("12 34567 89")); - textfield_->SetSelectionRange(gfx::Range(6)); + textfield_->SetEditableSelectionRange(gfx::Range(6)); EXPECT_TRUE( textfield_->IsTextEditCommandEnabled(ui::TextEditCommand::MOVE_PAGE_UP)); @@ -1107,7 +1107,7 @@ TEST_F(TextfieldTest, MovePageUpDownAndModifySelection) { test_api_->ExecuteTextEditCommand(ui::TextEditCommand::MOVE_PAGE_DOWN); EXPECT_EQ(gfx::Range(11), textfield_->GetSelectedRange()); - textfield_->SetSelectionRange(gfx::Range(6)); + textfield_->SetEditableSelectionRange(gfx::Range(6)); test_api_->ExecuteTextEditCommand( ui::TextEditCommand::MOVE_PAGE_UP_AND_MODIFY_SELECTION); EXPECT_EQ(gfx::Range(6, 0), textfield_->GetSelectedRange()); @@ -1130,7 +1130,7 @@ TEST_F(TextfieldTest, MovePageUpDownAndModifySelection) { TEST_F(TextfieldTest, MoveParagraphForwardBackwardAndModifySelection) { InitTextfield(); textfield_->SetText(ASCIIToUTF16("12 34567 89")); - textfield_->SetSelectionRange(gfx::Range(6)); + textfield_->SetEditableSelectionRange(gfx::Range(6)); test_api_->ExecuteTextEditCommand( ui::TextEditCommand::MOVE_PARAGRAPH_FORWARD_AND_MODIFY_SELECTION); @@ -2001,8 +2001,8 @@ TEST_F(TextfieldTest, TextInputClientTest) { EXPECT_EQ(0U, range.start()); EXPECT_EQ(10U, range.end()); - EXPECT_TRUE(client->SetSelectionRange(gfx::Range(1, 4))); - EXPECT_TRUE(client->GetSelectionRange(&range)); + EXPECT_TRUE(client->SetEditableSelectionRange(gfx::Range(1, 4))); + EXPECT_TRUE(client->GetEditableSelectionRange(&range)); EXPECT_EQ(gfx::Range(1, 4), range); base::string16 substring; @@ -2064,7 +2064,7 @@ TEST_F(TextfieldTest, TextInputClientTest) { textfield_->clear(); textfield_->SetText(ASCIIToUTF16("0123456789")); - EXPECT_TRUE(client->SetSelectionRange(gfx::Range(5, 5))); + EXPECT_TRUE(client->SetEditableSelectionRange(gfx::Range(5, 5))); client->ExtendSelectionAndDelete(4, 2); EXPECT_STR_EQ("0789", textfield_->text()); @@ -3227,23 +3227,23 @@ TEST_F(TextfieldTouchSelectionTest, MAYBE_TapOnSelection) { // Select range |sel_range| and check if touch selection handles are not // present and correct range is selected. - textfield_->SetSelectionRange(sel_range); + textfield_->SetEditableSelectionRange(sel_range); gfx::Range range; - textfield_->GetSelectionRange(&range); + textfield_->GetEditableSelectionRange(&range); EXPECT_FALSE(test_api_->touch_selection_controller()); EXPECT_EQ(sel_range, range); // Tap on selection and check if touch selectoin handles are shown, but // selection range is not modified. Tap(tap_point); - textfield_->GetSelectionRange(&range); + textfield_->GetEditableSelectionRange(&range); EXPECT_TRUE(test_api_->touch_selection_controller()); EXPECT_EQ(sel_range, range); // Tap again on selection and check if touch selection handles are still // present and selection is changed to a cursor at tap location. Tap(tap_point); - textfield_->GetSelectionRange(&range); + textfield_->GetEditableSelectionRange(&range); EXPECT_TRUE(test_api_->touch_selection_controller()); EXPECT_EQ(tap_range, range); } diff --git a/ui/views/examples/label_example.cc b/ui/views/examples/label_example.cc index 87189250851109..e1df4fe5d9c27a 100644 --- a/ui/views/examples/label_example.cc +++ b/ui/views/examples/label_example.cc @@ -181,7 +181,7 @@ void LabelExample::AddCustomLabel(View* container) { textfield_ = new Textfield(); textfield_->SetText(ASCIIToUTF16("Use the provided controls to configure the " "content and presentation of this custom label.")); - textfield_->SetSelectionRange(gfx::Range()); + textfield_->SetEditableSelectionRange(gfx::Range()); textfield_->set_controller(this); layout->AddView(textfield_); diff --git a/ui/views_bridge_mac/bridged_content_view.mm b/ui/views_bridge_mac/bridged_content_view.mm index 397425e89055e8..08f50f84157b37 100644 --- a/ui/views_bridge_mac/bridged_content_view.mm +++ b/ui/views_bridge_mac/bridged_content_view.mm @@ -97,7 +97,7 @@ bool IsImeTriggerEvent(NSEvent* event) { // If possible, modify actual_range to correspond to caret position. gfx::Range selection_range; - if (client->GetSelectionRange(&selection_range)) { + if (client->GetEditableSelectionRange(&selection_range)) { // Caret bounds correspond to end index of selection_range. *actual_range = gfx::Range(selection_range.end()); } @@ -1377,7 +1377,7 @@ - (BOOL)writeSelectionToPasteboard:(NSPasteboard*)pboard types:(NSArray*)types { return NO; gfx::Range selectionRange; - if (!textInputClient_->GetSelectionRange(&selectionRange)) + if (!textInputClient_->GetEditableSelectionRange(&selectionRange)) return NO; base::string16 text; @@ -1513,7 +1513,7 @@ - (NSRange)selectedRange { return NSMakeRange(NSNotFound, 0); gfx::Range range; - textInputClient_->GetSelectionRange(&range); + textInputClient_->GetEditableSelectionRange(&range); return range.ToNSRange(); }