Chromium Code Reviews| Index: chrome/browser/ui/views/omnibox/omnibox_view_views.cc |
| diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc |
| index 98ad3e568cb4cac06b580895a55fe1527c25a65f..f8856e693968e8a7ed369c22c3f5f9304737dd89 100644 |
| --- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc |
| +++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc |
| @@ -414,8 +414,19 @@ bool OmniboxViewViews::HandleEarlyTabActions(const ui::KeyEvent& event) { |
| return true; |
| } |
| -void OmniboxViewViews::AccessibilitySetValue(const base::string16& new_value) { |
| - SetUserText(new_value, true); |
| +void OmniboxViewViews::AccessibilitySetValue(const base::string16& new_value, |
| + bool replace) { |
| + base::string16 new_string = new_value; |
| + if (replace) { |
| + gfx::Range selection_range = saved_selection_for_focus_change_.IsValid() |
| + ? saved_selection_for_focus_change_ |
| + : GetSelectedRange(); |
| + base::string16 current_text = GetText(); |
| + base::string16 new_string = |
|
dmazzoni
2016/10/25 17:21:49
This definitely looks wrong. You're declaring a ne
Patti Lor
2016/10/26 00:57:15
Ah - thanks for picking up on that! I'm surprised
|
| + current_text.substr(0, selection_range.GetMin()) + new_value + |
| + current_text.substr(selection_range.GetMax()); |
| + } |
| + SetUserText(new_string, true); |
| } |
| void OmniboxViewViews::UpdateSecurityLevel() { |
| @@ -739,7 +750,14 @@ void OmniboxViewViews::GetAccessibleState(ui::AXViewState* state) { |
| base::string16::size_type entry_start; |
| base::string16::size_type entry_end; |
| - GetSelectionBounds(&entry_start, &entry_end); |
| + // Selection information is saved separately when focus is moved off the |
| + // current window - use that when there is no focus and it's valid. |
| + if (saved_selection_for_focus_change_.IsValid()) { |
| + entry_start = saved_selection_for_focus_change_.start(); |
| + entry_end = saved_selection_for_focus_change_.end(); |
| + } else { |
| + GetSelectionBounds(&entry_start, &entry_end); |
| + } |
| state->selection_start = entry_start; |
| state->selection_end = entry_end; |