Commit 03a3575d authored by Hiroki Sato's avatar Hiroki Sato Committed by Commit Bot

Cleanup arc AX(Node|Window)InfoData GetProperty methods

Bug: none
Test: unit_tests
Change-Id: I8de22deaf25eb279305f368949d7666e93db6e40
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2061918Reviewed-by: default avatarSara Kato <sarakato@chromium.org>
Commit-Queue: Hiroki Sato <hirokisato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742913}
parent 151a0f9c
......@@ -506,75 +506,35 @@ void AccessibilityNodeInfoDataWrapper::GetChildren(
bool AccessibilityNodeInfoDataWrapper::GetProperty(
AXBooleanProperty prop) const {
if (!node_ptr_->boolean_properties)
return false;
auto it = node_ptr_->boolean_properties->find(prop);
if (it == node_ptr_->boolean_properties->end())
return false;
return it->second;
return arc::GetBooleanProperty(node_ptr_, prop);
}
bool AccessibilityNodeInfoDataWrapper::GetProperty(AXIntProperty prop,
int32_t* out_value) const {
if (!node_ptr_->int_properties)
return false;
auto it = node_ptr_->int_properties->find(prop);
if (it == node_ptr_->int_properties->end())
return false;
*out_value = it->second;
return true;
return arc::GetProperty(node_ptr_->int_properties, prop, out_value);
}
bool AccessibilityNodeInfoDataWrapper::HasProperty(
AXStringProperty prop) const {
if (!node_ptr_->string_properties)
return false;
auto it = node_ptr_->string_properties->find(prop);
return it != node_ptr_->string_properties->end();
return arc::HasProperty(node_ptr_->string_properties, prop);
}
bool AccessibilityNodeInfoDataWrapper::GetProperty(
AXStringProperty prop,
std::string* out_value) const {
if (!HasProperty(prop))
return false;
auto it = node_ptr_->string_properties->find(prop);
*out_value = it->second;
return true;
return arc::GetProperty(node_ptr_->string_properties, prop, out_value);
}
bool AccessibilityNodeInfoDataWrapper::GetProperty(
AXIntListProperty prop,
std::vector<int32_t>* out_value) const {
if (!node_ptr_->int_list_properties)
return false;
auto it = node_ptr_->int_list_properties->find(prop);
if (it == node_ptr_->int_list_properties->end())
return false;
*out_value = it->second;
return true;
return arc::GetProperty(node_ptr_->int_list_properties, prop, out_value);
}
bool AccessibilityNodeInfoDataWrapper::GetProperty(
AXStringListProperty prop,
std::vector<std::string>* out_value) const {
if (!node_ptr_->string_list_properties)
return false;
auto it = node_ptr_->string_list_properties->find(prop);
if (it == node_ptr_->string_list_properties->end())
return false;
*out_value = it->second;
return true;
return arc::GetProperty(node_ptr_->string_list_properties, prop, out_value);
}
bool AccessibilityNodeInfoDataWrapper::HasCoveringSpan(
......
......@@ -4,6 +4,7 @@
#include "chrome/browser/chromeos/arc/accessibility/accessibility_window_info_data_wrapper.h"
#include "chrome/browser/chromeos/arc/accessibility/arc_accessibility_util.h"
#include "chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.h"
#include "components/exo/wm_helper.h"
#include "ui/accessibility/ax_enums.mojom.h"
......@@ -128,62 +129,30 @@ void AccessibilityWindowInfoDataWrapper::GetChildren(
bool AccessibilityWindowInfoDataWrapper::GetProperty(
mojom::AccessibilityWindowBooleanProperty prop) const {
if (!window_ptr_->boolean_properties)
return false;
auto it = window_ptr_->boolean_properties->find(prop);
if (it == window_ptr_->boolean_properties->end())
return false;
return it->second;
return arc::GetBooleanProperty(window_ptr_, prop);
}
bool AccessibilityWindowInfoDataWrapper::GetProperty(
mojom::AccessibilityWindowIntProperty prop,
int32_t* out_value) const {
if (!window_ptr_->int_properties)
return false;
auto it = window_ptr_->int_properties->find(prop);
if (it == window_ptr_->int_properties->end())
return false;
*out_value = it->second;
return true;
return arc::GetProperty(window_ptr_->int_properties, prop, out_value);
}
bool AccessibilityWindowInfoDataWrapper::HasProperty(
mojom::AccessibilityWindowStringProperty prop) const {
if (!window_ptr_->string_properties)
return false;
auto it = window_ptr_->string_properties->find(prop);
return it != window_ptr_->string_properties->end();
return arc::HasProperty(window_ptr_->string_properties, prop);
}
bool AccessibilityWindowInfoDataWrapper::GetProperty(
mojom::AccessibilityWindowStringProperty prop,
std::string* out_value) const {
if (!HasProperty(prop))
return false;
auto it = window_ptr_->string_properties->find(prop);
*out_value = it->second;
return true;
return arc::GetProperty(window_ptr_->string_properties, prop, out_value);
}
bool AccessibilityWindowInfoDataWrapper::GetProperty(
mojom::AccessibilityWindowIntListProperty prop,
std::vector<int32_t>* out_value) const {
if (!window_ptr_->int_list_properties)
return false;
auto it = window_ptr_->int_list_properties->find(prop);
if (it == window_ptr_->int_list_properties->end())
return false;
*out_value = it->second;
return true;
return arc::GetProperty(window_ptr_->int_list_properties, prop, out_value);
}
} // namespace arc
......@@ -196,16 +196,4 @@ bool HasImportantProperty(AXNodeInfoData* node) {
return false;
}
bool GetBooleanProperty(mojom::AccessibilityNodeInfoData* node,
mojom::AccessibilityBooleanProperty prop) {
if (!node || !node->boolean_properties)
return false;
auto it = node->boolean_properties->find(prop);
if (it == node->boolean_properties->end())
return false;
return it->second;
}
} // namespace arc
......@@ -27,10 +27,25 @@ bool IsImportantInAndroid(mojom::AccessibilityNodeInfoData* node);
bool HasImportantProperty(mojom::AccessibilityNodeInfoData* node);
// TODO(hirokisato) clean up GetProperty methods in AccessibilityNodeInfoData
// and AccessibilityWindowInfoData.
bool GetBooleanProperty(mojom::AccessibilityNodeInfoData* node,
mojom::AccessibilityBooleanProperty prop);
template <class DataType, class PropType>
bool GetBooleanProperty(DataType* node, PropType 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;
}
template <class PropMTypeMap, class PropType>
bool HasProperty(PropMTypeMap properties, PropType prop) {
if (!properties)
return false;
return properties->find(prop) != properties->end();
}
template <class PropMTypeMap, class PropType, class OutType>
bool GetProperty(PropMTypeMap properties, PropType prop, OutType* out_value) {
......
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