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

Unified Diff: ui/accessibility/ax_node_data.cc

Issue 2477463003: Replace ui::AXViewState with AXNodeData and AXActionData (Closed)
Patch Set: Fix test Created 4 years, 1 month 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
« no previous file with comments | « ui/accessibility/ax_node_data.h ('k') | ui/accessibility/ax_view_state.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/accessibility/ax_node_data.cc
diff --git a/ui/accessibility/ax_node_data.cc b/ui/accessibility/ax_node_data.cc
index 06c55e923b2811757047b18591d0ff912aeb5db2..66deec361b660a098663da34a9a7490dbd7b4af4 100644
--- a/ui/accessibility/ax_node_data.cc
+++ b/ui/accessibility/ax_node_data.cc
@@ -287,13 +287,48 @@ void AXNodeData::AddIntListAttribute(AXIntListAttribute attribute,
}
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) {
+ string_attributes[i].second = name;
+ return;
+ }
+ }
+
string_attributes.push_back(std::make_pair(AX_ATTR_NAME, name));
}
+void AXNodeData::SetName(const base::string16& name) {
+ SetName(base::UTF16ToUTF8(name));
+}
+
void AXNodeData::SetValue(const std::string& value) {
+ for (size_t i = 0; i < string_attributes.size(); ++i) {
+ if (string_attributes[i].first == AX_ATTR_VALUE) {
+ string_attributes[i].second = value;
+ return;
+ }
+ }
+
string_attributes.push_back(std::make_pair(AX_ATTR_VALUE, value));
}
+void AXNodeData::SetValue(const base::string16& value) {
+ SetValue(base::UTF16ToUTF8(value));
+}
+
+// static
+bool AXNodeData::IsFlagSet(uint32_t state, ui::AXState state_flag) {
+ return 0 != (state & (1 << state_flag));
+}
+
+void AXNodeData::AddStateFlag(ui::AXState state_flag) {
+ state |= (1 << state_flag);
+}
+
+bool AXNodeData::HasStateFlag(ui::AXState state_flag) const {
+ return IsFlagSet(state, state_flag);
+}
+
std::string AXNodeData::ToString() const {
std::string result;
« no previous file with comments | « ui/accessibility/ax_node_data.h ('k') | ui/accessibility/ax_view_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698