Commit d2b21bc2 authored by Kevin Bailey's avatar Kevin Bailey Committed by Commit Bot

[omnibox] Clean up arrow key handling

I missed a call to new function SelectionAtEnd(), and new function
could be implemented in a manner more consistent with the rest of
the file.

Bug: 868511
Change-Id: Ic5cfaba9ad4413ba5a9f7b311468ba11cd8037b6
Reviewed-on: https://chromium-review.googlesource.com/1195642
Commit-Queue: Kevin Bailey <krb@chromium.org>
Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587541}
parent 2d63f7b7
...@@ -240,10 +240,8 @@ void OmniboxViewViews::InstallPlaceholderText() { ...@@ -240,10 +240,8 @@ void OmniboxViewViews::InstallPlaceholderText() {
} }
bool OmniboxViewViews::SelectionAtEnd() { bool OmniboxViewViews::SelectionAtEnd() {
size_t start, end; const gfx::Range sel = GetSelectedRange();
GetSelectionBounds(&start, &end); return sel.GetMax() == text().size();
end = std::max(start, end);
return end == text().size();
} }
void OmniboxViewViews::EmphasizeURLComponents() { void OmniboxViewViews::EmphasizeURLComponents() {
...@@ -557,7 +555,7 @@ bool OmniboxViewViews::IsSelectAll() const { ...@@ -557,7 +555,7 @@ bool OmniboxViewViews::IsSelectAll() const {
void OmniboxViewViews::UpdatePopup() { void OmniboxViewViews::UpdatePopup() {
// Prevent inline autocomplete when the caret isn't at the end of the text. // Prevent inline autocomplete when the caret isn't at the end of the text.
const gfx::Range sel = GetSelectedRange(); const gfx::Range sel = GetSelectedRange();
model()->UpdateInput(!sel.is_empty(), sel.GetMax() < text().length()); model()->UpdateInput(!sel.is_empty(), !SelectionAtEnd());
} }
void OmniboxViewViews::ApplyCaretVisibility() { void OmniboxViewViews::ApplyCaretVisibility() {
...@@ -1314,11 +1312,8 @@ bool OmniboxViewViews::HandleKeyEvent(views::Textfield* textfield, ...@@ -1314,11 +1312,8 @@ bool OmniboxViewViews::HandleKeyEvent(views::Textfield* textfield,
case ui::VKEY_LEFT: case ui::VKEY_LEFT:
if (!(control || alt || shift)) { if (!(control || alt || shift)) {
size_t start, end; if (SelectionAtEnd() &&
GetSelectionBounds(&start, &end); // Can be null in tests.
end = std::max(start, end);
if (end == text().size() &&
// Can be nil in tests.
model()->popup_model() && model()->popup_model() &&
model()->popup_model()->SelectedLineHasTabMatch() && model()->popup_model()->SelectedLineHasTabMatch() &&
model()->popup_model()->selected_line_state() == model()->popup_model()->selected_line_state() ==
...@@ -1378,10 +1373,7 @@ bool OmniboxViewViews::HandleKeyEvent(views::Textfield* textfield, ...@@ -1378,10 +1373,7 @@ bool OmniboxViewViews::HandleKeyEvent(views::Textfield* textfield,
case ui::VKEY_SPACE: case ui::VKEY_SPACE:
if (!(control || alt || shift)) { if (!(control || alt || shift)) {
size_t start, end; if (SelectionAtEnd() &&
GetSelectionBounds(&start, &end);
end = std::max(start, end);
if (end == text().size() &&
model()->popup_model()->SelectedLineHasTabMatch() && model()->popup_model()->SelectedLineHasTabMatch() &&
model()->popup_model()->selected_line_state() == model()->popup_model()->selected_line_state() ==
OmniboxPopupModel::TAB_SWITCH) { OmniboxPopupModel::TAB_SWITCH) {
......
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