From bd0f9085e5bdbac74cc6e611f758768f15ad5415 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Mon, 11 Mar 2019 11:30:35 -0700 Subject: [PATCH] Adds a platfromViewId to SemanticsNode (#8055) --- lib/ui/semantics.dart | 8 ++++++++ lib/ui/semantics/semantics_node.h | 1 + lib/ui/semantics/semantics_update_builder.cc | 2 ++ lib/ui/semantics/semantics_update_builder.h | 1 + .../android/io/flutter/view/AccessibilityBridge.java | 2 ++ shell/platform/android/platform_view_android.cc | 3 ++- 6 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/ui/semantics.dart b/lib/ui/semantics.dart index b98d36fe2..55fb0367c 100644 --- a/lib/ui/semantics.dart +++ b/lib/ui/semantics.dart @@ -601,6 +601,11 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 { /// The fields 'textSelectionBase' and 'textSelectionExtent' describe the /// currently selected text within `value`. /// + /// The field `platformViewId` references the platform view, whose semantics + /// nodes will be added as children to this node. If a platform view is + /// specified, `childrenInHitTestOrder` and `childrenInTraversalOrder` must be + /// empty. + /// /// For scrollable nodes `scrollPosition` describes the current scroll /// position in logical pixel. `scrollExtentMax` and `scrollExtentMin` /// describe the maximum and minimum in-rage values that `scrollPosition` can @@ -629,6 +634,7 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 { int actions, int textSelectionBase, int textSelectionExtent, + int platformViewId, int scrollChildren, int scrollIndex, double scrollPosition, @@ -656,6 +662,7 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 { actions, textSelectionBase, textSelectionExtent, + platformViewId, scrollChildren, scrollIndex, scrollPosition, @@ -685,6 +692,7 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 { int actions, int textSelectionBase, int textSelectionExtent, + int platformViewId, int scrollChildren, int scrollIndex, double scrollPosition, diff --git a/lib/ui/semantics/semantics_node.h b/lib/ui/semantics/semantics_node.h index f6918e544..16a87a32d 100644 --- a/lib/ui/semantics/semantics_node.h +++ b/lib/ui/semantics/semantics_node.h @@ -86,6 +86,7 @@ struct SemanticsNode { int32_t actions = 0; int32_t textSelectionBase = -1; int32_t textSelectionExtent = -1; + int32_t platformViewId = -1; int32_t scrollChildren = 0; int32_t scrollIndex = 0; double scrollPosition = std::nan(""); diff --git a/lib/ui/semantics/semantics_update_builder.cc b/lib/ui/semantics/semantics_update_builder.cc index 575ba6e32..75cfdcf40 100644 --- a/lib/ui/semantics/semantics_update_builder.cc +++ b/lib/ui/semantics/semantics_update_builder.cc @@ -41,6 +41,7 @@ void SemanticsUpdateBuilder::updateNode( int actions, int textSelectionBase, int textSelectionExtent, + int platformViewId, int scrollChildren, int scrollIndex, double scrollPosition, @@ -68,6 +69,7 @@ void SemanticsUpdateBuilder::updateNode( node.actions = actions; node.textSelectionBase = textSelectionBase; node.textSelectionExtent = textSelectionExtent; + node.platformViewId = platformViewId; node.scrollChildren = scrollChildren; node.scrollIndex = scrollIndex; node.scrollPosition = scrollPosition; diff --git a/lib/ui/semantics/semantics_update_builder.h b/lib/ui/semantics/semantics_update_builder.h index ac8424d9f..fa6201c3d 100644 --- a/lib/ui/semantics/semantics_update_builder.h +++ b/lib/ui/semantics/semantics_update_builder.h @@ -29,6 +29,7 @@ class SemanticsUpdateBuilder int actions, int textSelectionBase, int textSelectionExtent, + int platformViewId, int scrollChildren, int scrollIndex, double scrollPosition, diff --git a/shell/platform/android/io/flutter/view/AccessibilityBridge.java b/shell/platform/android/io/flutter/view/AccessibilityBridge.java index 7d4e5060a..3c262fa9f 100644 --- a/shell/platform/android/io/flutter/view/AccessibilityBridge.java +++ b/shell/platform/android/io/flutter/view/AccessibilityBridge.java @@ -1614,6 +1614,7 @@ public class AccessibilityBridge extends AccessibilityNodeProvider { private int actions; private int textSelectionBase; private int textSelectionExtent; + private int platformViewId; private int scrollChildren; private int scrollIndex; private float scrollPosition; @@ -1748,6 +1749,7 @@ public class AccessibilityBridge extends AccessibilityNodeProvider { actions = buffer.getInt(); textSelectionBase = buffer.getInt(); textSelectionExtent = buffer.getInt(); + platformViewId = buffer.getInt(); scrollChildren = buffer.getInt(); scrollIndex = buffer.getInt(); scrollPosition = buffer.getFloat(); diff --git a/shell/platform/android/platform_view_android.cc b/shell/platform/android/platform_view_android.cc index a66e306c1..f31c08456 100644 --- a/shell/platform/android/platform_view_android.cc +++ b/shell/platform/android/platform_view_android.cc @@ -208,7 +208,7 @@ void PlatformViewAndroid::DispatchSemanticsAction(JNIEnv* env, void PlatformViewAndroid::UpdateSemantics( blink::SemanticsNodeUpdates update, blink::CustomAccessibilityActionUpdates actions) { - constexpr size_t kBytesPerNode = 38 * sizeof(int32_t); + constexpr size_t kBytesPerNode = 39 * sizeof(int32_t); constexpr size_t kBytesPerChild = sizeof(int32_t); constexpr size_t kBytesPerAction = 4 * sizeof(int32_t); @@ -244,6 +244,7 @@ void PlatformViewAndroid::UpdateSemantics( buffer_int32[position++] = node.actions; buffer_int32[position++] = node.textSelectionBase; buffer_int32[position++] = node.textSelectionExtent; + buffer_int32[position++] = node.platformViewId; buffer_int32[position++] = node.scrollChildren; buffer_int32[position++] = node.scrollIndex; buffer_float32[position++] = (float)node.scrollPosition; -- GitLab