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..52e0873c8a63536425313dba08d5c253fcf10a4c 100644 |
| --- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc |
| +++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc |
| @@ -414,8 +414,18 @@ 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 clear_first) { |
| + base::string16 new_string = new_value; |
| + if (!clear_first) { |
| + gfx::Range selection_range = saved_selection_for_focus_change_.IsValid() |
| + ? saved_selection_for_focus_change_ |
| + : GetSelectedRange(); |
| + base::string16 current_text = GetText(); |
| + new_string = current_text.substr(0, selection_range.GetMin()) + new_value + |
| + current_text.substr(selection_range.GetMax()); |
| + } |
| + SetUserText(new_string, true); |
|
dmazzoni
2016/10/26 04:26:02
Could you use InsertOrReplaceText() when clear_fir
Patti Lor
2016/10/27 00:38:48
Thanks for trying to dig deeper on this - I did or
|
| } |
| void OmniboxViewViews::UpdateSecurityLevel() { |
| @@ -739,7 +749,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; |