Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Closed
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
11 changes: 11 additions & 0 deletions shell/platform/common/accessibility_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ void AccessibilityBridge::ConvertFlutterUpdate(const SemanticsNode& node,
SetIntAttributesFromFlutterUpdate(node_data, node);
SetIntListAttributesFromFlutterUpdate(node_data, node);
SetStringListAttributesFromFlutterUpdate(node_data, node);
SetIdentifierFromFlutterUpdate(node_data, node);
SetNameFromFlutterUpdate(node_data, node);
SetValueFromFlutterUpdate(node_data, node);
SetTooltipFromFlutterUpdate(node_data, node);
Expand Down Expand Up @@ -530,6 +531,13 @@ void AccessibilityBridge::SetStringListAttributesFromFlutterUpdate(
}
}

void AccessibilityBridge::SetIdentifierFromFlutterUpdate(
ui::AXNodeData& node_data,
const SemanticsNode& node) {
node_data.AddStringAttribute(ax::mojom::StringAttribute::kAuthorUniqueId,
node.identifier);
}

void AccessibilityBridge::SetNameFromFlutterUpdate(ui::AXNodeData& node_data,
const SemanticsNode& node) {
node_data.SetName(node.label);
Expand Down Expand Up @@ -598,6 +606,9 @@ AccessibilityBridge::FromFlutterSemanticsNode(
result.scroll_extent_min = flutter_node.scroll_extent_min;
result.elevation = flutter_node.elevation;
result.thickness = flutter_node.thickness;
if (flutter_node.identifier) {
result.identifier = std::string(flutter_node.identifier);
}
if (flutter_node.label) {
result.label = std::string(flutter_node.label);
}
Expand Down
3 changes: 3 additions & 0 deletions shell/platform/common/accessibility_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ class AccessibilityBridge
double scroll_extent_min;
double elevation;
double thickness;
std::string identifier;
std::string label;
std::string hint;
std::string value;
Expand Down Expand Up @@ -227,6 +228,8 @@ class AccessibilityBridge
const SemanticsNode& node);
void SetStringListAttributesFromFlutterUpdate(ui::AXNodeData& node_data,
const SemanticsNode& node);
void SetIdentifierFromFlutterUpdate(ui::AXNodeData& node_data,
const SemanticsNode& node);
void SetNameFromFlutterUpdate(ui::AXNodeData& node_data,
const SemanticsNode& node);
void SetValueFromFlutterUpdate(ui::AXNodeData& node_data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ TEST(FlutterPlatformNodeDelegateTest, canPerfomActions) {
root.actions = static_cast<FlutterSemanticsAction>(0);
root.text_selection_base = -1;
root.text_selection_extent = -1;
root.identifier = "";
root.label = "root";
root.hint = "";
root.value = "";
Expand Down Expand Up @@ -91,6 +92,7 @@ TEST(FlutterPlatformNodeDelegateTest, canGetAXNode) {
root.actions = static_cast<FlutterSemanticsAction>(0);
root.text_selection_base = -1;
root.text_selection_extent = -1;
root.identifier = "";
root.label = "root";
root.hint = "";
root.value = "";
Expand All @@ -112,6 +114,7 @@ TEST(FlutterPlatformNodeDelegateTest, canCalculateBoundsCorrectly) {
std::make_shared<TestAccessibilityBridge>();
FlutterSemanticsNode2 root;
root.id = 0;
root.identifier = "";
root.label = "root";
root.hint = "";
root.value = "";
Expand All @@ -128,6 +131,7 @@ TEST(FlutterPlatformNodeDelegateTest, canCalculateBoundsCorrectly) {

FlutterSemanticsNode2 child1;
child1.id = 1;
child1.identifier = "";
child1.label = "child 1";
child1.hint = "";
child1.value = "";
Expand Down Expand Up @@ -158,6 +162,7 @@ TEST(FlutterPlatformNodeDelegateTest, canCalculateOffScreenBoundsCorrectly) {
std::make_shared<TestAccessibilityBridge>();
FlutterSemanticsNode2 root;
root.id = 0;
root.identifier = "";
root.label = "root";
root.hint = "";
root.value = "";
Expand All @@ -174,6 +179,7 @@ TEST(FlutterPlatformNodeDelegateTest, canCalculateOffScreenBoundsCorrectly) {

FlutterSemanticsNode2 child1;
child1.id = 1;
child1.identifier = "";
child1.label = "child 1";
child1.hint = "";
child1.value = "";
Expand Down Expand Up @@ -204,6 +210,7 @@ TEST(FlutterPlatformNodeDelegateTest, canUseOwnerBridge) {
std::make_shared<TestAccessibilityBridge>();
FlutterSemanticsNode2 root;
root.id = 0;
root.identifier = "";
root.label = "root";
root.hint = "";
root.value = "";
Expand All @@ -220,6 +227,7 @@ TEST(FlutterPlatformNodeDelegateTest, canUseOwnerBridge) {

FlutterSemanticsNode2 child1;
child1.id = 1;
child1.identifier = "";
child1.label = "child 1";
child1.hint = "";
child1.value = "";
Expand All @@ -236,7 +244,7 @@ TEST(FlutterPlatformNodeDelegateTest, canUseOwnerBridge) {
auto child1_node = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
auto owner_bridge = child1_node->GetOwnerBridge().lock();

bool result;
bool result = false;
gfx::RectF bounds = owner_bridge->RelativeToGlobalBounds(
child1_node->GetAXNode(), result, true);
EXPECT_EQ(bounds.x(), 0);
Expand All @@ -251,6 +259,7 @@ TEST(FlutterPlatformNodeDelegateTest, selfIsLowestPlatformAncestor) {
std::make_shared<TestAccessibilityBridge>();
FlutterSemanticsNode2 root;
root.id = 0;
root.identifier = "";
root.label = "root";
root.hint = "";
root.value = "";
Expand All @@ -273,6 +282,7 @@ TEST(FlutterPlatformNodeDelegateTest, canGetFromNodeID) {
std::make_shared<TestAccessibilityBridge>();
FlutterSemanticsNode2 root;
root.id = 0;
root.identifier = "";
root.label = "root";
root.hint = "";
root.value = "";
Expand All @@ -287,6 +297,7 @@ TEST(FlutterPlatformNodeDelegateTest, canGetFromNodeID) {

FlutterSemanticsNode2 child1;
child1.id = 1;
child1.identifier = "";
child1.label = "child 1";
child1.hint = "";
child1.value = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ @implementation AccessibilityBridgeTestViewController
root.actions = static_cast<FlutterSemanticsAction>(0);
root.text_selection_base = -1;
root.text_selection_extent = -1;
root.identifier = "";
root.label = "root";
root.hint = "";
root.value = "";
Expand Down Expand Up @@ -163,6 +164,7 @@ @implementation AccessibilityBridgeTestViewController
node1.actions = static_cast<FlutterSemanticsAction>(0);
node1.text_selection_base = -1;
node1.text_selection_extent = -1;
node1.identifier = "";
node1.label = "node1";
node1.hint = "";
node1.value = "";
Expand All @@ -180,6 +182,7 @@ @implementation AccessibilityBridgeTestViewController
node2.actions = static_cast<FlutterSemanticsAction>(0);
node2.text_selection_base = -1;
node2.text_selection_extent = -1;
node2.identifier = "";
node2.label = "node2";
node2.hint = "";
node2.value = "";
Expand Down Expand Up @@ -225,6 +228,7 @@ @implementation AccessibilityBridgeTestViewController
root.actions = static_cast<FlutterSemanticsAction>(0);
root.text_selection_base = -1;
root.text_selection_extent = -1;
root.identifier = "";
root.label = "root";
root.hint = "";
root.value = "";
Expand Down Expand Up @@ -271,6 +275,7 @@ @implementation AccessibilityBridgeTestViewController
root.actions = static_cast<FlutterSemanticsAction>(0);
root.text_selection_base = -1;
root.text_selection_extent = -1;
root.identifier = "";
root.label = "root";
root.hint = "";
root.value = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
root.actions = static_cast<FlutterSemanticsAction>(0);
root.text_selection_base = -1;
root.text_selection_extent = -1;
root.identifier = "";
root.label = "accessibility";
root.hint = "";
root.value = "";
Expand Down Expand Up @@ -79,6 +80,7 @@
root.actions = static_cast<FlutterSemanticsAction>(0);
root.text_selection_base = 1;
root.text_selection_extent = 3;
root.identifier = "";
root.label = "";
root.hint = "";
// Selectable text store its text in value
Expand Down Expand Up @@ -121,6 +123,7 @@
root.actions = static_cast<FlutterSemanticsAction>(0);
root.text_selection_base = -1;
root.text_selection_extent = -1;
root.identifier = "";
root.label = "";
root.hint = "";
// Selectable text store its text in value
Expand Down Expand Up @@ -162,6 +165,7 @@
// Initialize ax node data.
FlutterSemanticsNode2 root;
root.id = 0;
root.identifier = "";
root.label = "root";
root.hint = "";
root.value = "";
Expand All @@ -176,6 +180,7 @@

FlutterSemanticsNode2 child1;
child1.id = 1;
child1.identifier = "";
child1.label = "child 1";
child1.hint = "";
child1.value = "";
Expand Down Expand Up @@ -239,6 +244,7 @@
root.id = 0;
root.flags = static_cast<FlutterSemanticsFlag>(0);
root.actions = static_cast<FlutterSemanticsAction>(0);
root.identifier = "";
root.label = "root";
root.hint = "";
root.value = "";
Expand All @@ -260,6 +266,7 @@
child1.id = 1;
child1.flags = FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField;
child1.actions = static_cast<FlutterSemanticsAction>(0);
child1.identifier = "";
child1.label = "";
child1.hint = "";
child1.value = "textfield";
Expand Down Expand Up @@ -315,6 +322,7 @@
root.id = 0;
root.flags = static_cast<FlutterSemanticsFlag>(0);
root.actions = static_cast<FlutterSemanticsAction>(0);
root.identifier = "";
root.label = "root";
root.hint = "";
root.value = "";
Expand All @@ -336,6 +344,7 @@
child1.id = 1;
child1.flags = static_cast<FlutterSemanticsFlag>(0);
child1.actions = static_cast<FlutterSemanticsAction>(0);
child1.identifier = "";
child1.label = "";
child1.hint = "";
child1.value = "textfield";
Expand Down
2 changes: 2 additions & 0 deletions shell/platform/embedder/embedder.h
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,8 @@ typedef struct {
double elevation;
/// Describes how much space the semantics node takes up along the z-axis.
double thickness;
/// A technical identifier for the node.
const char* identifier;
/// A textual description of the node.
const char* label;
/// A brief description of the result of performing an action on the node.
Expand Down
1 change: 1 addition & 0 deletions shell/platform/embedder/embedder_semantics_update.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ void EmbedderSemanticsUpdate2::AddNode(const SemanticsNode& node) {
node.scrollExtentMin,
node.elevation,
node.thickness,
node.identifier.c_str(),
node.label.c_str(),
node.hint.c_str(),
node.value.c_str(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "flutter/shell/platform/windows/flutter_platform_node_delegate_windows.h"

#include "flutter/fml/logging.h"
#include "flutter/fml/platform/win/wstring_conversion.h"
#include "flutter/shell/platform/windows/accessibility_bridge_windows.h"
#include "flutter/shell/platform/windows/flutter_windows_view.h"
#include "flutter/third_party/accessibility/ax/ax_clipping_behavior.h"
Expand Down Expand Up @@ -78,6 +79,13 @@ gfx::NativeViewAccessible FlutterPlatformNodeDelegateWindows::HitTestSync(
return ax_platform_node_->GetNativeViewAccessible();
}

// |ui::AXPlatformNodeDelegate|
std::u16string FlutterPlatformNodeDelegateWindows::GetAuthorUniqueId() const {
return fml::WideStringToUtf16(
fml::Utf8ToWideString(GetData().GetStringAttribute(
ax::mojom::StringAttribute::kAuthorUniqueId)));
}

// |FlutterPlatformNodeDelegate|
gfx::Rect FlutterPlatformNodeDelegateWindows::GetBoundsRect(
const ui::AXCoordinateSystem coordinate_system,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class FlutterPlatformNodeDelegateWindows : public FlutterPlatformNodeDelegate {
int screen_physical_pixel_x,
int screen_physical_pixel_y) const override;

// |ui::AXPlatformNodeDelegate|
std::u16string GetAuthorUniqueId() const override;

// |FlutterPlatformNodeDelegate|
gfx::Rect GetBoundsRect(
const ui::AXCoordinateSystem coordinate_system,
Expand Down
2 changes: 0 additions & 2 deletions shell/platform/windows/flutter_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,6 @@ LRESULT FlutterWindow::OnGetObject(UINT const message,
if (root_view) {
CreateAxFragmentRoot();
if (is_uia_request) {
#ifdef FLUTTER_ENGINE_USE_UIA
// Retrieve UIA object for the root view.
Microsoft::WRL::ComPtr<IRawElementProviderSimple> root;
if (SUCCEEDED(
Expand All @@ -824,7 +823,6 @@ LRESULT FlutterWindow::OnGetObject(UINT const message,
} else {
FML_LOG(ERROR) << "Failed to query AX fragment root.";
}
#endif // FLUTTER_ENGINE_USE_UIA
} else if (is_msaa_request) {
// Create the accessibility root if it does not already exist.
// Return the IAccessible for the root view.
Expand Down
2 changes: 0 additions & 2 deletions shell/platform/windows/window_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,7 @@ TEST(MockWindow, DISABLED_GetObjectUia) {
bool uia_called = false;
ON_CALL(window, OnGetObject)
.WillByDefault(Invoke([&uia_called](UINT msg, WPARAM wpar, LPARAM lpar) {
#ifdef FLUTTER_ENGINE_USE_UIA
uia_called = true;
#endif // FLUTTER_ENGINE_USE_UIA
return static_cast<LRESULT>(0);
}));
EXPECT_CALL(window, OnGetObject).Times(1);
Expand Down
4 changes: 4 additions & 0 deletions third_party/accessibility/ax/ax_enum_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,8 @@ const char* ToString(ax::mojom::StringAttribute string_attribute) {
return "accessKey";
case ax::mojom::StringAttribute::kAriaInvalidValue:
return "ariaInvalidValue";
case ax::mojom::StringAttribute::kAuthorUniqueId:
return "authorUniqueId";
case ax::mojom::StringAttribute::kAutoComplete:
return "autoComplete";
case ax::mojom::StringAttribute::kChildTreeId:
Expand Down Expand Up @@ -1473,6 +1475,8 @@ ax::mojom::StringAttribute ParseStringAttribute(const char* string_attribute) {
return ax::mojom::StringAttribute::kAccessKey;
if (0 == strcmp(string_attribute, "ariaInvalidValue"))
return ax::mojom::StringAttribute::kAriaInvalidValue;
if (0 == strcmp(string_attribute, "authorUniqueId"))
return ax::mojom::StringAttribute::kAuthorUniqueId;
if (0 == strcmp(string_attribute, "autoComplete"))
return ax::mojom::StringAttribute::kAutoComplete;
if (0 == strcmp(string_attribute, "childTreeId"))
Expand Down
1 change: 1 addition & 0 deletions third_party/accessibility/ax/ax_enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ enum class StringAttribute {
kAccessKey,
// Only used when invalid_state == invalid_state_other.
kAriaInvalidValue,
kAuthorUniqueId,
kAutoComplete,
kChildTreeId,
kClassName,
Expand Down
3 changes: 3 additions & 0 deletions third_party/accessibility/ax/ax_node_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,9 @@ std::string AXNodeData::ToString() const {
case ax::mojom::StringAttribute::kAriaInvalidValue:
result += " aria_invalid_value=" + value;
break;
case ax::mojom::StringAttribute::kAuthorUniqueId:
result += " author_unique_id=" + value;
break;
case ax::mojom::StringAttribute::kAutoComplete:
result += " autocomplete=" + value;
break;
Expand Down