Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3291)

Unified Diff: chrome/browser/ui/views/omnibox/omnibox_view_views.cc

Issue 2341633006: MacViews/a11y: Allow accessibility clients to update the selected text. (Closed)
Patch Set: Make set value callbacks not have a const bool |replace| arg. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;

Powered by Google App Engine
This is Rietveld 408576698