Skip to content

Commit

Permalink
Swap setTraversalBefore to setTraversalAfter, since setTraversalBefor…
Browse files Browse the repository at this point in the history
…e is broken. (flutter#4656)

It seems that setTraversalBefore doesn't work as well as setTraversalAfter for some reason, although I'm using them the same way. Some apps would lock up TalkBack when traversing if setTraversalBefore was set, but not with the equivalent setTraversalAfter.

It's not entirely clear why this is, but I'm going with this to at least get it fixed for apps we know about.

Addresses flutter/flutter#14600

See also flutter/flutter#14607
  • Loading branch information
gspencergoog authored Feb 12, 2018
1 parent ab3b3a6 commit f5a4a93
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions lib/ui/semantics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 {
String increasedValue,
String decreasedValue,
TextDirection textDirection,
int nextNodeId,
int previousNodeId,
Float64List transform,
Int32List children,
}) {
Expand All @@ -423,7 +423,7 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 {
increasedValue,
decreasedValue,
textDirection != null ? textDirection.index + 1 : 0,
nextNodeId ?? -1,
previousNodeId ?? -1,
transform,
children,);
}
Expand All @@ -446,7 +446,7 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 {
String increasedValue,
String decreasedValue,
int textDirection,
int nextNodeId,
int previousNodeId,
Float64List transform,
Int32List children,
) native 'SemanticsUpdateBuilder_updateNode';
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/semantics/semantics_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct SemanticsNode {
std::string increasedValue;
std::string decreasedValue;
int32_t textDirection = 0; // 0=unknown, 1=rtl, 2=ltr
int32_t nextNodeId = -1;
int32_t previousNodeId = -1;

SkRect rect = SkRect::MakeEmpty();
SkMatrix44 transform = SkMatrix44(SkMatrix44::kIdentity_Constructor);
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/semantics/semantics_update_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void SemanticsUpdateBuilder::updateNode(int id,
std::string increasedValue,
std::string decreasedValue,
int textDirection,
int nextNodeId,
int previousNodeId,
const tonic::Float64List& transform,
const tonic::Int32List& children) {
SemanticsNode node;
Expand All @@ -71,7 +71,7 @@ void SemanticsUpdateBuilder::updateNode(int id,
node.increasedValue = increasedValue;
node.decreasedValue = decreasedValue;
node.textDirection = textDirection;
node.nextNodeId = nextNodeId;
node.previousNodeId = previousNodeId;
node.transform.setColMajord(transform.data());
node.children = std::vector<int32_t>(
children.data(), children.data() + children.num_elements());
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/semantics/semantics_update_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class SemanticsUpdateBuilder
std::string increasedValue,
std::string decreasedValue,
int textDirection,
int nextNodeId,
int previousNodeId,
const tonic::Float64List& transform,
const tonic::Int32List& children);

Expand Down
10 changes: 5 additions & 5 deletions shell/platform/android/io/flutter/view/AccessibilityBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ public AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId) {

result.setSelected(object.hasFlag(Flag.IS_SELECTED));
result.setText(object.getValueLabelHint());
result.setTraversalBefore(mOwner,
object.nextNodeId == -1 ? View.NO_ID : object.nextNodeId);
result.setTraversalAfter(mOwner,
object.previousNodeId == -1 ? View.NO_ID : object.previousNodeId);

// Accessibility Focus
if (mA11yFocusedObject != null && mA11yFocusedObject.id == virtualViewId) {
Expand Down Expand Up @@ -693,7 +693,7 @@ private class SemanticsObject {
String decreasedValue;
String hint;
TextDirection textDirection;
int nextNodeId;
int previousNodeId;

boolean hadPreviousConfig = false;
int previousFlags;
Expand Down Expand Up @@ -746,7 +746,7 @@ boolean didScroll() {
void log(String indent, boolean recursive) {
Log.i(TAG, indent + "SemanticsObject id=" + id + " label=" + label + " actions=" + actions + " flags=" + flags + "\n" +
indent + " +-- textDirection=" + textDirection + "\n"+
indent + " +-- nextNodeId=" + nextNodeId + "\n"+
indent + " +-- previousNodeId=" + previousNodeId + "\n"+
indent + " +-- rect.ltrb=(" + left + ", " + top + ", " + right + ", " + bottom + ")\n" +
indent + " +-- transform=" + Arrays.toString(transform) + "\n");
if (children != null && recursive) {
Expand Down Expand Up @@ -793,7 +793,7 @@ void updateWith(ByteBuffer buffer, String[] strings) {

textDirection = TextDirection.fromInt(buffer.getInt());

nextNodeId = buffer.getInt();
previousNodeId = buffer.getInt();

left = buffer.getFloat();
top = buffer.getFloat();
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/android/platform_view_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ void PlatformViewAndroid::UpdateSemantics(
strings.push_back(node.hint);
}
buffer_int32[position++] = node.textDirection;
buffer_int32[position++] = node.nextNodeId;
buffer_int32[position++] = node.previousNodeId;
buffer_float32[position++] = node.rect.left();
buffer_float32[position++] = node.rect.top();
buffer_float32[position++] = node.rect.right();
Expand Down

0 comments on commit f5a4a93

Please sign in to comment.