Commit 4f3d0ebe authored by manukh's avatar manukh Committed by Commit Bot

[omnibox] [rich-autocomplete] Rename vars to inline_autocompletion.

inline_autocomplet(ion|e_text)][_] were both used to refer to the
suffix autocompletion of a match and the omnibox. Likewise,
prefix_autocomplet(ion|e_text)[_] were both used to refer to the prefix
autocompletion.

This CL renames the 'e_text' instances to 'ion' as it's both shorter and
the predominant usage.

This is just a renaming change with no behaviour change.

Bug: 1062446
Change-Id: I979b0fc9a383d319d0dcc62ba833b6ae266b32cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2427203Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Commit-Queue: manuk hovanesian <manukh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810787}
parent 52d0e0e4
......@@ -483,11 +483,11 @@ void AutocompleteControllerAndroid::NotifySuggestionsReceived(
autocomplete_result.hidden_group_ids());
// Get the inline-autocomplete text.
base::string16 inline_autocomplete_text;
base::string16 inline_autocompletion;
if (auto* default_match = autocomplete_result.default_match())
inline_autocomplete_text = default_match->inline_autocompletion;
inline_autocompletion = default_match->inline_autocompletion;
ScopedJavaLocalRef<jstring> inline_text =
ConvertUTF16ToJavaString(env, inline_autocomplete_text);
ConvertUTF16ToJavaString(env, inline_autocompletion);
jlong j_autocomplete_result_raw_ptr =
reinterpret_cast<intptr_t>(&(autocomplete_result));
Java_AutocompleteController_onSuggestionsReceived(
......
......@@ -560,8 +560,8 @@ void OmniboxEditModel::StartAutocomplete(bool has_selected_text,
input_.set_current_title(client_->GetTitle());
input_.set_prevent_inline_autocomplete(
prevent_inline_autocomplete || just_deleted_text_ ||
(has_selected_text && inline_autocomplete_text_.empty() &&
prefix_autocompletion_text_.empty()) ||
(has_selected_text && inline_autocompletion_.empty() &&
prefix_autocompletion_.empty()) ||
(paste_state_ != NONE));
input_.set_prefer_keyword(is_keyword_selected());
input_.set_allow_exact_keyword_match(is_keyword_selected() ||
......@@ -1295,7 +1295,7 @@ bool OmniboxEditModel::MaybeStartQueryForPopup() {
void OmniboxEditModel::OnPopupDataChanged(
const base::string16& text,
bool is_temporary_text,
const base::string16& prefix_autocompletion_text,
const base::string16& prefix_autocompletion,
const base::string16& keyword,
bool is_keyword_hint,
const base::string16& additional_text) {
......@@ -1335,8 +1335,8 @@ void OmniboxEditModel::OnPopupDataChanged(
if (save_original_selection) {
// Save the original selection and URL so it can be reverted later.
has_temporary_text_ = true;
inline_autocomplete_text_.clear();
prefix_autocompletion_text_.clear();
inline_autocompletion_.clear();
prefix_autocompletion_.clear();
view_->OnInlineAutocompleteTextCleared();
}
// Arrowing around the popup cancels control-enter.
......@@ -1356,16 +1356,15 @@ void OmniboxEditModel::OnPopupDataChanged(
return;
}
inline_autocomplete_text_ = text;
prefix_autocompletion_text_ = prefix_autocompletion_text;
if (inline_autocomplete_text_.empty() && prefix_autocompletion_text_.empty())
inline_autocompletion_ = text;
prefix_autocompletion_ = prefix_autocompletion;
if (inline_autocompletion_.empty() && prefix_autocompletion_.empty())
view_->OnInlineAutocompleteTextCleared();
const base::string16& user_text =
user_input_in_progress_ ? user_text_ : input_.text();
if (keyword_state_changed && is_keyword_selected() &&
inline_autocomplete_text_.empty() &&
prefix_autocompletion_text_.empty()) {
inline_autocompletion_.empty() && prefix_autocompletion_.empty()) {
// If we reach here, the user most likely entered keyword mode by inserting
// a space between a keyword name and a search string (as pressing space or
// tab after the keyword name alone would have been be handled in
......@@ -1385,8 +1384,8 @@ void OmniboxEditModel::OnPopupDataChanged(
view_->SetWindowTextAndCaretPos(user_text, 0, false, true);
} else {
view_->OnInlineAutocompleteTextMaybeChanged(
prefix_autocompletion_text_ + user_text + inline_autocomplete_text_,
prefix_autocompletion_text_.length(), user_text.length());
prefix_autocompletion_ + user_text + inline_autocompletion_,
prefix_autocompletion_.length(), user_text.length());
view_->SetAdditionalText(additional_text);
}
// We need to invoke OnChanged in case the destination url changed (as could
......@@ -1433,9 +1432,9 @@ bool OmniboxEditModel::OnAfterPossibleChange(
// change any other state, lest arrowing around the omnibox do something like
// reset |just_deleted_text_|. Note that modifying the selection accepts any
// inline autocompletion, which results in a user text change.
if (!state_changes.text_differs && (!state_changes.selection_differs ||
(inline_autocomplete_text_.empty() &&
prefix_autocompletion_text_.empty()))) {
if (!state_changes.text_differs &&
(!state_changes.selection_differs ||
(inline_autocompletion_.empty() && prefix_autocompletion_.empty()))) {
if (state_changes.keyword_differs) {
// We won't need the below logic for creating a keyword by a space at the
// end or in the middle, or by typing a '?', but we do need to update the
......@@ -1567,8 +1566,8 @@ void OmniboxEditModel::InternalSetUserText(const base::string16& text) {
user_text_ = text;
original_user_text_with_keyword_.clear();
just_deleted_text_ = false;
inline_autocomplete_text_.clear();
prefix_autocompletion_text_.clear();
inline_autocompletion_.clear();
prefix_autocompletion_.clear();
view_->OnInlineAutocompleteTextCleared();
}
......
......@@ -361,7 +361,7 @@ class OmniboxEditModel {
// a different match, or the inline autocomplete text.
// |is_temporary_text| is true if |text| contains the temporary text for
// a match, and is false if |text| contains the inline autocomplete text.
// |prefix_autocompletion_text| is the prefix autocomplete text.
// |prefix_autocompletion| is the prefix autocomplete text.
// |destination_for_temporary_text_change| is NULL (if temporary text should
// not change) or the pre-change destination URL (if temporary text should
// change) so we can save it off to restore later.
......@@ -371,13 +371,12 @@ class OmniboxEditModel {
// |additional_text| is additional omnibox text to be displayed adjacent to
// the omnibox view.
// Virtual to allow testing.
virtual void OnPopupDataChanged(
const base::string16& text,
bool is_temporary_text,
const base::string16& prefix_autocompletion_text,
const base::string16& keyword,
bool is_keyword_hint,
const base::string16& additional_text);
virtual void OnPopupDataChanged(const base::string16& text,
bool is_temporary_text,
const base::string16& prefix_autocompletion,
const base::string16& keyword,
bool is_keyword_hint,
const base::string16& additional_text);
// Called by the OmniboxView after something changes, with details about what
// state changes occurred. Updates internal state, updates the popup if
......@@ -579,15 +578,15 @@ class OmniboxEditModel {
base::string16 url_for_remembered_user_selection_;
// Inline autocomplete is allowed if the user has not just deleted text, and
// no temporary text is showing. In this case, inline_autocomplete_text_ is
// no temporary text is showing. In this case, inline_autocompletion_ is
// appended to the user_text_ and displayed selected (at least initially).
//
// NOTE: When the popup is closed there should never be inline autocomplete
// text (actions that close the popup should either accept the text, convert
// it to a normal selection, or change the edit entirely).
bool just_deleted_text_;
base::string16 inline_autocomplete_text_;
base::string16 prefix_autocompletion_text_;
base::string16 inline_autocompletion_;
base::string16 prefix_autocompletion_;
// Used by OnPopupDataChanged to keep track of whether there is currently a
// temporary text.
......
......@@ -216,40 +216,40 @@ TEST_F(OmniboxEditModelTest, AdjustTextForCopyReaderMode) {
TEST_F(OmniboxEditModelTest, DISABLED_InlineAutocompleteText) {
// Test if the model updates the inline autocomplete text in the view.
EXPECT_EQ(base::string16(), view()->inline_autocomplete_text());
EXPECT_EQ(base::string16(), view()->inline_autocompletion());
model()->SetUserText(base::ASCIIToUTF16("he"));
model()->OnPopupDataChanged(base::ASCIIToUTF16("llo"),
/*is_temporary_text=*/false, base::string16(),
base::string16(), false, base::string16());
EXPECT_EQ(base::ASCIIToUTF16("hello"), view()->GetText());
EXPECT_EQ(base::ASCIIToUTF16("llo"), view()->inline_autocomplete_text());
EXPECT_EQ(base::ASCIIToUTF16("llo"), view()->inline_autocompletion());
base::string16 text_before = base::ASCIIToUTF16("he");
base::string16 text_after = base::ASCIIToUTF16("hel");
OmniboxView::StateChanges state_changes{
&text_before, &text_after, 3, 3, false, true, false, false};
model()->OnAfterPossibleChange(state_changes, true);
EXPECT_EQ(base::string16(), view()->inline_autocomplete_text());
EXPECT_EQ(base::string16(), view()->inline_autocompletion());
model()->OnPopupDataChanged(base::ASCIIToUTF16("lo"),
/*is_temporary_text=*/false, base::string16(),
base::string16(), false, base::string16());
EXPECT_EQ(base::ASCIIToUTF16("hello"), view()->GetText());
EXPECT_EQ(base::ASCIIToUTF16("lo"), view()->inline_autocomplete_text());
EXPECT_EQ(base::ASCIIToUTF16("lo"), view()->inline_autocompletion());
model()->Revert();
EXPECT_EQ(base::string16(), view()->GetText());
EXPECT_EQ(base::string16(), view()->inline_autocomplete_text());
EXPECT_EQ(base::string16(), view()->inline_autocompletion());
model()->SetUserText(base::ASCIIToUTF16("he"));
model()->OnPopupDataChanged(base::ASCIIToUTF16("llo"),
/*is_temporary_text=*/false, base::string16(),
base::string16(), false, base::string16());
EXPECT_EQ(base::ASCIIToUTF16("hello"), view()->GetText());
EXPECT_EQ(base::ASCIIToUTF16("llo"), view()->inline_autocomplete_text());
EXPECT_EQ(base::ASCIIToUTF16("llo"), view()->inline_autocompletion());
model()->AcceptTemporaryTextAsUserText();
EXPECT_EQ(base::ASCIIToUTF16("hello"), view()->GetText());
EXPECT_EQ(base::string16(), view()->inline_autocomplete_text());
EXPECT_EQ(base::string16(), view()->inline_autocompletion());
}
// iOS doesn't use elisions in the Omnibox textfield.
......@@ -269,7 +269,7 @@ TEST_F(OmniboxEditModelTest, RespectUnelisionInZeroSuggest) {
EXPECT_TRUE(view()->IsSelectAll());
// Test that we don't clobber the unelided text with inline autocomplete text.
EXPECT_EQ(base::string16(), view()->inline_autocomplete_text());
EXPECT_EQ(base::string16(), view()->inline_autocompletion());
model()->StartZeroSuggestRequest();
model()->OnPopupDataChanged(base::string16(), /*is_temporary_text=*/false,
base::string16(), base::string16(), false,
......
......@@ -52,12 +52,12 @@ class TestOmniboxEditModel : public OmniboxEditModel {
void OnPopupDataChanged(const base::string16& text,
bool is_temporary_text,
const base::string16& prefix_autocompletion_text,
const base::string16& prefix_autocompletion,
const base::string16& keyword,
bool is_keyword_hint,
const base::string16& additional_text) override {
OmniboxEditModel::OnPopupDataChanged(text, is_temporary_text,
prefix_autocompletion_text, keyword,
prefix_autocompletion, keyword,
is_keyword_hint, additional_text);
text_ = text;
is_temporary_text_ = is_temporary_text;
......
......@@ -76,7 +76,7 @@ void TestOmniboxView::OnInlineAutocompleteTextMaybeChanged(
size_t user_text_length) {
const bool text_changed = text_ != display_text;
text_ = display_text;
inline_autocomplete_text_ = display_text.substr(user_text_length);
inline_autocompletion_ = display_text.substr(user_text_length);
// Just like the Views control, only change the selection if the text has
// actually changed.
......@@ -85,7 +85,7 @@ void TestOmniboxView::OnInlineAutocompleteTextMaybeChanged(
}
void TestOmniboxView::OnInlineAutocompleteTextCleared() {
inline_autocomplete_text_.clear();
inline_autocompletion_.clear();
}
void TestOmniboxView::OnRevertTemporaryText(const base::string16& display_text,
......
......@@ -26,8 +26,8 @@ class TestOmniboxView : public OmniboxView {
void SetModel(std::unique_ptr<OmniboxEditModel> model);
const base::string16& inline_autocomplete_text() const {
return inline_autocomplete_text_;
const base::string16& inline_autocompletion() const {
return inline_autocompletion_;
}
static State CreateState(std::string text,
......@@ -82,7 +82,7 @@ class TestOmniboxView : public OmniboxView {
private:
base::string16 text_;
base::string16 inline_autocomplete_text_;
base::string16 inline_autocompletion_;
gfx::Range selection_;
gfx::Range saved_temporary_selection_;
};
......
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