Flutter Engine
The 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
8#include "flutter/lib/ui/semantics/custom_accessibility_action.h"
9#include "flutter/lib/ui/semantics/semantics_node.h"
10#include "flutter/shell/platform/embedder/embedder.h"
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:
52
54
55 // Get the semantic update. The pointer is only valid while
56 // |EmbedderSemanticsUpdate2| exists.
57 FlutterSemanticsUpdate2* get() { return &update_; }
58
59 private:
60 // These fields hold temporary embedder-specific objects that
61 // must remain valid for the duration of the semantics update callback.
62 // They are automatically cleaned up when |EmbedderSemanticsUpdate2| is
63 // destroyed.
65 std::vector<FlutterSemanticsNode2> nodes_;
66 std::vector<FlutterSemanticsNode2*> node_pointers_;
67 std::vector<FlutterSemanticsCustomAction2> actions_;
68 std::vector<FlutterSemanticsCustomAction2*> action_pointers_;
69
70 std::vector<std::unique_ptr<std::vector<const FlutterStringAttribute*>>>
71 node_string_attributes_;
72 std::vector<std::unique_ptr<FlutterStringAttribute>> string_attributes_;
73 std::vector<std::unique_ptr<FlutterLocaleStringAttribute>> locale_attributes_;
74 std::unique_ptr<FlutterSpellOutStringAttribute> spell_out_attribute_;
75
76 // Translates engine semantic nodes to embedder semantic nodes.
77 void AddNode(const SemanticsNode& node);
78
79 // Translates engine semantic custom actions to embedder semantic custom
80 // actions.
81 void AddAction(const CustomAccessibilityAction& action);
82
83 // A helper struct for |CreateStringAttributes|.
84 struct EmbedderStringAttributes {
85 // The number of string attribute pointers in |attributes|.
86 size_t count;
87 // An array of string attribute pointers.
88 const FlutterStringAttribute** attributes;
89 };
90
91 // Translates engine string attributes to embedder string attributes.
92 EmbedderStringAttributes CreateStringAttributes(
93 const StringAttributes& attribute);
94
95 FML_DISALLOW_COPY_AND_ASSIGN(EmbedderSemanticsUpdate2);
96};
97
98} // namespace flutter
99
100#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_SEMANTICS_UPDATE_H_
#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:1502