Chromium Code Reviews| Index: chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.cc |
| diff --git a/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.cc b/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.cc |
| index a4a92086903d75b413ad9a51b4221e2e0f2ca356..626bf4ff8f9fe80c884ce09944dafb69e43fbb88 100644 |
| --- a/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.cc |
| +++ b/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.cc |
| @@ -83,6 +83,20 @@ bool GetBooleanProperty(arc::mojom::AccessibilityNodeInfoData* node, |
| return it->second; |
| } |
| +bool GetIntProperty(arc::mojom::AccessibilityNodeInfoData* node, |
| + arc::mojom::AccessibilityIntProperty prop, |
|
dmazzoni
2017/03/17 03:22:37
nit: indentation
David Tseng
2017/03/17 15:38:32
Done.
|
| + int32_t* out_value) { |
| + if (!node->intProperties) |
| + return false; |
| + |
| + auto it = node->intProperties->find(prop); |
| + if (it == node->intProperties->end()) |
| + return false; |
| + |
| + *out_value = it->second; |
| + return true; |
| +} |
| + |
| bool GetStringProperty(arc::mojom::AccessibilityNodeInfoData* node, |
| arc::mojom::AccessibilityStringProperty prop, |
| std::string* out_value) { |
| @@ -306,6 +320,7 @@ void AXTreeSourceArc::SerializeNode(mojom::AccessibilityNodeInfoData* node, |
| return; |
| out_data->id = node->id; |
| + using AXIntProperty = arc::mojom::AccessibilityIntProperty; |
| using AXStringProperty = arc::mojom::AccessibilityStringProperty; |
| std::string text; |
| if (GetStringProperty(node, AXStringProperty::TEXT, &text)) |
| @@ -329,6 +344,17 @@ void AXTreeSourceArc::SerializeNode(mojom::AccessibilityNodeInfoData* node, |
| if (out_data->role == ui::AX_ROLE_TEXT_FIELD && !text.empty()) |
| out_data->AddStringAttribute(ui::AX_ATTR_VALUE, text); |
| + |
| + // Integer properties. |
| + int32_t val; |
| + if (GetIntProperty(node, AXIntProperty::TEXT_SELECTION_START, |
|
yawano
2017/03/17 08:38:23
Node can have both TEXT_SELECTION_START and TEXT_S
David Tseng
2017/03/17 15:38:32
Done.
|
| + &val) && val >= 0) { |
| + out_data->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, val); |
| + out_data->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, val); |
|
yawano
2017/03/17 08:38:23
This line of setting AX_ATTR_TEXT_SEL_END would be
David Tseng
2017/03/17 15:38:32
Yeah totally; was wip while I was trying to figure
|
| + } else if (GetIntProperty(node, AXIntProperty::TEXT_SELECTION_END, |
| + &val) && val >= 0) { |
| + out_data->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, val); |
| + } |
| } |
| void AXTreeSourceArc::Reset() { |