Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 6dd49f0

Browse files
authored
iOS a11y text entry (~70% of it) (#4575)
* implement iOS text field editing in a11y mode * address Chinmay's comments * replace node in child list when changing type
1 parent 9bc2efd commit 6dd49f0

28 files changed

+779
-126
lines changed

content_handler/accessibility_bridge.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ AccessibilityBridge::AccessibilityBridge(app::ApplicationContext* context)
2020
: writer_(context->ConnectToEnvironmentService<maxwell::ContextWriter>()) {}
2121

2222
void AccessibilityBridge::UpdateSemantics(
23-
const std::vector<blink::SemanticsNode>& update) {
24-
for (const auto& node : update) {
23+
const blink::SemanticsNodeUpdates& update) {
24+
for (const auto& update : update) {
25+
const auto& node = update.second;
2526
semantics_nodes_[node.id] = node;
2627
}
2728
std::vector<int> visited_nodes;

content_handler/accessibility_bridge.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class AccessibilityBridge {
2121

2222
// Update the internal representation of the semantics nodes, and write the
2323
// semantics to Context Service.
24-
void UpdateSemantics(const std::vector<blink::SemanticsNode>& update);
24+
void UpdateSemantics(const blink::SemanticsNodeUpdates& update);
2525

2626
private:
2727
// Walk the semantics node tree starting at |id|, and store the id of each

content_handler/runtime_holder.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ void RuntimeHolder::Render(std::unique_ptr<flow::LayerTree> layer_tree) {
370370
}));
371371
}
372372

373-
void RuntimeHolder::UpdateSemantics(std::vector<blink::SemanticsNode> update) {
373+
void RuntimeHolder::UpdateSemantics(blink::SemanticsNodeUpdates update) {
374374
accessibility_bridge_->UpdateSemantics(update);
375375
}
376376

content_handler/runtime_holder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class RuntimeHolder : public blink::RuntimeDelegate,
6565
std::string DefaultRouteName() override;
6666
void ScheduleFrame(bool regenerate_layer_tree = true) override;
6767
void Render(std::unique_ptr<flow::LayerTree> layer_tree) override;
68-
void UpdateSemantics(std::vector<blink::SemanticsNode> update) override;
68+
void UpdateSemantics(blink::SemanticsNodeUpdates update) override;
6969
void HandlePlatformMessage(
7070
fxl::RefPtr<blink::PlatformMessage> message) override;
7171
void DidCreateMainIsolate(Dart_Isolate isolate) override;

lib/ui/semantics/semantics_node.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <stdint.h>
99

1010
#include <string>
11+
#include <unordered_map>
1112
#include <vector>
1213

1314
#include "third_party/skia/include/core/SkMatrix44.h"
@@ -70,6 +71,12 @@ struct SemanticsNode {
7071
std::vector<int32_t> children;
7172
};
7273

74+
// Contains semantic nodes that need to be updated.
75+
//
76+
// The keys in the map are stable node IDd, and the values contain
77+
// semantic information for the node corresponding to the ID.
78+
using SemanticsNodeUpdates = std::unordered_map<int32_t, SemanticsNode>;
79+
7380
} // namespace blink
7481

7582
#endif // FLUTTER_LIB_UI_SEMANTICS_SEMANTICS_NODE_H_

lib/ui/semantics/semantics_update.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ IMPLEMENT_WRAPPERTYPEINFO(ui, SemanticsUpdate);
2121
DART_BIND_ALL(SemanticsUpdate, FOR_EACH_BINDING)
2222

2323
fxl::RefPtr<SemanticsUpdate> SemanticsUpdate::create(
24-
std::vector<SemanticsNode> nodes) {
24+
SemanticsNodeUpdates nodes) {
2525
return fxl::MakeRefCounted<SemanticsUpdate>(std::move(nodes));
2626
}
2727

28-
SemanticsUpdate::SemanticsUpdate(std::vector<SemanticsNode> nodes)
28+
SemanticsUpdate::SemanticsUpdate(SemanticsNodeUpdates nodes)
2929
: nodes_(std::move(nodes)) {}
3030

3131
SemanticsUpdate::~SemanticsUpdate() = default;
3232

33-
std::vector<SemanticsNode> SemanticsUpdate::takeNodes() {
33+
SemanticsNodeUpdates SemanticsUpdate::takeNodes() {
3434
return std::move(nodes_);
3535
}
3636

lib/ui/semantics/semantics_update.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
#ifndef FLUTTER_LIB_UI_SEMANTICS_SEMANTICS_UPDATE_H_
66
#define FLUTTER_LIB_UI_SEMANTICS_SEMANTICS_UPDATE_H_
77

8-
#include <vector>
9-
108
#include "flutter/lib/ui/semantics/semantics_node.h"
119
#include "lib/tonic/dart_wrappable.h"
1210

@@ -23,18 +21,18 @@ class SemanticsUpdate : public fxl::RefCountedThreadSafe<SemanticsUpdate>,
2321

2422
public:
2523
~SemanticsUpdate() override;
26-
static fxl::RefPtr<SemanticsUpdate> create(std::vector<SemanticsNode> nodes);
24+
static fxl::RefPtr<SemanticsUpdate> create(SemanticsNodeUpdates nodes);
2725

28-
std::vector<SemanticsNode> takeNodes();
26+
SemanticsNodeUpdates takeNodes();
2927

3028
void dispose();
3129

3230
static void RegisterNatives(tonic::DartLibraryNatives* natives);
3331

3432
private:
35-
explicit SemanticsUpdate(std::vector<SemanticsNode> nodes);
33+
explicit SemanticsUpdate(SemanticsNodeUpdates nodes);
3634

37-
std::vector<SemanticsNode> nodes_;
35+
SemanticsNodeUpdates nodes_;
3836
};
3937

4038
} // namespace blink

lib/ui/semantics/semantics_update_builder.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void SemanticsUpdateBuilder::updateNode(int id,
6969
node.transform.setColMajord(transform.data());
7070
node.children = std::vector<int32_t>(
7171
children.data(), children.data() + children.num_elements());
72-
nodes_.push_back(node);
72+
nodes_[id] = node;
7373
}
7474

7575
fxl::RefPtr<SemanticsUpdate> SemanticsUpdateBuilder::build() {

lib/ui/semantics/semantics_update_builder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class SemanticsUpdateBuilder
5151
private:
5252
explicit SemanticsUpdateBuilder();
5353

54-
std::vector<SemanticsNode> nodes_;
54+
SemanticsNodeUpdates nodes_;
5555
};
5656

5757
} // namespace blink

runtime/runtime_delegate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class RuntimeDelegate {
2020
virtual std::string DefaultRouteName() = 0;
2121
virtual void ScheduleFrame(bool regenerate_layer_tree = true) = 0;
2222
virtual void Render(std::unique_ptr<flow::LayerTree> layer_tree) = 0;
23-
virtual void UpdateSemantics(std::vector<SemanticsNode> update) = 0;
23+
virtual void UpdateSemantics(blink::SemanticsNodeUpdates update) = 0;
2424
virtual void HandlePlatformMessage(fxl::RefPtr<PlatformMessage> message) = 0;
2525

2626
virtual void DidCreateMainIsolate(Dart_Isolate isolate);

0 commit comments

Comments
 (0)