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

Remove dead code for recreating a11y node delegates #43359

Merged
merged 1 commit into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions shell/platform/common/accessibility_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,6 @@ AccessibilityBridge::GetPendingEvents() const {
return result;
}

void AccessibilityBridge::RecreateNodeDelegates() {
for (const auto& [node_id, old_platform_node_delegate] : id_wrapper_map_) {
std::shared_ptr<FlutterPlatformNodeDelegate> platform_node_delegate =
CreateFlutterPlatformNodeDelegate();
platform_node_delegate->Init(
std::static_pointer_cast<FlutterPlatformNodeDelegate::OwnerBridge>(
shared_from_this()),
old_platform_node_delegate->GetAXNode());
id_wrapper_map_[node_id] = platform_node_delegate;
}
}

void AccessibilityBridge::OnNodeWillBeDeleted(ui::AXTree* tree,
ui::AXNode* node) {}

Expand Down
10 changes: 0 additions & 10 deletions shell/platform/common/accessibility_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,6 @@ class AccessibilityBridge
virtual std::shared_ptr<FlutterPlatformNodeDelegate>
CreateFlutterPlatformNodeDelegate() = 0;

//------------------------------------------------------------------------------
/// @brief Recreate all FlutterPlatformNodeDelegates.
///
/// This can be useful for subclasses when updating some
/// properties that are used by node delegates, such as views.
/// Each node is recreated using
/// CreateFlutterPlatformNodeDelegate, then initialized using
/// AXNodes from their corresponding old one.
void RecreateNodeDelegates();

private:
// See FlutterSemanticsNode in embedder.h
typedef struct {
Expand Down
34 changes: 0 additions & 34 deletions shell/platform/common/accessibility_bridge_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,40 +205,6 @@ TEST(AccessibilityBridgeTest, CanFireChildrenChangedCorrectly) {
Contains(ui::AXEventGenerator::Event::SUBTREE_CREATED));
}

TEST(AccessibilityBridgeTest, CanRecreateNodeDelegates) {
std::shared_ptr<TestAccessibilityBridge> bridge =
std::make_shared<TestAccessibilityBridge>();

std::vector<int32_t> children{1};
FlutterSemanticsNode2 root = CreateSemanticsNode(0, "root", &children);
FlutterSemanticsNode2 child1 = CreateSemanticsNode(1, "child 1");

bridge->AddFlutterSemanticsNodeUpdate(root);
bridge->AddFlutterSemanticsNodeUpdate(child1);
bridge->CommitUpdates();

auto root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0);
auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(1);
EXPECT_FALSE(root_node.expired());
EXPECT_FALSE(child1_node.expired());

bridge->RecreateNodeDelegates();

// Old tree is destroyed.
EXPECT_TRUE(root_node.expired());
EXPECT_TRUE(child1_node.expired());

// New tree still has the data.
auto new_root_node = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
auto new_child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
EXPECT_EQ(new_root_node->GetChildCount(), 1);
EXPECT_EQ(new_root_node->GetData().child_ids[0], 1);
EXPECT_EQ(new_root_node->GetName(), "root");

EXPECT_EQ(new_child1_node->GetChildCount(), 0);
EXPECT_EQ(new_child1_node->GetName(), "child 1");
}

TEST(AccessibilityBridgeTest, CanHandleSelectionChangeCorrectly) {
std::shared_ptr<TestAccessibilityBridge> bridge =
std::make_shared<TestAccessibilityBridge>();
Expand Down
2 changes: 0 additions & 2 deletions shell/platform/common/test_accessibility_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ namespace flutter {

class TestAccessibilityBridge : public AccessibilityBridge {
public:
using AccessibilityBridge::RecreateNodeDelegates;

TestAccessibilityBridge() = default;

void DispatchAccessibilityAction(AccessibilityNodeId target,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ class AccessibilityBridgeMac : public AccessibilityBridge {
FlutterSemanticsAction action,
fml::MallocMapping data) override;

// Update the default view controller, and recreate the corresponding
// accessibility node delegate.
//
// This is called by the engine when the default view controller is updated.
void UpdateDefaultViewController(__weak FlutterViewController* view_controller);

protected:
// |AccessibilityBridge|
void OnAccessibilityEvent(ui::AXEventGenerator::TargetedEvent targeted_event) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@
__weak FlutterViewController* view_controller)
: flutter_engine_(flutter_engine), view_controller_(view_controller) {}

void AccessibilityBridgeMac::UpdateDefaultViewController(
__weak FlutterViewController* view_controller) {
view_controller_ = view_controller;
RecreateNodeDelegates();
}

void AccessibilityBridgeMac::OnAccessibilityEvent(
ui::AXEventGenerator::TargetedEvent targeted_event) {
if (!view_controller_.viewLoaded || !view_controller_.view.window) {
Expand Down