Skip to content

Commit

Permalink
Adds a platfromViewId to SemanticsNode (flutter#8055)
Browse files Browse the repository at this point in the history
  • Loading branch information
goderbauer committed Mar 11, 2019
1 parent a71609f commit bd0f908
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/ui/semantics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -629,6 +634,7 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 {
int actions,
int textSelectionBase,
int textSelectionExtent,
int platformViewId,
int scrollChildren,
int scrollIndex,
double scrollPosition,
Expand Down Expand Up @@ -656,6 +662,7 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 {
actions,
textSelectionBase,
textSelectionExtent,
platformViewId,
scrollChildren,
scrollIndex,
scrollPosition,
Expand Down Expand Up @@ -685,6 +692,7 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 {
int actions,
int textSelectionBase,
int textSelectionExtent,
int platformViewId,
int scrollChildren,
int scrollIndex,
double scrollPosition,
Expand Down
1 change: 1 addition & 0 deletions lib/ui/semantics/semantics_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -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("");
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/semantics/semantics_update_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ void SemanticsUpdateBuilder::updateNode(
int actions,
int textSelectionBase,
int textSelectionExtent,
int platformViewId,
int scrollChildren,
int scrollIndex,
double scrollPosition,
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions lib/ui/semantics/semantics_update_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class SemanticsUpdateBuilder
int actions,
int textSelectionBase,
int textSelectionExtent,
int platformViewId,
int scrollChildren,
int scrollIndex,
double scrollPosition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1614,6 +1614,7 @@ private static boolean nullableHasAncestor(SemanticsNode target, Predicate<Seman
private int actions;
private int textSelectionBase;
private int textSelectionExtent;
private int platformViewId;
private int scrollChildren;
private int scrollIndex;
private float scrollPosition;
Expand Down Expand Up @@ -1748,6 +1749,7 @@ private void updateWith(@NonNull ByteBuffer buffer, @NonNull String[] strings) {
actions = buffer.getInt();
textSelectionBase = buffer.getInt();
textSelectionExtent = buffer.getInt();
platformViewId = buffer.getInt();
scrollChildren = buffer.getInt();
scrollIndex = buffer.getInt();
scrollPosition = buffer.getFloat();
Expand Down
3 changes: 2 additions & 1 deletion shell/platform/android/platform_view_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit bd0f908

Please sign in to comment.