Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit bd0f908

Browse files
authored
Adds a platfromViewId to SemanticsNode (#8055)
1 parent a71609f commit bd0f908

6 files changed

Lines changed: 16 additions & 1 deletion

File tree

lib/ui/semantics.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,11 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 {
601601
/// The fields 'textSelectionBase' and 'textSelectionExtent' describe the
602602
/// currently selected text within `value`.
603603
///
604+
/// The field `platformViewId` references the platform view, whose semantics
605+
/// nodes will be added as children to this node. If a platform view is
606+
/// specified, `childrenInHitTestOrder` and `childrenInTraversalOrder` must be
607+
/// empty.
608+
///
604609
/// For scrollable nodes `scrollPosition` describes the current scroll
605610
/// position in logical pixel. `scrollExtentMax` and `scrollExtentMin`
606611
/// describe the maximum and minimum in-rage values that `scrollPosition` can
@@ -629,6 +634,7 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 {
629634
int actions,
630635
int textSelectionBase,
631636
int textSelectionExtent,
637+
int platformViewId,
632638
int scrollChildren,
633639
int scrollIndex,
634640
double scrollPosition,
@@ -656,6 +662,7 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 {
656662
actions,
657663
textSelectionBase,
658664
textSelectionExtent,
665+
platformViewId,
659666
scrollChildren,
660667
scrollIndex,
661668
scrollPosition,
@@ -685,6 +692,7 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 {
685692
int actions,
686693
int textSelectionBase,
687694
int textSelectionExtent,
695+
int platformViewId,
688696
int scrollChildren,
689697
int scrollIndex,
690698
double scrollPosition,

lib/ui/semantics/semantics_node.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ struct SemanticsNode {
8686
int32_t actions = 0;
8787
int32_t textSelectionBase = -1;
8888
int32_t textSelectionExtent = -1;
89+
int32_t platformViewId = -1;
8990
int32_t scrollChildren = 0;
9091
int32_t scrollIndex = 0;
9192
double scrollPosition = std::nan("");

lib/ui/semantics/semantics_update_builder.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ void SemanticsUpdateBuilder::updateNode(
4141
int actions,
4242
int textSelectionBase,
4343
int textSelectionExtent,
44+
int platformViewId,
4445
int scrollChildren,
4546
int scrollIndex,
4647
double scrollPosition,
@@ -68,6 +69,7 @@ void SemanticsUpdateBuilder::updateNode(
6869
node.actions = actions;
6970
node.textSelectionBase = textSelectionBase;
7071
node.textSelectionExtent = textSelectionExtent;
72+
node.platformViewId = platformViewId;
7173
node.scrollChildren = scrollChildren;
7274
node.scrollIndex = scrollIndex;
7375
node.scrollPosition = scrollPosition;

lib/ui/semantics/semantics_update_builder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class SemanticsUpdateBuilder
2929
int actions,
3030
int textSelectionBase,
3131
int textSelectionExtent,
32+
int platformViewId,
3233
int scrollChildren,
3334
int scrollIndex,
3435
double scrollPosition,

shell/platform/android/io/flutter/view/AccessibilityBridge.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,7 @@ private static boolean nullableHasAncestor(SemanticsNode target, Predicate<Seman
16141614
private int actions;
16151615
private int textSelectionBase;
16161616
private int textSelectionExtent;
1617+
private int platformViewId;
16171618
private int scrollChildren;
16181619
private int scrollIndex;
16191620
private float scrollPosition;
@@ -1748,6 +1749,7 @@ private void updateWith(@NonNull ByteBuffer buffer, @NonNull String[] strings) {
17481749
actions = buffer.getInt();
17491750
textSelectionBase = buffer.getInt();
17501751
textSelectionExtent = buffer.getInt();
1752+
platformViewId = buffer.getInt();
17511753
scrollChildren = buffer.getInt();
17521754
scrollIndex = buffer.getInt();
17531755
scrollPosition = buffer.getFloat();

shell/platform/android/platform_view_android.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ void PlatformViewAndroid::DispatchSemanticsAction(JNIEnv* env,
208208
void PlatformViewAndroid::UpdateSemantics(
209209
blink::SemanticsNodeUpdates update,
210210
blink::CustomAccessibilityActionUpdates actions) {
211-
constexpr size_t kBytesPerNode = 38 * sizeof(int32_t);
211+
constexpr size_t kBytesPerNode = 39 * sizeof(int32_t);
212212
constexpr size_t kBytesPerChild = sizeof(int32_t);
213213
constexpr size_t kBytesPerAction = 4 * sizeof(int32_t);
214214

@@ -244,6 +244,7 @@ void PlatformViewAndroid::UpdateSemantics(
244244
buffer_int32[position++] = node.actions;
245245
buffer_int32[position++] = node.textSelectionBase;
246246
buffer_int32[position++] = node.textSelectionExtent;
247+
buffer_int32[position++] = node.platformViewId;
247248
buffer_int32[position++] = node.scrollChildren;
248249
buffer_int32[position++] = node.scrollIndex;
249250
buffer_float32[position++] = (float)node.scrollPosition;

0 commit comments

Comments
 (0)