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

Commit 8ecc23d

Browse files
authored
Remove dead code for recreating a11y node delegates (#43359)
This PR removes some dead code for recreating a11y node delegates. These code was used to refresh a11y information when the macOS embedder live swapped view controllers, but have become obsolete since #39145 removed the support for such live swapping. ## Pre-launch Checklist - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [ ] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [ ] I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See [testing the engine] for instructions on writing and running engine tests. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I signed the [CLA]. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style [testing the engine]: https://github.com/flutter/flutter/wiki/Testing-the-engine [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat
1 parent 60f328d commit 8ecc23d

File tree

6 files changed

+0
-70
lines changed

6 files changed

+0
-70
lines changed

shell/platform/common/accessibility_bridge.cc

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -149,18 +149,6 @@ AccessibilityBridge::GetPendingEvents() const {
149149
return result;
150150
}
151151

152-
void AccessibilityBridge::RecreateNodeDelegates() {
153-
for (const auto& [node_id, old_platform_node_delegate] : id_wrapper_map_) {
154-
std::shared_ptr<FlutterPlatformNodeDelegate> platform_node_delegate =
155-
CreateFlutterPlatformNodeDelegate();
156-
platform_node_delegate->Init(
157-
std::static_pointer_cast<FlutterPlatformNodeDelegate::OwnerBridge>(
158-
shared_from_this()),
159-
old_platform_node_delegate->GetAXNode());
160-
id_wrapper_map_[node_id] = platform_node_delegate;
161-
}
162-
}
163-
164152
void AccessibilityBridge::OnNodeWillBeDeleted(ui::AXTree* tree,
165153
ui::AXNode* node) {}
166154

shell/platform/common/accessibility_bridge.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,16 +157,6 @@ class AccessibilityBridge
157157
virtual std::shared_ptr<FlutterPlatformNodeDelegate>
158158
CreateFlutterPlatformNodeDelegate() = 0;
159159

160-
//------------------------------------------------------------------------------
161-
/// @brief Recreate all FlutterPlatformNodeDelegates.
162-
///
163-
/// This can be useful for subclasses when updating some
164-
/// properties that are used by node delegates, such as views.
165-
/// Each node is recreated using
166-
/// CreateFlutterPlatformNodeDelegate, then initialized using
167-
/// AXNodes from their corresponding old one.
168-
void RecreateNodeDelegates();
169-
170160
private:
171161
// See FlutterSemanticsNode in embedder.h
172162
typedef struct {

shell/platform/common/accessibility_bridge_unittests.cc

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -205,40 +205,6 @@ TEST(AccessibilityBridgeTest, CanFireChildrenChangedCorrectly) {
205205
Contains(ui::AXEventGenerator::Event::SUBTREE_CREATED));
206206
}
207207

208-
TEST(AccessibilityBridgeTest, CanRecreateNodeDelegates) {
209-
std::shared_ptr<TestAccessibilityBridge> bridge =
210-
std::make_shared<TestAccessibilityBridge>();
211-
212-
std::vector<int32_t> children{1};
213-
FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root", &children);
214-
FlutterSemanticsNode2 child1 = CreateSemanticsNode(1, "child 1");
215-
216-
bridge->AddFlutterSemanticsNodeUpdate(root);
217-
bridge->AddFlutterSemanticsNodeUpdate(child1);
218-
bridge->CommitUpdates();
219-
220-
auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0);
221-
auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(1);
222-
EXPECT_FALSE(root_node.expired());
223-
EXPECT_FALSE(child1_node.expired());
224-
225-
bridge->RecreateNodeDelegates();
226-
227-
// Old tree is destroyed.
228-
EXPECT_TRUE(root_node.expired());
229-
EXPECT_TRUE(child1_node.expired());
230-
231-
// New tree still has the data.
232-
auto new_root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
233-
auto new_child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
234-
EXPECT_EQ(new_root_node->GetChildCount(), 1);
235-
EXPECT_EQ(new_root_node->GetData().child_ids[0], 1);
236-
EXPECT_EQ(new_root_node->GetName(), "root");
237-
238-
EXPECT_EQ(new_child1_node->GetChildCount(), 0);
239-
EXPECT_EQ(new_child1_node->GetName(), "child 1");
240-
}
241-
242208
TEST(AccessibilityBridgeTest, CanHandleSelectionChangeCorrectly) {
243209
std::shared_ptr<TestAccessibilityBridge> bridge =
244210
std::make_shared<TestAccessibilityBridge>();

shell/platform/common/test_accessibility_bridge.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ namespace flutter {
1111

1212
class TestAccessibilityBridge : public AccessibilityBridge {
1313
public:
14-
using AccessibilityBridge::RecreateNodeDelegates;
15-
1614
TestAccessibilityBridge() = default;
1715

1816
void DispatchAccessibilityAction(AccessibilityNodeId target,

shell/platform/darwin/macos/framework/Source/AccessibilityBridgeMac.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@ class AccessibilityBridgeMac : public AccessibilityBridge {
4040
FlutterSemanticsAction action,
4141
fml::MallocMapping data) override;
4242

43-
// Update the default view controller, and recreate the corresponding
44-
// accessibility node delegate.
45-
//
46-
// This is called by the engine when the default view controller is updated.
47-
void UpdateDefaultViewController(__weak FlutterViewController* view_controller);
48-
4943
protected:
5044
// |AccessibilityBridge|
5145
void OnAccessibilityEvent(ui::AXEventGenerator::TargetedEvent targeted_event) override;

shell/platform/darwin/macos/framework/Source/AccessibilityBridgeMac.mm

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@
2424
__weak FlutterViewController* view_controller)
2525
: flutter_engine_(flutter_engine), view_controller_(view_controller) {}
2626

27-
void AccessibilityBridgeMac::UpdateDefaultViewController(
28-
__weak FlutterViewController* view_controller) {
29-
view_controller_ = view_controller;
30-
RecreateNodeDelegates();
31-
}
32-
3327
void AccessibilityBridgeMac::OnAccessibilityEvent(
3428
ui::AXEventGenerator::TargetedEvent targeted_event) {
3529
if (!view_controller_.viewLoaded || !view_controller_.view.window) {

0 commit comments

Comments
 (0)