Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
semantics_update_builder.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
7#include <utility>
8
11#include "third_party/skia/include/core/SkScalar.h"
16
17namespace flutter {
18
20 StringAttributes& destination,
21 const std::vector<NativeStringAttribute*>& native_attributes) {
22 for (const auto& native_attribute : native_attributes) {
23 destination.push_back(native_attribute->GetAttribute());
24 }
25}
26
28
29SemanticsUpdateBuilder::SemanticsUpdateBuilder() = default;
30
32
34 int id,
35 Dart_Handle flags,
36 int actions,
37 int maxValueLength,
38 int currentValueLength,
39 int textSelectionBase,
40 int textSelectionExtent,
41 int platformViewId,
42 int scrollChildren,
43 int scrollIndex,
44 int traversalParent,
45 double scrollPosition,
46 double scrollExtentMax,
47 double scrollExtentMin,
48 double left,
49 double top,
50 double right,
51 double bottom,
52 std::string identifier,
53 std::string label,
54 const std::vector<NativeStringAttribute*>& labelAttributes,
55 std::string value,
56 const std::vector<NativeStringAttribute*>& valueAttributes,
57 std::string increasedValue,
58 const std::vector<NativeStringAttribute*>& increasedValueAttributes,
59 std::string decreasedValue,
60 const std::vector<NativeStringAttribute*>& decreasedValueAttributes,
61 std::string hint,
62 const std::vector<NativeStringAttribute*>& hintAttributes,
63 std::string tooltip,
64 int textDirection,
65 const tonic::Float64List& transform,
66 const tonic::Float64List& hitTestTransform,
67 const tonic::Int32List& childrenInTraversalOrder,
68 const tonic::Int32List& childrenInHitTestOrder,
69 const tonic::Int32List& localContextActions,
70 int headingLevel,
71 std::string linkUrl,
72 int role,
73 const std::vector<std::string>& controlsNodes,
74 int validationResult,
75 int hitTestBehavior,
76 int inputType,
77 std::string locale,
78 std::string minValue,
79 std::string maxValue) {
80 FML_CHECK(scrollChildren == 0 ||
81 (scrollChildren > 0 && childrenInHitTestOrder.data()))
82 << "Semantics update contained scrollChildren but did not have "
83 "childrenInHitTestOrder";
84 SemanticsNode node;
85 node.id = id;
86 auto* flags_object =
88 node.flags = flags_object->GetFlags();
89 node.actions = actions;
90 node.maxValueLength = maxValueLength;
91 node.currentValueLength = currentValueLength;
92 node.textSelectionBase = textSelectionBase;
93 node.textSelectionExtent = textSelectionExtent;
94 node.platformViewId = platformViewId;
95 node.scrollChildren = scrollChildren;
96 node.scrollIndex = scrollIndex;
97 node.traversalParent = traversalParent;
98 node.scrollPosition = scrollPosition;
99 node.scrollExtentMax = scrollExtentMax;
100 node.scrollExtentMin = scrollExtentMin;
101 node.minValue = std::move(minValue);
102 node.maxValue = std::move(maxValue);
103 node.rect = SkRect::MakeLTRB(SafeNarrow(left), SafeNarrow(top),
104 SafeNarrow(right), SafeNarrow(bottom));
105 node.identifier = std::move(identifier);
106 node.label = std::move(label);
107 pushStringAttributes(node.labelAttributes, labelAttributes);
108 node.value = std::move(value);
109 pushStringAttributes(node.valueAttributes, valueAttributes);
110 node.increasedValue = std::move(increasedValue);
111 pushStringAttributes(node.increasedValueAttributes, increasedValueAttributes);
112 node.decreasedValue = std::move(decreasedValue);
113 pushStringAttributes(node.decreasedValueAttributes, decreasedValueAttributes);
114 node.hint = std::move(hint);
115 pushStringAttributes(node.hintAttributes, hintAttributes);
116 node.tooltip = std::move(tooltip);
117 node.textDirection = textDirection;
118 SkScalar scalarTransform[16];
119 for (int i = 0; i < 16; ++i) {
120 scalarTransform[i] = SafeNarrow(transform.data()[i]);
121 }
122 node.transform = SkM44::ColMajor(scalarTransform);
123 SkScalar scalarHitTestTransform[16];
124 for (int i = 0; i < 16; ++i) {
125 scalarHitTestTransform[i] = SafeNarrow(hitTestTransform.data()[i]);
126 }
127 node.hitTestTransform = SkM44::ColMajor(scalarHitTestTransform);
129 std::vector<int32_t>(childrenInTraversalOrder.data(),
130 childrenInTraversalOrder.data() +
131 childrenInTraversalOrder.num_elements());
132 node.childrenInHitTestOrder = std::vector<int32_t>(
133 childrenInHitTestOrder.data(),
134 childrenInHitTestOrder.data() + childrenInHitTestOrder.num_elements());
135 node.customAccessibilityActions = std::vector<int32_t>(
136 localContextActions.data(),
137 localContextActions.data() + localContextActions.num_elements());
138 node.headingLevel = headingLevel;
139 node.linkUrl = std::move(linkUrl);
140 node.role = static_cast<SemanticsRole>(role);
141 node.validationResult =
142 static_cast<SemanticsValidationResult>(validationResult);
143 node.locale = std::move(locale);
144
145 nodes_[id] = node;
146}
147
149 std::string label,
150 std::string hint,
151 int overrideId) {
153 action.id = id;
154 action.overrideId = overrideId;
155 action.label = std::move(label);
156 action.hint = std::move(hint);
157 actions_[id] = action;
158}
159
160void SemanticsUpdateBuilder::build(Dart_Handle semantics_update_handle) {
161 SemanticsUpdate::create(semantics_update_handle, std::move(nodes_),
162 std::move(actions_));
164}
165
166} // namespace flutter
void build(Dart_Handle semantics_update_handle)
void updateCustomAction(int id, std::string label, std::string hint, int overrideId)
void updateNode(int id, Dart_Handle flags, int actions, int maxValueLength, int currentValueLength, int textSelectionBase, int textSelectionExtent, int platformViewId, int scrollChildren, int scrollIndex, int traversalParent, double scrollPosition, double scrollExtentMax, double scrollExtentMin, double left, double top, double right, double bottom, std::string identifier, std::string label, const std::vector< NativeStringAttribute * > &labelAttributes, std::string value, const std::vector< NativeStringAttribute * > &valueAttributes, std::string increasedValue, const std::vector< NativeStringAttribute * > &increasedValueAttributes, std::string decreasedValue, const std::vector< NativeStringAttribute * > &decreasedValueAttributes, std::string hint, const std::vector< NativeStringAttribute * > &hintAttributes, std::string tooltip, int textDirection, const tonic::Float64List &transform, const tonic::Float64List &hitTestTransform, const tonic::Int32List &childrenInTraversalOrder, const tonic::Int32List &childrenInHitTestOrder, const tonic::Int32List &customAccessibilityActions, int headingLevel, std::string linkUrl, int role, const std::vector< std::string > &controlsNodes, int validationResult, int hitTestBehavior, int inputType, std::string locale, std::string minValue, std::string maxValue)
static void create(Dart_Handle semantics_update_handle, SemanticsNodeUpdates nodes, CustomAccessibilityActionUpdates actions)
#define IMPLEMENT_WRAPPERTYPEINFO(LibraryName, ClassName)
int32_t value
#define FML_CHECK(condition)
Definition logging.h:104
void pushStringAttributes(StringAttributes &destination, const std::vector< NativeStringAttribute * > &native_attributes)
SemanticsValidationResult
static float SafeNarrow(double value)
std::vector< StringAttributePtr > StringAttributes
StringAttributes decreasedValueAttributes
StringAttributes hintAttributes
StringAttributes increasedValueAttributes
StringAttributes valueAttributes
StringAttributes labelAttributes
std::vector< int32_t > childrenInHitTestOrder
SemanticsValidationResult validationResult
std::vector< int32_t > customAccessibilityActions
std::vector< int32_t > childrenInTraversalOrder
const uintptr_t id