Rename {Get,Set}SelectionRange to {Get,Set}EditableSelectionRange.
Some implementation of TextInputClient interface, for example RWHVA, can
have text outside of an editable text field.
For those views, {Get, Set}SelectionRange is confusing names because
it's not clear whether they return selections outside of the editable
text field or not.
This CL renames them to {Get, Set}EditableSelectionRange to make it
clear that they returns only selections in an editable text field.
Bug: 901439, 908762
Test: Build.
Change-Id: I99e6140a635a61b755ebfa35efff2d306cec8d32
Reviewed-on: https://chromium-review.googlesource.com/c/1373932
Commit-Queue: Yuichiro Hanada <yhanada@chromium.org>
Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: Mitsuru Oshima (gardener - slow) <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#616605}
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 1142470..ce72993c 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 @@
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 @@
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 @@
ui::TextInputClient* client = GetTextInputClient();
gfx::Range selection_range;
- client->GetSelectionRange(&selection_range);
+ client->GetEditableSelectionRange(&selection_range);
if (text.empty() &&
selection_range.start() == static_cast<uint32_t>(selection_start) &&
selection_range.end() == static_cast<uint32_t>(selection_end)) {
@@ -214,7 +214,7 @@
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 @@
}
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 cae24c7..b2cfba3 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 @@
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 5d8845c..0ff96ed 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 @@
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 157308a..6bcd332d 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 @@
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 7181aa6c..18a58f4 100644
--- a/components/arc/ime/arc_ime_service.cc
+++ b/components/arc/ime/arc_ime_service.cc
@@ -442,7 +442,7 @@
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 @@
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 695df6e..23297e1 100644
--- a/components/arc/ime/arc_ime_service.h
+++ b/components/arc/ime/arc_ime_service.h
@@ -113,7 +113,7 @@
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 @@
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 549b372..c044f65 100644
--- a/components/arc/ime/arc_ime_service_unittest.cc
+++ b/components/arc/ime/arc_ime_service_unittest.cc
@@ -348,7 +348,7 @@
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 ad34380e..f2534c4c 100644
--- a/components/exo/text_input.cc
+++ b/components/exo/text_input.cc
@@ -172,12 +172,12 @@
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 96c6f444..4a47440 100644
--- a/components/exo/text_input.h
+++ b/components/exo/text_input.h
@@ -114,8 +114,8 @@
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 caa00ceb..642e956 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 @@
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 @@
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 e719fb1..1be2dec 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 @@
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 3d0644a..7628598 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 @@
}
// 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 @@
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 3299270..34dfc79 100644
--- a/ui/base/ime/dummy_text_input_client.cc
+++ b/ui/base/ime/dummy_text_input_client.cc
@@ -92,11 +92,11 @@
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 acc72b86..e313b035 100644
--- a/ui/base/ime/dummy_text_input_client.h
+++ b/ui/base/ime/dummy_text_input_client.h
@@ -40,8 +40,8 @@
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 f7343b3..9a79312 100644
--- a/ui/base/ime/input_method_auralinux.cc
+++ b/ui/base/ime/input_method_auralinux.cc
@@ -281,7 +281,7 @@
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 24963915..cc67ef7 100644
--- a/ui/base/ime/input_method_auralinux_unittest.cc
+++ b/ui/base/ime/input_method_auralinux_unittest.cc
@@ -252,7 +252,7 @@
*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 76f14cac..fc96c61b 100644
--- a/ui/base/ime/input_method_base.cc
+++ b/ui/base/ime/input_method_base.cc
@@ -259,7 +259,7 @@
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 918bd6e..79a9f5a6f 100644
--- a/ui/base/ime/input_method_chromeos.cc
+++ b/ui/base/ime/input_method_chromeos.cc
@@ -240,7 +240,7 @@
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 5b4a72a8..3ab3975 100644
--- a/ui/base/ime/input_method_chromeos_unittest.cc
+++ b/ui/base/ime/input_method_chromeos_unittest.cc
@@ -275,7 +275,7 @@
*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 333607e7..6b7c3be 100644
--- a/ui/base/ime/input_method_win_base.cc
+++ b/ui/base/ime/input_method_win_base.cc
@@ -350,7 +350,8 @@
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 @@
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 c475c43..4bcaf18c 100644
--- a/ui/base/ime/text_input_client.h
+++ b/ui/base/ime/text_input_client.h
@@ -127,23 +127,25 @@
// 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 @@
// 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 a65641e1..ed22f58 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 @@
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 8f19410..5c729fcd 100644
--- a/ui/views/cocoa/bridged_native_widget_unittest.mm
+++ b/ui/views/cocoa/bridged_native_widget_unittest.mm
@@ -591,7 +591,7 @@
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 @@
// 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 98aab8c..fe8decc9 100644
--- a/ui/views/controls/prefix_selector.cc
+++ b/ui/views/controls/prefix_selector.cc
@@ -112,12 +112,12 @@
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 801c9112..de9caa3 100644
--- a/ui/views/controls/prefix_selector.h
+++ b/ui/views/controls/prefix_selector.h
@@ -55,8 +55,8 @@
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 2ff6033..90968d5c 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -1046,7 +1046,7 @@
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 @@
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 f5d0914..38b5655 100644
--- a/ui/views/controls/textfield/textfield.h
+++ b/ui/views/controls/textfield/textfield.h
@@ -349,8 +349,8 @@
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 879ebf11..7b3f7fd 100644
--- a/ui/views/controls/textfield/textfield_unittest.cc
+++ b/ui/views/controls/textfield/textfield_unittest.cc
@@ -970,7 +970,7 @@
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 @@
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, 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 @@
#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 @@
// 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_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, 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 @@
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 @@
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 @@
// 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 87189250..e1df4fe 100644
--- a/ui/views/examples/label_example.cc
+++ b/ui/views/examples/label_example.cc
@@ -181,7 +181,7 @@
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 397425e..08f50f84 100644
--- a/ui/views_bridge_mac/bridged_content_view.mm
+++ b/ui/views_bridge_mac/bridged_content_view.mm
@@ -97,7 +97,7 @@
// 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 @@
return NO;
gfx::Range selectionRange;
- if (!textInputClient_->GetSelectionRange(&selectionRange))
+ if (!textInputClient_->GetEditableSelectionRange(&selectionRange))
return NO;
base::string16 text;
@@ -1513,7 +1513,7 @@
return NSMakeRange(NSNotFound, 0);
gfx::Range range;
- textInputClient_->GetSelectionRange(&range);
+ textInputClient_->GetEditableSelectionRange(&range);
return range.ToNSRange();
}