OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/renderer/extensions/automation_internal_custom_bindings.h" | 5 #include "chrome/renderer/extensions/automation_internal_custom_bindings.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
982 v8::Local<v8::Object> event_params(v8::Object::New(GetIsolate())); | 982 v8::Local<v8::Object> event_params(v8::Object::New(GetIsolate())); |
983 event_params->Set(CreateV8String(isolate, "treeID"), | 983 event_params->Set(CreateV8String(isolate, "treeID"), |
984 v8::Integer::New(GetIsolate(), params.tree_id)); | 984 v8::Integer::New(GetIsolate(), params.tree_id)); |
985 event_params->Set(CreateV8String(isolate, "targetID"), | 985 event_params->Set(CreateV8String(isolate, "targetID"), |
986 v8::Integer::New(GetIsolate(), params.id)); | 986 v8::Integer::New(GetIsolate(), params.id)); |
987 event_params->Set(CreateV8String(isolate, "eventType"), | 987 event_params->Set(CreateV8String(isolate, "eventType"), |
988 CreateV8String(isolate, ToString(params.event_type))); | 988 CreateV8String(isolate, ToString(params.event_type))); |
989 args->Set(0U, event_params); | 989 args->Set(0U, event_params); |
990 context()->DispatchEvent("automationInternal.onAccessibilityEvent", args); | 990 context()->DispatchEvent("automationInternal.onAccessibilityEvent", args); |
991 } | 991 } |
992 void AutomationInternalCustomBindings::OnNodeDataWillChange( | |
993 ui::AXTree* tree, | |
994 const ui::AXNodeData& old_node_data, | |
995 const ui::AXNodeData& new_node_data) { | |
996 if (old_node_data.GetStringAttribute(ui::AX_ATTR_NAME) != | |
997 new_node_data.GetStringAttribute(ui::AX_ATTR_NAME)) | |
998 text_changed_node_ids_.push_back(new_node_data.id); | |
999 } | |
992 | 1000 |
993 void AutomationInternalCustomBindings::OnTreeDataChanged(ui::AXTree* tree) {} | 1001 void AutomationInternalCustomBindings::OnTreeDataChanged(ui::AXTree* tree) {} |
994 | 1002 |
995 void AutomationInternalCustomBindings::OnNodeWillBeDeleted(ui::AXTree* tree, | 1003 void AutomationInternalCustomBindings::OnNodeWillBeDeleted(ui::AXTree* tree, |
996 ui::AXNode* node) { | 1004 ui::AXNode* node) { |
997 SendTreeChangeEvent( | 1005 SendTreeChangeEvent( |
998 api::automation::TREE_CHANGE_TYPE_NODEREMOVED, | 1006 api::automation::TREE_CHANGE_TYPE_NODEREMOVED, |
999 tree, node); | 1007 tree, node); |
1000 deleted_node_ids_.push_back(node->id()); | 1008 deleted_node_ids_.push_back(node->id()); |
1001 } | 1009 } |
(...skipping 21 matching lines...) Expand all Loading... | |
1023 } | 1031 } |
1024 | 1032 |
1025 void AutomationInternalCustomBindings::OnAtomicUpdateFinished( | 1033 void AutomationInternalCustomBindings::OnAtomicUpdateFinished( |
1026 ui::AXTree* tree, | 1034 ui::AXTree* tree, |
1027 bool root_changed, | 1035 bool root_changed, |
1028 const std::vector<ui::AXTreeDelegate::Change>& changes) { | 1036 const std::vector<ui::AXTreeDelegate::Change>& changes) { |
1029 auto iter = axtree_to_tree_cache_map_.find(tree); | 1037 auto iter = axtree_to_tree_cache_map_.find(tree); |
1030 if (iter == axtree_to_tree_cache_map_.end()) | 1038 if (iter == axtree_to_tree_cache_map_.end()) |
1031 return; | 1039 return; |
1032 | 1040 |
1033 for (auto change : changes) { | 1041 for (auto change : changes) { |
Devlin
2016/02/22 18:21:45
drive-by: can this be const auto&?
David Tseng
2016/02/22 22:55:49
Done.
| |
1034 ui::AXNode* node = change.node; | 1042 ui::AXNode* node = change.node; |
1035 switch (change.type) { | 1043 switch (change.type) { |
1036 case NODE_CREATED: | 1044 case NODE_CREATED: |
1037 SendTreeChangeEvent( | 1045 SendTreeChangeEvent( |
1038 api::automation::TREE_CHANGE_TYPE_NODECREATED, | 1046 api::automation::TREE_CHANGE_TYPE_NODECREATED, |
1039 tree, node); | 1047 tree, node); |
1040 break; | 1048 break; |
1041 case SUBTREE_CREATED: | 1049 case SUBTREE_CREATED: |
1042 SendTreeChangeEvent( | 1050 SendTreeChangeEvent( |
1043 api::automation::TREE_CHANGE_TYPE_SUBTREECREATED, | 1051 api::automation::TREE_CHANGE_TYPE_SUBTREECREATED, |
1044 tree, node); | 1052 tree, node); |
1045 break; | 1053 break; |
1046 case NODE_CHANGED: | 1054 case NODE_CHANGED: |
1047 SendTreeChangeEvent( | 1055 SendTreeChangeEvent( |
1048 api::automation::TREE_CHANGE_TYPE_NODECHANGED, | 1056 api::automation::TREE_CHANGE_TYPE_NODECHANGED, |
1049 tree, node); | 1057 tree, node); |
1050 break; | 1058 break; |
1051 } | 1059 } |
1052 } | 1060 } |
1061 | |
1062 for (size_t i = 0; i < text_changed_node_ids_.size(); ++i) { | |
Devlin
2016/02/22 18:21:45
nit: prefer range-based (C++11-style) for-loops.
David Tseng
2016/02/22 22:55:49
Done.
| |
1063 SendTreeChangeEvent(api::automation::TREE_CHANGE_TYPE_TEXTCHANGED, tree, | |
1064 tree->GetFromId(text_changed_node_ids_[i])); | |
1065 } | |
1066 text_changed_node_ids_.clear(); | |
1053 } | 1067 } |
1054 | 1068 |
1055 void AutomationInternalCustomBindings::SendTreeChangeEvent( | 1069 void AutomationInternalCustomBindings::SendTreeChangeEvent( |
1056 api::automation::TreeChangeType change_type, | 1070 api::automation::TreeChangeType change_type, |
1057 ui::AXTree* tree, | 1071 ui::AXTree* tree, |
1058 ui::AXNode* node) { | 1072 ui::AXNode* node) { |
1059 // Don't send tree change events when it's not the active profile. | 1073 // Don't send tree change events when it's not the active profile. |
1060 if (!is_active_profile_) | 1074 if (!is_active_profile_) |
1061 return; | 1075 return; |
1062 | 1076 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1146 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 2U)); | 1160 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 2U)); |
1147 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id)); | 1161 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id)); |
1148 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size())); | 1162 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size())); |
1149 args->Set(1U, nodes); | 1163 args->Set(1U, nodes); |
1150 for (size_t i = 0; i < ids.size(); ++i) | 1164 for (size_t i = 0; i < ids.size(); ++i) |
1151 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i])); | 1165 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i])); |
1152 context()->DispatchEvent("automationInternal.onNodesRemoved", args); | 1166 context()->DispatchEvent("automationInternal.onNodesRemoved", args); |
1153 } | 1167 } |
1154 | 1168 |
1155 } // namespace extensions | 1169 } // namespace extensions |
OLD | NEW |