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

Unified Diff: ui/views/controls/textfield/textfield.cc

Issue 2341633006: MacViews/a11y: Allow accessibility clients to update the selected text. (Closed)
Patch Set: Move accessibility notification for text selection being changed to SelectRange() instead. Created 4 years, 3 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: ui/views/controls/textfield/textfield.cc
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc
index c0a889cd339ca675907ca3dedfd1adc1d9b1c6f1..cdc773873cede1250cf6c3e3c213614f09d86fe5 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -486,6 +486,7 @@ const gfx::Range& Textfield::GetSelectedRange() const {
void Textfield::SelectRange(const gfx::Range& range) {
model_->SelectRange(range);
UpdateAfterChange(false, true);
+ NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_SELECTION_CHANGED, true);
}
const gfx::SelectionModel& Textfield::GetSelectionModel() const {
@@ -937,6 +938,9 @@ void Textfield::GetAccessibleState(ui::AXViewState* state) {
state->set_value_callback =
base::Bind(&Textfield::AccessibilitySetValue,
weak_ptr_factory_.GetWeakPtr());
+ state->replace_selection_callback =
+ base::Bind(&Textfield::AccessibilityReplaceSelection,
+ weak_ptr_factory_.GetWeakPtr());
}
}
@@ -1777,6 +1781,13 @@ void Textfield::AccessibilitySetValue(const base::string16& new_value) {
}
}
+void Textfield::AccessibilityReplaceSelection(const base::string16& new_value) {
+ if (!read_only()) {
+ InsertOrReplaceText(new_value);
+ ClearSelection();
tapted 2016/09/27 07:16:30 do we want to extend the selection here too?
Patti Lor 2016/10/20 04:19:34 No - Cocoa doesn't, so I was following that behavi
+ }
+}
+
void Textfield::UpdateBackgroundColor() {
const SkColor color = GetBackgroundColor();
if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {

Powered by Google App Engine
This is Rietveld 408576698