Commit 8ddf0a69 authored by David Tseng's avatar David Tseng Committed by Commit Bot

Be more strict when performing rect-based sorting

On further scrutiny of the Android codebase, the following constraints get used to identify |IsAccessibilityFocusable|, which gets used to decide whether a node contributes to the computed bounds of a node or not.

Any of these conditions makes a node "accessibility focusable", used here to mean "should use its rect" when sorting for child ordering
- actionable nodes
- top level scrollables with text

In ARC++, we cannot seem to rely entirely upon replicating the exact logic, but keep the spirit of what is meant. To that end, we want to sort nodes by layout.

This change gets much closer to what we want by:
- allowing computed bounds to be empty (meaning it has no meaningful content). In these cases, we simply rely upon tree ordering
- be very conservative when using a node's bounds. Only actionable nodes should matter. This potentially misses non-focusable nodes with text, or non-clickable nodes with text. However, mis-sorting a node is much much worse.

This change does not consider virtual hierarchies, which should likely not trigger reodering, since an author has explicit contorl over child ordering in those cases.

Change-Id: Iacffc5f2d88b6d52b732dadda8a01fd735665018
Reviewed-on: https://chromium-review.googlesource.com/989657
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547790}
parent ddea0efc
......@@ -306,6 +306,8 @@ source_set("chromeos") {
"apps/intent_helper/apps_navigation_throttle.h",
"arc/accessibility/arc_accessibility_helper_bridge.cc",
"arc/accessibility/arc_accessibility_helper_bridge.h",
"arc/accessibility/arc_accessibility_util.cc",
"arc/accessibility/arc_accessibility_util.h",
"arc/accessibility/ax_tree_source_arc.cc",
"arc/accessibility/ax_tree_source_arc.h",
"arc/arc_migration_constants.h",
......
dtseng@chromium.org
yawano@chromium.org
file://ui/accessibility/OWNERS
# TEAM: chromium-accessibility@chromium.org
# COMPONENT: UI>Accessibility
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/arc/accessibility/arc_accessibility_util.h"
#include "components/arc/common/accessibility_helper.mojom.h"
namespace arc {
bool GetProperty(mojom::AccessibilityNodeInfoData* node,
mojom::AccessibilityBooleanProperty prop) {
if (!node->boolean_properties)
return false;
auto it = node->boolean_properties->find(prop);
if (it == node->boolean_properties->end())
return false;
return it->second;
}
bool GetProperty(mojom::AccessibilityNodeInfoData* node,
mojom::AccessibilityIntProperty prop,
int32_t* out_value) {
if (!node->int_properties)
return false;
auto it = node->int_properties->find(prop);
if (it == node->int_properties->end())
return false;
*out_value = it->second;
return true;
}
bool HasProperty(mojom::AccessibilityNodeInfoData* node,
mojom::AccessibilityStringProperty prop) {
if (!node->string_properties)
return false;
auto it = node->string_properties->find(prop);
return it != node->string_properties->end();
}
bool GetProperty(mojom::AccessibilityNodeInfoData* node,
mojom::AccessibilityStringProperty prop,
std::string* out_value) {
if (!HasProperty(node, prop))
return false;
auto it = node->string_properties->find(prop);
*out_value = it->second;
return true;
}
bool GetProperty(mojom::AccessibilityNodeInfoData* node,
mojom::AccessibilityIntListProperty prop,
std::vector<int32_t>* out_value) {
if (!node->int_list_properties)
return false;
auto it = node->int_list_properties->find(prop);
if (it == node->int_list_properties->end())
return false;
*out_value = it->second;
return true;
}
bool GetProperty(mojom::AccessibilityNodeInfoData* node,
mojom::AccessibilityStringListProperty prop,
std::vector<std::string>* out_value) {
if (!node->string_list_properties)
return false;
auto it = node->string_list_properties->find(prop);
if (it == node->string_list_properties->end())
return false;
*out_value = it->second;
return true;
}
} // namespace arc
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_ARC_ACCESSIBILITY_ARC_ACCESSIBILITY_UTIL_H_
#define CHROME_BROWSER_CHROMEOS_ARC_ACCESSIBILITY_ARC_ACCESSIBILITY_UTIL_H_
#include <stdint.h>
#include <string>
#include <vector>
namespace arc {
namespace mojom {
class AccessibilityNodeInfoData;
enum class AccessibilityBooleanProperty;
enum class AccessibilityIntProperty;
enum class AccessibilityStringProperty;
enum class AccessibilityIntListProperty;
enum class AccessibilityStringListProperty;
} // namespace mojom
bool GetProperty(mojom::AccessibilityNodeInfoData* node,
mojom::AccessibilityBooleanProperty prop);
bool GetProperty(mojom::AccessibilityNodeInfoData* node,
mojom::AccessibilityIntProperty prop,
int32_t* out_value);
bool HasProperty(mojom::AccessibilityNodeInfoData* node,
mojom::AccessibilityStringProperty prop);
bool GetProperty(mojom::AccessibilityNodeInfoData* node,
mojom::AccessibilityStringProperty prop,
std::string* out_value);
bool GetProperty(mojom::AccessibilityNodeInfoData* node,
mojom::AccessibilityIntListProperty prop,
std::vector<int32_t>* out_value);
bool GetProperty(mojom::AccessibilityNodeInfoData* node,
mojom::AccessibilityStringListProperty prop,
std::vector<std::string>* out_value);
} // namespace arc
#endif // CHROME_BROWSER_CHROMEOS_ARC_ACCESSIBILITY_ARC_ACCESSIBILITY_UTIL_H_
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