From c4fb8a6051cfcb03b04d1a245be73fb9fbeeadc5 Mon Sep 17 00:00:00 2001 From: Zachary Anderson Date: Thu, 19 Aug 2021 14:40:34 -0700 Subject: [PATCH] Revert "Adds semantics tooltip support (#27893)" (flutter/engine#28207) This reverts commit 366e66802a35abf55bcb649b9bf58921b174b59a. --- engine/src/flutter/lib/ui/semantics.dart | 26 ++++----- .../flutter/lib/ui/semantics/semantics_node.h | 1 - .../ui/semantics/semantics_update_builder.cc | 2 - .../ui/semantics/semantics_update_builder.h | 1 - .../lib/src/engine/semantics/semantics.dart | 24 ++++---- .../lib/web_ui/lib/src/ui/semantics.dart | 12 ++-- .../test/engine/semantics/semantics_test.dart | 12 ---- .../engine/semantics/semantics_tester.dart | 12 ---- .../io/flutter/view/AccessibilityBridge.java | 34 ----------- .../platform_view_android_delegate.cc | 9 +-- ...latform_view_android_delegate_unittests.cc | 10 +--- .../flutter/view/AccessibilityBridgeTest.java | 44 --------------- .../ios/framework/Source/SemanticsObject.mm | 14 ++--- .../framework/Source/SemanticsObjectTest.mm | 16 ------ .../platform/embedder/fixtures/main.dart | 56 ++++++------------- .../fuchsia/flutter/accessibility_bridge.cc | 9 --- .../flutter/accessibility_bridge_unittest.cc | 46 --------------- .../lib/src/locale_initialization.dart | 12 ---- .../lib/src/send_text_focus_semantics.dart | 12 ---- 19 files changed, 49 insertions(+), 303 deletions(-) diff --git a/engine/src/flutter/lib/ui/semantics.dart b/engine/src/flutter/lib/ui/semantics.dart index 08c539c4a2f..b702109bc42 100644 --- a/engine/src/flutter/lib/ui/semantics.dart +++ b/engine/src/flutter/lib/ui/semantics.dart @@ -800,9 +800,6 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass1 { /// and `decreasedValue` respectively. Their contents must not be changed during /// the semantics update. /// - /// The `tooltip` is a string that describe additional information when user - /// hover or long press on the backing widget of this semantics node. - /// /// The fields `textSelectionBase` and `textSelectionExtent` describe the /// currently selected text within `value`. A value of -1 indicates no /// current text selection base or extent. @@ -860,16 +857,15 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass1 { required double thickness, required Rect rect, required String label, - required List labelAttributes, + List? labelAttributes, required String value, - required List valueAttributes, + List? valueAttributes, required String increasedValue, - required List increasedValueAttributes, + List? increasedValueAttributes, required String decreasedValue, - required List decreasedValueAttributes, + List? decreasedValueAttributes, required String hint, - required List hintAttributes, - String? tooltip, + List? hintAttributes, TextDirection? textDirection, required Float64List transform, required Int32List childrenInTraversalOrder, @@ -911,7 +907,6 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass1 { decreasedValueAttributes, hint, hintAttributes, - tooltip, textDirection != null ? textDirection.index + 1 : 0, transform, childrenInTraversalOrder, @@ -940,16 +935,15 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass1 { double elevation, double thickness, String label, - List labelAttributes, + List? labelAttributes, String value, - List valueAttributes, + List? valueAttributes, String increasedValue, - List increasedValueAttributes, + List? increasedValueAttributes, String decreasedValue, - List decreasedValueAttributes, + List? decreasedValueAttributes, String hint, - List hintAttributes, - String? tooltip, + List? hintAttributes, int textDirection, Float64List transform, Int32List childrenInTraversalOrder, diff --git a/engine/src/flutter/lib/ui/semantics/semantics_node.h b/engine/src/flutter/lib/ui/semantics/semantics_node.h index 6fc4d733d69..b75d94eb5a0 100644 --- a/engine/src/flutter/lib/ui/semantics/semantics_node.h +++ b/engine/src/flutter/lib/ui/semantics/semantics_node.h @@ -131,7 +131,6 @@ struct SemanticsNode { StringAttributes increasedValueAttributes; std::string decreasedValue; StringAttributes decreasedValueAttributes; - std::string tooltip; int32_t textDirection = 0; // 0=unknown, 1=rtl, 2=ltr SkRect rect = SkRect::MakeEmpty(); // Local space, relative to parent. diff --git a/engine/src/flutter/lib/ui/semantics/semantics_update_builder.cc b/engine/src/flutter/lib/ui/semantics/semantics_update_builder.cc index e1b1a6adad5..beae3a3b1e4 100644 --- a/engine/src/flutter/lib/ui/semantics/semantics_update_builder.cc +++ b/engine/src/flutter/lib/ui/semantics/semantics_update_builder.cc @@ -76,7 +76,6 @@ void SemanticsUpdateBuilder::updateNode( std::vector decreasedValueAttributes, std::string hint, std::vector hintAttributes, - std::string tooltip, int textDirection, const tonic::Float64List& transform, const tonic::Int32List& childrenInTraversalOrder, @@ -115,7 +114,6 @@ void SemanticsUpdateBuilder::updateNode( pushStringAttributes(node.decreasedValueAttributes, decreasedValueAttributes); node.hint = hint; pushStringAttributes(node.hintAttributes, hintAttributes); - node.tooltip = tooltip; node.textDirection = textDirection; SkScalar scalarTransform[16]; for (int i = 0; i < 16; ++i) { diff --git a/engine/src/flutter/lib/ui/semantics/semantics_update_builder.h b/engine/src/flutter/lib/ui/semantics/semantics_update_builder.h index 6f83e471d2c..96c29a1bcea 100644 --- a/engine/src/flutter/lib/ui/semantics/semantics_update_builder.h +++ b/engine/src/flutter/lib/ui/semantics/semantics_update_builder.h @@ -55,7 +55,6 @@ class SemanticsUpdateBuilder std::vector decreasedValueAttributes, std::string hint, std::vector hintAttributes, - std::string tooltip, int textDirection, const tonic::Float64List& transform, const tonic::Int32List& childrenInTraversalOrder, diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/semantics/semantics.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/semantics/semantics.dart index fbd06b16fda..4e544c5fe12 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/semantics/semantics.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/semantics/semantics.dart @@ -78,16 +78,15 @@ class SemanticsNodeUpdate { required this.scrollExtentMin, required this.rect, required this.label, - required this.labelAttributes, + this.labelAttributes, required this.hint, - required this.hintAttributes, + this.hintAttributes, required this.value, - required this.valueAttributes, + this.valueAttributes, required this.increasedValue, - required this.increasedValueAttributes, + this.increasedValueAttributes, required this.decreasedValue, - required this.decreasedValueAttributes, - this.tooltip, + this.decreasedValueAttributes, this.textDirection, required this.transform, required this.elevation, @@ -143,34 +142,31 @@ class SemanticsNodeUpdate { final String label; /// See [ui.SemanticsUpdateBuilder.updateNode]. - final List labelAttributes; + final List? labelAttributes; /// See [ui.SemanticsUpdateBuilder.updateNode]. final String hint; /// See [ui.SemanticsUpdateBuilder.updateNode]. - final List hintAttributes; + final List? hintAttributes; /// See [ui.SemanticsUpdateBuilder.updateNode]. final String value; /// See [ui.SemanticsUpdateBuilder.updateNode]. - final List valueAttributes; + final List? valueAttributes; /// See [ui.SemanticsUpdateBuilder.updateNode]. final String increasedValue; /// See [ui.SemanticsUpdateBuilder.updateNode]. - final List increasedValueAttributes; + final List? increasedValueAttributes; /// See [ui.SemanticsUpdateBuilder.updateNode]. final String decreasedValue; /// See [ui.SemanticsUpdateBuilder.updateNode]. - final List decreasedValueAttributes; - - /// See [ui.SemanticsUpdateBuilder.updateNode]. - final String? tooltip; + final List? decreasedValueAttributes; /// See [ui.SemanticsUpdateBuilder.updateNode]. final ui.TextDirection? textDirection; diff --git a/engine/src/flutter/lib/web_ui/lib/src/ui/semantics.dart b/engine/src/flutter/lib/web_ui/lib/src/ui/semantics.dart index 59adfda24e2..f3a6ca21a71 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/ui/semantics.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/ui/semantics.dart @@ -349,16 +349,15 @@ class SemanticsUpdateBuilder { required double thickness, required Rect rect, required String label, - required List labelAttributes, + List? labelAttributes, required String value, - required List valueAttributes, + List? valueAttributes, required String increasedValue, - required List increasedValueAttributes, + List? increasedValueAttributes, required String decreasedValue, - required List decreasedValueAttributes, + List? decreasedValueAttributes, required String hint, - required List hintAttributes, - String? tooltip, + List? hintAttributes, TextDirection? textDirection, required Float64List transform, required Int32List childrenInTraversalOrder, @@ -391,7 +390,6 @@ class SemanticsUpdateBuilder { decreasedValueAttributes: decreasedValueAttributes, hint: hint, hintAttributes: hintAttributes, - tooltip: tooltip, textDirection: textDirection, transform: engine.toMatrix32(transform), elevation: elevation, diff --git a/engine/src/flutter/lib/web_ui/test/engine/semantics/semantics_test.dart b/engine/src/flutter/lib/web_ui/test/engine/semantics/semantics_test.dart index d3ba3c33c6f..3af88c138d6 100644 --- a/engine/src/flutter/lib/web_ui/test/engine/semantics/semantics_test.dart +++ b/engine/src/flutter/lib/web_ui/test/engine/semantics/semantics_test.dart @@ -1488,16 +1488,10 @@ void updateNode( double thickness = 0.0, ui.Rect rect = ui.Rect.zero, String label = '', - List labelAttributes = const [], String hint = '', - List hintAttributes = const [], String value = '', - List valueAttributes = const [], String increasedValue = '', - List increasedValueAttributes = const [], String decreasedValue = '', - List decreasedValueAttributes = const [], - String tooltip = '', ui.TextDirection textDirection = ui.TextDirection.ltr, Float64List? transform, Int32List? childrenInTraversalOrder, @@ -1526,16 +1520,10 @@ void updateNode( thickness: thickness, rect: rect, label: label, - labelAttributes: labelAttributes, hint: hint, - hintAttributes: hintAttributes, value: value, - valueAttributes: valueAttributes, increasedValue: increasedValue, - increasedValueAttributes: increasedValueAttributes, decreasedValue: decreasedValue, - decreasedValueAttributes: decreasedValueAttributes, - tooltip: tooltip, textDirection: textDirection, transform: transform, childrenInTraversalOrder: childrenInTraversalOrder, diff --git a/engine/src/flutter/lib/web_ui/test/engine/semantics/semantics_tester.dart b/engine/src/flutter/lib/web_ui/test/engine/semantics/semantics_tester.dart index 87712016434..b812c8de983 100644 --- a/engine/src/flutter/lib/web_ui/test/engine/semantics/semantics_tester.dart +++ b/engine/src/flutter/lib/web_ui/test/engine/semantics/semantics_tester.dart @@ -115,16 +115,10 @@ class SemanticsTester { double? thickness, ui.Rect? rect, String? label, - List? labelAttributes, String? hint, - List? hintAttributes, String? value, - List? valueAttributes, String? increasedValue, - List? increasedValueAttributes, String? decreasedValue, - List? decreasedValueAttributes, - String? tooltip, ui.TextDirection? textDirection, Float64List? transform, Int32List? additionalActions, @@ -312,16 +306,10 @@ class SemanticsTester { scrollExtentMin: scrollExtentMin ?? 0, rect: effectiveRect, label: label ?? '', - labelAttributes: labelAttributes ?? const [], hint: hint ?? '', - hintAttributes: hintAttributes ?? const [], value: value ?? '', - valueAttributes: valueAttributes ?? const [], increasedValue: increasedValue ?? '', - increasedValueAttributes: increasedValueAttributes ?? const [], decreasedValue: decreasedValue ?? '', - decreasedValueAttributes: decreasedValueAttributes ?? const [], - tooltip: tooltip ?? '', transform: transform != null ? toMatrix32(transform) : Matrix4.identity().storage, elevation: elevation ?? 0, thickness: thickness ?? 0, diff --git a/engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java b/engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java index 3894721d907..b88301dabd6 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java @@ -266,15 +266,6 @@ public class AccessibilityBridge extends AccessibilityNodeProvider { /** The user has opened a tooltip. */ @Override public void onTooltip(@NonNull String message) { - // Native Android tooltip is no longer announced when it pops up after API 28 and is - // handled by - // AccessibilityNodeInfo.setTooltipText instead. - // - // To reproduce native behavior, see - // https://developer.android.com/guide/topics/ui/tooltips. - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - return; - } AccessibilityEvent e = obtainAccessibilityEvent(ROOT_NODE_ID, AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); e.getText().add(message); @@ -829,31 +820,15 @@ public class AccessibilityBridge extends AccessibilityNodeProvider { result.setLiveRegion(View.ACCESSIBILITY_LIVE_REGION_POLITE); } - // Scopes routes are not focusable, only need to set the content - // for non-scopes-routes semantics nodes. if (semanticsNode.hasFlag(Flag.IS_TEXT_FIELD)) { result.setText(semanticsNode.getValueLabelHint()); } else if (!semanticsNode.hasFlag(Flag.SCOPES_ROUTE)) { CharSequence content = semanticsNode.getValueLabelHint(); - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) { - if (semanticsNode.tooltip != null) { - // For backward compatibility with Flutter SDK before Android API - // level 28, the tooltip is appended at the end of content description. - content = content != null ? content : ""; - content = content + "\n" + semanticsNode.tooltip; - } - } if (content != null) { result.setContentDescription(content); } } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - if (semanticsNode.tooltip != null) { - result.setTooltipText(semanticsNode.tooltip); - } - } - boolean hasCheckedState = semanticsNode.hasFlag(Flag.HAS_CHECKED_STATE); boolean hasToggledState = semanticsNode.hasFlag(Flag.HAS_TOGGLED_STATE); if (BuildConfig.DEBUG && (hasCheckedState && hasToggledState)) { @@ -2213,12 +2188,6 @@ public class AccessibilityBridge extends AccessibilityNodeProvider { private String hint; private List hintAttributes; - // The textual description of the backing widget's tooltip. - // - // The tooltip is attached through AccessibilityNodInfo.setTooltipText if - // API level >= 28; otherwise, this is attached to the end of content description. - @Nullable private String tooltip; - // The id of the sibling node that is before this node in traversal // order. // @@ -2421,9 +2390,6 @@ public class AccessibilityBridge extends AccessibilityNodeProvider { hintAttributes = getStringAttributesFromBuffer(buffer, stringAttributeArgs); - stringIndex = buffer.getInt(); - tooltip = stringIndex == -1 ? null : strings[stringIndex]; - textDirection = TextDirection.fromInt(buffer.getInt()); left = buffer.getFloat(); diff --git a/engine/src/flutter/shell/platform/android/platform_view_android_delegate/platform_view_android_delegate.cc b/engine/src/flutter/shell/platform/android/platform_view_android_delegate/platform_view_android_delegate.cc index 8cfa5bed47a..1f6522f86a9 100644 --- a/engine/src/flutter/shell/platform/android/platform_view_android_delegate/platform_view_android_delegate.cc +++ b/engine/src/flutter/shell/platform/android/platform_view_android_delegate/platform_view_android_delegate.cc @@ -42,7 +42,7 @@ PlatformViewAndroidDelegate::PlatformViewAndroidDelegate( void PlatformViewAndroidDelegate::UpdateSemantics( flutter::SemanticsNodeUpdates update, flutter::CustomAccessibilityActionUpdates actions) { - constexpr size_t kBytesPerNode = 47 * sizeof(int32_t); + constexpr size_t kBytesPerNode = 46 * sizeof(int32_t); constexpr size_t kBytesPerChild = sizeof(int32_t); constexpr size_t kBytesPerCustomAction = sizeof(int32_t); constexpr size_t kBytesPerAction = 4 * sizeof(int32_t); @@ -148,13 +148,6 @@ void PlatformViewAndroidDelegate::UpdateSemantics( putStringAttributesIntoBuffer(node.hintAttributes, buffer_int32, position, string_attribute_args); - if (node.tooltip.empty()) { - buffer_int32[position++] = -1; - } else { - buffer_int32[position++] = strings.size(); - strings.push_back(node.tooltip); - } - buffer_int32[position++] = node.textDirection; buffer_float32[position++] = node.rect.left(); buffer_float32[position++] = node.rect.top(); diff --git a/engine/src/flutter/shell/platform/android/platform_view_android_delegate/platform_view_android_delegate_unittests.cc b/engine/src/flutter/shell/platform/android/platform_view_android_delegate/platform_view_android_delegate_unittests.cc index 6c370e4ae2f..674544b176a 100644 --- a/engine/src/flutter/shell/platform/android/platform_view_android_delegate/platform_view_android_delegate_unittests.cc +++ b/engine/src/flutter/shell/platform/android/platform_view_android_delegate/platform_view_android_delegate_unittests.cc @@ -19,10 +19,9 @@ TEST(PlatformViewShell, UpdateSemanticsDoesFlutterViewUpdateSemantics) { flutter::SemanticsNode node0; node0.id = 0; node0.label = "label"; - node0.tooltip = "tooltip"; update.insert(std::make_pair(0, std::move(node0))); - std::vector expected_buffer(188); + std::vector expected_buffer(184); std::vector> expected_string_attribute_args(0); size_t position = 0; int32_t* buffer_int32 = reinterpret_cast(&expected_buffer[0]); @@ -52,8 +51,6 @@ TEST(PlatformViewShell, UpdateSemanticsDoesFlutterViewUpdateSemantics) { buffer_int32[position++] = -1; // node0.decreasedValueAttributes buffer_int32[position++] = -1; // node0.hint buffer_int32[position++] = -1; // node0.hintAttributes - buffer_int32[position++] = expected_strings.size(); // node0.tooltip - expected_strings.push_back(node0.tooltip); buffer_int32[position++] = node0.textDirection; buffer_float32[position++] = node0.rect.left(); buffer_float32[position++] = node0.rect.top(); @@ -96,7 +93,7 @@ TEST(PlatformViewShell, node0.hintAttributes.push_back(locale_attribute); update.insert(std::make_pair(0, std::move(node0))); - std::vector expected_buffer(220); + std::vector expected_buffer(216); std::vector> expected_string_attribute_args; size_t position = 0; int32_t* buffer_int32 = reinterpret_cast(&expected_buffer[0]); @@ -135,10 +132,9 @@ TEST(PlatformViewShell, buffer_int32[position++] = 3; // node0.hintAttributes[0].end buffer_int32[position++] = 1; // node0.hintAttributes[0].type buffer_int32[position++] = - expected_string_attribute_args.size(); // node0.hintAttributes[0].args + expected_string_attribute_args.size(); // node0.labelAttributes[0].args expected_string_attribute_args.push_back( {locale_attribute->locale.begin(), locale_attribute->locale.end()}); - buffer_int32[position++] = -1; // node0.tooltip buffer_int32[position++] = node0.textDirection; buffer_float32[position++] = node0.rect.left(); buffer_float32[position++] = node0.rect.top(); diff --git a/engine/src/flutter/shell/platform/android/test/io/flutter/view/AccessibilityBridgeTest.java b/engine/src/flutter/shell/platform/android/test/io/flutter/view/AccessibilityBridgeTest.java index c2ea02f6ae9..49df2d82ea1 100644 --- a/engine/src/flutter/shell/platform/android/test/io/flutter/view/AccessibilityBridgeTest.java +++ b/engine/src/flutter/shell/platform/android/test/io/flutter/view/AccessibilityBridgeTest.java @@ -719,43 +719,6 @@ public class AccessibilityBridgeTest { assertEquals(actual.getSpanEnd(spellOutSpan), 9); } - @TargetApi(28) - @Test - public void itSetsTooltipCorrectly() { - AccessibilityChannel mockChannel = mock(AccessibilityChannel.class); - AccessibilityViewEmbedder mockViewEmbedder = mock(AccessibilityViewEmbedder.class); - AccessibilityManager mockManager = mock(AccessibilityManager.class); - View mockRootView = mock(View.class); - Context context = mock(Context.class); - when(mockRootView.getContext()).thenReturn(context); - when(context.getPackageName()).thenReturn("test"); - AccessibilityBridge accessibilityBridge = - setUpBridge( - /*rootAccessibilityView=*/ mockRootView, - /*accessibilityChannel=*/ mockChannel, - /*accessibilityManager=*/ mockManager, - /*contentResolver=*/ null, - /*accessibilityViewEmbedder=*/ mockViewEmbedder, - /*platformViewsAccessibilityDelegate=*/ null); - - ViewParent mockParent = mock(ViewParent.class); - when(mockRootView.getParent()).thenReturn(mockParent); - when(mockManager.isEnabled()).thenReturn(true); - // Create a node with tooltip. - TestSemanticsNode root = new TestSemanticsNode(); - root.id = 0; - root.tooltip = "tooltip"; - - TestSemanticsUpdate testSemanticsUpdate = root.toUpdate(); - testSemanticsUpdate.sendUpdateToBridge(accessibilityBridge); - - // Test the generated AccessibilityNodeInfo for the node we created - // and verify it has correct tooltip text. - AccessibilityNodeInfo nodeInfo = accessibilityBridge.createAccessibilityNodeInfo(0); - CharSequence actual = nodeInfo.getTooltipText(); - assertEquals(actual.toString(), root.tooltip); - } - @TargetApi(21) @Test public void itCanCreateAccessibilityNodeInfoWithSetText() { @@ -1589,7 +1552,6 @@ public class AccessibilityBridgeTest { List decreasedValueAttributes; String hint = null; List hintAttributes; - String tooltip = null; int textDirection = 0; float left = 0.0f; float top = 0.0f; @@ -1641,12 +1603,6 @@ public class AccessibilityBridgeTest { updateString(increasedValue, increasedValueAttributes, bytes, strings, stringAttributeArgs); updateString(decreasedValue, decreasedValueAttributes, bytes, strings, stringAttributeArgs); updateString(hint, hintAttributes, bytes, strings, stringAttributeArgs); - if (tooltip == null) { - bytes.putInt(-1); - } else { - strings.add(tooltip); - bytes.putInt(strings.size() - 1); - } bytes.putInt(textDirection); bytes.putFloat(left); bytes.putFloat(top); diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm index 04048ea8d66..5109b087314 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm @@ -610,16 +610,10 @@ CGRect ConvertRectToGlobal(SemanticsObject* reference, CGRect local_rect) { - (NSString*)accessibilityLabel { if (![self isAccessibilityBridgeAlive]) return nil; - NSString* label; - if (![self node].label.empty()) { - label = @([self node].label.data()); - } - if (![self node].tooltip.empty()) { - label = [NSString stringWithFormat:@"%@%@", - label ? [NSString stringWithFormat:@"%@\n", label] : @"", - @([self node].tooltip.data())]; - } - return label; + + if ([self node].label.empty()) + return nil; + return @([self node].label.data()); } - (NSAttributedString*)accessibilityAttributedLabel { diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm index 4dfe87b57c3..046112ee83f 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm @@ -468,22 +468,6 @@ class MockAccessibilityBridgeNoWindow : public AccessibilityBridgeIos { XCTAssertTrue([scrollable_object.accessibilityHint isEqualToString:@"hint"]); } -- (void)testFlutterSemanticsObjectMergeTooltipToLabel { - flutter::MockAccessibilityBridge* mock = new flutter::MockAccessibilityBridge(); - mock->isVoiceOverRunningValue = true; - fml::WeakPtrFactory factory(mock); - fml::WeakPtr bridge = factory.GetWeakPtr(); - - flutter::SemanticsNode node; - node.rect = SkRect::MakeXYWH(0, 0, 100, 200); - node.label = "label"; - node.tooltip = "tooltip"; - FlutterSemanticsObject* object = [[FlutterSemanticsObject alloc] initWithBridge:bridge uid:0]; - [object setSemanticsNode:&node]; - XCTAssertTrue(object.isAccessibilityElement); - XCTAssertTrue([object.accessibilityLabel isEqualToString:@"label\ntooltip"]); -} - - (void)testFlutterScrollableSemanticsObjectReturnsParentContainerIfNoChildren { flutter::MockAccessibilityBridge* mock = new flutter::MockAccessibilityBridge(); mock->isVoiceOverRunningValue = true; diff --git a/engine/src/flutter/shell/platform/embedder/fixtures/main.dart b/engine/src/flutter/shell/platform/embedder/fixtures/main.dart index 5866aa0a09e..bd2232b656f 100644 --- a/engine/src/flutter/shell/platform/embedder/fixtures/main.dart +++ b/engine/src/flutter/shell/platform/embedder/fixtures/main.dart @@ -120,7 +120,6 @@ void a11y_main() async { ..updateNode( id: 42, label: 'A: root', - labelAttributes: [], rect: Rect.fromLTRB(0.0, 0.0, 10.0, 10.0), transform: kTestTransform, childrenInTraversalOrder: Int32List.fromList([84, 96]), @@ -139,21 +138,15 @@ void a11y_main() async { scrollExtentMin: 0.0, elevation: 0.0, thickness: 0.0, - hint: '', - hintAttributes: [], - value: '', - valueAttributes: [], - increasedValue: '', - increasedValueAttributes: [], - decreasedValue: '', - decreasedValueAttributes: [], - tooltip: '', + hint: "", + value: "", + increasedValue: "", + decreasedValue: "", additionalActions: Int32List(0), ) ..updateNode( id: 84, label: 'B: leaf', - labelAttributes: [], rect: Rect.fromLTRB(40.0, 40.0, 80.0, 80.0), transform: kTestTransform, actions: 0, @@ -170,15 +163,10 @@ void a11y_main() async { scrollExtentMin: 0.0, elevation: 0.0, thickness: 0.0, - hint: '', - hintAttributes: [], - value: '', - valueAttributes: [], - increasedValue: '', - increasedValueAttributes: [], - decreasedValue: '', - decreasedValueAttributes: [], - tooltip: '', + hint: "", + value: "", + increasedValue: "", + decreasedValue: "", additionalActions: Int32List(0), childrenInHitTestOrder: Int32List(0), childrenInTraversalOrder: Int32List(0), @@ -186,7 +174,6 @@ void a11y_main() async { ..updateNode( id: 96, label: 'C: branch', - labelAttributes: [], rect: Rect.fromLTRB(40.0, 40.0, 80.0, 80.0), transform: kTestTransform, childrenInTraversalOrder: Int32List.fromList([128]), @@ -205,21 +192,15 @@ void a11y_main() async { scrollExtentMin: 0.0, elevation: 0.0, thickness: 0.0, - hint: '', - hintAttributes: [], - value: '', - valueAttributes: [], - increasedValue: '', - increasedValueAttributes: [], - decreasedValue: '', - decreasedValueAttributes: [], - tooltip: '', + hint: "", + value: "", + increasedValue: "", + decreasedValue: "", additionalActions: Int32List(0), ) ..updateNode( id: 128, label: 'D: leaf', - labelAttributes: [], rect: Rect.fromLTRB(40.0, 40.0, 80.0, 80.0), transform: kTestTransform, additionalActions: Int32List.fromList([21]), @@ -237,15 +218,10 @@ void a11y_main() async { scrollExtentMin: 0.0, elevation: 0.0, thickness: 0.0, - hint: '', - hintAttributes: [], - value: '', - valueAttributes: [], - increasedValue: '', - increasedValueAttributes: [], - decreasedValue: '', - decreasedValueAttributes: [], - tooltip: '', + hint: "", + value: "", + increasedValue: "", + decreasedValue: "", childrenInHitTestOrder: Int32List(0), childrenInTraversalOrder: Int32List(0), ) diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/accessibility_bridge.cc b/engine/src/flutter/shell/platform/fuchsia/flutter/accessibility_bridge.cc index 76a1da4a53b..1493d11f75a 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/accessibility_bridge.cc +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/accessibility_bridge.cc @@ -331,15 +331,6 @@ AccessibilityBridge::GetNodeAttributes(const flutter::SemanticsNode& node, *added_size += node.label.size(); } - if (node.tooltip.size() > fuchsia::accessibility::semantics::MAX_LABEL_SIZE) { - attributes.set_secondary_label(node.tooltip.substr( - 0, fuchsia::accessibility::semantics::MAX_LABEL_SIZE)); - *added_size += fuchsia::accessibility::semantics::MAX_LABEL_SIZE; - } else { - attributes.set_secondary_label(node.tooltip); - *added_size += node.tooltip.size(); - } - if (node.HasFlag(flutter::SemanticsFlags::kIsKeyboardKey)) { attributes.set_is_keyboard_key(true); } diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/accessibility_bridge_unittest.cc b/engine/src/flutter/shell/platform/fuchsia/flutter/accessibility_bridge_unittest.cc index 61ba6d4cfc8..6f06e792362 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/accessibility_bridge_unittest.cc +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/accessibility_bridge_unittest.cc @@ -585,52 +585,6 @@ TEST_F(AccessibilityBridgeTest, TruncatesLargeLabel) { EXPECT_FALSE(semantics_manager_.UpdateOverflowed()); } -TEST_F(AccessibilityBridgeTest, TruncatesLargeToolTip) { - // Test that tooltips which are too long are truncated. - flutter::SemanticsNode node0; - node0.id = 0; - - flutter::SemanticsNode node1; - node1.id = 1; - - flutter::SemanticsNode bad_node; - bad_node.id = 2; - bad_node.tooltip = - std::string(fuchsia::accessibility::semantics::MAX_LABEL_SIZE + 1, '2'); - - node0.childrenInTraversalOrder = {1, 2}; - node0.childrenInHitTestOrder = {1, 2}; - - accessibility_bridge_->AddSemanticsNodeUpdate( - { - {0, node0}, - {1, node1}, - {2, bad_node}, - }, - 1.f); - RunLoopUntilIdle(); - - // Nothing to delete, but we should have broken - EXPECT_EQ(0, semantics_manager_.DeleteCount()); - EXPECT_EQ(1, semantics_manager_.UpdateCount()); - EXPECT_EQ(1, semantics_manager_.CommitCount()); - EXPECT_EQ(3U, semantics_manager_.LastUpdatedNodes().size()); - auto trimmed_node = - std::find_if(semantics_manager_.LastUpdatedNodes().begin(), - semantics_manager_.LastUpdatedNodes().end(), - [id = static_cast(bad_node.id)]( - fuchsia::accessibility::semantics::Node const& node) { - return node.node_id() == id; - }); - ASSERT_NE(trimmed_node, semantics_manager_.LastUpdatedNodes().end()); - ASSERT_TRUE(trimmed_node->has_attributes()); - EXPECT_EQ( - trimmed_node->attributes().secondary_label(), - std::string(fuchsia::accessibility::semantics::MAX_LABEL_SIZE, '2')); - EXPECT_FALSE(semantics_manager_.DeleteOverflowed()); - EXPECT_FALSE(semantics_manager_.UpdateOverflowed()); -} - TEST_F(AccessibilityBridgeTest, TruncatesLargeValue) { // Test that values which are too long are truncated. flutter::SemanticsNode node0; diff --git a/engine/src/flutter/testing/scenario_app/lib/src/locale_initialization.dart b/engine/src/flutter/testing/scenario_app/lib/src/locale_initialization.dart index d6a9afcdae5..1a9d73fd433 100644 --- a/engine/src/flutter/testing/scenario_app/lib/src/locale_initialization.dart +++ b/engine/src/flutter/testing/scenario_app/lib/src/locale_initialization.dart @@ -52,7 +52,6 @@ class LocaleInitialization extends Scenario { actions: 1, rect: const Rect.fromLTRB(0.0, 0.0, 414.0, 48.0), label: window.locales.toString(), - labelAttributes: [], textDirection: TextDirection.ltr, textSelectionBase: -1, textSelectionExtent: -1, @@ -68,14 +67,9 @@ class LocaleInitialization extends Scenario { elevation: 0.0, thickness: 0.0, hint: '', - hintAttributes: [], value: '', - valueAttributes: [], increasedValue: '', - increasedValueAttributes: [], decreasedValue: '', - decreasedValueAttributes: [], - tooltip: '', childrenInTraversalOrder: Int32List(0), childrenInHitTestOrder: Int32List(0), additionalActions: Int32List(0), @@ -107,7 +101,6 @@ class LocaleInitialization extends Scenario { actions: 1, rect: const Rect.fromLTRB(0.0, 0.0, 414.0, 48.0), label: label, - labelAttributes: [], textDirection: TextDirection.ltr, textSelectionBase: 0, textSelectionExtent: 0, @@ -123,14 +116,9 @@ class LocaleInitialization extends Scenario { elevation: 0.0, thickness: 0.0, hint: '', - hintAttributes: [], value: '', - valueAttributes: [], increasedValue: '', - increasedValueAttributes: [], decreasedValue: '', - decreasedValueAttributes: [], - tooltip: '', childrenInTraversalOrder: Int32List(0), childrenInHitTestOrder: Int32List(0), additionalActions: Int32List(0), diff --git a/engine/src/flutter/testing/scenario_app/lib/src/send_text_focus_semantics.dart b/engine/src/flutter/testing/scenario_app/lib/src/send_text_focus_semantics.dart index 7ecc04b7d04..94997cf0701 100644 --- a/engine/src/flutter/testing/scenario_app/lib/src/send_text_focus_semantics.dart +++ b/engine/src/flutter/testing/scenario_app/lib/src/send_text_focus_semantics.dart @@ -47,7 +47,6 @@ class SendTextFocusSemantics extends Scenario { actions: 1, rect: const Rect.fromLTRB(0.0, 0.0, 414.0, 48.0), label: 'flutter textfield', - labelAttributes: [], textDirection: TextDirection.ltr, textSelectionBase: -1, textSelectionExtent: -1, @@ -63,14 +62,9 @@ class SendTextFocusSemantics extends Scenario { elevation: 0.0, thickness: 0.0, hint: '', - hintAttributes: [], value: '', - valueAttributes: [], increasedValue: '', - increasedValueAttributes: [], decreasedValue: '', - decreasedValueAttributes: [], - tooltip: '', childrenInTraversalOrder: Int32List(0), childrenInHitTestOrder: Int32List(0), additionalActions: Int32List(0), @@ -110,7 +104,6 @@ class SendTextFocusSemantics extends Scenario { actions: 18433, rect: const Rect.fromLTRB(0.0, 0.0, 414.0, 48.0), label: 'focused flutter textfield', - labelAttributes: [], textDirection: TextDirection.ltr, textSelectionBase: 0, textSelectionExtent: 0, @@ -126,14 +119,9 @@ class SendTextFocusSemantics extends Scenario { elevation: 0.0, thickness: 0.0, hint: '', - hintAttributes: [], value: '', - valueAttributes: [], increasedValue: '', - increasedValueAttributes: [], decreasedValue: '', - decreasedValueAttributes: [], - tooltip: '', childrenInTraversalOrder: Int32List(0), childrenInHitTestOrder: Int32List(0), additionalActions: Int32List(0),