Flutter Engine
 
Loading...
Searching...
No Matches
embedder_semantics_update.h
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
5#ifndef FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_SEMANTICS_UPDATE_H_
6#define FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_SEMANTICS_UPDATE_H_
7
11
12namespace flutter {
13
14// A semantic update, used by the embedder API's v1 and v2 semantic update
15// callbacks.
17 public:
20
22
23 // Get the semantic update. The pointer is only valid while
24 // |EmbedderSemanticsUpdate| exists.
25 FlutterSemanticsUpdate* get() { return &update_; }
26
27 private:
29 std::vector<FlutterSemanticsNode> nodes_;
30 std::vector<FlutterSemanticsCustomAction> actions_;
31
32 // Translates engine semantic nodes to embedder semantic nodes.
33 void AddNode(const SemanticsNode& node);
34
35 // Translates engine semantic custom actions to embedder semantic custom
36 // actions.
37 void AddAction(const CustomAccessibilityAction& action);
38
40};
41
42// A semantic update, used by the embedder API's v3 semantic update callback.
43//
44// This holds temporary embedder-specific objects that are translated from
45// the engine's internal representation and passed back to the semantics
46// update callback. Once the callback finishes, this object is destroyed
47// and the temporary embedder-specific objects are automatically cleaned up.
49 public:
51 const SemanticsNodeUpdates& nodes,
53
55
56 // Get the semantic update. The pointer is only valid while
57 // |EmbedderSemanticsUpdate2| exists.
58 FlutterSemanticsUpdate2* get() { return &update_; }
59
60 private:
61 // These fields hold temporary embedder-specific objects that
62 // must remain valid for the duration of the semantics update callback.
63 // They are automatically cleaned up when |EmbedderSemanticsUpdate2| is
64 // destroyed.
66 std::vector<FlutterSemanticsNode2> nodes_;
67 std::vector<FlutterSemanticsNode2*> node_pointers_;
68 std::vector<FlutterSemanticsCustomAction2> actions_;
69 std::vector<FlutterSemanticsCustomAction2*> action_pointers_;
70 std::vector<std::unique_ptr<FlutterSemanticsFlags>> flags_;
71
72 std::vector<std::unique_ptr<std::vector<const FlutterStringAttribute*>>>
73 node_string_attributes_;
74 std::vector<std::unique_ptr<FlutterStringAttribute>> string_attributes_;
75 std::vector<std::unique_ptr<FlutterLocaleStringAttribute>> locale_attributes_;
76 std::unique_ptr<FlutterSpellOutStringAttribute> spell_out_attribute_;
77
78 // Translates engine semantic nodes to embedder semantic nodes.
79 void AddNode(const SemanticsNode& node);
80
81 // Translates engine semantic custom actions to embedder semantic custom
82 // actions.
83 void AddAction(const CustomAccessibilityAction& action);
84
85 // A helper struct for |CreateStringAttributes|.
86 struct EmbedderStringAttributes {
87 // The number of string attribute pointers in |attributes|.
88 size_t count;
89 // An array of string attribute pointers.
90 const FlutterStringAttribute** attributes;
91 };
92
93 // Translates engine string attributes to embedder string attributes.
94 EmbedderStringAttributes CreateStringAttributes(
95 const StringAttributes& attribute);
96
97 FML_DISALLOW_COPY_AND_ASSIGN(EmbedderSemanticsUpdate2);
98};
99
100} // namespace flutter
101
102#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_SEMANTICS_UPDATE_H_
G_BEGIN_DECLS FlutterViewId view_id
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
std::unordered_map< int32_t, SemanticsNode > SemanticsNodeUpdates
std::unordered_map< int32_t, CustomAccessibilityAction > CustomAccessibilityActionUpdates
std::vector< StringAttributePtr > StringAttributes
A batch of updates to semantics nodes and custom actions.
Definition embedder.h:1796