Commit 1cb1342f authored by Martin Robinson's avatar Martin Robinson Committed by Commit Bot

Improve handling of AtkCoordType

This fixes some issues with the interpretation of AtkCoordType in the
platform accessibility implementation.

Bug: 1020160
Change-Id: If5458444d224502a6355f74e9548175949751b4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1897831Reviewed-by: default avatarJoanmarie Diggs <jdiggs@igalia.com>
Commit-Queue: Martin Robinson <mrobinson@igalia.com>
Cr-Commit-Position: refs/heads/master@{#712935}
parent a9871df8
......@@ -3763,9 +3763,19 @@ gfx::Rect AXPlatformNodeAuraLinux::GetExtentsRelativeToAtkCoordinateType(
AtkCoordType coord_type) const {
gfx::Rect extents = delegate_->GetBoundsRect(AXCoordinateSystem::kScreen,
AXClippingBehavior::kUnclipped);
if (coord_type == ATK_XY_WINDOW) {
gfx::Vector2d frame_origin = -GetParentOriginInScreenCoordinates();
extents.Offset(frame_origin);
switch (coord_type) {
case ATK_XY_SCREEN:
break;
case ATK_XY_WINDOW: {
gfx::Vector2d window_origin = -GetParentFrameOriginInScreenCoordinates();
extents.Offset(window_origin);
break;
}
case ATK_XY_PARENT: {
gfx::Vector2d parent_origin = -GetParentOriginInScreenCoordinates();
extents.Offset(parent_origin);
break;
}
}
return extents;
......@@ -3806,15 +3816,9 @@ void AXPlatformNodeAuraLinux::GetSize(gint* width, gint* height) {
gfx::NativeViewAccessible
AXPlatformNodeAuraLinux::HitTestSync(gint x, gint y, AtkCoordType coord_type) {
if (coord_type == ATK_XY_WINDOW) {
if (AtkObject* atk_object = GetParent()) {
gfx::Point window_coords = FindAtkObjectParentCoords(atk_object);
x += window_coords.x();
y += window_coords.y();
}
}
return delegate_->HitTestSync(x, y);
gfx::Point scroll_to(x, y);
scroll_to = ConvertPointToScreenCoordinates(scroll_to, coord_type);
return delegate_->HitTestSync(scroll_to.x(), scroll_to.y());
}
bool AXPlatformNodeAuraLinux::GrabFocus() {
......@@ -4173,16 +4177,7 @@ void AXPlatformNodeAuraLinux::ScrollToPoint(AtkCoordType atk_coord_type,
int x,
int y) {
gfx::Point scroll_to(x, y);
switch (atk_coord_type) {
case ATK_XY_SCREEN:
break;
case ATK_XY_WINDOW:
scroll_to += GetParentFrameOriginInScreenCoordinates();
break;
case ATK_XY_PARENT:
scroll_to += GetParentOriginInScreenCoordinates();
break;
}
scroll_to = ConvertPointToScreenCoordinates(scroll_to, atk_coord_type);
ui::AXActionData action_data;
action_data.target_node_id = GetData().id;
......@@ -4412,4 +4407,18 @@ AXPlatformNodeAuraLinux::GetSelectionOffsetsFromFindInPage() {
return iterator->second;
}
gfx::Point AXPlatformNodeAuraLinux::ConvertPointToScreenCoordinates(
const gfx::Point& point,
AtkCoordType atk_coord_type) {
switch (atk_coord_type) {
case ATK_XY_WINDOW:
return point + GetParentFrameOriginInScreenCoordinates();
case ATK_XY_PARENT:
return point + GetParentOriginInScreenCoordinates();
case ATK_XY_SCREEN:
default:
return point;
}
}
} // namespace ui
......@@ -334,6 +334,9 @@ class AX_EXPORT AXPlatformNodeAuraLinux : public AXPlatformNodeBase {
// The AtkStateType for a checkable node can vary depending on the role.
AtkStateType GetAtkStateTypeForCheckableNode();
gfx::Point ConvertPointToScreenCoordinates(const gfx::Point& point,
AtkCoordType atk_coord_type);
// Keep information of latest AtkInterfaces mask to refresh atk object
// interfaces accordingly if needed.
int interface_mask_ = 0;
......
......@@ -698,6 +698,11 @@ TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkComponentsGetExtentsPositionSize) {
EXPECT_EQ(800, width);
EXPECT_EQ(600, height);
AtkObject* hit_test_result = atk_component_ref_accessible_at_point(
ATK_COMPONENT(root_obj), x_left, y_top, ATK_XY_SCREEN);
ASSERT_EQ(hit_test_result, root_obj);
g_object_unref(hit_test_result);
atk_component_get_position(ATK_COMPONENT(root_obj), &x_left, &y_top,
ATK_XY_SCREEN);
EXPECT_EQ(110, x_left);
......@@ -705,15 +710,20 @@ TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkComponentsGetExtentsPositionSize) {
atk_component_get_extents(ATK_COMPONENT(root_obj), &x_left, &y_top, &width,
&height, ATK_XY_WINDOW);
EXPECT_EQ(110, x_left);
EXPECT_EQ(240, y_top);
EXPECT_EQ(0, x_left);
EXPECT_EQ(0, y_top);
EXPECT_EQ(800, width);
EXPECT_EQ(600, height);
hit_test_result = atk_component_ref_accessible_at_point(
ATK_COMPONENT(root_obj), x_left + 2, y_top + 2, ATK_XY_WINDOW);
ASSERT_EQ(hit_test_result, root_obj);
g_object_unref(hit_test_result);
atk_component_get_position(ATK_COMPONENT(root_obj), &x_left, &y_top,
ATK_XY_WINDOW);
EXPECT_EQ(110, x_left);
EXPECT_EQ(240, y_top);
EXPECT_EQ(0, x_left);
EXPECT_EQ(0, y_top);
atk_component_get_size(ATK_COMPONENT(root_obj), &width, &height);
EXPECT_EQ(800, width);
......@@ -732,6 +742,11 @@ TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkComponentsGetExtentsPositionSize) {
EXPECT_EQ(200, width);
EXPECT_EQ(200, height);
hit_test_result = atk_component_ref_accessible_at_point(
ATK_COMPONENT(root_obj), x_left, y_top, ATK_XY_SCREEN);
ASSERT_EQ(hit_test_result, child_obj);
g_object_unref(hit_test_result);
atk_component_get_extents(ATK_COMPONENT(child_obj), &x_left, &y_top, &width,
&height, ATK_XY_WINDOW);
EXPECT_EQ(90, x_left);
......@@ -739,6 +754,11 @@ TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkComponentsGetExtentsPositionSize) {
EXPECT_EQ(200, width);
EXPECT_EQ(200, height);
hit_test_result = atk_component_ref_accessible_at_point(
ATK_COMPONENT(root_obj), x_left, y_top, ATK_XY_WINDOW);
ASSERT_EQ(hit_test_result, child_obj);
g_object_unref(hit_test_result);
atk_component_get_extents(ATK_COMPONENT(child_obj), nullptr, &y_top, &width,
&height, ATK_XY_SCREEN);
EXPECT_EQ(200, height);
......
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