Commit e672028c authored by Tess Eisenberger's avatar Tess Eisenberger Committed by Commit Bot

[fuchsia] Fix a11y bounding boxes

This patch corrects an invariant violation in which Chrome was swapping
the min and max y coordinates when reporting bounding boxes to Fuchsia's
a11y-manager.

Bug: fuchsia:59709
Change-Id: I65122ef06d2089243d1d0688707ca8caf335b2b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2473361Reviewed-by: default avatarSergey Ulanov <sergeyu@chromium.org>
Reviewed-by: default avatarSharon Yang <yangsharon@chromium.org>
Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
Auto-Submit: Tess Eisenberger <teisenbe@google.com>
Cr-Commit-Position: refs/heads/master@{#817707}
parent 52619ffb
......@@ -187,10 +187,10 @@ std::vector<uint32_t> ConvertChildIds(std::vector<int32_t> ids,
fuchsia::ui::gfx::BoundingBox ConvertBoundingBox(gfx::RectF bounds) {
fuchsia::ui::gfx::BoundingBox box;
box.min = scenic::NewVector3({bounds.bottom_left().x(),
bounds.bottom_left().y(), 0.0f});
box.max = scenic::NewVector3({bounds.top_right().x(), bounds.top_right().y(),
0.0f});
// Since the origin is at the top left, min should represent the top left and
// max should be the bottom right.
box.min = scenic::NewVector3({bounds.x(), bounds.y(), 0.0f});
box.max = scenic::NewVector3({bounds.right(), bounds.bottom(), 0.0f});
return box;
}
......
......@@ -97,8 +97,9 @@ std::pair<ui::AXNodeData, Node> CreateSemanticNodeAllFieldsSet() {
attributes.set_label(kLabel1);
attributes.set_secondary_label(kDescription1);
fuchsia::ui::gfx::BoundingBox box;
box.min = scenic::NewVector3({kRectX, kRectY + kRectHeight, 0.0f});
box.max = scenic::NewVector3({kRectHeight, kRectY, 0.0f});
box.min = scenic::NewVector3({kRectX, kRectY, 0.0f});
box.max =
scenic::NewVector3({kRectX + kRectWidth, kRectY + kRectHeight, 0.0f});
fuchsia::ui::gfx::Matrix4Value mat =
scenic::NewMatrix4Value(k4DIdentityMatrix);
States states;
......@@ -181,8 +182,9 @@ TEST_F(AXTreeConverterTest, FieldMismatch) {
states.set_hidden(false);
states.set_checked_state(CheckedState::UNCHECKED);
fuchsia::ui::gfx::BoundingBox box;
box.min = scenic::NewVector3({kRectX, kRectY + kRectHeight, 0.0f});
box.max = scenic::NewVector3({kRectHeight, kRectY, 0.0f});
box.min = scenic::NewVector3({kRectX, kRectY, 0.0f});
box.max =
scenic::NewVector3({kRectX + kRectWidth, kRectY + kRectHeight, 0.0f});
fuchsia::ui::gfx::Matrix4Value mat =
scenic::NewMatrix4Value(k4DIdentityMatrix);
auto expected_node = CreateSemanticNode(
......@@ -208,6 +210,26 @@ TEST_F(AXTreeConverterTest, FieldMismatch) {
EXPECT_FALSE(fidl::Equals(converted_node, expected_node));
}
TEST_F(AXTreeConverterTest, LocationFieldRespectsTypeInvariants) {
ui::AXRelativeBounds relative_bounds = ui::AXRelativeBounds();
relative_bounds.bounds = gfx::RectF(kRectX, kRectY, kRectWidth, kRectHeight);
relative_bounds.transform =
std::make_unique<gfx::Transform>(gfx::Transform::kSkipInitialization);
relative_bounds.transform->MakeIdentity();
auto source_node_data = CreateAXNodeData(
ax::mojom::Role::kHeader, ax::mojom::Action::kSetValue,
std::vector<int32_t>{kChildId1, kChildId2, kChildId3}, relative_bounds,
kLabel1, kDescription1, ax::mojom::CheckedState::kFalse);
auto converted_node = AXNodeDataToSemanticNode(source_node_data, kRootId);
// The type definition of the location field requires that in order to be
// interpreted as having non-zero length in a dimension, the min must be less
// than the max in that dimension.
EXPECT_LE(converted_node.location().min.x, converted_node.location().max.x);
EXPECT_LE(converted_node.location().min.y, converted_node.location().max.y);
EXPECT_LE(converted_node.location().min.z, converted_node.location().max.z);
}
TEST_F(AXTreeConverterTest, DefaultAction) {
auto nodes = CreateSemanticNodeAllFieldsSet();
auto& source_node_data = nodes.first;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment