Skip to content

Commit

Permalink
Expose platform view ID on embedder semantics node (flutter#13345)
Browse files Browse the repository at this point in the history
This exposes platform_view_id on the embedder API's FlutterSemanticNode.

In bd0f908 (flutter#8055), platformViewId was
added to SemanticsNode. This field is non-zero when the SemanticsNode
represents a platform view and is typically used by embedders as a means
of identifying locations where a platform view's 'native' accessibility
tree should be injected into the platform-specific accessibility tree
constructed by the embedder.

Due to the intended use of this field, the Flutter framework is meant to
enforce that this node has a child count of zero.
  • Loading branch information
cbracken authored Oct 25, 2019
1 parent 29b1725 commit 4f300e6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions shell/platform/embedder/embedder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@ FlutterEngineResult FlutterEngineInitialize(size_t version,
&node.childrenInHitTestOrder[0],
node.customAccessibilityActions.size(),
&node.customAccessibilityActions[0],
node.platformViewId,
};
ptr(&embedder_node, user_data);
}
Expand Down
13 changes: 8 additions & 5 deletions shell/platform/embedder/embedder.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,11 @@ typedef struct {
double bottom;
} FlutterRect;

/// The identifier of the platform view. This identifier is specified by the
/// application when a platform view is added to the scene via the
/// `SceneBuilder.addPlatformView` call.
typedef int64_t FlutterPlatformViewIdentifier;

/// `FlutterSemanticsNode` ID used as a sentinel to signal the end of a batch of
/// semantics node updates.
FLUTTER_EXPORT
Expand Down Expand Up @@ -529,6 +534,9 @@ typedef struct {
/// Array of `FlutterSemanticsCustomAction` IDs associated with this node.
/// Has length `custom_accessibility_actions_count`.
const int32_t* custom_accessibility_actions;
/// Identifier of the platform view associated with this semantics node, or
/// zero if none.
FlutterPlatformViewIdentifier platform_view_id;
} FlutterSemanticsNode;

/// `FlutterSemanticsCustomAction` ID used as a sentinel to signal the end of a
Expand Down Expand Up @@ -653,11 +661,6 @@ typedef struct {
VoidCallback destruction_callback;
} FlutterSoftwareBackingStore;

/// The identifier of the platform view. This identifier is specified by the
/// application when a platform view is added to the scene via the
/// `SceneBuilder.addPlatformView` call.
typedef int64_t FlutterPlatformViewIdentifier;

typedef struct {
/// The size of this struct. Must be sizeof(FlutterPlatformView).
size_t struct_size;
Expand Down
1 change: 1 addition & 0 deletions shell/platform/embedder/fixtures/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ void a11y_main() async { // ignore: non_constant_identifier_names
rect: Rect.fromLTRB(40.0, 40.0, 80.0, 80.0),
transform: kTestTransform,
additionalActions: Int32List.fromList(<int>[21]),
platformViewId: 0x3f3,
)
..updateCustomAction(
id: 21,
Expand Down
6 changes: 6 additions & 0 deletions shell/platform/embedder/tests/embedder_a11y_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ TEST_F(Embedder11yTest, A11yTreeIsConsistent) {
ASSERT_EQ(7.0, node->transform.pers0);
ASSERT_EQ(8.0, node->transform.pers1);
ASSERT_EQ(9.0, node->transform.pers2);

if (node->id == 128) {
ASSERT_EQ(0x3f3, node->platform_view_id);
} else {
ASSERT_EQ(0, node->platform_view_id);
}
}
});

Expand Down

0 comments on commit 4f300e6

Please sign in to comment.