From 4a9e6782a769fa6b6b77cda5a02d2e7708f14377 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Wed, 25 Oct 2017 16:02:43 -0700 Subject: [PATCH] Announce the correct new value after increase/decrease has been performed on iOS (#4282) --- lib/ui/semantics.dart | 15 ++++++++++++--- lib/ui/semantics/semantics_node.h | 2 ++ lib/ui/semantics/semantics_update_builder.cc | 4 ++++ lib/ui/semantics/semantics_update_builder.h | 2 ++ .../ios/framework/Source/accessibility_bridge.mm | 2 ++ 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/ui/semantics.dart b/lib/ui/semantics.dart index 3584442880..7d5f537c2c 100644 --- a/lib/ui/semantics.dart +++ b/lib/ui/semantics.dart @@ -215,9 +215,12 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 { /// with an action that is no longer possible. /// /// The `label` is a string that describes this node. The `value` property - /// describes the current value of the node as a string. The `hint` string - /// describes what result an action performed on this node has. The reading - /// direction of all these strings is given by `textDirection`. + /// describes the current value of the node as a string. The `increasedValue` + /// string will become the `value` string after a [SemanticsAction.increase] + /// action is performed. The `decreasedValue` string will become the `value` + /// string after a [SemanticsAction.decrease] action is performed. The `hint` + /// string describes what result an action performed on this node has. The + /// reading direction of all these strings is given by `textDirection`. /// /// The `rect` is the region occupied by this node in its own coordinate /// system. @@ -232,6 +235,8 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 { String label, String hint, String value, + String increasedValue, + String decreasedValue, TextDirection textDirection, Float64List transform, Int32List children @@ -248,6 +253,8 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 { label, hint, value, + increasedValue, + decreasedValue, textDirection != null ? textDirection.index + 1 : 0, transform, children); @@ -263,6 +270,8 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 { String label, String hint, String value, + String increasedValue, + String decreasedValue, int textDirection, Float64List transform, Int32List children diff --git a/lib/ui/semantics/semantics_node.h b/lib/ui/semantics/semantics_node.h index 3c70ac3951..33806bacd1 100644 --- a/lib/ui/semantics/semantics_node.h +++ b/lib/ui/semantics/semantics_node.h @@ -54,6 +54,8 @@ struct SemanticsNode { std::string label; std::string hint; std::string value; + std::string increasedValue; + std::string decreasedValue; int32_t textDirection = 0; // 0=unknown, 1=rtl, 2=ltr SkRect rect = SkRect::MakeEmpty(); diff --git a/lib/ui/semantics/semantics_update_builder.cc b/lib/ui/semantics/semantics_update_builder.cc index 83d6121db0..49de90b6bc 100644 --- a/lib/ui/semantics/semantics_update_builder.cc +++ b/lib/ui/semantics/semantics_update_builder.cc @@ -44,6 +44,8 @@ void SemanticsUpdateBuilder::updateNode(int id, std::string label, std::string hint, std::string value, + std::string increasedValue, + std::string decreasedValue, int textDirection, const tonic::Float64List& transform, const tonic::Int32List& children) { @@ -55,6 +57,8 @@ void SemanticsUpdateBuilder::updateNode(int id, node.label = label; node.hint = hint; node.value = value; + node.increasedValue = increasedValue; + node.decreasedValue = decreasedValue; node.textDirection = textDirection; node.transform.setColMajord(transform.data()); node.children = std::vector( diff --git a/lib/ui/semantics/semantics_update_builder.h b/lib/ui/semantics/semantics_update_builder.h index 23cabfc63e..ae8cbee7ad 100644 --- a/lib/ui/semantics/semantics_update_builder.h +++ b/lib/ui/semantics/semantics_update_builder.h @@ -35,6 +35,8 @@ class SemanticsUpdateBuilder std::string label, std::string hint, std::string value, + std::string increasedValue, + std::string decreasedValue, int textDirection, const tonic::Float64List& transform, const tonic::Int32List& children); diff --git a/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm b/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm index 4467e30e4c..193af2eaa4 100644 --- a/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm +++ b/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm @@ -245,12 +245,14 @@ bool GeometryComparator(SemanticsObject* a, SemanticsObject* b) { - (void)accessibilityIncrement { if (_node.HasAction(blink::SemanticsAction::kIncrease)) { + _node.value = _node.increasedValue; _bridge->DispatchSemanticsAction(_uid, blink::SemanticsAction::kIncrease); } } - (void)accessibilityDecrement { if (_node.HasAction(blink::SemanticsAction::kDecrease)) { + _node.value = _node.decreasedValue; _bridge->DispatchSemanticsAction(_uid, blink::SemanticsAction::kDecrease); } } -- GitLab