Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Unified Diff: ui/accessibility/ax_node_data.cc

Issue 2873373005: Add custom action support (Closed)
Patch Set: Rebase. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/accessibility/ax_node_data.cc
diff --git a/ui/accessibility/ax_node_data.cc b/ui/accessibility/ax_node_data.cc
index ffaa3eb7405c963931605cb091fe9a8cd44d221d..2b5884e61893b390646c95e9eb7e3fba81aae82c 100644
--- a/ui/accessibility/ax_node_data.cc
+++ b/ui/accessibility/ax_node_data.cc
@@ -184,6 +184,7 @@ AXNodeData::AXNodeData(const AXNodeData& other) {
float_attributes = other.float_attributes;
bool_attributes = other.bool_attributes;
intlist_attributes = other.intlist_attributes;
+ stringlist_attributes = other.stringlist_attributes;
html_attributes = other.html_attributes;
child_ids = other.child_ids;
location = other.location;
@@ -201,6 +202,7 @@ AXNodeData& AXNodeData::operator=(AXNodeData other) {
float_attributes = other.float_attributes;
bool_attributes = other.bool_attributes;
intlist_attributes = other.intlist_attributes;
+ stringlist_attributes = other.stringlist_attributes;
html_attributes = other.html_attributes;
child_ids = other.child_ids;
location = other.location;
@@ -347,6 +349,31 @@ bool AXNodeData::GetIntListAttribute(AXIntListAttribute attribute,
return false;
}
+bool AXNodeData::HasStringListAttribute(AXStringListAttribute attribute) const {
+ auto iter = FindInVectorOfPairs(attribute, stringlist_attributes);
+ return iter != stringlist_attributes.end();
+}
+
+const std::vector<std::string>& AXNodeData::GetStringListAttribute(
+ AXStringListAttribute attribute) const {
+ CR_DEFINE_STATIC_LOCAL(std::vector<std::string>, empty_vector, ());
+ auto iter = FindInVectorOfPairs(attribute, stringlist_attributes);
+ if (iter != stringlist_attributes.end())
+ return iter->second;
+ return empty_vector;
+}
+
+bool AXNodeData::GetStringListAttribute(AXStringListAttribute attribute,
+ std::vector<std::string>* value) const {
+ auto iter = FindInVectorOfPairs(attribute, stringlist_attributes);
+ if (iter != stringlist_attributes.end()) {
+ *value = iter->second;
+ return true;
+ }
+
+ return false;
+}
+
bool AXNodeData::GetHtmlAttribute(
const char* html_attr, std::string* value) const {
for (size_t i = 0; i < html_attributes.size(); ++i) {
@@ -394,6 +421,11 @@ void AXNodeData::AddIntListAttribute(AXIntListAttribute attribute,
intlist_attributes.push_back(std::make_pair(attribute, value));
}
+void AXNodeData::AddStringListAttribute(AXStringListAttribute attribute,
+ const std::vector<std::string>& value) {
+ stringlist_attributes.push_back(std::make_pair(attribute, value));
+}
+
void AXNodeData::SetName(const std::string& name) {
for (size_t i = 0; i < string_attributes.size(); ++i) {
if (string_attributes[i].first == AX_ATTR_NAME) {

Powered by Google App Engine
This is Rietveld 408576698